wok-current rev 21757
tazboot: spave 40k+ for zImage
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon Jun 24 16:31:09 2019 +0200 (2019-06-24) |
parents | 56ab00f400e9 |
children | d8f824013cf6 |
files | linld/stuff/src/A20.ASM linld/stuff/src/COMMON.H linld/stuff/src/CRTL.ASM linld/stuff/src/CRTL.H linld/stuff/src/CRTLX.H linld/stuff/src/JUMP.ASM linld/stuff/src/LOAD.CPP linld/stuff/src/MEMTOP.ASM linld/stuff/src/TAZBOOT.CPP linld/stuff/src/XMM.ASM linld/stuff/src/_BEG.ASM linld/stuff/src/pipehole.awk |
line diff
1.1 --- a/linld/stuff/src/A20.ASM Sat Jun 22 21:11:47 2019 +0200 1.2 +++ b/linld/stuff/src/A20.ASM Mon Jun 24 16:31:09 2019 +0200 1.3 @@ -16,6 +16,7 @@ 1.4 enable_a20_methods: 1.5 dw _enable_a20_fast, _enable_a20_kbd, _enable_a20_xmm, die 1.6 msg_a20 db "Can't use A20",0 1.7 +overflow db "Loaded too close to 9000:0",0 1.8 1.9 ends _DATA 1.10 1.11 @@ -84,12 +85,59 @@ 1.12 endp _enable_a20_fast 1.13 1.14 ;*************************************************************** 1.15 +;_fastcall void moverm(bx:struct himem *m); 1.16 +;*************************************************************** 1.17 + 1.18 + global @moverm$qp11image_himem:near 1.19 +@moverm$qp11image_himem: 1.20 + push si di 1.21 + global sssp:dword 1.22 + extrn _heap_top:word 1.23 + ifdef NO386 1.24 + extrn _topseg:near 1.25 + call near _topseg 1.26 + mov cl,4 1.27 + org $-4 1.28 +sssp dd ? 1.29 + mov [word sssp+2],ax 1.30 + ;extrn _initrd_desc:dword 1.31 + ;mov [word _initrd_desc+2],ax 1.32 + xchg ax,dx 1.33 + mov ax,[_heap_top] 1.34 + shr ax,cl 1.35 + else 1.36 + p386 1.37 + mov ax,[_heap_top] 1.38 + shr ax,4 1.39 + mov dx,9000h 1.40 + org $-4 1.41 +sssp dd ? 1.42 + endif 1.43 + mov es,dx 1.44 + mov cx,cs 1.45 + add ax,cx 1.46 + cmp ax,dx 1.47 + jb @@nooverflow 1.48 +; Oops! We can stomp on our toes... better stop now 1.49 + mov bx,offset overflow 1.50 + call near die 1.51 +@@nooverflow: 1.52 + mov cx,[bx-5] ; size 1.53 + mov si,[bx-2] ; data 1.54 + xor di,di 1.55 + rep 1.56 + movsb 1.57 + ;push ds 1.58 + ;pop es 1.59 + ;pop di si 1.60 + pop di 1.61 + 1.62 +;*************************************************************** 1.63 ;void enable_a20_or_die(); 1.64 ;*************************************************************** 1.65 - global _enable_a20_or_die:near 1.66 proc _enable_a20_or_die near 1.67 1.68 - push si 1.69 + ;push si 1.70 mov si,offset enable_a20_methods 1.71 jmp @@check 1.72 @@loop: 1.73 @@ -108,7 +156,7 @@ 1.74 ; time on certain systems; Toshiba Tecras are known to have this 1.75 ; problem. 1.76 1.77 - push ds es 1.78 + push ds 1.79 xor bx,bx 1.80 mov ds,bx 1.81 mov cx,0FFFFh 1.82 @@ -124,13 +172,15 @@ 1.83 sti 1.84 a20ko: 1.85 loopne a20lp 1.86 - xchg ax,cx 1.87 - pop es ds 1.88 + ;xchg ax,cx 1.89 + pop ds 1.90 ;ret 1.91 1.92 ;endp _check_a20 1.93 1.94 jne @@loop 1.95 + ;push ds 1.96 + ;pop es 1.97 pop si 1.98 ret 1.99
2.1 --- a/linld/stuff/src/COMMON.H Sat Jun 22 21:11:47 2019 +0200 2.2 +++ b/linld/stuff/src/COMMON.H Mon Jun 24 16:31:09 2019 +0200 2.3 @@ -2,7 +2,7 @@ 2.4 // 2.5 // Common defs not belonging to CRTL 2.6 2.7 -#define NL "\r\n" 2.8 +#define NL "\n" 2.9 #define VERSION_STR "0.97" 2.10 2.11 #if 0 // DEBUG
3.1 --- a/linld/stuff/src/CRTL.ASM Sat Jun 22 21:11:47 2019 +0200 3.2 +++ b/linld/stuff/src/CRTL.ASM Mon Jun 24 16:31:09 2019 +0200 3.3 @@ -19,8 +19,7 @@ 3.4 global _heap_top 3.5 extrn _bss_end 3.6 _heap_top dw _bss_end 3.7 -msg_hang db "High mem corrupted - not exiting to DOS" 3.8 -msg_lf db 10,0 3.9 +msg_hang db "High mem corrupted - not exiting to DOS",0 3.10 vcpi_alloc_err db "VCPI " 3.11 msg_malloc db "malloc error",0 3.12 ifdef EXTRA 3.13 @@ -86,18 +85,14 @@ 3.14 global @strcatb$qpxzct1:near 3.15 proc @strcatb$qpxzct1 near 3.16 3.17 - ifdef EXTRA 3.18 mov cl,7Fh 3.19 db 0bah ; mov dx,imm opcode 3.20 global @strcpy$qpxzct1:near 3.21 @strcpy$qpxzct1: 3.22 xor cx,cx 3.23 - endif 3.24 push si 3.25 xchg ax,si ; b 3.26 - ifdef EXTRA 3.27 jcxz @@nocat 3.28 - endif 3.29 dec bx 3.30 @@catlp: 3.31 inc bx 3.32 @@ -185,29 +180,32 @@ 3.33 ;_fastcall void puts(bx:const char* s): 3.34 ;*************************************************************** 3.35 global @puts$qpxzc:near 3.36 - proc @puts$qpxzc near 3.37 3.38 ; global puts:near ; puts(bx) 3.39 +@putsz: 3.40 + call @putc 3.41 +@puts$qpxzc: 3.42 puts: 3.43 - call @@putsz 3.44 - mov bx,offset msg_lf 3.45 - mov dl,13 3.46 -@@putcz: 3.47 - mov ah,2 3.48 - int 21h 3.49 -@@putsz: 3.50 mov dl,[bx] 3.51 inc bx 3.52 or dl,dl 3.53 - jne @@putcz ; ZF=1 (for malloc failure) 3.54 + jne @putsz 3.55 + mov dl,10 3.56 +@putc: 3.57 + cmp dl,10 3.58 + jne @putcz 3.59 + call @putcz2 3.60 +@putcz2: 3.61 + xor dl,7 ; 10^13 1010^1101 3.62 +@putcz: 3.63 + mov ah,2 3.64 + int 21h 3.65 ret 3.66 3.67 - endp @puts$qpxzc 3.68 - 3.69 - 3.70 3.71 ;*************************************************************** 3.72 ;_fastcall int open(bx:const char* name, int flags=O_RDONLY); 3.73 +;_fastcall int openargs(bx:const char* name, int flags=O_RDONLY); 3.74 ;*************************************************************** 3.75 global openargs:near ; openargs(bx) 3.76 openargs: 3.77 @@ -508,8 +506,19 @@ 3.78 endif 3.79 3.80 ;*************************************************************** 3.81 +;_fastcall char* strdup(bx:const char* a); 3.82 ;_fastcall char* malloc_or_die(ax:unsigned size); 3.83 ;*************************************************************** 3.84 + global @strdup$qpxzc:near 3.85 +@strdup$qpxzc: 3.86 + mov ax,[_heap_top] 3.87 + xchg ax,bx 3.88 + call @strcpy$qpxzct1 3.89 + xchg ax,bx 3.90 +xchg_heap_top: 3.91 + xchg ax,[_heap_top] 3.92 + ret 3.93 + 3.94 global @malloc_or_die$qui:near 3.95 proc @malloc_or_die$qui near 3.96 3.97 @@ -520,11 +529,10 @@ 3.98 mov bx,sp 3.99 add bh,-14h ; MIN_STACK=_1k+PAGE_SIZE 3.100 sub bx,ax ; can't overflow 3.101 + add ax,cx 3.102 cmp bx,cx 3.103 mov bx,offset msg_malloc 3.104 - jb die 3.105 - add [_heap_top],cx ; _BEG has zero'd heap 3.106 - ret 3.107 + ja xchg_heap_top 3.108 3.109 endp @malloc_or_die$qui 3.110 3.111 @@ -545,9 +553,8 @@ 3.112 mov al,[_no_exit] 3.113 or al,al 3.114 jne @@hang 3.115 - extrn exit:near 3.116 - inc ax 3.117 - jmp near exit 3.118 + mov ah,4Ch 3.119 + int 21h 3.120 @@hang: 3.121 mov bx, offset msg_hang 3.122 call puts 3.123 @@ -1330,7 +1337,7 @@ 3.124 global _progname:near 3.125 proc _progname near 3.126 3.127 - push si di es 3.128 + push si di 3.129 mov ah,30h 3.130 int 21h 3.131 xor di,di 3.132 @@ -1363,7 +1370,7 @@ 3.133 push es 3.134 pop ds 3.135 @@skip: 3.136 - pop es di si 3.137 + pop di si 3.138 ret 3.139 3.140 endp _progname
4.1 --- a/linld/stuff/src/CRTL.H Sat Jun 22 21:11:47 2019 +0200 4.2 +++ b/linld/stuff/src/CRTL.H Mon Jun 24 16:31:09 2019 +0200 4.3 @@ -21,6 +21,8 @@ 4.4 4.5 void parse_cmdline(); 4.6 extern _fastcall void strcatb(const char* a,const char* b); 4.7 +extern _fastcall void strcpy(const char* a,const char* b); 4.8 +extern _fastcall int strdup(const char* a); 4.9 #ifdef USE_ARGSTR 4.10 extern _fastcall int argstr(const char *s, const char keywords[], const char **var); 4.11 extern _fastcall int argnum(char *s, const char keywords[], unsigned long *var); 4.12 @@ -33,6 +35,7 @@ 4.13 //extern "C" int open(const char* name, int flags); 4.14 extern _fastcall int open(const char* name); 4.15 extern _fastcall int close(int fd); 4.16 +extern _fastcall int moverm(struct image_himem *m); 4.17 extern _fastcall int readrm(struct image_himem *m, int sz); 4.18 extern _fastcall int read(int fd, void* data, int sz); 4.19 extern _fastcall long lseekcur(int fd, int whence);
5.1 --- a/linld/stuff/src/CRTLX.H Sat Jun 22 21:11:47 2019 +0200 5.2 +++ b/linld/stuff/src/CRTLX.H Mon Jun 24 16:31:09 2019 +0200 5.3 @@ -1,7 +1,6 @@ 5.4 // This file is distributed under GPL 5.5 // 5.6 extern _fastcall long lseekset2(int fd, unsigned long* whence); 5.7 -extern _fastcall void strcpy(const char* a,const char* b); 5.8 extern _fastcall void strcat(const char* a,const char* b); 5.9 extern _fastcall int strcmp(const char* a,const char* b); 5.10 //extern "C" char* strstr(const char* a,const char* b);
6.1 --- a/linld/stuff/src/JUMP.ASM Sat Jun 22 21:11:47 2019 +0200 6.2 +++ b/linld/stuff/src/JUMP.ASM Mon Jun 24 16:31:09 2019 +0200 6.3 @@ -11,15 +11,9 @@ 6.4 p386 6.5 endif 6.6 6.7 - group DGROUP _TEXT,_DATA,_BSS 6.8 + group DGROUP _TEXT,_BSS 6.9 assume cs:DGROUP,ds:DGROUP 6.10 6.11 - segment _DATA byte public use16 'DATA' 6.12 - 6.13 -overflow db "Loaded too close to 9000:0",0 6.14 - 6.15 - ends _DATA 6.16 - 6.17 segment _BSS byte public use16 'BSS' 6.18 6.19 global _imgs:dword 6.20 @@ -90,38 +84,14 @@ 6.21 global _boot_kernel:near 6.22 proc _boot_kernel near 6.23 6.24 + ifdef NO386 6.25 p8086 6.26 - extrn _heap_top:word 6.27 - global sssp:dword 6.28 - ifdef NO386 6.29 - extrn _topseg:near 6.30 - call near _topseg 6.31 - mov cl,4 6.32 - org $-4 6.33 -sssp dd ? 6.34 - mov [word sssp+2],ax 6.35 - xchg ax,bx 6.36 - mov ax,[_heap_top] 6.37 - shr ax,cl 6.38 else 6.39 p386 6.40 - mov ax,[_heap_top] 6.41 - shr ax,4 6.42 - mov bx,9000h 6.43 - org $-4 6.44 -sssp dd ? 6.45 endif 6.46 - mov es,bx 6.47 - mov dx,cs 6.48 - add ax,dx 6.49 - cmp ax,bx 6.50 - jb @@nooverflow 6.51 -; Oops! We can stomp on our toes... better stop now 6.52 - mov bx,offset overflow 6.53 - extrn die:near 6.54 - call near die 6.55 -@@nooverflow: 6.56 ;cli ; we start doing destructive things to DOS 6.57 + extrn sssp:word 6.58 + mov es,[sssp+2] 6.59 push es 6.60 pop ss 6.61 mov sp,0A000h 6.62 @@ -131,18 +101,12 @@ 6.63 lodsw 6.64 push ax ; _csip high 6.65 push [word si-4] ; _csip low 6.66 + lodsw 6.67 else 6.68 - mov si,offset _rm_size ; _rm_size, _pm_high, _rm_buf 6.69 - push [dword si-4] ; _csip 6.70 + mov si,offset _rm_size+2 ; _rm_size, _pm_high, _rm_buf 6.71 + push [dword si-6] ; _csip 6.72 endif 6.73 - lodsw 6.74 - xchg ax,cx ; _rm_size 6.75 lodsb ; _pm_high 6.76 - mov si,[si] ; _rm_buf 6.77 - xor di,di 6.78 - ;cld 6.79 - rep 6.80 - movsb 6.81 extrn _cmdline:word 6.82 mov si,[_cmdline] 6.83 mov di,8000h
7.1 --- a/linld/stuff/src/LOAD.CPP Sat Jun 22 21:11:47 2019 +0200 7.2 +++ b/linld/stuff/src/LOAD.CPP Mon Jun 24 16:31:09 2019 +0200 7.3 @@ -122,8 +122,10 @@ 7.4 static u8 pm_high; // @ = @rm_size + 2, see JUMP.ASM 7.5 static u8* rm_buf; // @ = @rm_size + 3, see JUMP.ASM 7.6 struct image_himem imgs[2]; 7.7 +u32 far *initrd_desc = (u32 far *) MK_FP(0x9000,0x218); 7.8 7.9 static const char kernel_file_error[] = "Can't use kernel file"; 7.10 +char *version_string=""; 7.11 char* load_kernel() { 7.12 7.13 struct image_himem *m = ± 7.14 @@ -131,10 +133,9 @@ 7.15 #define _pm_high (((u8*)(m))[-3]) 7.16 #define _rm_size (*(u16*)((u8*)(m)-5)) 7.17 #define _csip (*(u32*)((u8*)(m)-9)) 7.18 - char *version_string; 7.19 { 7.20 struct kernelparams_t *kernelparams; 7.21 - kernelparams = &(((first1k_t*) (_rm_buf(m) = (u8 *)malloc_or_die(_32k)))->params); 7.22 + kernelparams = &(((first1k_t*) (_rm_buf(m) = (u8 *)heap_top))->params); 7.23 #define first1k ((first1k_t*)((u8 *)kernelparams-0x1F1)) 7.24 7.25 *((u16 *)&_csip+1)=topseg()|0x20; 7.26 @@ -143,7 +144,6 @@ 7.27 open_image(m, kernel_name); 7.28 7.29 do { 7.30 - // Do not use malloc below until heap_top adjustment (see <*>) 7.31 if (readrm(m, 0x200) == 0x200) { 7.32 7.33 lseekcur(m->fd,-0x200); 7.34 @@ -159,7 +159,7 @@ 7.35 if((kernelparams->setup_sects)>=(_32k/512) || // 0th sector not counted 7.36 kernelparams->boot_flag != 0xAA55) 7.37 die("Not a kernel"); 7.38 - heap_top = _rm_buf(m)+(_rm_size=0x200*(kernelparams->setup_sects+1)); // <*> 7.39 + _rm_size=0x200*(kernelparams->setup_sects+1); 7.40 m->size -= _rm_size; 7.41 m->chunk_size -= _rm_size; 7.42 7.43 @@ -173,7 +173,6 @@ 7.44 7.45 if((int)vid_mode) kernelparams->vid_mode = vid_mode; 7.46 if((int)root_dev) kernelparams->root_dev = root_dev; 7.47 - version_string = ""; 7.48 7.49 if(kernelparams->header == HdrS) { // starting linux 1.3.73 7.50 if(kernelparams->loadflags & 1) { 7.51 @@ -183,10 +182,10 @@ 7.52 pm_high++; 7.53 7.54 // Hook on int15 to work around fn 88 DOS breakage 7.55 - hook_int15_88(); 7.56 + hook_int15_88(); // break _ES 7.57 } 7.58 if (kernelparams->kernel_version) 7.59 - version_string = (char *) first1k+kernelparams->kernel_version+0x200; 7.60 + version_string = (char *) strdup((char *) first1k+kernelparams->kernel_version+0x200); 7.61 kernelparams->type_of_loader = 0xff; // kernel do not know us (yet :-) 7.62 if(kernelparams->version >= 0x201) { 7.63 // * offset limit of the setup heap 7.64 @@ -206,40 +205,23 @@ 7.65 } 7.66 7.67 cmd_line_ok: 7.68 - // Check and enable A20 if needed 7.69 - enable_a20_or_die(); 7.70 + 7.71 + // Move setup & Check and enable A20 if needed 7.72 + moverm(m); // break _ES 7.73 7.74 // Read remaining kernel (pm part) 7.75 // Try to load kernel high, maybe even blindly storing it 7.76 // in unallocated memory as a last resort 7.77 7.78 - { 7.79 - struct image_himem *m = ± 7.80 - if((u16)(((m->fallback=(u32(u16(_CS)+0x1000)<<4))+m->size)>>16) >= 7.81 + if((u16)(((m->fallback=(u32(u16(_CS)+(u16(heap_top)>>4)+1)<<4))+m->size)>>16) >= 7.82 (u16)(topseg()>>12) || _pm_high) { 7.83 m->fallback = base_himem; 7.84 } 7.85 7.86 load_image(m); 7.87 - } 7.88 return version_string; 7.89 } 7.90 7.91 -struct initrdparams_t { 7.92 - u32 header; // 0202 Magic signature "HdrS" 7.93 - u16 version; // 0206 Boot protocol version supported 7.94 - u16 realmode_switch_ofs; // 0208 Hook called just before rm->pm 7.95 - u16 realmode_switch_seg; 7.96 - u16 start_sys_seg; // 020C 7.97 - u16 kernel_version; // 020E Points to kernel version string 7.98 - u8 type_of_loader; // 0210 Boot loader identifier 7.99 - u8 loadflags; // 0211 Boot protocol option flags 7.100 - u16 setup_move_size;// 0212 Move to high memory size (used with hooks) 7.101 - u32 code32_start; // 0214 Boot loader hook (see below) 7.102 - u32 initrd_buf; // 0218 initrd load address (set by boot loader) 7.103 - u32 initrd_size; // 021C initrd size (set by boot loader) 7.104 -}; 7.105 - 7.106 // Read initrd if needed 7.107 void load_initrd() { 7.108 struct image_himem *m = &initrd; 7.109 @@ -262,9 +244,8 @@ 7.110 7.111 load_image(m); 7.112 7.113 - struct initrdparams_t *initrdparams = ((struct initrdparams_t *)&(((first1k_t*) _rm_buf(m-1))->params.header)); 7.114 - if(initrdparams->header == HdrS) { 7.115 - initrdparams->initrd_buf = m->fallback; 7.116 - initrdparams->initrd_size = m->size; 7.117 + if (*version_string) { 7.118 + initrd_desc[0] = m->fallback; 7.119 + initrd_desc[1] = m->size; 7.120 } 7.121 }
8.1 --- a/linld/stuff/src/MEMTOP.ASM Sat Jun 22 21:11:47 2019 +0200 8.2 +++ b/linld/stuff/src/MEMTOP.ASM Mon Jun 24 16:31:09 2019 +0200 8.3 @@ -82,14 +82,16 @@ 8.4 call rdcmos17 8.5 popf 8.6 tokb: 8.7 + mov cl,10 ;multiply by 1024 8.8 + ifndef NO386 8.9 + add ah,4h ;account for 1024 low kb 8.10 + setc dl ; (optimized to death) 8.11 + shld dx,ax,cl 8.12 + shl ax,cl ; (kbytes -> bytes) 8.13 + else 8.14 xor dx,dx 8.15 add ah,4h ;account for 1024 low kb 8.16 adc dx,dx ; (optimized to death) 8.17 - mov cl,10 ;multiply by 1024 8.18 - ifndef NO386 8.19 - shld dx,ax,cl 8.20 - shl ax,cl ; (kbytes -> bytes) 8.21 - else 8.22 db 0A9h ; test ax,04B1h 8.23 global N_LXLSH@4:near 8.24 N_LXLSH@4: 8.25 @@ -208,6 +210,8 @@ 8.26 xchg ax,[es:bx+15*4+2] 8.27 mov [word saved15+2],ax 8.28 endif 8.29 + ;push ds 8.30 + ;pop es 8.31 @@skip: 8.32 ret 8.33 int15_88:
9.1 --- a/linld/stuff/src/TAZBOOT.CPP Sat Jun 22 21:11:47 2019 +0200 9.2 +++ b/linld/stuff/src/TAZBOOT.CPP Mon Jun 24 16:31:09 2019 +0200 9.3 @@ -170,15 +170,15 @@ 9.4 try_default_args(); 9.5 dousage: 9.6 die("Usage: tazboot [[@commands]|[-f][-b base_himem][kernel=<bzImage>] \ 9.7 -[initrd=<rootfs>[,<rootfs2>...]] [bootfrom=<isofile>] ...]\r\n\n\ 9.8 -Defaults: tazboot kernel=bzImage auto\r\n\n\ 9.9 -Examples for tazboot.cmd:\r\n\n\ 9.10 - bootfrom=\\isos\\slitaz-4.0.iso\r\n\ 9.11 - kernel=boot/bzImage\r\n\ 9.12 - initrd=boot/rootfs4.gz,boot/rootfs3.gz,boot/rootfs2.gz,boot/rootfs1.gz,\\slitaz\\extrafs.gz\r\n\ 9.13 - rw root=/dev/null vga=normal autologin\r\n\n\ 9.14 - kernel=\\slitaz\\elks\r\n\ 9.15 - root=/dev/bda1 ro\r\n"); 9.16 +[initrd=<rootfs>[,<rootfs2>...]] [bootfrom=<isofile>] ...]\n\n\ 9.17 +Defaults: tazboot kernel=bzImage auto\n\n\ 9.18 +Examples for tazboot.cmd:\n\n\ 9.19 + bootfrom=\\isos\\slitaz-4.0.iso\n\ 9.20 + kernel=boot/bzImage\n\ 9.21 + initrd=boot/rootfs4.gz,boot/rootfs3.gz,boot/rootfs2.gz,boot/rootfs1.gz,\\slitaz\\extrafs.gz\n\ 9.22 + rw root=/dev/null vga=normal autologin\n\n\ 9.23 + kernel=\\slitaz\\elks\n\ 9.24 + root=/dev/bda1 ro\n"); 9.25 } 9.26 bootiso(argv + 1); 9.27 chdirname(*argv);
10.1 --- a/linld/stuff/src/XMM.ASM Sat Jun 22 21:11:47 2019 +0200 10.2 +++ b/linld/stuff/src/XMM.ASM Mon Jun 24 16:31:09 2019 +0200 10.3 @@ -51,18 +51,18 @@ 10.4 endif 10.5 jne @@gotit 10.6 10.7 - xchg ax,cx ; save cmd 10.8 + push ax ; save cmd 10.9 mov ax,4300h ; installation check in al 10.10 int 2fh 10.11 mov bx,offset xmm_fail 10.12 - push cs 10.13 + push ds 10.14 pop es 10.15 cmp al,80h 10.16 jne @@err 10.17 mov ax,4310h ; get driver address in es:bx 10.18 int 2fh 10.19 @@err: 10.20 - xchg ax,cx ; restore cmd 10.21 + pop ax ; restore cmd 10.22 mov [si],bx 10.23 mov [si+2],es 10.24 @@gotit:
11.1 --- a/linld/stuff/src/_BEG.ASM Sat Jun 22 21:11:47 2019 +0200 11.2 +++ b/linld/stuff/src/_BEG.ASM Mon Jun 24 16:31:09 2019 +0200 11.3 @@ -26,8 +26,13 @@ 11.4 ends _DATA 11.5 11.6 segment _BSS byte public use16 'BSS' 11.7 + 11.8 +STACK_SIZE = 1024 11.9 + 11.10 global _bss_start:byte 11.11 label _bss_start byte 11.12 + db STACK_SIZE-2 dup(?) 11.13 +stktop dw ? 11.14 ifdef EXTRA 11.15 global _cpu_features:dword 11.16 _cpu_features dd ? 11.17 @@ -47,7 +52,8 @@ 11.18 ;*************************************************************** 11.19 ; clear bss 11.20 ;*************************************************************** 11.21 - mov si,offset _bss_start 11.22 + mov sp,offset stktop 11.23 + mov si,sp 11.24 mov bx, 0F000h ; cld ; cli & empty string 11.25 clearbss: 11.26 mov [si],bl ; clear bss + heap + sp 11.27 @@ -140,7 +146,7 @@ 11.28 ;call _get_vcpi_interface 11.29 mov bx,offset msg_badmapping 11.30 jnz no_vcpi 11.31 - inc [byte bx+_vcpi-msg_badmapping] 11.32 + inc [word bx+_vcpi-msg_badmapping] 11.33 endcpu386: 11.34 ifdef EXTRA 11.35 pushfd 11.36 @@ -251,14 +257,12 @@ 11.37 endif 11.38 11.39 ;*************************************************************** 11.40 - extrn _main:near 11.41 - call _main 11.42 + extrn _main:near 11.43 + call _main 11.44 + ;never return 11.45 11.46 ;*************************************************************** 11.47 - global exit:near 11.48 -exit: 11.49 - mov ah,4Ch 11.50 - int 21h 11.51 + 11.52 ends _TEXT 11.53 11.54
12.1 --- a/linld/stuff/src/pipehole.awk Sat Jun 22 21:11:47 2019 +0200 12.2 +++ b/linld/stuff/src/pipehole.awk Mon Jun 24 16:31:09 2019 +0200 12.3 @@ -5,6 +5,70 @@ 12.4 12.5 if (/^@.*:$/ || / endp$/) afterjmp=0 12.6 if (/dword ptr/) is386=1 12.7 + sub(/DGROUP:_imgs\+65534/,"[di-2]") 12.8 + if (/cmd_line_ptr =/ && is386 == 0) isload=7 12.9 + if (isload == 7) { # LOAD.LST 12.10 + if (/add/ || /xor/ || /extrn/ || /N_LXLSH@/ || /cl,4/) next 12.11 + if (/,ax/) { 12.12 + sub(/ax/,"8000h") 12.13 + isload=0 12.14 + } 12.15 + if (/,dx/) { 12.16 + print " mov cl,12" 12.17 + print " shr ax,cl" 12.18 + sub(/dx/,"ax") 12.19 + } 12.20 + } 12.21 + if (/\[0\] = m-\>fallback/) isload=6 12.22 + if (isload == 6) { # LOAD.LST 12.23 + if (/si\+2/) { 12.24 + print " inc si" 12.25 + $0=" inc si" 12.26 + } 12.27 + if (/les/) sub(/bx,/,"ax,") 12.28 + if (/bx\+4/ || /es:/) { 12.29 + if (/bx\+4/) isload=0 12.30 + next 12.31 + } 12.32 + if (/si\+6/) { 12.33 + print " xchg ax,di" 12.34 + print " movsw" 12.35 + print " movsw" 12.36 + print " movsw" 12.37 + print " movsw" 12.38 + print " xchg ax,di" 12.39 + next 12.40 + } 12.41 + } 12.42 + if (/version_string = /) isload=5 12.43 + if (isload == 5) { # LOAD.LST 12.44 + sub(/ax,/,"bx,") 12.45 + if (/_version_string,/) isload=0 12.46 + if (/mov bx,ax/) next 12.47 + } 12.48 + if (/topseg\(\)>>12/) isload=4 12.49 + if (isload == 4 && is386 == 0) { # LOAD.LST 12.50 + if (/push/ || /pop/) next 12.51 + if (/ax,cs/) { 12.52 + print " cwd" 12.53 + sub(/ax,cs/,"bx,cs") 12.54 + } 12.55 + if (/dx,dx/) next 12.56 + sub(/ax,dx/,"ax,bx") 12.57 + if (/call/) isload=400 12.58 + } 12.59 + if (isload == 400 && /,0/) { 12.60 + sub(/,0/,",dh") 12.61 + isload=0 12.62 + } 12.63 + if (isload == 4 && is386) { # LOAD.LST 12.64 + sub(/dx,cs/,"edx,cs") 12.65 + sub(/eax/,"edx") 12.66 + sub(/ax,9/,"dx,9") 12.67 + if (/,0/) sub(/,0/,",dh") 12.68 + if (/movzx/) next 12.69 + if (/fallback = base_himem/) { isload=0 } 12.70 + } 12.71 if (/void load_initrd\(\)/) isload=3 12.72 if (isload == 3) { # LOAD.LST 12.73 if(/push di/ || /pop di/) next 12.74 @@ -17,9 +81,9 @@ 12.75 sub(/je/,"jcxz") 12.76 if (/ax,word/) next 12.77 sub(/,ax/,",cx") 12.78 - if (/version_string/) isload=0 12.79 + if (/version_string/ || /starting linux 1\.3\.73/) isload=0 12.80 } 12.81 - if (/heap_top = _rm_buf/) isload=1 12.82 + if (/_rm_size=0x200/ || /heap_top = _rm_buf/) isload=1 12.83 if (isload == 1) { # LOAD.LST 12.84 if (/mov al,byte ptr/ && is386) { 12.85 print " movzx eax,byte ptr [si]" 12.86 @@ -190,6 +254,8 @@ 12.87 if (isotazboot == 100) { # TAZBOOT.LST 12.88 if (/cx,ax/) { 12.89 print " mov si,offset _isostate+8" 12.90 + print " push ds" 12.91 + print " pop es" 12.92 print " xchg ax,di" 12.93 print " movsw" 12.94 print " movsw"