# HG changeset patch # User Pascal Bellard # Date 1540135830 -7200 # Node ID 81a3d87e09650d6d96f4e7bf88242fd8db8ef153 # Parent 71d2f23048269c26c331d48a0feee0bee6b39ca3 linld: ipxe does not respect realmode_switch protocol diff -r 71d2f2304826 -r 81a3d87e0965 linld/stuff/src/CRTL.ASM --- a/linld/stuff/src/CRTL.ASM Sat Oct 20 21:17:14 2018 +0200 +++ b/linld/stuff/src/CRTL.ASM Sun Oct 21 17:30:30 2018 +0200 @@ -471,7 +471,7 @@ ends ;}; ;*************************************************************** -;void next_chunk(struct image_himem *di); +;long next_chunk(struct image_himem *di); ;*************************************************************** proc next_chunk near @@ -861,29 +861,22 @@ global _open_image:near proc _open_image near - arg fname :word, \ - m :word = PARAM_SIZE - - push bp - mov bp,sp - push si di + pop ax ;caller return address + pop bx ; name + pop cx ; m + push cx + push bx + push ax + push di + mov di,cx ifndef NO386 xor eax,eax ; 1st loop flag + eos else xor ax,ax ; 1st loop flag + eos endif - mov di,[m] - cmp [(image_himem di).fd],ax - jnz @@alreadydone - ifndef NO386 - mov [(image_himem di).size],eax ; m->size = 0L - else - mov [word (image_himem di).size],ax ; m->size = 0L - mov [word ((image_himem di).size)+2],ax - endif mov [(image_himem di).next_chunk],offset next_chunk - mov si,[fname] - mov [(image_himem di).state],si + mov [(image_himem di).state],bx + push bx @@next: push di call [(image_himem di).next_chunk] ; m->next_chunk() @@ -905,22 +898,16 @@ inc cx ; jcxnz loop @@next endif - mov [(image_himem di).state],si - push di + pop [(image_himem di).state] call [(image_himem di).next_chunk] ; m->next_chunk() - pop di -@@alreadydone: - push ax -image_done: - pop ax - pop di si bp + pop di ret endp _open_image ;*************************************************************** -;int read_image(struct image_himem *m, void* data, int sz); +;int read_image(struct image_himem *m, char* data, int sz); ;*************************************************************** global _read_image:near proc _read_image near @@ -931,7 +918,7 @@ push bp mov bp,sp - push si di + push di ifndef NO386 push 0 ; return value else @@ -941,23 +928,19 @@ mov di,[m] @@loop: ifndef NO386 - xor ecx,ecx - mov cx,[word sz] -@@chksz: + movzx ecx,[word sz] mov eax,[(image_himem di).chunk_size] cmp ecx,eax jb @@szok - xchg eax,ecx else mov cx,[word sz] -@@chksz: mov ax,[word (image_himem di).chunk_size] cmp cx,ax jb @@szok cmp [word ((image_himem di).chunk_size)+2],0 ; hi m->chunk_size jne @@szok + endif xchg ax,cx - endif @@szok: jcxz image_done push cx @@ -966,7 +949,7 @@ call _read pop dx pop bx - pop dx + pop cx jc image_done add bx,ax xor cx,cx @@ -985,7 +968,7 @@ @@fill: test al,3 je @@filled - mov [bx],dl + mov [bx],dh inc bx inc ax jmp @@fill @@ -996,19 +979,21 @@ sub [word (image_himem di).remaining],ax sbb [word ((image_himem di).remaining)+2],dx endif - add [bp-4-2],ax + add [bp-2-2],ax add [word data],ax sub [word sz],ax pushf - and cx,[(image_himem di).next_chunk] - jz @@same_chunk + jcxz @@same_chunk push di - call cx ; m->next_chunk() + call [(image_himem di).next_chunk] pop di @@same_chunk: popf jnz @@loop - jmp image_done +image_done: + pop ax + pop di bp + ret endp _read_image diff -r 71d2f2304826 -r 81a3d87e0965 linld/stuff/src/HIMEM.CPP --- a/linld/stuff/src/HIMEM.CPP Sat Oct 20 21:17:14 2018 +0200 +++ b/linld/stuff/src/HIMEM.CPP Sun Oct 21 17:30:30 2018 +0200 @@ -9,25 +9,8 @@ struct image_himem imgs[2]; int skip_alloc; -// Called from inside kernel just before rm->pm -// _loadds _saveregs: done by hand -void far last_ditch() { -// cli(); // we start doing *really* destructive things to DOS/BIOS - // it means: do not even try to enable ints - // or call BIOS services after this - asm { - push ds - push cs - pop ds -#ifndef NO386 - pusha -#else - push ax - push bx - push cx - push dx -#endif - } +// Called just before rm->pm +void last_ditch() { struct image_himem *m = ± vm2rm(); if(((u16 *)&m->fallback)[1] >= 0x10) m->fallback = _1m; // >= _1m ? @@ -68,17 +51,6 @@ } while(p != m->bufv); } } - asm { -#ifndef NO386 - popa -#else - pop dx - pop cx - pop bx - pop ax -#endif - pop ds - } } void load_image(struct image_himem *m) { diff -r 71d2f2304826 -r 81a3d87e0965 linld/stuff/src/JUMP.ASM --- a/linld/stuff/src/JUMP.ASM Sat Oct 20 21:17:14 2018 +0200 +++ b/linld/stuff/src/JUMP.ASM Sun Oct 21 17:30:30 2018 +0200 @@ -143,23 +143,16 @@ mov ch,10h ; 4k rep movsb + cmp al,cl ; load high ? + pushf ifdef NO386 add bh,9 - endif - cmp al,cl ; load high ? - ifdef noelks - jne @@isbzimage - else - jne @@isbzimagez - endif - ifdef NO386 push bx ; topseg()+0x0900 else push 9800h+(4096/16) ; 4096 bytes for cmdline endif ; finish loading extrn @last_ditch$qv:near - push cs call @last_ditch$qv ; self move ;cld @@ -169,7 +162,14 @@ xor di,di ; set ZF rep movsb - mov ax,[word _imgs+2+2] ; get pm->fallback high word + push es + dos_shutdown ; clear di; ds=0 + pop es + popf + jne @@isbzimage + mov ax,[word cs:_imgs+2+2] ; get pm->fallback high word + push es + call near @@isbzimage ; pop cs ; ds=es=ss ; prepare memcpy32 size & srcofs param to move zImage pm mov dx,8 @@ -182,9 +182,6 @@ push cx ; size lo=up to 512k push ax ; src ofs ho = pm.fallback - push es - dos_shutdown ; clear di - call near @@isbzimage ; pop cs ; ds=es=ss ;in al,70h ;or al,80h ; disable NMI ;out 70h,al @@ -227,7 +224,6 @@ mov es,cx mov ch,05h ; 500h mini rep -@@isbzimagez: movsw @@notelks: endif diff -r 71d2f2304826 -r 81a3d87e0965 linld/stuff/src/LOAD.CPP --- a/linld/stuff/src/LOAD.CPP Sat Oct 20 21:17:14 2018 +0200 +++ b/linld/stuff/src/LOAD.CPP Sun Oct 21 17:30:30 2018 +0200 @@ -193,11 +193,6 @@ // Hook on int15 to work around fn 88 DOS breakage hook_int15_88(); - - // * will be called just before rm -> pm - extern void far last_ditch(); - kernelparams->realmode_switch_ofs = ofs((void *)last_ditch); - kernelparams->realmode_switch_seg = seg(last_ditch); } if(kernelparams->kernel_version) version_string = (char *) first1k+kernelparams->kernel_version+0x200;