wok rev 22183

linld: 8086 may load zImage (elks)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Nov 10 18:20:50 2019 +0100 (2019-11-10)
parents 8e65b867668e
children 54fe236b54a6
files linld/stuff/src/A20.ASM linld/stuff/src/LINLD.CPP linld/stuff/src/_BEG.ASM
line diff
     1.1 --- a/linld/stuff/src/A20.ASM	Sun Nov 10 16:17:01 2019 +0100
     1.2 +++ b/linld/stuff/src/A20.ASM	Sun Nov 10 18:20:50 2019 +0100
     1.3 @@ -18,6 +18,9 @@
     1.4  		dw	_enable_a20_fast, _enable_a20_kbd, _enable_a20_xmm, die
     1.5  msg_a20		db	"Can't use A20",0
     1.6  overflow	db	"Out of memory",0
     1.7 +		ifdef	NO386
     1.8 +bzimage86	db	"No bzImage on 8086",0
     1.9 +		endif
    1.10  	global	sssp:dword
    1.11  	global	_initrd_desc:dword
    1.12  _initrd_desc	dd	90000218h
    1.13 @@ -110,7 +113,13 @@
    1.14  		mov	cx,0fffh
    1.15  		extrn	_pm_high:byte
    1.16  		test	[_pm_high],cl
    1.17 +		je	@zimage
    1.18 +		extrn	_cpu386:byte
    1.19 +		test	[_cpu386],cl
    1.20  		jne	@bzimage
    1.21 +		mov	bx,offset bzimage86
    1.22 +		jmp	godie
    1.23 +@zimage:
    1.24  		xchg	ax,dx
    1.25  		cmp	ax,cx
    1.26  		jae	@sys@ok
    1.27 @@ -138,6 +147,10 @@
    1.28  		extrn	_topseg:near
    1.29  		call	near _topseg
    1.30  		mov	[word sssp+2],ax
    1.31 +		and	ch,0
    1.32 +		org	$-1
    1.33 +		global	_vcpi:byte
    1.34 +_vcpi		db	?
    1.35  		else
    1.36                  p386
    1.37  		movzx	eax,[word _heap_top]
    1.38 @@ -169,6 +182,8 @@
    1.39  @bzimage:
    1.40  		xchg	ax,dx
    1.41  		mov	ax,9000h
    1.42 +		extrn	_vcpi:byte
    1.43 +		and	ch,[_vcpi]
    1.44  		endif
    1.45  		add	dh,ch		; room for malloc_bufv_or_die
    1.46  		cmp	dx,ax
    1.47 @@ -176,6 +191,7 @@
    1.48  @overflow:
    1.49  ; Oops! We can stomp on our toes... better stop now
    1.50  		mov	bx,offset overflow
    1.51 +godie:
    1.52  		call	near die
    1.53  @nooverflow:
    1.54  		les	cx,[bx-4]	; rm size
     2.1 --- a/linld/stuff/src/LINLD.CPP	Sun Nov 10 16:17:01 2019 +0100
     2.2 +++ b/linld/stuff/src/LINLD.CPP	Sun Nov 10 18:20:50 2019 +0100
     2.3 @@ -164,5 +164,5 @@
     2.4  #endif
     2.5  
     2.6      // Let compiler be happy
     2.7 -    return _AX;
     2.8 +    //return _AX;
     2.9  }
     3.1 --- a/linld/stuff/src/_BEG.ASM	Sun Nov 10 16:17:01 2019 +0100
     3.2 +++ b/linld/stuff/src/_BEG.ASM	Sun Nov 10 18:20:50 2019 +0100
     3.3 @@ -18,11 +18,12 @@
     3.4          global  _data_start:byte
     3.5          label   _data_start byte
     3.6  		ifndef	NO386
     3.7 -msg_badcpu      db      "I need 386+ CPU in real mode or under VCPI manager",0
     3.8 +msg_badcpu      db      "I need 386+ CPU in real mode w/o paging"
     3.9 +		db	" or "
    3.10 +msg_badmapping	db	"under VCPI 4.0+ manager with low 640k 1:1 mapping"
    3.11 +        global  _vcpi:byte
    3.12 +_vcpi		db	0
    3.13  		endif
    3.14 -        global  _vcpi:byte
    3.15 -msg_badmapping  db      "VCPI: low 640k need 1:1 mapping"
    3.16 -_vcpi		db	0
    3.17  
    3.18          ends    _DATA
    3.19  
    3.20 @@ -36,6 +37,11 @@
    3.21          label   _version_string byte
    3.22  		db	STACK_SIZE-2 dup(?)
    3.23  stktop		dw	?
    3.24 +		ifdef	NO386
    3.25 +        global  _cpu386:byte
    3.26 +_cpu386		db	?
    3.27 +		org	$-1
    3.28 +		endif
    3.29          global  _cpu_features:dword
    3.30  _cpu_features	dd	?
    3.31          ends    _BSS
    3.32 @@ -73,9 +79,9 @@
    3.33  		add	dh,bh		; NS=386+, S+NC=286, S+C=86/186
    3.34  		ifndef	NO386
    3.35  		mov	bx,offset msg_badcpu
    3.36 -                js	godie   	;it is not a 386+
    3.37 +                js	godie   	;it is not a 386+, die
    3.38  		else
    3.39 -                js	endcpu86   	;it is not a 386+
    3.40 +                js	endcpu86   	;it is not a 386+, try ELKS & co
    3.41  		endif
    3.42                  p386
    3.43  ; Check for vm
    3.44 @@ -89,11 +95,15 @@
    3.45                  mov     eax,cr0
    3.46                  inc     eax             ;CR0_PG to S
    3.47  		jns	endcpu386
    3.48 -no_vcpi:
    3.49 +		ifndef	NO386
    3.50                  p8086
    3.51                  extrn   die:near
    3.52  godie:
    3.53 +no_vcpi:
    3.54  		call	near die
    3.55 +		else
    3.56 +		jmp	endcpu86
    3.57 +		endif
    3.58  
    3.59  ;***************************************************************
    3.60  ; checks for vcpi
    3.61 @@ -145,9 +155,16 @@
    3.62  ;    get_vcpi_interface() || die("VCPI: low 640k: need 1:1 mapping");
    3.63                  ;extrn   _get_vcpi_interface:near
    3.64  		;call	_get_vcpi_interface
    3.65 +		ifndef	NO386
    3.66  		mov	bx,offset msg_badmapping
    3.67  		jnz	no_vcpi
    3.68 -		inc	[byte bx+_vcpi-msg_badmapping]
    3.69 +		dec	[byte bx+_vcpi-msg_badmapping]
    3.70 +		else
    3.71 +		jnz	no_vcpi
    3.72 +		extrn	_vcpi:byte
    3.73 +		dec	[byte _vcpi]
    3.74 +no_vcpi:
    3.75 +		endif
    3.76  endcpu386:
    3.77  		pushfd
    3.78  		pop	dx
    3.79 @@ -164,6 +181,9 @@
    3.80  		je	@@no_cpuid	; CPUID feature bit changed ?
    3.81  		mov	eax,80000001h	; Extended Processor Info and Feature Bits
    3.82  		cpuid
    3.83 +		ifdef	NO386
    3.84 +		mov	dl,-1		; set 386 flag
    3.85 +		endif
    3.86  		mov	[_cpu_features],edx
    3.87  @@no_cpuid:
    3.88  endcpu86: