wok rev 24022
linld: basic iso9660 support
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Mar 14 19:55:20 2021 +0000 (2021-03-14) |
parents | 010fc15e8b9d |
children | 526688f99354 |
files | busybox/stuff/busybox-1.31.config-static linld/stuff/src/COMMON.H linld/stuff/src/CRTL.ASM linld/stuff/src/ISO9660.CPP linld/stuff/src/ISO9660.H linld/stuff/src/ISOSTATE.INC linld/stuff/src/JUMP.ASM linld/stuff/src/LINK.CMD linld/stuff/src/LINLD.CPP linld/stuff/src/LOAD.CPP linld/stuff/src/MEMCPY32.ASM linld/stuff/src/VCPI.ASM linld/stuff/src/_BEG.ASM linld/stuff/src/pipehole.awk |
line diff
1.1 --- a/busybox/stuff/busybox-1.31.config-static Sat Mar 06 18:53:34 2021 +0000 1.2 +++ b/busybox/stuff/busybox-1.31.config-static Sun Mar 14 19:55:20 2021 +0000 1.3 @@ -279,7 +279,7 @@ 1.4 # CONFIG_OD is not set 1.5 # CONFIG_PASTE is not set 1.6 # CONFIG_PRINTENV is not set 1.7 -# CONFIG_PRINTF is not set 1.8 +CONFIG_PRINTF=y 1.9 CONFIG_PWD=y 1.10 # CONFIG_READLINK is not set 1.11 # CONFIG_FEATURE_READLINK_FOLLOW is not set 1.12 @@ -441,7 +441,7 @@ 1.13 # CONFIG_FEATURE_FIND_MTIME is not set 1.14 # CONFIG_FEATURE_FIND_MMIN is not set 1.15 # CONFIG_FEATURE_FIND_PERM is not set 1.16 -# CONFIG_FEATURE_FIND_TYPE is not set 1.17 +CONFIG_FEATURE_FIND_TYPE=y 1.18 # CONFIG_FEATURE_FIND_EXECUTABLE is not set 1.19 # CONFIG_FEATURE_FIND_XDEV is not set 1.20 # CONFIG_FEATURE_FIND_MAXDEPTH is not set 1.21 @@ -1111,7 +1111,7 @@ 1.22 # CONFIG_ASH_IDLE_TIMEOUT is not set 1.23 # CONFIG_ASH_MAIL is not set 1.24 # CONFIG_ASH_ECHO is not set 1.25 -# CONFIG_ASH_PRINTF is not set 1.26 +CONFIG_ASH_PRINTF=y 1.27 # CONFIG_ASH_TEST is not set 1.28 # CONFIG_ASH_HELP is not set 1.29 # CONFIG_ASH_GETOPTS is not set
2.1 --- a/linld/stuff/src/COMMON.H Sat Mar 06 18:53:34 2021 +0000 2.2 +++ b/linld/stuff/src/COMMON.H Sun Mar 14 19:55:20 2021 +0000 2.3 @@ -1,7 +1,8 @@ 2.4 //#define WITH_XMM_ALLOC add himem.sys driver 2.5 //#define LARGE_ZIMAGE may load system in high memory temporarily 2.6 //#define INT15_E820 add int15/eax=E820 driver 2.7 -//#define BASIC_ISO9660 non rockridge support 2.8 +//#define RAW_ISO9660 raw filename support with ';1' or '.' trailers 2.9 +#define BASIC_ISO9660 non rockridge support 2.10 #define ROCKRIDGE iso 9660 posix name support 2.11 #define ISO9660 iso= support 2.12 #define QUICK_BOOT /q bypass shutdown hack, /v keeps v86 2.13 @@ -18,9 +19,6 @@ 2.14 /* End of the optional features */ 2.15 2.16 #ifdef ISOHOOK 2.17 -#ifndef ISO9660 2.18 -#define ISO9660 2.19 -#endif 2.20 #ifndef ROCKRIDGE 2.21 #define ROCKRIDGE 2.22 #endif 2.23 @@ -28,6 +26,11 @@ 2.24 #define CPU64 2.25 #endif 2.26 #endif 2.27 +#if defined(ROCKRIDGE) || defined(BASIC_ISO9660) || defined(RAW_ISO9660) 2.28 +#ifndef ISO9660 2.29 +#define ISO9660 2.30 +#endif 2.31 +#endif 2.32 2.33 // This file is distributed under GPL 2.34 // 2.35 @@ -92,6 +95,8 @@ 2.36 2.37 extern u8 pm_low; 2.38 2.39 +extern u8 buf4k[4096]; 2.40 + 2.41 extern u32 far *initrd_desc; 2.42 #define cmdline (cmdstr[0]) 2.43 #define kernel_name (cmdstr[1])
3.1 --- a/linld/stuff/src/CRTL.ASM Sat Mar 06 18:53:34 2021 +0000 3.2 +++ b/linld/stuff/src/CRTL.ASM Sun Mar 14 19:55:20 2021 +0000 3.3 @@ -34,17 +34,14 @@ 3.4 3.5 segment _BSS byte public use16 'BSS' 3.6 3.7 - ifdef ISO9660 3.8 - include "isostate.inc" 3.9 - public _isostate 3.10 -_isostate isostate <?> 3.11 - org $-7 3.12 - endif 3.13 - global buf4k:byte 3.14 -label buf4k byte 3.15 -_xfer_buf db 4096 dup (?) 3.16 -filecnt db ? ; in fact 0 minus file count... 3.17 -nextfilename dw ? 3.18 + ifdef ISO9660 3.19 + global _buf2k:byte 3.20 +label _buf2k byte 3.21 + db 2048 dup (?) 3.22 + endif 3.23 + global _buf4k:byte 3.24 +label _buf4k byte 3.25 + db 4096 dup (?) 3.26 3.27 ends _BSS 3.28 3.29 @@ -110,7 +107,7 @@ 3.30 mov ax,3d00h ; read-only+compatibility 3.31 else 3.32 mov ah,3dh ; read-only+compatibility 3.33 - mov dx,bx 3.34 + mov dx,bx ; open(DS:DX=filename,al=access,cl=attributes) 3.35 endif 3.36 ;mov cl,0 ; attribute mask 3.37 call dos 3.38 @@ -135,6 +132,10 @@ 3.39 ret 3.40 3.41 ifdef ISO9660 3.42 + 3.43 + include "isostate.inc" 3.44 + extrn _isostate:isostate 3.45 + 3.46 ;*************************************************************** 3.47 ;_fastcall int:C open(bx:const char* name, int flags=O_RDONLY); 3.48 ;_fastcall int:C openargs(bx:const char* name, int flags=O_RDONLY); 3.49 @@ -182,7 +183,7 @@ 3.50 3.51 global close:near ; close(ax) 3.52 close: 3.53 - mov bh,3Eh 3.54 + mov bh,3Eh ; close(BX:handle) 3.55 ifdef ISO9660 3.56 mov cx,[_isostate.fd] 3.57 jcxz dosbx 3.58 @@ -232,7 +233,7 @@ 3.59 pop bx 3.60 endif 3.61 readfd: 3.62 - mov ah,3Fh 3.63 + mov ah,3Fh ; read(BX=handle,DS:DX=to,CX=count) 3.64 ;jcxz fail 3.65 dos: 3.66 int 21h 3.67 @@ -274,14 +275,14 @@ 3.68 ;*************************************************************** 3.69 proc @readmenu$qv near 3.70 3.71 - mov dx,18 3.72 + mov dx,20 3.73 xor cx,cx 3.74 call seeksetpos0 ; filepos = 0 3.75 - mov dx,offset _isostate.filemod 3.76 - ; //magic = x->filemod; 3.77 - mov cl,10 3.78 - call readfd ; // read x->filemod + x->fileofs & x->filesize 3.79 - mov bx,offset _isostate.fileofs 3.80 + mov dx,offset _isostate.fileofs 3.81 + mov cl,8 3.82 + push dx 3.83 + call readfd ; // read x->fileofs & x->filesize 3.84 + pop bx 3.85 ; x->fileofs = 0x7FF0 - (x->filesize &= 0xFFFF); 3.86 mov ax,7FF0h 3.87 cwd 3.88 @@ -335,9 +336,9 @@ 3.89 3.90 call isolseek ; filepos = 0 3.91 jc fail 3.92 - mov dh,10 3.93 - mov ax,offset _isostate.buffer 3.94 - jmp @read$dxaxbx ; read(fd,buffer,2560+) 3.95 + mov cx,2048 3.96 + mov dx,offset _buf2k 3.97 + jmp readfd ; read(fd,buf2k,2048) 3.98 3.99 endp @isoreadsector$qpxul 3.100 endif 3.101 @@ -394,9 +395,11 @@ 3.102 inc bx 3.103 xchg ax,bx 3.104 xor dl,[bx] ; dl ^= *a++ 3.105 + ifndef RAW_ISO9660 3.106 ifndef ROCKRIDGE 3.107 and dl,0dfh ; case insensitive 3.108 endif 3.109 + endif 3.110 jne fail ; return -1 3.111 inc bx 3.112 or dl,dl ; clear C 3.113 @@ -947,7 +950,7 @@ 3.114 else 3.115 les ax,[dword di] 3.116 endif 3.117 - mov cx,offset _xfer_buf 3.118 + mov cx,offset _buf4k 3.119 storepage: ; storepage(edx,cx) 3.120 ifndef NO386 3.121 push 0 3.122 @@ -1066,7 +1069,7 @@ 3.123 xchg ax,cx 3.124 @@szok: 3.125 jcxz image_done 3.126 - lea dx,[di+_xfer_buf] 3.127 + lea dx,[di+_buf4k] 3.128 mov bx,[(image_himem si).fd] 3.129 call @read$cxdxbx 3.130 jb image_done 3.131 @@ -1083,7 +1086,7 @@ 3.132 @@fill: 3.133 test al,3 3.134 je @@filled 3.135 - mov [di+_xfer_buf],dl 3.136 + mov [di+_buf4k],dl 3.137 inc di 3.138 inc ax 3.139 jmp @@fill
4.1 --- a/linld/stuff/src/ISO9660.CPP Sat Mar 06 18:53:34 2021 +0000 4.2 +++ b/linld/stuff/src/ISO9660.CPP Sun Mar 14 19:55:20 2021 +0000 4.3 @@ -11,10 +11,13 @@ 4.4 { \ 4.5 extern void isoreadrootsector(void); \ 4.6 isoreadrootsector(); \ 4.7 - setdirpage(x->dirpage, (* (unsigned long *) (isostate.buffer + 0x9E))); \ 4.8 - x->dirsize = filesize2dirsize(* (unsigned long *) (isostate.buffer + 0xA6)); \ 4.9 + setdirpage(x->dirpage, (* (unsigned long *) (buf2k + 0x9E))); \ 4.10 + x->dirsize = filesize2dirsize(* (unsigned long *) (buf2k + 0xA6)); \ 4.11 } 4.12 4.13 +#ifdef RAW_ISO9660 4.14 +#define BASIC_ISO9660 4.15 +#endif 4.16 #if !defined(BASIC_ISO9660) && !defined(ROCKRIDGE) 4.17 #define BASIC_ISO9660 4.18 #endif 4.19 @@ -24,25 +27,27 @@ 4.20 4.21 struct isostate *x=&isostate; 4.22 4.23 - p = x->buffer; 4.24 + p = buf2k; 4.25 if (x->curpos >= SECTORSZ || * (short *) (p + x->curpos) == 0) { 4.26 + x->curpos = 0; 4.27 if ((x->curdirsize =- DIRSECTORSZ) < 0) return -1; 4.28 isoreadsector(&x->curdirofs); // x->filepos = 0 4.29 //x->curdirofs += SECTORSZ; 4.30 *(int *)((char *) &x->curdirofs+1) += SECTORSZ/256; 4.31 - x->curpos = 0; 4.32 } 4.33 p += x->curpos; 4.34 x->fileofs = (* (unsigned long *) (p + 2)) << SECTORBITS; 4.35 if ((x->entrysize = * (short *) p) == 0) { 4.36 return -1; 4.37 } 4.38 - x->filemod = 0x81ED; if (p[25] & 2) ((char *)&(x->filemod))[1] = 0x41; 4.39 +#ifdef CHECKISOFILETYPE 4.40 + x->c = p[25]; 4.41 +#endif 4.42 register char *s; 4.43 x->filesize = * (unsigned long *) (p + 10); 4.44 s = ".."+1-p[33]; 4.45 #ifdef ROCKRIDGE 4.46 - p = x->buffer + 34 + ((p[32] + x->curpos) & -2); 4.47 + p = buf2k + 34 + ((p[32] + x->curpos) & -2); 4.48 x->curpos += x->entrysize; 4.49 do { 4.50 register len = p[2]; 4.51 @@ -52,19 +57,21 @@ 4.52 goto found; 4.53 } 4.54 p += len; 4.55 - } while (x->buffer + x->curpos - 3 >= p); 4.56 + } while (buf2k - 3 + x->curpos >= p); 4.57 #endif 4.58 #ifdef BASIC_ISO9660 4.59 # ifdef ROCKRIDGE 4.60 - p = x->buffer + 32 + x->curpos - x->entrysize; 4.61 + p = buf2k + 32 + x->curpos - x->entrysize; 4.62 # else 4.63 x->curpos += x->entrysize; 4.64 p += 32; 4.65 # endif 4.66 if (((* (short *) p) & 0xFEFF) -1 != 0) { 4.67 s = p + 1; p += *p; 4.68 - if (* (short *) (p-1) != 0x313B) p+=2; // no ;1 to remove 4.69 +# ifndef RAW_ISO9660 4.70 + if (* (short *) (p-1) == 0x313B) p-=2; // remove ;1 4.71 if (*p != '.') p++; 4.72 +# endif 4.73 *p = 0; 4.74 } 4.75 #endif 4.76 @@ -92,12 +99,12 @@ 4.77 4.78 s = (char *) x->filename2open; 4.79 if (*s == '/') { 4.80 + isoroot(); 4.81 + //if (strncmp(buf2k+1,"CD001",5) == -1) return -1; 4.82 + //if (*(int*)(buf2k+1) != 0x4443) return -1; 4.83 + next: 4.84 s++; 4.85 - isoroot(); 4.86 - //if (strncmp(x->buffer+1,"CD001,5) == -1) return -1; 4.87 - //if (*(int*)(x->buffer+1) != 0x4443) return -1; 4.88 } 4.89 - next: 4.90 name = s; 4.91 do s++; while (*s && *s != '/'); 4.92 c = *s; *s = 0; 4.93 @@ -125,12 +132,14 @@ 4.94 #endif 4.95 if (strcmp(i, n) != -1) break; 4.96 } while (1); 4.97 - *s++ = c; 4.98 -#define IS_DIR(x)( (*((char*) &x + 1) & (char)0676) == (char)0) 4.99 - if (IS_DIR(x->filemod)) { 4.100 + *s = c; 4.101 + if (c) { 4.102 +#ifdef CHECKISOFILETYPE 4.103 + if ((x->c & 2) == 0) return -1; 4.104 +#endif 4.105 cpytodirpage(x->dirpage, x->fileofs); 4.106 x->dirsize = filesize2dirsize(x->filesize); 4.107 - if (c) goto next; 4.108 + goto next; 4.109 } 4.110 isolseek(&x->fileofs); 4.111 return x->fd;
5.1 --- a/linld/stuff/src/ISO9660.H Sat Mar 06 18:53:34 2021 +0000 5.2 +++ b/linld/stuff/src/ISO9660.H Sun Mar 14 19:55:20 2021 +0000 5.3 @@ -10,7 +10,6 @@ 5.4 unsigned curpos; 5.5 char *filename2open; 5.6 int fd; 5.7 - unsigned short filemod; 5.8 unsigned long fileofs; 5.9 unsigned long filesize; 5.10 unsigned long filepos; 5.11 @@ -19,18 +18,16 @@ 5.12 typedef unsigned dirpagetype; 5.13 dirpagetype dirpage; 5.14 unsigned long curdirofs; 5.15 + char _64bits; 5.16 + char c; 5.17 int entrysize; 5.18 const char *tmp; 5.19 - char c; 5.20 - char _64bits; 5.21 #define SECTORSZ 2048 5.22 #define SECTORBITS 11 5.23 - char buffer[SECTORSZ+512]; // RR overflow 5.24 } isostate; 5.25 #define isofd isostate.fd 5.26 #define isofileofs isostate.fileofs 5.27 #define isofilesize isostate.filesize 5.28 -#define isofilemod isostate.filemod 5.29 #define isofilename isostate.filename 5.30 extern _fastcall void isolseek(const unsigned long *offset); 5.31 extern _fastcall int isoreadsector(const unsigned long *offset); 5.32 @@ -38,4 +35,5 @@ 5.33 extern int isoreaddir(void); 5.34 #define isolabel() do { isofileofs=0x8028; isofilesize=32; } while (0) 5.35 #define setiso(x) (isostate.fd = open(x)) 5.36 +extern u8 buf2k[2048]; 5.37 #endif
6.1 --- a/linld/stuff/src/ISOSTATE.INC Sat Mar 06 18:53:34 2021 +0000 6.2 +++ b/linld/stuff/src/ISOSTATE.INC Sun Mar 14 19:55:20 2021 +0000 6.3 @@ -4,19 +4,19 @@ 6.4 curpos dw ? ; 0 unsigned curpos; 6.5 filename2open dw ? ; 2 char *filename2open; 6.6 fd dw ? ; 4 int fd; 6.7 -filemod dw ? ; 6 unsigned short filemod; 6.8 -fileofs dd ? ; 8 unsigned long fileofs; 6.9 -filesize dd ? ;12 unsigned long filesize; 6.10 -filepos dd ? ;16 unsigned long filepos; 6.11 -filename dw ? ;20 char *filename; 6.12 -curdirsize dw ? ;22 dirsizetype curdirsize; 6.13 -dirsize dw ? ;24 dirsizetype dirsize; 6.14 -dirpape dw ? ;26 unsigned short dirpage; 6.15 -curdirofs dd ? ;28 unsigned long curdirofs; 6.16 +fileofs dd ? ; 6 unsigned long fileofs; 6.17 +filesize dd ? ;10 unsigned long filesize; 6.18 +filepos dd ? ;14 unsigned long filepos; 6.19 +filename dw ? ;18 char *filename; 6.20 +curdirsize dw ? ;20 dirsizetype curdirsize; 6.21 +dirsize dw ? ;22 dirsizetype dirsize; 6.22 +dirpape dw ? ;24 unsigned short dirpage; 6.23 +curdirofs dd ? ;26 unsigned long curdirofs; 6.24 +_64bits db ? ;30 char _64bits; 6.25 ;overlap 6.26 +c db ? ;31 char c; 6.27 entrysize dw ? ;32 int entrysize; 6.28 tmp dw ? ;34 const char *tmp; 6.29 -c db ? ;36 char c; 6.30 -_64bits db ? ;37 char _64bits; 6.31 -buffer db ? ;38 char buffer[2048+512]; 6.32 ends isostate ; } isostate; 6.33 + 6.34 +ISOSTATE_OVERLAP = 5
7.1 --- a/linld/stuff/src/JUMP.ASM Sat Mar 06 18:53:34 2021 +0000 7.2 +++ b/linld/stuff/src/JUMP.ASM Sun Mar 14 19:55:20 2021 +0000 7.3 @@ -289,8 +289,6 @@ 7.4 7.5 endp _boot_kernel 7.6 7.7 -movedend: 7.8 - 7.9 ends _TEXT 7.10 7.11 end
8.1 --- a/linld/stuff/src/LINK.CMD Sat Mar 06 18:53:34 2021 +0000 8.2 +++ b/linld/stuff/src/LINK.CMD Sun Mar 14 19:55:20 2021 +0000 8.3 @@ -1,1 +1,1 @@ 8.4 -_beg.obj linld.obj memtop.obj memcpy32.obj jump.obj vcpi.obj xmm.obj a20.obj crtl.obj load.obj himem.obj iso9660.obj _end.obj, linld 8.5 +_beg.obj linld.obj jump.obj memtop.obj memcpy32.obj vcpi.obj xmm.obj a20.obj crtl.obj load.obj himem.obj iso9660.obj _end.obj, linld
9.1 --- a/linld/stuff/src/LINLD.CPP Sat Mar 06 18:53:34 2021 +0000 9.2 +++ b/linld/stuff/src/LINLD.CPP Sun Mar 14 19:55:20 2021 +0000 9.3 @@ -9,9 +9,9 @@ 9.4 extern char bzimagestr[]; 9.5 const char* cmdstr[4] = {"auto",bzimagestr,NULL,NULL}; 9.6 #ifdef QUICK_BOOT 9.7 -u32 cmdnum[7]; 9.8 +extern u32 cmdnum[7]; 9.9 #else 9.10 -u32 cmdnum[5]; 9.11 +extern u32 cmdnum[5]; 9.12 #endif 9.13 9.14 inline void syntax() { 9.15 @@ -44,7 +44,6 @@ 9.16 ); 9.17 } 9.18 9.19 -extern char buf_cmdline[128]; 9.20 int main(int argc, char *argv[]) { 9.21 9.22 (void) argc; 9.23 @@ -76,17 +75,25 @@ 9.24 kernel_name=*argv; 9.25 continue; 9.26 } 9.27 - *clp = (const char *) buf_cmdline + 1; 9.28 - strcatb((const char *) buf_cmdline,*argv); 9.29 + *clp = (const char *) heap_top +1; 9.30 + strcatb((const char *) heap_top,*argv); 9.31 } while (*++argv); 9.32 puts(*clp); 9.33 + asm{ 9.34 + xchg ax,bx 9.35 + mov bx,offset _heap_top 9.36 + cmp ax,[bx] 9.37 + jc skip 9.38 + mov [bx],ax 9.39 + } 9.40 +skip: 9.41 #ifdef ISO9660 9.42 if (isofile) setiso(isofile); 9.43 #endif 9.44 set_cmdline(*clp); 9.45 load_kernel(); 9.46 load_initrd(); 9.47 - boot_kernel(); 9.48 + //boot_kernel(); 9.49 9.50 // Let compiler be happy 9.51 return _AX;
10.1 --- a/linld/stuff/src/LOAD.CPP Sat Mar 06 18:53:34 2021 +0000 10.2 +++ b/linld/stuff/src/LOAD.CPP Sun Mar 14 19:55:20 2021 +0000 10.3 @@ -116,9 +116,6 @@ 10.4 #else 10.5 #define topseg() 0x9000 10.6 #endif 10.7 -static u16 rm_size; 10.8 -static u8* rm_buf; // @ = @rm_size + 2, see A20.ASM 10.9 -struct image_himem imgs[2]; 10.10 10.11 void load_kernel() { 10.12
11.1 --- a/linld/stuff/src/MEMCPY32.ASM Sat Mar 06 18:53:34 2021 +0000 11.2 +++ b/linld/stuff/src/MEMCPY32.ASM Sun Mar 14 19:55:20 2021 +0000 11.3 @@ -231,6 +231,9 @@ 11.4 11.5 endp memcpy32 11.6 11.7 + global movedend:near 11.8 +movedend: 11.9 + 11.10 ends _TEXT 11.11 11.12 end
12.1 --- a/linld/stuff/src/VCPI.ASM Sat Mar 06 18:53:34 2021 +0000 12.2 +++ b/linld/stuff/src/VCPI.ASM Sun Mar 14 19:55:20 2021 +0000 12.3 @@ -160,8 +160,8 @@ 12.4 sub edi,edx 12.5 mov al,3 ;add present+writable bits 12.6 mov [bx+di],eax ;stuff it into pagedir[0] 12.7 - push ds 12.8 - pop es ;es:di->page0,es:di+1000h->pagedir 12.9 + ;push ds 12.10 + ;pop es ;es:di->page0,es:di+1000h->pagedir 12.11 ;page directory will use only one entry (4 bytes): 12.12 ;cr3 => pagedir => page0 => ######## 12.13 ; (1 entry) (1024 => # 4M #
13.1 --- a/linld/stuff/src/_BEG.ASM Sat Mar 06 18:53:34 2021 +0000 13.2 +++ b/linld/stuff/src/_BEG.ASM Sun Mar 14 19:55:20 2021 +0000 13.3 @@ -8,6 +8,38 @@ 13.4 %nomacs 13.5 13.6 include "common.inc" 13.7 + include "himem.inc" 13.8 + include "isostate.inc" 13.9 + 13.10 + ifdef QUICK_BOOT 13.11 +CMDNUMCNT = 7 13.12 + else 13.13 +CMDNUMCNT = 5 13.14 + endif 13.15 + 13.16 + macro alloc_isostate 13.17 + public _isostate 13.18 +_isostate isostate <?> 13.19 + org $-ISOSTATE_OVERLAP 13.20 + endm 13.21 + 13.22 + macro alloc_image 13.23 +rm_size dw ? ; _imgs-4 13.24 +rm_buf dw ? ; _imgs-2 13.25 + global _imgs:byte 13.26 +label _imgs byte 13.27 +img_kernel image_himem ? 13.28 +img_initrd image_himem ? 13.29 + endm 13.30 + 13.31 + macro alloc_misc 13.32 + global _cmdnum:word 13.33 +label _cmdnum word 13.34 + dd CMDNUMCNT dup(?) 13.35 + 13.36 + global _himem_buf:dword 13.37 +_himem_buf dd ? 13.38 + endm 13.39 13.40 p8086 13.41 13.42 @@ -34,6 +66,14 @@ 13.43 13.44 segment _BSS byte public use16 'BSS' 13.45 13.46 + ifdef ISO9660 13.47 + ifndef VCPI 13.48 + alloc_isotate 13.49 + else 13.50 +room_for_isostate = 1 13.51 + endif 13.52 + endif 13.53 + 13.54 ifdef ISOHOOK 13.55 extrn _big_cmdline:byte 13.56 db 254 dup(?) 13.57 @@ -45,11 +85,27 @@ 13.58 _cpu386 db ? 13.59 ifdef CPU64 13.60 org $-1 13.61 - endif 13.62 - ifdef CPU64 13.63 global _cpu_features:dword 13.64 _cpu_features dd ? 13.65 +room_for_image = 1 13.66 + else 13.67 + alloc_image 13.68 endif 13.69 + 13.70 + ifndef BSS_OVERLAP_BOOT 13.71 + 13.72 + ifdef room_for_isostate 13.73 + alloc_isostate 13.74 + endif 13.75 + 13.76 + ifdef room_for_image 13.77 + alloc_image 13.78 + endif 13.79 + 13.80 + alloc_misc 13.81 + 13.82 + endif 13.83 + 13.84 ends _BSS 13.85 13.86 segment _TEXT byte public use16 'CODE' 13.87 @@ -67,11 +123,6 @@ 13.88 ;*************************************************************** 13.89 mov sp,offset stktop 13.90 mov bx, 0F000h ; cld ; cli & empty string 13.91 - org $-4-2 13.92 - global _himem_buf:dword 13.93 -_himem_buf dd ? 13.94 - global _buf_cmdline:word 13.95 -_buf_cmdline dw ? ; 128 bytes, must start with 00 13.96 mov si,offset _bss_start 13.97 clearbss: 13.98 mov [si],bl ; clear bss + heap 13.99 @@ -128,8 +179,10 @@ 13.100 ifdef VCPI 13.101 ; Check whether it is safe to call 67h 13.102 xor eax,eax 13.103 - mov es,ax 13.104 - cmp [dword es:67h*4],eax 13.105 + push ds 13.106 + mov ds,ax 13.107 + cmp [dword 67h*4],eax 13.108 + pop ds 13.109 je no_vcpi 13.110 mov ah,0DEh ; check for vcpi present 13.111 int 67h 13.112 @@ -187,11 +240,6 @@ 13.113 ;*************************************************************** 13.114 ; build argv & argc 13.115 ;*************************************************************** 13.116 - extrn _bss_end:word 13.117 - mov di,offset _bss_end 13.118 - global _heap_top 13.119 - org $-2 13.120 -_heap_top dw ? 13.121 mov si,80h 13.122 ifdef ISOHOOK 13.123 mov bx,offset _big_cmdline 13.124 @@ -212,6 +260,41 @@ 13.125 endif 13.126 xchg ax,bx 13.127 mov [bx+si],bh ; set eos 13.128 + 13.129 +;*************************************************************** 13.130 + 13.131 + ifdef BSS_OVERLAP_BOOT 13.132 + mov al,0 13.133 + mov di,100h 13.134 + mov cx,offset clean-100h 13.135 + 13.136 + org $-(CMDNUMCNT*4)-4 13.137 + 13.138 + ifdef room_for_image 13.139 + org $-2-2-(2*size image_himem) 13.140 + endif 13.141 + 13.142 + ifdef room_for_isostate 13.143 + org $+ISOSTATE_OVERLAP-size isostate 13.144 + alloc_isostate 13.145 + endif 13.146 + 13.147 + ifdef room_for_image 13.148 + alloc_image 13.149 + endif 13.150 + 13.151 + alloc_misc 13.152 +clean: 13.153 + rep 13.154 + stosb 13.155 + endif 13.156 + 13.157 +;*************************************************************** 13.158 + extrn _bss_end:word 13.159 + mov di,offset _bss_end 13.160 + global _heap_top 13.161 + org $-2 13.162 +_heap_top dw ? 13.163 ;xor dx,dx 13.164 ;push dx ; envp (already cleared) 13.165 ;mov [word di],dx ; argv[0] = 0 (idem)
14.1 --- a/linld/stuff/src/pipehole.awk Sat Mar 06 18:53:34 2021 +0000 14.2 +++ b/linld/stuff/src/pipehole.awk Sun Mar 14 19:55:20 2021 +0000 14.3 @@ -9,6 +9,7 @@ 14.4 if (file == "" && /debug S/) { file=$3; gsub(/\"/,"",file) } 14.5 if (/debug S/) print " %PAGESIZE 1000" 14.6 if (file == "linld.cpp") { 14.7 +#print " linld=" islinld " ;" $0 14.8 if (/\[si/ || /si,/ || /,si/) sub(/si/,"di") 14.9 else if (/\[di/ || /di,/ || /,di/) sub(/di/,"si") 14.10 if (/add di,2/) $0=" scasw ; " $0 14.11 @@ -24,6 +25,7 @@ 14.12 if (islinld==3 && /bx,word ptr/) { print "; " $0; next } 14.13 if (/fileexist\$qpxzc/) islinld=4 14.14 if (islinld==4) { 14.15 + if (/DGROUP:_heap_top/) next 14.16 if (/ax,-1/) { 14.17 print " inc ax" 14.18 print " mov ax,word ptr [di]" 14.19 @@ -46,6 +48,14 @@ 14.20 print " mov bx,word ptr [si+6]" 14.21 $0=" or bx,bx" 14.22 } 14.23 + if (/heap_top \+1;/) islinld=6 14.24 + if (islinld==6) { 14.25 + sub(/ax/,"bx") 14.26 + if (/strcatb/) { 14.27 + print " dec bx" 14.28 + islinld=4 14.29 + } 14.30 + } 14.31 } # file == "linld.cpp" 14.32 if (file == "himem.cpp") { 14.33 if (/sp,bp/ || /pop bp/ || /enter/ || /leave/) next 14.34 @@ -243,52 +253,54 @@ 14.35 } 14.36 } # file == "load.cpp" 14.37 if (file == "iso9660.cpp") { 14.38 - if (/ptr \[si\+8\],/) { si="si"; di="di" } 14.39 - if (/ptr \[di\+8\],/) { si="di"; di="si" } 14.40 - if (/leave/ || /enter/ || /bp-2/ || /bp,sp/ || /push bp/ || /sub sp,/) next 14.41 - if (/ptr \[.i\+10\],dx/) next 14.42 - if (/ptr \[.i\+8\],ax/) next 14.43 - if (/ptr \[.i\+8\],eax/) next 14.44 + if (/di,offset DGROUP:_buf2k/) { si="si"; di="di" } 14.45 + if (/si,offset DGROUP:_buf2k/) { si="di"; di="si" } 14.46 + if (/leave/ || /enter/ || /bp/ || /sub sp,/) next 14.47 + if (/ptr \[.i\+8\],dx/) next 14.48 + if (/ptr \[.i\+6\],ax/) next 14.49 + if (/ptr \[.i\+6\],eax/) next 14.50 if (/x,word ptr \[.i\+32\]/) next 14.51 +#print " iso=" isiso " ;" $0 14.52 if (/add word ptr \[.i\],ax/) sub(/ax/,"cx") 14.53 - if (/ax,word ptr \[si\+24\]/) sub(/mov ax,/,"les ax,d") 14.54 - if (/ax,word ptr \[si\+26\]/) next 14.55 - if (/word ptr \[si\+29\],ax/) sub(/ax/,"es") 14.56 - if (/\[si\],-1/) $0=" not word ptr [si]" 14.57 + if (/ax,word ptr \[si\+22\]/) sub(/mov ax,/,"les ax,d") 14.58 + if (/ax,word ptr \[si\+24\]/) next 14.59 + if (/word ptr \[si\+27\],ax/) sub(/ax/,"es") 14.60 sub(/di,word ptr DGROUP:_isostate\+2/,"di,word ptr [si+2]") 14.61 - if (/p = x->buffer \+ 32 \+ x->curpos/) isiso=21 14.62 -#print "iso=" isiso " ; " $0 14.63 + if (/p = buf2k \+ 32 \+ x->curpos/) isiso=21 14.64 + sub(/-257/,"-257 ; clear C") 14.65 if (isiso == 21) { # ISO9660.LST 14.66 - if (/si,ax/) next 14.67 - if (/ax,70/) { 14.68 - print " lea si,[bx+3+32]" 14.69 - $0=" sub si,cx" 14.70 - } 14.71 + if (/si,ax/) $0=" sub si,cx" 14.72 + sub(/ax,/,"si,") 14.73 if (/# else/) isiso=0 14.74 } 14.75 - if (/cx,si/) isiso=20 14.76 + if (/cx,si/) { 14.77 + if (isiso == 0) print " inc " di 14.78 + isiso=20 14.79 + } 14.80 if (isiso == 20) { # ISO9660.LST 14.81 if (/bx,dx/) { 14.82 isiso=12 14.83 next 14.84 } 14.85 + if (/inc cx/) next 14.86 if (/al,byte ptr/) $0=" ;inc ax" 14.87 - sub(/\[si-1\]/,"[si]") 14.88 - if (/p != .\./) print " inc " di " ; see ;inc ax" 14.89 - if (/i],0/) sub(/,0/,",ah") 14.90 + if (/i],0/) { 14.91 + sub(/,0/,",ah ; clear C") 14.92 + sub(/mov/,"and") 14.93 + } 14.94 sub(/cx/,"dx") 14.95 if (/filename = s;/) { 14.96 isiso=0 14.97 } 14.98 } 14.99 if (isiso == 19) { # ISO9660.LST 14.100 - if (/short @2@282/) $0=" jc restoreC" 14.101 - if (/si\+34/ || /ax,dx/ || /ax,di/ || /cmp ax,-1/ || /sub ax,/) next 14.102 + if (/short @2@310/) $0=" jc restoreC" 14.103 + if (/si\+32/ || /ax,dx/ || /ax,di/ || /cmp ax,-1/ || /sub ax,/) next 14.104 sub(/dx,/,"ax,") 14.105 - if (/ax,word ptr \[si\+20\]/) sub(/ax/,"bx") 14.106 + if (/ax,word ptr \[si\+18\]/) sub(/ax/,"bx") 14.107 if (/bx,offset/) sub(/bx/,"ax") 14.108 if (/short @2@282/) sub(/je/,"jnc") 14.109 - if (/\[si\+37\],0/) sub(/,0/,",ch") 14.110 + if (/\[si\+35\],0/) sub(/,0/,",ch") 14.111 if (/@strcmp\$qpxzct1/) { 14.112 print 14.113 print "restoreC:" 14.114 @@ -296,71 +308,75 @@ 14.115 isiso=1 14.116 } 14.117 } 14.118 - if (/ax,-8/) { isiso=18; next } 14.119 if (isiso == 18) { # ISO9660.LST 14.120 - if (/ax,ax/) { isiso=0;next } 14.121 - sub(/mov/,"sub") 14.122 - sub(/,ax/,",8") 14.123 + if (/endif/) isiso=1 14.124 } 14.125 if (isiso == 17) { # ISO9660.LST 14.126 - if (/inc di/) $0="; " $0 14.127 - if (/_isostate\+205/) { 14.128 + if (/si\+22/) { 14.129 + print "next:" 14.130 + print " mov word ptr [si+24],bx" 14.131 print 14.132 - $0=" jmp setdirofsnsz" 14.133 + isiso=0 14.134 + } 14.135 + if (/_buf2k\+167/) { 14.136 + print 14.137 + $0="" 14.138 } 14.139 else sub(/ax/,"bx") 14.140 - if (/si\+24/) isiso=0 14.141 if (/,bx/) next 14.142 if (/isoreadrootsector/) { 14.143 print 14.144 - print " xor word ptr [si+39],17475 ; clear C" 14.145 - $0=" jne returnNotC" 14.146 + print " mov ax,word ptr [_buf2k+1]" 14.147 + print " xor ax,17475 ; clear C, CD" 14.148 + print "jne_returnNotC:" 14.149 + print " cmc" 14.150 + $0=" jne returnC" 14.151 } 14.152 } 14.153 - if (/cpytodirpage.x->dirpage/) isiso=16 14.154 + if (/if \(c\)/) isiso=16 14.155 if (isiso == 16) { # ISO9660.LST 14.156 - if (/filesize2dirsize/) { 14.157 - print " mov bx,word ptr [si+9]" 14.158 - print " mov ax,word ptr [si+13]" 14.159 - print "setdirofsnsz:" 14.160 - print " inc di" 14.161 - print " mov word ptr [si+26],bx" 14.162 + if (/cmp/) { 14.163 + print " mov bx,word ptr [si+7]" 14.164 + print " mov ax,word ptr [si+11]" 14.165 + print " dec cx" 14.166 + print " jns next" 14.167 } 14.168 - if (/ax,/ || /si\+13/ || /si\+26/) next 14.169 - if (/si\+24/) isiso=1 14.170 + if (/isolseek/) isiso=1 14.171 + else if (! /;/) next 14.172 } 14.173 if (/found:/) isiso=15 14.174 if (isiso != 15 && /si,offset DGROUP:_isostate/) $0=";" $0 14.175 if (isiso == 15) { # ISO9660.LST 14.176 if (/xor/) { 14.177 - print " stc" 14.178 - print "returnNotC:" 14.179 - print " cmc" 14.180 print "returnC:" 14.181 print " sbb ax,ax" 14.182 print "return:" 14.183 next 14.184 } 14.185 - if (/i\+20\],cx/) sub(/cx/,"dx") 14.186 - if (/@1@422:/ || /bp$/ || /bp,sp/ || /sp,2/) next 14.187 + if (/i\+18\],cx/) sub(/cx/,"dx") 14.188 + if (/@1@422:/) next 14.189 if (/\[di\],47/) isiso=17 14.190 } 14.191 - if (/short @1@142/) { isiso=14; next } 14.192 if (isiso == 14) { # ISO9660.LST 14.193 - if (/ax,-1/) next 14.194 + if (/ax,/ || /jge/) next 14.195 + sub(/mov/,"sub") 14.196 + sub(/,ax/,",8") 14.197 if (/jmp/) { 14.198 - print " JUMPS" 14.199 - print " jb returnC" 14.200 - $0=" NOJUMPS" 14.201 + print " ;JUMPS" 14.202 + print " jb returnCXZC" 14.203 + $0=" ;NOJUMPS" 14.204 + isiso=0 14.205 } 14.206 } 14.207 - if (/p = x->buffer \+ 34/) isiso=13 14.208 + if (/p = buf2k \+ 34/) isiso=13 14.209 if (isiso == 13) { # ISO9660.LST 14.210 if (/cbw/) $0=" ;cbw" 14.211 if (/i,.i/) $0=" xchg ax,bx" 14.212 - if (/i,ax/) $0=" lea " di ",[bx+" si "+72]" 14.213 - if (/i,72/ || /word ptr \[.i\+32\]/) next 14.214 - if (/register len/) isiso=12 14.215 + if (/i,ax/) $0=" xchg ax," di 14.216 + if (/i,70/ || /word ptr \[.i\+32\]/) next 14.217 + if (/register len/) { 14.218 + isiso=12 14.219 + } 14.220 } 14.221 if (isiso == 12) { # ISO9660.LST 14.222 if (/.i\+2/) sub(/al/,"bl") 14.223 @@ -373,25 +389,28 @@ 14.224 if (/while/) isiso=120 14.225 } 14.226 if (isiso == 120) { # ISO9660.LST 14.227 - sub(/ax,/,"bx,") 14.228 + sub(/ax/,"bx") 14.229 + if (/cmp bx,/) $0=" cmp " di ",bx" 14.230 + sub(/jae/,"jb") 14.231 if (/endif/) isiso=0 14.232 } 14.233 if (/curpos >= SECT/) isiso=10 14.234 if (isiso == 10) { # ISO9660.LST 14.235 - if (/cmp/) { 14.236 + if (/,2048/) { 14.237 + print " xor cx,cx" 14.238 sub(/cmp /,"mov bx,") 14.239 sub(/i.*/,"i]") 14.240 print 14.241 $0=" cmp bh,2048/256" 14.242 } 14.243 - if (/mov/) { 14.244 - isiso=0 14.245 - next 14.246 - } 14.247 + if (/DGROUP:_buf2k\[bx\],0/) $0=" cmp word ptr [bx+" di "],cx" 14.248 + sub(/,0/,",cx") 14.249 + if (/\[.i\],cx/) isiso=14 14.250 + else if (/mov/) next 14.251 } 14.252 if (/<< SECTORBITS/) isiso=9 14.253 if (isiso == 9) { # ISO9660.LST 14.254 - if (/dx,/) next 14.255 + if (/dx,/) next 14.256 sub(/mov ax,/,"les ax,d") 14.257 if (/^ call/) { 14.258 print " extrn N_LXLSH@ES:near" 14.259 @@ -405,53 +424,60 @@ 14.260 sub(/mov dx,/,"les dx,d") 14.261 sub(/\],ax/,"],es") 14.262 sub(/cx,/,"dx,") 14.263 - if (/filemod/) isiso=0 14.264 + if (/sub/) isiso=0 14.265 } 14.266 if (/entrysize =/) isiso=5 14.267 if (isiso == 5) { # ISO9660.LST 14.268 if (/ax,ax/) next 14.269 - if (/word ptr \[.i\+32\],ax/) next 14.270 + if (/word ptr \[.i\+3.\],ax/) next 14.271 sub(/ax/,"cx") 14.272 sub(/je/,"jcxz") 14.273 if (/jcxz/) { 14.274 hold=0 14.275 print s 14.276 - sub(/@1@114/,"returnNotC") 14.277 + print " stc" 14.278 + print "returnCXZC:" 14.279 + sub(/@1@1../,"returnC") 14.280 print 14.281 - if (is386) $0=" mov dword ptr [" si "+8],eax" 14.282 + if (is386) $0=" mov dword ptr [" si "+6],eax" 14.283 else { 14.284 - print " mov word ptr [" si "+10],dx" 14.285 - $0=" mov word ptr [" si "+8],ax" 14.286 + print " mov word ptr [" si "+8],dx" 14.287 + $0=" mov word ptr [" si "+6],ax" 14.288 } 14.289 } 14.290 if (/return/) isiso=0 14.291 } 14.292 if (/do s\+\+; while/) isiso=3 14.293 if (isiso == 3) { # ISO9660.LST 14.294 + if (/do \{/) print "while1:" 14.295 sub(/cmp byte ptr \[.i\]/,"sub al") 14.296 if (/inc /) { r=$2; print; next } 14.297 if (/al,0/) print " mov al,[" r "]" 14.298 if (/al,byte ptr \[/) next 14.299 if (/byte ptr \[.*\],0/) next 14.300 + if (/byte ptr \[si\+31\],al/) next 14.301 } 14.302 if (/ptr .isoreaddir/) isiso=1 14.303 if (isiso == 1) { # ISO9660.LST 14.304 + if (/xor/) isiso=18 14.305 if (/n = name;/) { 14.306 isiso=19 14.307 print " xchg ax,cx" 14.308 print " xchg cl,byte ptr [di] ; c" 14.309 } 14.310 - if (/short @2@366/) sub(/jne/,"jnc") 14.311 - if (/short @2@282/) sub(/je/,"jc") 14.312 - if (/short @2@562/) sub(/@2@562/,"returnNotC") 14.313 + sub(/jne/,"jnc") 14.314 + if (/short @2@450/) $0=" jc returnC" 14.315 + if (/je/) $0=" jc while1" 14.316 + if (/short @2@562/) sub(/@2@562/,"jne_returnNotC") 14.317 + if (/jmp/) $0=" jmp jne_returnNotC" 14.318 if (/ax,word ptr \[si\+4\]/) $0=" xchg ax,bx ; " $0 14.319 - if (/\[di\],al/) next 14.320 - if (/@2@310/) next 14.321 + if (/\[di\],al/ || /al,byte ptr/) next 14.322 + if (/@2@338/) next 14.323 if (/ax,-1/) next 14.324 if (/inc di/ || /@@0/) next 14.325 - if (/@2@142$/) { print " inc di"; sub(/jmp/,"loop") } 14.326 + if (/@2@142$/) print " inc di" 14.327 } 14.328 - if (/i\+36\]/) next 14.329 + if (/i\+34\]/) next 14.330 sub(/di,offset DGROUP:_isostate/,"di,si") 14.331 } # file == "iso9660.cpp" 14.332 if (wascall) { 14.333 @@ -785,7 +811,7 @@ 14.334 } 14.335 if (afterjmp) print ";" $0 14.336 else print 14.337 - if (/^ jmp / || /^ call near ptr _boot_kernel/ || 14.338 + if (/^ jmp / || /boot_kernel\(\);/ || 14.339 /^ call near ptr @die\$qpxzc/ || 14.340 /^ call near ptr @exit\$qv/) afterjmp=1 14.341 }