# HG changeset patch # User Pascal Bellard # Date 1573382754 -3600 # Node ID 08212b207b25e24870a70f4e03ac130ed898d6df # Parent ee7d4644eb132cd5ddbb8b4ef53405a427195e12 linld: check memory size for vcpi diff -r ee7d4644eb13 -r 08212b207b25 linld/stuff/src/A20.ASM --- a/linld/stuff/src/A20.ASM Sat Nov 09 17:39:43 2019 +0100 +++ b/linld/stuff/src/A20.ASM Sun Nov 10 11:45:54 2019 +0100 @@ -99,14 +99,7 @@ global @moverm$qp11image_himem:near @moverm$qp11image_himem: push si di - extrn _pm_high:byte - mov si,offset _pm_high - ifdef MOVE_SETUP - mov di,8000h - sub di,[bx-4] ; rm size - extrn _rm_offset:word - mov [_rm_offset],di - endif + xor di,di extrn _heap_top:word ifdef NO386 mov ax,[_heap_top] @@ -115,7 +108,8 @@ mov dx,cs add dx,ax mov cx,0fffh - test [byte si],cl + extrn _pm_high:byte + test [_pm_high],cl jne @bzimage xchg ax,dx cmp ax,cx @@ -130,7 +124,11 @@ add ax,[word ((image_himem bx).size)] adc dx,[word ((image_himem bx).size)+2] ifdef MOVE_SETUP - sub ax,di ; -rm_offset + mov di,8000h + sub di,[bx-4] ; rm size + extrn _rm_offset:word + mov [_rm_offset],di + sub ax,di ; -rm_offset sbb dx,cx endif mov cl,12 @@ -147,7 +145,8 @@ mov dx,cs add ax,dx mov cx,0fffh - test [byte si],cl + extrn _pm_high:byte + test [_pm_high],cl jne @bzimage cmp ax,cx jae @sys@ok @@ -158,16 +157,20 @@ mov [(image_himem bx).fallback],eax add eax,[(image_himem bx).size] ifdef MOVE_SETUP + mov di,8000h + sub di,[bx-4] ; rm size extrn _rm_offset:word - movzx ecx,di ; -rm_offset + mov [_rm_offset],di + movzx ecx,di ; -rm_offset sub eax,ecx endif shl eax,4 + mov ch,0 @bzimage: xchg ax,dx mov ax,9000h endif - mov es,ax + add dh,ch ; room for malloc_bufv_or_die cmp dx,ax jb @nooverflow @overflow: @@ -175,14 +178,9 @@ mov bx,offset overflow call near die @nooverflow: - ifdef MOVE_SETUP - cmp [si],al - je @@do_move - endif - xor di,di -@@do_move: - mov si,[bx-2] ; rm data - mov cx,[bx-4] ; rm size + les cx,[bx-4] ; rm size + mov si,es ; rm data + mov es,ax @@move_clear: movsb mov [byte si-1],al diff -r ee7d4644eb13 -r 08212b207b25 linld/stuff/src/pipehole.awk --- a/linld/stuff/src/pipehole.awk Sat Nov 09 17:39:43 2019 +0100 +++ b/linld/stuff/src/pipehole.awk Sun Nov 10 11:45:54 2019 +0100 @@ -124,9 +124,8 @@ } if (/cmd_line_ptr =/ && is386 == 0) isload=7 if (isload == 7) { # LOAD.LST - if (/add/ || /xor/ || /extrn/ || /N_LXLSH@/ || /cl,4/) next + if (/add/ || /xor/ || /extrn/ || /N_LXLSH@/ || /cl,4/ || /,ax/) next if (/enable A20 if needed/) { print nextinst; isload=0 } - if (/,ax/) $0=" mov bx,55" if (/i-463/) $0=" mov bx,-463" if (/i-465/) { sub(/465/,"2"); sub(/\[/,"[bx+") @@ -135,6 +134,7 @@ if (/,dx/) { print " mov cl,12" print " shr ax,cl" + print " mov bx,55" sub(/dx/,"ax") } } @@ -170,6 +170,13 @@ } sub(/,ax/,",es") if (/,dx/) isload=0 + if (/add ax,word ptr/) $0=" add ax,cx" + if (/i\+29\],0/) { + sub(/,0$/,"") + sub(/cmp /,"mov cx,") + } + sub(/je/,"jcxz") + if (/@strcpy/) isload=0 } if (/void load_initrd\(\)/) isload=3 if (isload == 3) { # LOAD.LST