wok rev 20484

linld: ipxe does not respect realmode_switch protocol
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Oct 21 17:30:30 2018 +0200 (2018-10-21)
parents 71d2f2304826
children f5088c165f51
files linld/stuff/src/CRTL.ASM linld/stuff/src/HIMEM.CPP linld/stuff/src/JUMP.ASM linld/stuff/src/LOAD.CPP
line diff
     1.1 --- a/linld/stuff/src/CRTL.ASM	Sat Oct 20 21:17:14 2018 +0200
     1.2 +++ b/linld/stuff/src/CRTL.ASM	Sun Oct 21 17:30:30 2018 +0200
     1.3 @@ -471,7 +471,7 @@
     1.4  ends				;};
     1.5  
     1.6  ;***************************************************************
     1.7 -;void next_chunk(struct image_himem *di);
     1.8 +;long next_chunk(struct image_himem *di);
     1.9  ;***************************************************************
    1.10          proc    next_chunk near
    1.11  
    1.12 @@ -861,29 +861,22 @@
    1.13          global  _open_image:near
    1.14          proc    _open_image near
    1.15  
    1.16 -		arg	fname	:word,	\
    1.17 -			m	:word	= PARAM_SIZE
    1.18 -
    1.19 -		push	bp
    1.20 -		mov	bp,sp
    1.21 -                push	si di
    1.22 +		pop	ax			;caller return address
    1.23 +		pop	bx			; name
    1.24 +		pop	cx			; m
    1.25 +		push	cx
    1.26 +		push	bx
    1.27 +		push	ax
    1.28 +                push	di
    1.29 +		mov	di,cx
    1.30  		ifndef	NO386
    1.31                  xor	eax,eax			; 1st loop flag + eos
    1.32  		else
    1.33                  xor	ax,ax			; 1st loop flag + eos
    1.34  		endif
    1.35 -                mov	di,[m]
    1.36 -		cmp	[(image_himem di).fd],ax
    1.37 -                jnz	@@alreadydone
    1.38 -		ifndef	NO386
    1.39 -		mov	[(image_himem di).size],eax	; m->size = 0L
    1.40 -		else
    1.41 -		mov	[word (image_himem di).size],ax	; m->size = 0L
    1.42 -		mov	[word ((image_himem di).size)+2],ax
    1.43 -		endif
    1.44  		mov	[(image_himem di).next_chunk],offset next_chunk
    1.45 -                mov	si,[fname]
    1.46 -                mov	[(image_himem di).state],si
    1.47 +                mov	[(image_himem di).state],bx
    1.48 +		push	bx
    1.49  @@next:
    1.50  		push	di
    1.51                  call	[(image_himem di).next_chunk]	; m->next_chunk()
    1.52 @@ -905,22 +898,16 @@
    1.53  		inc	cx			; jcxnz
    1.54  		loop	@@next
    1.55  		endif
    1.56 -                mov	[(image_himem di).state],si
    1.57 -		push	di
    1.58 +                pop	[(image_himem di).state]
    1.59                  call	[(image_himem di).next_chunk]	; m->next_chunk()
    1.60 -		pop	di
    1.61 -@@alreadydone:
    1.62 -                push	ax
    1.63 -image_done:
    1.64 -                pop	ax
    1.65 -                pop	di si bp
    1.66 +                pop	di
    1.67  		ret
    1.68  
    1.69          endp    _open_image
    1.70  
    1.71  
    1.72  ;***************************************************************
    1.73 -;int read_image(struct image_himem *m, void* data, int sz);
    1.74 +;int read_image(struct image_himem *m, char* data, int sz);
    1.75  ;***************************************************************
    1.76          global  _read_image:near
    1.77          proc    _read_image near
    1.78 @@ -931,7 +918,7 @@
    1.79  
    1.80  		push	bp
    1.81  		mov	bp,sp
    1.82 -		push	si di
    1.83 +		push	di
    1.84  		ifndef	NO386
    1.85  		push	0		; return value
    1.86  		else
    1.87 @@ -941,23 +928,19 @@
    1.88  		mov	di,[m]
    1.89  @@loop:
    1.90  		ifndef	NO386
    1.91 -		xor	ecx,ecx
    1.92 -		mov	cx,[word sz]
    1.93 -@@chksz:
    1.94 +		movzx	ecx,[word sz]
    1.95  		mov	eax,[(image_himem di).chunk_size]
    1.96  		cmp	ecx,eax
    1.97  		jb	@@szok
    1.98 -		xchg	eax,ecx
    1.99  		else
   1.100  		mov	cx,[word sz]
   1.101 -@@chksz:
   1.102  		mov	ax,[word (image_himem di).chunk_size]
   1.103  		cmp	cx,ax
   1.104  		jb	@@szok
   1.105  		cmp	[word ((image_himem di).chunk_size)+2],0	; hi m->chunk_size
   1.106  		jne	@@szok
   1.107 +		endif
   1.108  		xchg	ax,cx
   1.109 -		endif
   1.110  @@szok:
   1.111  		jcxz	image_done
   1.112  		push	cx
   1.113 @@ -966,7 +949,7 @@
   1.114  		call	_read
   1.115  		pop	dx
   1.116  		pop	bx
   1.117 -		pop	dx
   1.118 +		pop	cx
   1.119  		jc	image_done
   1.120  		add	bx,ax
   1.121  		xor	cx,cx
   1.122 @@ -985,7 +968,7 @@
   1.123  @@fill:
   1.124  		test	al,3
   1.125  		je	@@filled
   1.126 -		mov	[bx],dl
   1.127 +		mov	[bx],dh
   1.128  		inc	bx
   1.129  		inc	ax
   1.130  		jmp	@@fill
   1.131 @@ -996,19 +979,21 @@
   1.132  		sub	[word (image_himem di).remaining],ax
   1.133  		sbb	[word ((image_himem di).remaining)+2],dx
   1.134  		endif
   1.135 -		add	[bp-4-2],ax
   1.136 +		add	[bp-2-2],ax
   1.137  		add	[word data],ax
   1.138  		sub	[word sz],ax
   1.139  		pushf
   1.140 -                and	cx,[(image_himem di).next_chunk]
   1.141 -		jz	@@same_chunk
   1.142 +		jcxz	@@same_chunk
   1.143  		push	di
   1.144 -                call	cx			; m->next_chunk()
   1.145 +                call	[(image_himem di).next_chunk]
   1.146  		pop	di
   1.147  @@same_chunk:
   1.148  		popf
   1.149  		jnz	@@loop
   1.150 -		jmp	image_done
   1.151 +image_done:
   1.152 +                pop	ax
   1.153 +                pop	di bp
   1.154 +		ret
   1.155  
   1.156          endp    _read_image
   1.157  
     2.1 --- a/linld/stuff/src/HIMEM.CPP	Sat Oct 20 21:17:14 2018 +0200
     2.2 +++ b/linld/stuff/src/HIMEM.CPP	Sun Oct 21 17:30:30 2018 +0200
     2.3 @@ -9,25 +9,8 @@
     2.4  struct image_himem imgs[2];
     2.5  int skip_alloc;
     2.6  
     2.7 -// Called from inside kernel just before rm->pm
     2.8 -// _loadds _saveregs: done by hand
     2.9 -void far last_ditch() {
    2.10 -//    cli();  // we start doing *really* destructive things to DOS/BIOS
    2.11 -            // it means: do not even try to enable ints
    2.12 -            // or call BIOS services after this
    2.13 -    asm {
    2.14 -        push    ds
    2.15 -        push    cs
    2.16 -        pop     ds
    2.17 -#ifndef NO386
    2.18 -        pusha
    2.19 -#else
    2.20 -        push	ax
    2.21 -        push	bx
    2.22 -        push	cx
    2.23 -        push	dx
    2.24 -#endif
    2.25 -    }
    2.26 +// Called just before rm->pm
    2.27 +void last_ditch() {
    2.28      struct image_himem *m = &pm;
    2.29      vm2rm();
    2.30      if(((u16 *)&m->fallback)[1] >= 0x10) m->fallback = _1m; // >= _1m ?
    2.31 @@ -68,17 +51,6 @@
    2.32              } while(p != m->bufv);
    2.33          }
    2.34      }
    2.35 -    asm {
    2.36 -#ifndef NO386
    2.37 -        popa
    2.38 -#else
    2.39 -        pop	dx
    2.40 -        pop	cx
    2.41 -        pop	bx
    2.42 -        pop	ax
    2.43 -#endif
    2.44 -        pop     ds
    2.45 -    }
    2.46  }
    2.47  
    2.48  void load_image(struct image_himem *m) {
     3.1 --- a/linld/stuff/src/JUMP.ASM	Sat Oct 20 21:17:14 2018 +0200
     3.2 +++ b/linld/stuff/src/JUMP.ASM	Sun Oct 21 17:30:30 2018 +0200
     3.3 @@ -143,23 +143,16 @@
     3.4  		mov	ch,10h			; 4k
     3.5  		rep
     3.6  		  movsb
     3.7 +		cmp	al,cl			; load high ?
     3.8 +		pushf
     3.9  		ifdef	NO386
    3.10  		add	bh,9
    3.11 -		endif
    3.12 -		cmp	al,cl			; load high ?
    3.13 -		ifdef  noelks
    3.14 -		jne	@@isbzimage
    3.15 -		else
    3.16 -		jne	@@isbzimagez
    3.17 -		endif
    3.18 -		ifdef	NO386
    3.19  		push	bx			; topseg()+0x0900
    3.20  		else
    3.21  		push	9800h+(4096/16)		; 4096 bytes for cmdline
    3.22  		endif
    3.23  		; finish loading
    3.24  		extrn   @last_ditch$qv:near
    3.25 -		push	cs
    3.26  		call	@last_ditch$qv
    3.27  		; self move
    3.28  		;cld
    3.29 @@ -169,7 +162,14 @@
    3.30  		xor	di,di			; set ZF
    3.31  		rep
    3.32  		  movsb
    3.33 -		mov	ax,[word _imgs+2+2]	; get pm->fallback high word
    3.34 +		push	es
    3.35 +		dos_shutdown			; clear di; ds=0
    3.36 +		pop	es
    3.37 +		popf
    3.38 +		jne	@@isbzimage
    3.39 +		mov	ax,[word cs:_imgs+2+2]	; get pm->fallback high word
    3.40 +		push	es
    3.41 +		call	near @@isbzimage	; pop cs ; ds=es=ss
    3.42  
    3.43  		; prepare memcpy32 size & srcofs param to move zImage pm
    3.44  		mov	dx,8
    3.45 @@ -182,9 +182,6 @@
    3.46  		push	cx			; size lo=up to 512k
    3.47  		push	ax			; src ofs ho = pm.fallback
    3.48  
    3.49 -		push	es
    3.50 -		dos_shutdown			; clear di
    3.51 -		call	near @@isbzimage	; pop cs ; ds=es=ss
    3.52  		;in	al,70h
    3.53  		;or	al,80h			; disable NMI
    3.54  		;out	70h,al
    3.55 @@ -227,7 +224,6 @@
    3.56  		mov	es,cx
    3.57  		mov	ch,05h		; 500h mini
    3.58  		rep
    3.59 -@@isbzimagez:
    3.60  		  movsw
    3.61  @@notelks:
    3.62  		endif
     4.1 --- a/linld/stuff/src/LOAD.CPP	Sat Oct 20 21:17:14 2018 +0200
     4.2 +++ b/linld/stuff/src/LOAD.CPP	Sun Oct 21 17:30:30 2018 +0200
     4.3 @@ -193,11 +193,6 @@
     4.4  
     4.5              // Hook on int15 to work around fn 88 DOS breakage
     4.6              hook_int15_88();
     4.7 -
     4.8 -            // * will be called just before rm -> pm
     4.9 -	    extern void far last_ditch();
    4.10 -            kernelparams->realmode_switch_ofs = ofs((void *)last_ditch);
    4.11 -            kernelparams->realmode_switch_seg = seg(last_ditch);
    4.12          }
    4.13          if(kernelparams->kernel_version)
    4.14              version_string = (char *) first1k+kernelparams->kernel_version+0x200;