wok rev 22152
linld: hack for VCPI
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Wed Nov 06 21:02:18 2019 +0100 (2019-11-06) |
parents | a1677855824a |
children | 5e2ff29a06d7 |
files | linld/stuff/src/CRTL.ASM linld/stuff/src/CRTL.H linld/stuff/src/HIMEM.CPP linld/stuff/src/JUMP.ASM linld/stuff/src/LOAD.CPP linld/stuff/src/VCPI.ASM linld/stuff/src/pipehole.awk |
line diff
1.1 --- a/linld/stuff/src/CRTL.ASM Wed Nov 06 17:56:42 2019 +0100 1.2 +++ b/linld/stuff/src/CRTL.ASM Wed Nov 06 21:02:18 2019 +0100 1.3 @@ -57,8 +57,6 @@ 1.4 org $-7 1.5 endif 1.6 _xfer_buf db 4096 dup (?) 1.7 - global _no_exit:byte 1.8 -_no_exit db ? 1.9 filecnt db ? ; in fact 0 minus file count... 1.10 nextfilename dw ? 1.11 ifdef LARGE_IMAGES 1.12 @@ -178,33 +176,6 @@ 1.13 1.14 1.15 ;*************************************************************** 1.16 -;_fastcall void puts(bx:const char* s): 1.17 -;*************************************************************** 1.18 - global @puts$qpxzc:near 1.19 - 1.20 -; global puts:near ; puts(bx) 1.21 -@putsz: 1.22 - call @putc 1.23 -@puts$qpxzc: 1.24 -puts: 1.25 - mov dl,[bx] 1.26 - inc bx 1.27 - or dl,dl 1.28 - jne @putsz 1.29 - mov dl,10 1.30 -@putc: 1.31 - cmp dl,10 1.32 - jne @putcz 1.33 - call @putcz2 1.34 -@putcz2: 1.35 - xor dl,7 ; 10^13 1010^1101 1.36 -@putcz: 1.37 - mov ah,2 1.38 - int 21h 1.39 - ret 1.40 - 1.41 - 1.42 -;*************************************************************** 1.43 ;_fastcall int open(bx:const char* name, int flags=O_RDONLY); 1.44 ;_fastcall int openargs(bx:const char* name, int flags=O_RDONLY); 1.45 ;*************************************************************** 1.46 @@ -504,13 +475,14 @@ 1.47 1.48 endif 1.49 1.50 + include "himem.inc" 1.51 + 1.52 ;*************************************************************** 1.53 ;_fastcall char* strdup(bx:const char* a); 1.54 ;_fastcall char* malloc_or_die(ax:unsigned size); 1.55 ;*************************************************************** 1.56 global @strdup$qpxzc:near 1.57 @strdup$qpxzc: 1.58 -strdup: ; ax = strdup(bx) 1.59 mov ax,[_heap_top] 1.60 xchg ax,bx 1.61 call @strcpy$qpxzct1 ; bx = strcpy(bx, ax) end +1 1.62 @@ -533,8 +505,8 @@ 1.63 1.64 ;*************************************************************** 1.65 ;_fastcall int die(bx:const char* msg); 1.66 -;int exit(); 1.67 -;int abort(); 1.68 +;int exit(ax:int status); 1.69 +;int abort(void); 1.70 ;*************************************************************** 1.71 global @die$qpxzc:near 1.72 proc @die$qpxzc near 1.73 @@ -545,12 +517,10 @@ 1.74 global @exit$qv:near 1.75 @exit$qv: 1.76 _exit: 1.77 - mov al,[_no_exit] 1.78 - or al,al 1.79 - jne @@hang 1.80 + extrn _imgs:image_himem 1.81 + mov cx,[(word _imgs.buf)+2] ; no_exit ? 1.82 mov ah,4Ch 1.83 - int 21h 1.84 -@@hang: 1.85 + jcxz do_int21h 1.86 mov bx, offset msg_hang 1.87 call puts 1.88 ; global _abort:near 1.89 @@ -561,7 +531,33 @@ 1.90 1.91 endp @die$qpxzc 1.92 1.93 - include "himem.inc" 1.94 +;*************************************************************** 1.95 +;_fastcall void puts(bx:const char* s): 1.96 +;*************************************************************** 1.97 + global @puts$qpxzc:near 1.98 + 1.99 +; global puts:near ; puts(bx) 1.100 +@putsz: 1.101 + call @putc 1.102 +@puts$qpxzc: 1.103 +puts: 1.104 + mov dl,[bx] 1.105 + inc bx 1.106 + or dl,dl 1.107 + jne @putsz 1.108 + mov dl,10 1.109 +@putc: 1.110 + cmp dl,10 1.111 + jne @putcz 1.112 + call @putcz2 1.113 +@putcz2: 1.114 + xor dl,7 ; 10^13 1010^1101 1.115 +@putcz: 1.116 + mov ah,2 1.117 +do_int21h: 1.118 + int 21h 1.119 + ret 1.120 + 1.121 1.122 ;*************************************************************** 1.123 ;static long next_chunk(struct image_himem *di); 1.124 @@ -691,8 +687,7 @@ 1.125 endif 1.126 shl eax,12 ; i*_4k 1.127 ; if (edx < pm.fallback+i*_4k && edx >= pm.fallback) again 1.128 - extrn _imgs 1.129 - mov bx,offset _imgs+2 1.130 + mov bx,offset _imgs.fallback 1.131 push eax 1.132 add eax,[bx-2+2] 1.133 cmp eax,edx ; pm.fallback+i*_4k <= edx ? 1.134 @@ -702,8 +697,7 @@ 1.135 jae @@vcpi_alloc 1.136 @@pmok: 1.137 ; if (edx >= initrd.fallback+i*_4k && edx < initrd.fallback+initrd.size) again 1.138 - extrn _imgs 1.139 - mov bx,offset _imgs+32+2 1.140 + mov bx,offset _imgs.fallback+32 1.141 add eax,[bx-2+2] ; +initrd.fallback 1.142 cmp eax,edx ; initrd.fallback+i*_4k > edx ? 1.143 ja @@initrdok
2.1 --- a/linld/stuff/src/CRTL.H Wed Nov 06 17:56:42 2019 +0100 2.2 +++ b/linld/stuff/src/CRTL.H Wed Nov 06 21:02:18 2019 +0100 2.3 @@ -47,7 +47,6 @@ 2.4 #define sti() do { asm { sti } } while(0) 2.5 #define int3() do { asm { db 0cch } } while(0) 2.6 #define nop() do { asm { db 90h } } while(0) 2.7 -extern char no_exit; 2.8 extern void exit(); 2.9 extern _fastcall int die(const char* msg); 2.10 //extern "C" char* malloc_or_die(unsigned size);
3.1 --- a/linld/stuff/src/HIMEM.CPP Wed Nov 06 17:56:42 2019 +0100 3.2 +++ b/linld/stuff/src/HIMEM.CPP Wed Nov 06 21:02:18 2019 +0100 3.3 @@ -9,9 +9,8 @@ 3.4 int skip_alloc; 3.5 3.6 void load_image(struct image_himem *m) { 3.7 - no_exit++; // die() won't return to DOS 3.8 m->remaining = m->size; 3.9 - m->buf = m->fallback; 3.10 + m->buf = m->fallback; // set no_exit btw: die() won't return to DOS 3.11 u32 buf; 3.12 u32* bufv= &buf; 3.13 if(((u16 *)&m->fallback)[1] >= 0x10 && !skip_alloc) { // >= _1m ?
4.1 --- a/linld/stuff/src/JUMP.ASM Wed Nov 06 17:56:42 2019 +0100 4.2 +++ b/linld/stuff/src/JUMP.ASM Wed Nov 06 21:02:18 2019 +0100 4.3 @@ -133,13 +133,13 @@ 4.4 xor ax,2b30h ; ipxe ? 4.5 loopne @@notipxe 4.6 4.7 - dos_shutdown ; clear si; ds=0 4.8 - push cs 4.9 - pop ds 4.10 ; finish loading 4.11 extrn @last_ditch$qv:near 4.12 push cs 4.13 call @last_ditch$qv 4.14 + dos_shutdown ; clear si; ds=0; kill VCPI 4.15 + push cs 4.16 + pop ds 4.17 4.18 @@notipxe: 4.19 pop cx
5.1 --- a/linld/stuff/src/LOAD.CPP Wed Nov 06 17:56:42 2019 +0100 5.2 +++ b/linld/stuff/src/LOAD.CPP Wed Nov 06 21:02:18 2019 +0100 5.3 @@ -158,6 +158,7 @@ 5.4 if((kernelparams->setup_sects)>=(_32k/512) || // 0th sector not counted 5.5 kernelparams->boot_flag != 0xAA55) 5.6 die("Not a kernel"); 5.7 + heap_top += // Hack for VCPI. Need fix. 5.8 _rm_size=0x200*(kernelparams->setup_sects+1); 5.9 m->size -= _rm_size; 5.10 m->chunk_size -= _rm_size; 5.11 @@ -174,7 +175,7 @@ 5.12 if((int)root_dev) kernelparams->root_dev = root_dev; 5.13 5.14 if(kernelparams->header == HdrS) { // starting linux 1.3.73 5.15 - if(kernelparams->loadflags & 1) { 5.16 + if(kernelparams->loadflags & 1) { // zImage as pre 1.3.73 5.17 extern void far last_ditch(); 5.18 kernelparams->realmode_switch_ofs = (u16) last_ditch; 5.19 kernelparams->realmode_switch_seg = _CS;
6.1 --- a/linld/stuff/src/VCPI.ASM Wed Nov 06 17:56:42 2019 +0100 6.2 +++ b/linld/stuff/src/VCPI.ASM Wed Nov 06 21:02:18 2019 +0100 6.3 @@ -140,11 +140,7 @@ 6.4 ;push ax 6.5 6.6 ;Calculate pagedir/page0 addrs, initialize cr3 and pagedir[0] 6.7 - xor eax,eax 6.8 ; heap_top = prepare_vcpi(malloc_or_die(8*1024+4)); 6.9 - mov ah,8*1024/256 6.10 - extrn malloc_or_die:near 6.11 - call malloc_or_die 6.12 6.13 mov edx,cs 6.14 shl edx,4 ;edx = linear addr of CS 6.15 @@ -159,6 +155,8 @@ 6.16 add bx,8 6.17 js @@fixup 6.18 mov bh,10h 6.19 + extrn _heap_top:word 6.20 + movzx eax,[_heap_top] 6.21 add eax,edx 6.22 and ax,0f000h ;eax = 4k aligned linear addr of pagebuf 6.23 add eax,ebx ;eax=page0 linear addr 6.24 @@ -176,7 +174,6 @@ 6.25 ; => ######## 6.26 ; Return 6.27 lea ax,[bx+di+4] 6.28 - extrn _heap_top:word 6.29 mov [_heap_top],ax 6.30 ;ret 6.31
7.1 --- a/linld/stuff/src/pipehole.awk Wed Nov 06 17:56:42 2019 +0100 7.2 +++ b/linld/stuff/src/pipehole.awk Wed Nov 06 21:02:18 2019 +0100 7.3 @@ -87,7 +87,7 @@ 7.4 $0="; " $0 7.5 } 7.6 } 7.7 - if (/word ptr \[si\+21\],513$/) isload=11 7.8 + if (/i\+21\],513$/) isload=11 7.9 if (isload == 12) { # LOAD.LST 7.10 if (/cmp/) next 7.11 if (/jb/) isload=0 7.12 @@ -96,13 +96,17 @@ 7.13 if (isload == 11) { # LOAD.LST 7.14 if (/cmp/) { 7.15 print " mov cx,513" 7.16 - $0=" sub cx,word ptr [si+21]" 7.17 + sub(/cmp /,"sub cx,") 7.18 + sub(/,513/,"") 7.19 } 7.20 if (/jb/) isload=12 7.21 sub(/jb/,"ja") 7.22 } 7.23 - sub(/DGROUP:_imgs\+65534/,"[di-2]") 7.24 - if (/short @1@366$/) isload=10 7.25 + if (/i,offset/) split($2,sidi,",") 7.26 + if (sidi[1] == "si") sidi[2]="di" 7.27 + else sidi[2]="si" 7.28 + sub(/DGROUP:_imgs\+65534/,"[" sidi[1] "-2]") 7.29 + if (/m, _rm_size/) isload=10 7.30 if (isload == 10) { # LOAD.LST 7.31 if (/^ je /) next 7.32 if (/ptr @die\$qpxzc/) { 7.33 @@ -124,12 +128,12 @@ 7.34 if (isload == 7) { # LOAD.LST 7.35 if (/add/ || /xor/ || /extrn/ || /N_LXLSH@/ || /cl,4/) next 7.36 if (/enable A20 if needed/) { 7.37 - print " mov word ptr [bx+si],8000h" 7.38 + print " mov word ptr [bx+" sidi[2] "],8000h" 7.39 isload=0 7.40 } 7.41 if (/,ax/) $0=" mov bx,55" 7.42 - if (/si-463/) $0=" mov bx,-463" 7.43 - if (/si-465/) $0=" mov word ptr [bx+si-2],-23745" 7.44 + if (/i-463/) $0=" mov bx,-463" 7.45 + if (/i-465/) { sub(/465/,"2"); sub(/\[/,"[bx+"); } 7.46 if (/,dx/) { 7.47 print " mov cl,12" 7.48 print " shr ax,cl" 7.49 @@ -225,11 +229,10 @@ 7.50 if (isload == 1) { # LOAD.LST 7.51 if (/ptr .die\$qpxzc/) $0="@die@:\n" $0 7.52 if (/mov al,byte ptr/ && is386) { 7.53 - print " movzx eax,byte ptr [si]" 7.54 - next 7.55 + sub(/mov al/,"movzx eax") 7.56 } 7.57 if (is386 == 0) { 7.58 - if (/di-5\],ax/) print " cwd" 7.59 + if (/m->size -= _rm_size/) print " cwd" 7.60 sub(/,0$/,",dx") 7.61 } 7.62 if (/ax,word ptr/) next