# HG changeset patch # User Pascal Bellard # Date 1573654082 -3600 # Node ID 664d83fb04f94b323a855f0de69a069e9e73e892 # Parent babd38118a53530732e823863115d4701d130514 linld: 8086 may load zImage (again) diff -r babd38118a53 -r 664d83fb04f9 linld/stuff/src/A20.ASM --- a/linld/stuff/src/A20.ASM Wed Nov 13 15:07:56 2019 +0100 +++ b/linld/stuff/src/A20.ASM Wed Nov 13 15:08:02 2019 +0100 @@ -111,9 +111,9 @@ mov dx,cs add dx,ax mov cx,0fffh - extrn _pm_high:byte - test [_pm_high],cl - je @zimage + extrn _pm_low:byte + test [_pm_low],cl + jne @zimage extrn _cpu386:byte test [_cpu386],cl jne @bzimage @@ -159,9 +159,9 @@ mov dx,cs add ax,dx mov cx,0fffh - extrn _pm_high:byte - test [_pm_high],cl - jne @bzimage + extrn _pm_low:byte + test [_pm_low],cl + je @bzimage cmp ax,cx jae @sys@ok xchg ax,cx diff -r babd38118a53 -r 664d83fb04f9 linld/stuff/src/COMMON.H --- a/linld/stuff/src/COMMON.H Wed Nov 13 15:07:56 2019 +0100 +++ b/linld/stuff/src/COMMON.H Wed Nov 13 15:08:02 2019 +0100 @@ -54,7 +54,7 @@ #define initrd (imgs[1]) #define pm2initrd(p) (p+1) -extern u8 pm_high; +extern u8 pm_low; extern int skip_alloc; extern u32 base_himem; extern u32 far *initrd_desc; diff -r babd38118a53 -r 664d83fb04f9 linld/stuff/src/JUMP.ASM --- a/linld/stuff/src/JUMP.ASM Wed Nov 13 15:07:56 2019 +0100 +++ b/linld/stuff/src/JUMP.ASM Wed Nov 13 15:08:02 2019 +0100 @@ -92,40 +92,30 @@ endif ;cli ; we start doing destructive things to DOS extrn sssp:word - mov es,[sssp+2] - push es - pop ss - mov sp,0A000h - extrn _csip:dword - ifdef NO386 - mov si,offset _csip - lodsw - push [word si] - push ax - else - push [dword _csip] - endif - - ifdef NO386 - mov cx,ss - add ch,9 - push cx ; topseg()+0x0900 - else - push 9800h+(4096/16) ; 4096 bytes for cmdline - endif - + mov ax,[sssp+2] + mov es,ax extrn _cmdline:word mov si,[_cmdline] mov di,8000h - mov ch,10h ; 4k + mov cx,2000h ; 4k for cmdline + 4k up to sp rep movsb + push es + pop ss + mov sp,di - mov cl,0 ; load high ? + mov dx,2000h + global _csip_hilo:word + org $-2 +_csip_hilo dw ? + xchg al,dh ; 9020 / 9000 + push ax + push dx ; 0000 / 0042 + + mov cl,1 ; load high ? org $-1 - global _pm_high:byte -_pm_high db ? - inc cx + global _pm_low:byte +_pm_low db ? push cx mov ax,[word ss:024Ch] xor ax,2b30h ; ipxe ? @@ -141,29 +131,8 @@ @@notipxe: pop cx - pop es ; min 2048 bytes for stack loop @@isbzimage - ; self move - ;cld - extrn gdt_data - mov cx,offset gdt_data+8 - xor di,di ; A000 -9000 -0800(>movedend) - rep - movsb - mov si,offset _imgs+2 - lodsw - xchg ax,bx ; get pm->fallback low word - lodsw ; get pm->fallback high word - ifdef MOVE_SETUP - mov si,0 - global _rm_offset:word - org $-2 -_rm_offset dw ? - endif - push es - call near @@isbzimage ; pop cs ; ds=es=ss - ; prepare memcpy32 size & srcofs param to move zImage pm ifndef NO386 push 8 ; size hi @@ -171,59 +140,100 @@ mov dx,8 push dx ; size hi endif - push cx ; size lo=up to 512k - push ax ; src ofs hi = pm.fallback + push si ; size lo=up to 512k + push [dword _imgs+2] ; src ofs = pm.fallback ;in al,70h ;or al,80h ; disable NMI ;out 70h,al - push bx ; src ofs lo - xor di,di - push di ; src seg=0 + push si ; src seg=0 inc cx push cx ; dst ofs hi - push di ; dst ofs lo : 64k + push si ; dst ofs lo : 64k + + ; self move + extrn gdt_data + mov cx,offset gdt_data+8 + ;xor di,di ; A000 -9000 -0800(>movedend) + + ifdef NO386 + mov ax,ss + add ax,900h + push ax ; topseg()+0x0900 + else + push 9800h+(4096/16) ; 4096 bytes for cmdline + endif + pop es + push es + + call near @@movsb@jmp ; movsb; pop cs ; ds=es=ss + extrn memcpy32:near call memcpy32 ifdef MOVE_SETUP + mov si,0 + global _rm_offset:word + org $-2 +_rm_offset dw ? ;xor di,di - mov cx,8000h + ;mov cx,8000h ;sub cx,si - rep - movsb + ;rep + ; movsb endif ifndef noelks + ifdef MOVE_SETUP ifndef NO386 - cmp [dword 1E6h],'SKLE' + mov eax,[dword si+1E6h] + xor eax,'SKLE' + else + mov ax,[si+1E6h] + xor ax,'LE' jne @@notelks - xor si,si + mov ax,[si+1E8h] + xor ax,'SK' + endif else - mov si,1E6h - lodsw - cmp ax,'LE' + ifndef NO386 + mov eax,[dword 1E6h] + xor eax,'SKLE' + else + mov ax,[1E6h] + xor ax,'LE' jne @@notelks - lodsw + mov ax,[1E8h] xor ax,'SK' + endif + endif jne @@notelks - xchg ax,si + mov cx,100h ; DS=ES=SS=0100 + mov ss,cx + push ss + pop es + mov cl,20h ; CS=0120 + push cx + push ax ; IP=0000 endif ifdef MOVE_SETUP - mov ch,1h ; DS=ES=SS=0100 +@@notelks: + mov ch,7Eh +@@movsb@jmp: + xor di,di + rep + movsb else - mov cx,100h ; DS=ES=SS=0100 - endif - mov ss,cx - mov es,cx - mov cl,20h ; CS=0120 - push cx - push si ; IP=0000 - mov ch,3Fh ; 05h min, 3Fh max + ifndef noelks + xchg ax,si + mov ch,7Eh ; 0Ah min, 7Eh max +@@movsb@jmp: + xor di,di rep - movsw + movsb @@notelks: + endif endif @@isbzimage: push ss diff -r babd38118a53 -r 664d83fb04f9 linld/stuff/src/LOAD.CPP --- a/linld/stuff/src/LOAD.CPP Wed Nov 13 15:07:56 2019 +0100 +++ b/linld/stuff/src/LOAD.CPP Wed Nov 13 15:08:02 2019 +0100 @@ -111,8 +111,6 @@ const u32 HdrS = 'H' + ('d'<<8) + (u32('r')<<16) + (u32('S')<<24); -// register value to launch the kernel real mode code -u32 csip; #ifdef NO386 extern "C" u16 topseg(); #else @@ -128,13 +126,11 @@ struct image_himem *m = ± #define _rm_buf(m) (((u8**)(m))[-1]) #define _rm_size (((u16*)(m))[-2]) -#define _csip (((u32*)(m))[-2]) { struct kernelparams_t *kernelparams; kernelparams = &(((first1k_t*) (_rm_buf(m) = (u8 *)heap_top))->params); #define first1k ((first1k_t*)((u8 *)kernelparams-0x1F1)) - *((u16 *)&_csip+1)=topseg()|0x20; // Open kernel, read first kb, check it m->errmsg = kernel_file_error; open_image(m, kernel_name); @@ -146,7 +142,8 @@ if(kernelparams->setup_sects == 0) { #if 1 if(* (int *) &first1k->pad10[0x3F-0x24] == 0x3AE8) { - _csip+=0xFFE00042; + extern u16 csip_hilo; + csip_hilo=0x0042; } else #endif @@ -176,7 +173,7 @@ kernelparams->realmode_switch_ofs = (u16) last_ditch; kernelparams->realmode_switch_seg = _CS; m->fallback = base_himem; - pm_high++; + pm_low--; // Hook on int15 to work around fn 88 DOS breakage hook_int15_88(); // break _ES diff -r babd38118a53 -r 664d83fb04f9 linld/stuff/src/pipehole.awk --- a/linld/stuff/src/pipehole.awk Wed Nov 13 15:07:56 2019 +0100 +++ b/linld/stuff/src/pipehole.awk Wed Nov 13 15:08:02 2019 +0100 @@ -553,6 +553,7 @@ if (isnum(args[2])) { for (i = kept++; i > 0; i--) line[i] = line[i-1] line[0] = "\tlea\t" regs[1] ",[" regs[2] op args[2] "]" + sub(/\+-/,"-",line[0]) hold=10; next } line[kept++]=$0