wok-current rev 22288

linld: 8086 may load zImage (again)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Nov 13 15:08:02 2019 +0100 (2019-11-13)
parents babd38118a53
children 501273c1ac98
files linld/stuff/src/A20.ASM linld/stuff/src/COMMON.H linld/stuff/src/JUMP.ASM linld/stuff/src/LOAD.CPP linld/stuff/src/pipehole.awk
line diff
     1.1 --- a/linld/stuff/src/A20.ASM	Wed Nov 13 15:07:56 2019 +0100
     1.2 +++ b/linld/stuff/src/A20.ASM	Wed Nov 13 15:08:02 2019 +0100
     1.3 @@ -111,9 +111,9 @@
     1.4  		mov	dx,cs
     1.5  		add	dx,ax
     1.6  		mov	cx,0fffh
     1.7 -		extrn	_pm_high:byte
     1.8 -		test	[_pm_high],cl
     1.9 -		je	@zimage
    1.10 +		extrn	_pm_low:byte
    1.11 +		test	[_pm_low],cl
    1.12 +		jne	@zimage
    1.13  		extrn	_cpu386:byte
    1.14  		test	[_cpu386],cl
    1.15  		jne	@bzimage
    1.16 @@ -159,9 +159,9 @@
    1.17  		mov	dx,cs
    1.18  		add	ax,dx
    1.19  		mov	cx,0fffh
    1.20 -		extrn	_pm_high:byte
    1.21 -		test	[_pm_high],cl
    1.22 -		jne	@bzimage
    1.23 +		extrn	_pm_low:byte
    1.24 +		test	[_pm_low],cl
    1.25 +		je	@bzimage
    1.26  		cmp	ax,cx
    1.27  		jae	@sys@ok
    1.28  		xchg	ax,cx
     2.1 --- a/linld/stuff/src/COMMON.H	Wed Nov 13 15:07:56 2019 +0100
     2.2 +++ b/linld/stuff/src/COMMON.H	Wed Nov 13 15:08:02 2019 +0100
     2.3 @@ -54,7 +54,7 @@
     2.4  #define initrd (imgs[1])
     2.5  #define pm2initrd(p) (p+1)
     2.6  
     2.7 -extern u8 pm_high;
     2.8 +extern u8 pm_low;
     2.9  extern int skip_alloc;
    2.10  extern u32 base_himem;
    2.11  extern u32 far *initrd_desc;
     3.1 --- a/linld/stuff/src/JUMP.ASM	Wed Nov 13 15:07:56 2019 +0100
     3.2 +++ b/linld/stuff/src/JUMP.ASM	Wed Nov 13 15:08:02 2019 +0100
     3.3 @@ -92,40 +92,30 @@
     3.4  		endif
     3.5  		;cli				; we start doing destructive things to DOS
     3.6  		extrn	sssp:word
     3.7 -		mov	es,[sssp+2]
     3.8 -		push	es
     3.9 -		pop	ss
    3.10 -		mov	sp,0A000h
    3.11 -		extrn	_csip:dword
    3.12 -		ifdef NO386
    3.13 -		mov	si,offset _csip
    3.14 -		lodsw
    3.15 -		push	[word si]
    3.16 -		push	ax
    3.17 -		else
    3.18 -		push	[dword _csip]
    3.19 -		endif
    3.20 -
    3.21 -		ifdef	NO386
    3.22 -		mov	cx,ss
    3.23 -		add	ch,9
    3.24 -		push	cx			; topseg()+0x0900
    3.25 -		else
    3.26 -		push	9800h+(4096/16)		; 4096 bytes for cmdline
    3.27 -		endif
    3.28 -
    3.29 +		mov	ax,[sssp+2]
    3.30 +		mov	es,ax
    3.31  		extrn	_cmdline:word
    3.32  		mov	si,[_cmdline]
    3.33  		mov	di,8000h
    3.34 -		mov	ch,10h			; 4k
    3.35 +		mov	cx,2000h		; 4k for cmdline + 4k up to sp
    3.36  		rep
    3.37  		  movsb
    3.38 +		push	es
    3.39 +		pop	ss
    3.40 +		mov	sp,di
    3.41  
    3.42 -		mov	cl,0			; load high ?
    3.43 +		mov	dx,2000h
    3.44 +		global	_csip_hilo:word
    3.45 +		org	$-2
    3.46 +_csip_hilo	dw	?
    3.47 +		xchg	al,dh	; 9020 / 9000
    3.48 +		push	ax
    3.49 +		push	dx	; 0000 / 0042
    3.50 +
    3.51 +		mov	cl,1			; load high ?
    3.52  		org	$-1
    3.53 -		global	_pm_high:byte
    3.54 -_pm_high	db	?
    3.55 -		inc	cx
    3.56 +		global	_pm_low:byte
    3.57 +_pm_low		db	?
    3.58  		push	cx
    3.59  		mov	ax,[word ss:024Ch]
    3.60  		xor	ax,2b30h		; ipxe ?
    3.61 @@ -141,29 +131,8 @@
    3.62  
    3.63  @@notipxe:
    3.64  		pop	cx
    3.65 -		pop	es			; min 2048 bytes for stack
    3.66  		loop	@@isbzimage
    3.67  
    3.68 -		; self move
    3.69 -		;cld
    3.70 -		extrn	gdt_data
    3.71 -		mov	cx,offset gdt_data+8
    3.72 -		xor	di,di			;  A000 -9000 -0800(>movedend)
    3.73 -		rep
    3.74 -		  movsb
    3.75 -		mov	si,offset _imgs+2
    3.76 -		lodsw
    3.77 -		xchg	ax,bx			; get pm->fallback low word
    3.78 -		lodsw				; get pm->fallback high word
    3.79 -		ifdef	MOVE_SETUP
    3.80 -		mov	si,0
    3.81 -	global	_rm_offset:word
    3.82 -		org	$-2
    3.83 -_rm_offset	dw	?
    3.84 -		endif
    3.85 -		push	es
    3.86 -		call	near @@isbzimage	; pop cs ; ds=es=ss
    3.87 -
    3.88  		; prepare memcpy32 size & srcofs param to move zImage pm
    3.89  		ifndef	NO386
    3.90  		push	8			; size hi
    3.91 @@ -171,59 +140,100 @@
    3.92  		mov	dx,8
    3.93  		push	dx			; size hi
    3.94  		endif
    3.95 -		push	cx			; size lo=up to 512k
    3.96 -		push	ax			; src ofs hi = pm.fallback
    3.97 +		push	si			; size lo=up to 512k
    3.98 +		push	[dword _imgs+2]		; src ofs = pm.fallback
    3.99  
   3.100  		;in	al,70h
   3.101  		;or	al,80h			; disable NMI
   3.102  		;out	70h,al
   3.103  
   3.104 -		push	bx			; src ofs lo
   3.105 -		xor	di,di
   3.106 -		push	di			; src seg=0
   3.107 +		push	si			; src seg=0
   3.108  		inc	cx
   3.109  		push	cx			; dst ofs hi
   3.110 -		push	di			; dst ofs lo : 64k
   3.111 +		push	si			; dst ofs lo : 64k
   3.112 +
   3.113 +		; self move
   3.114 +		extrn	gdt_data
   3.115 +		mov	cx,offset gdt_data+8
   3.116 +		;xor	di,di			;  A000 -9000 -0800(>movedend)
   3.117 +
   3.118 +		ifdef	NO386
   3.119 +		mov	ax,ss
   3.120 +		add	ax,900h
   3.121 +		push	ax			; topseg()+0x0900
   3.122 +		else
   3.123 +		push	9800h+(4096/16)		; 4096 bytes for cmdline
   3.124 +		endif
   3.125 +		pop	es
   3.126 +		push	es
   3.127 +
   3.128 +		call	near @@movsb@jmp	; movsb; pop cs ; ds=es=ss
   3.129 +
   3.130  		extrn   memcpy32:near
   3.131  		call	memcpy32
   3.132  
   3.133  		ifdef	MOVE_SETUP
   3.134 +		mov	si,0
   3.135 +	global	_rm_offset:word
   3.136 +		org	$-2
   3.137 +_rm_offset	dw	?
   3.138  		;xor	di,di
   3.139 -		mov	cx,8000h
   3.140 +		;mov	cx,8000h
   3.141  		;sub	cx,si
   3.142 -		rep
   3.143 -		  movsb
   3.144 +		;rep
   3.145 +		;  movsb
   3.146  		endif
   3.147  
   3.148  		ifndef  noelks
   3.149 +		ifdef	MOVE_SETUP
   3.150  		ifndef	NO386
   3.151 -		cmp	[dword 1E6h],'SKLE'
   3.152 +		mov	eax,[dword si+1E6h]
   3.153 +		xor	eax,'SKLE'
   3.154 +		else
   3.155 +		mov	ax,[si+1E6h]
   3.156 +		xor	ax,'LE'
   3.157  		jne	@@notelks
   3.158 -		xor	si,si
   3.159 +		mov	ax,[si+1E8h]
   3.160 +		xor	ax,'SK'
   3.161 +		endif
   3.162  		else
   3.163 -		mov	si,1E6h
   3.164 -		lodsw
   3.165 -		cmp	ax,'LE'
   3.166 +		ifndef	NO386
   3.167 +		mov	eax,[dword 1E6h]
   3.168 +		xor	eax,'SKLE'
   3.169 +		else
   3.170 +		mov	ax,[1E6h]
   3.171 +		xor	ax,'LE'
   3.172  		jne	@@notelks
   3.173 -		lodsw
   3.174 +		mov	ax,[1E8h]
   3.175  		xor	ax,'SK'
   3.176 +		endif
   3.177 +		endif
   3.178  		jne	@@notelks
   3.179 -		xchg	ax,si
   3.180 +		mov	cx,100h		; DS=ES=SS=0100
   3.181 +		mov	ss,cx
   3.182 +		push	ss
   3.183 +		pop	es
   3.184 +		mov	cl,20h		; CS=0120
   3.185 +		push	cx
   3.186 +		push	ax		; IP=0000
   3.187  		endif
   3.188  		ifdef	MOVE_SETUP
   3.189 -		mov	ch,1h		; DS=ES=SS=0100
   3.190 +@@notelks:
   3.191 +		mov	ch,7Eh
   3.192 +@@movsb@jmp:
   3.193 +		xor	di,di
   3.194 +		rep
   3.195 +		  movsb
   3.196  		else
   3.197 -		mov	cx,100h		; DS=ES=SS=0100
   3.198 -		endif
   3.199 -		mov	ss,cx
   3.200 -		mov	es,cx
   3.201 -		mov	cl,20h		; CS=0120
   3.202 -		push	cx
   3.203 -		push	si		; IP=0000
   3.204 -		mov	ch,3Fh		; 05h min, 3Fh max
   3.205 +		 ifndef  noelks
   3.206 +		xchg	ax,si
   3.207 +		mov	ch,7Eh		; 0Ah min, 7Eh max
   3.208 +@@movsb@jmp:
   3.209 +		xor	di,di
   3.210  		rep
   3.211 -		  movsw
   3.212 +		  movsb
   3.213  @@notelks:
   3.214 +		 endif
   3.215  		endif
   3.216  @@isbzimage:
   3.217  		push	ss
     4.1 --- a/linld/stuff/src/LOAD.CPP	Wed Nov 13 15:07:56 2019 +0100
     4.2 +++ b/linld/stuff/src/LOAD.CPP	Wed Nov 13 15:08:02 2019 +0100
     4.3 @@ -111,8 +111,6 @@
     4.4  
     4.5  const u32 HdrS = 'H' + ('d'<<8) + (u32('r')<<16) + (u32('S')<<24);
     4.6  
     4.7 -// register value to launch the kernel real mode code
     4.8 -u32 csip;
     4.9  #ifdef NO386
    4.10  extern "C" u16 topseg();
    4.11  #else
    4.12 @@ -128,13 +126,11 @@
    4.13      struct	image_himem *m = &pm;
    4.14  #define _rm_buf(m)	(((u8**)(m))[-1])
    4.15  #define _rm_size	(((u16*)(m))[-2])
    4.16 -#define _csip		(((u32*)(m))[-2])
    4.17    {
    4.18      struct kernelparams_t *kernelparams;
    4.19      kernelparams = &(((first1k_t*) (_rm_buf(m) = (u8 *)heap_top))->params);
    4.20  #define first1k		((first1k_t*)((u8 *)kernelparams-0x1F1))
    4.21  
    4.22 -    *((u16 *)&_csip+1)=topseg()|0x20;
    4.23      // Open kernel, read first kb, check it
    4.24      m->errmsg = kernel_file_error;
    4.25      open_image(m, kernel_name);
    4.26 @@ -146,7 +142,8 @@
    4.27      if(kernelparams->setup_sects == 0) {
    4.28  #if 1
    4.29          if(* (int *) &first1k->pad10[0x3F-0x24] == 0x3AE8) {
    4.30 -            _csip+=0xFFE00042;
    4.31 +	    extern u16 csip_hilo;
    4.32 +	    csip_hilo=0x0042;
    4.33          }
    4.34          else
    4.35  #endif
    4.36 @@ -176,7 +173,7 @@
    4.37  	    kernelparams->realmode_switch_ofs = (u16) last_ditch;
    4.38  	    kernelparams->realmode_switch_seg = _CS;
    4.39  	    m->fallback = base_himem;
    4.40 -            pm_high++;
    4.41 +            pm_low--;
    4.42  
    4.43              // Hook on int15 to work around fn 88 DOS breakage
    4.44              hook_int15_88(); // break _ES
     5.1 --- a/linld/stuff/src/pipehole.awk	Wed Nov 13 15:07:56 2019 +0100
     5.2 +++ b/linld/stuff/src/pipehole.awk	Wed Nov 13 15:08:02 2019 +0100
     5.3 @@ -553,6 +553,7 @@
     5.4  			if (isnum(args[2])) {
     5.5  				for (i = kept++; i > 0; i--) line[i] = line[i-1]
     5.6  				line[0] = "\tlea\t" regs[1] ",[" regs[2] op args[2] "]"
     5.7 +				sub(/\+-/,"-",line[0])
     5.8  				hold=10; next
     5.9  			}
    5.10  			line[kept++]=$0