# HG changeset patch # User Pascal Bellard # Date 1488716528 -3600 # Node ID 6f494adb2c71ff23cdf6abefe0fa07b259e89973 # Parent 9facff0f7d4ebfc6e990f4d1262430c78f030cc4 linld/tazboot: can boot memtest & ipxe diff -r 9facff0f7d4e -r 6f494adb2c71 linld/stuff/src/!COMPILEX.BAT --- a/linld/stuff/src/!COMPILEX.BAT Sat Mar 04 22:10:01 2017 +0100 +++ b/linld/stuff/src/!COMPILEX.BAT Sun Mar 05 13:22:08 2017 +0100 @@ -1,7 +1,7 @@ path ..\BC31;%PATH% call !clean.bat -rem tasm /la /m /dNO386 *.asm > asm.log -tasm /la /m /dNO386 /dLARGE_IMAGES *.asm > asm.log +rem tasm /la /m /dEXTRA /dNO386 *.asm > asm.log +tasm /la /m /dEXTRA /dNO386 /dLARGE_IMAGES *.asm > asm.log rem @pause rem bcc @bccopt.opt -S -mt *.cpp bcc @bccopt.opt -S -mt -DLARGE_IMAGES *.cpp diff -r 9facff0f7d4e -r 6f494adb2c71 linld/stuff/src/CRTL.ASM --- a/linld/stuff/src/CRTL.ASM Sat Mar 04 22:10:01 2017 +0100 +++ b/linld/stuff/src/CRTL.ASM Sun Mar 05 13:22:08 2017 +0100 @@ -23,6 +23,9 @@ msg_crlf db 13,10,0 vcpi_alloc_err db "vcpi " msg_malloc db "malloc failure",0 + ifdef EXTRA +tazboot_cmd db "tazboot.cmd",0 + endif ends _DATA @@ -35,6 +38,9 @@ ifdef LARGE_IMAGES curdata dw ? endif + ifdef EXTRA +ultoabuf db 12 dup (?) + endif ends _BSS @@ -249,9 +255,9 @@ endp _read - + ifdef EXTRA ;*************************************************************** -;long lseekset(int fd, long sz); +;long lseekset(int fd, unsigned long sz); ;*************************************************************** global _lseekset:near proc _lseekset near @@ -262,6 +268,21 @@ pop cx ; sz hi push cx push dx + + else +;*************************************************************** +;long seekset(int fd, unsigned sz); +;*************************************************************** + global _seekset:near + proc _seekset near + + xor cx,cx + pop ax ;caller return address + pop bx ; fd + pop dx ; sz + push dx + endif + push bx push ax global lseekset:near @@ -278,7 +299,43 @@ xor cx,cx jmp dos + ifdef EXTRA endp _lseekset + else + endp _seekset + endif + + ifdef EXTRA +struc isostate ; struct isostate { +fd dw ? ; 0 int fd; +fileofs dd ? ; 2 unsigned long fileofs; +filesize dd ? ; 6 unsigned long filesize; +filemod dw ? ;10 unsigned short filemod; +filename dw ? ;12 char *filename; +dirofs dd ? ;14 unsigned long dirofs; +dirsize dd ? ;16 unsigned long dirsize; +curdirofs dd ? ;20 unsigned long curdirofs; +curdirsize dd ? ;24 unsigned long curdirsize; +curpos dd ? ;28 unsigned long curpos; +ends ; } isostate; +;*************************************************************** +;unsigned long isolseek(const unsigned long *offset); +;*************************************************************** + global _isolseek:near + proc _isolseek near + + pop ax + pop bx + push bx + push ax + mov dx,[bx] + mov cx,[bx+2] + extrn _isostate:isostate + mov bx,[_isostate.fd] + jmp lseekset ; (bx=fd, sz=cx:dx) + + endp _isolseek + endif ;*************************************************************** @@ -1177,8 +1234,294 @@ endp _topseg endif + ifdef EXTRA + p8086 + +;*************************************************************** +;int strcmp(const char* a,const char* b); +;*************************************************************** + global _strcmp:near + proc _strcmp near + + pop cx ;caller return address + pop bx ; a + pop ax ; b + push ax + push bx + push cx + push si + xchg ax,si + sub bx,si +@@lp: + mov al,[si] + sub al,[bx+si] + jnz @@out + lodsb + cmp al,0 + jne @@lp +@@out: + cbw + pop si + ret + + endp _strcmp + + +;*************************************************************** +;char strstr(const char* a,const char* b); +;*************************************************************** + global _strstr:near + proc _strstr near + + pop ax ;caller return address + pop cx ; a + pop dx ; b + push dx + push cx + push ax + push si +@@loop: + xor ax,ax + mov si,cx + cmp [si],al ; *a + jz @@end ; return ax = NULL + mov bx,dx + sub bx,si +@@match: + or ah,[bx+si] ; *b + jz @@found + lodsb + sub ah,al + jz @@match + inc cx + jmp @@loop +@@found: + xchg ax,cx +@@end: + pop si + ret + + endp _strstr + + +;*************************************************************** +;char *progname(void) +;*************************************************************** + global _progname:near + proc _progname near + + push si di es + mov ah,30h + int 21h + cmp al,3 + jb @@skip + xor di,di + mov es,[cs:2Ch] + mov cx,-1 + mov ax,di +@@loop1: + repne + scasb + scasb + jne @@loop1 + lea si,[di+2] + mov bx, si + call strlen + xchg ax,cx + inc cx + call malloc_or_die + xchg ax,di + push ds + push ds + push es + pop ds + pop es + push di +@@loop2: + lodsb + stosb + or al,al + jnz @@loop2 + pop ax + pop ds +@@skip: + pop es di si + ret + + endp _progname + + +;*************************************************************** +;int chdir(char *path); +;*************************************************************** + global _chdir:near + proc _chdir near + + pop ax + pop dx + push dx + push ax +chdir: + stc + mov ax,713Bh + int 21h + jnc @@end + mov ah,3Bh + int 21h +@@end: + sbb ax,ax + ret + + endp _chdir + + +;*************************************************************** +;int chdirname(char *path) +;*************************************************************** + global _chdirname:near + proc _chdirname near + + pop ax + pop bx + push bx + push ax + + cmp [byte bx+1],3Ah + jne @@nodisk + mov dl,[bx] + or dl,20h + sub dl,61h + mov ah,0Eh + push bx + int 21h + pop bx + inc bx + inc bx +@@nodisk: + mov dx,bx + xor cx,cx +@@next: + mov al,[bx] + cmp al,5Ch + jne @@tsteos + mov cx,bx +@@tsteos: + inc bx + or al,al + jnz @@next + cbw + jcxz @@end + mov bx,cx + push [word bx] + mov [bx],al + push bx + call chdir + pop bx + pop [word bx] +@@end: + ret + + endp _chdirname + + +;*************************************************************** +;char *ultoa(unsigned long n); +;*************************************************************** + global _ultoa:near + proc _ultoa near + + pop ax + pop cx + pop dx + push dx + push cx + push ax ; DX:CX = n + push si + mov si,10 + mov bx,offset ultoabuf+11 +@@loop: + dec bx + xchg ax,dx + xor dx,dx + div si ; DX:AX = 0000:hi(n) + xchg ax,cx ; CX = hi(n)/10 + div si ; DX:AX = hi(n)%10:lo(n) + xchg ax,cx ; CX = lo(n/10) + xchg ax,dx ; DX = hi(n)/10 = hi(n/10) + add al,'0' + mov [bx],al + mov ax,cx + or ax,dx + jnz @@loop + xchg ax,bx + pop si + ret + + endp _ultoa + + +;*************************************************************** +;unsigned long kver2ul(char *kernel_version); +;*************************************************************** + global _kver2ul:near + proc _kver2ul near + + pop bx + pop ax + push ax + push bx + push bp si di + xchg ax,si + xor di,di + push di + push di + mov bp,sp + inc di + inc di + mov cl,4 +@@number: + xor ax,ax +@@digit: + shl al,cl + shl ax,cl + lodsb + sub al,30h + cmp al,9 + jbe @@digit + mov [bp+di],ah + dec di + jns @@number + pop ax + pop dx + pop di si bp +kver2ulret: + ret + + endp _kver2ul + + +;*************************************************************** +;void try_default_args(); +;*************************************************************** + global _try_default_args:near + proc _try_default_args near + + mov bx,offset tazboot_cmd + call open + jc kver2ulret + mov cx,4096 + mov di,[_heap_top] + push cx + extrn read_cmdline:near + jmp near read_cmdline ; read_cmdline(ax,di,cx) + + endp _try_default_args + + endif + ends _TEXT end ;###### END OF FILE ############################################ + diff -r 9facff0f7d4e -r 6f494adb2c71 linld/stuff/src/CRTL.H --- a/linld/stuff/src/CRTL.H Sat Mar 04 22:10:01 2017 +0100 +++ b/linld/stuff/src/CRTL.H Sun Mar 05 13:22:08 2017 +0100 @@ -40,7 +40,7 @@ extern "C" void abort(); extern "C" int read(int fd, void* data, int sz); extern "C" int write(int fd, const void* data, int sz); -extern "C" long lseekset(int fd, long sz); +extern "C" long seekset(int fd, unsigned sz); extern "C" void* malloc(unsigned sz); extern "C" int puts(const char* s); extern "C" unsigned long strtol(const char *s); diff -r 9facff0f7d4e -r 6f494adb2c71 linld/stuff/src/CRTLX.ASM --- a/linld/stuff/src/CRTLX.ASM Sat Mar 04 22:10:01 2017 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,391 +0,0 @@ -;*************************************************************** -;****** This file is distributed under GPL -;*************************************************************** - ideal - %crefref - %noincl - %nomacs - p8086 - - group DGROUP _TEXT,_DATA,_BSS - assume cs:DGROUP,ds:DGROUP - - segment _DATA byte public use16 'DATA' - -tazboot_cmd db "tazboot.cmd",0 - - ends _DATA - - segment _BSS byte public use16 'BSS' - -ultoabuf db 12 dup (?) - - ends _BSS - - segment _TEXT byte public use16 'CODE' - -;*************************************************************** -;int strcmp(const char* a,const char* b); -;*************************************************************** - global _strcmp:near - proc _strcmp near - - pop cx ;caller return address - pop bx ; a - pop ax ; b - push ax - push bx - push cx - push si - xchg ax,si - sub bx,si -@@lp: - mov al,[si] - sub al,[bx+si] - jnz @@out - lodsb - cmp al,0 - jne @@lp -@@out: - cbw - pop si - ret - - endp _strcmp - - -;*************************************************************** -;char strstr(const char* a,const char* b); -;*************************************************************** - global _strstr:near - proc _strstr near - - pop ax ;caller return address - pop cx ; a - pop dx ; b - push dx - push cx - push ax - push si -@@loop: - xor ax,ax - mov si,cx - cmp [si],al ; *a - jz @@end ; return ax = NULL - mov bx,dx - sub bx,si -@@match: - or ah,[bx+si] ; *b - jz @@found - lodsb - sub ah,al - jz @@match - inc cx - jmp @@loop -@@found: - xchg ax,cx -@@end: - pop si - ret - - endp _strstr - - -macro cpuid - db 0fh,0A2h -endm -;*************************************************************** -;int cpuhaslm(void) -;*************************************************************** - global _cpuhaslm:near - proc _cpuhaslm near - - pushf -; Check for oldies - mov bh, 0F0h - push bx ; < 286 : flags[12..15] are forced 1 - popf ; = 286 : flags[12..15] are forced 0 - pushf ; > 286 : only flags[15] is forced 0 - pop dx - popf - add dh,bh ; NS=386+, NC=286 - clc - js @@bad ;it is a 86/186/286, not a 386+ - p386 - pushfd - pop dx - pop ax - mov bl,al - xor al,20h ; toggle CPUID feature bit 21 - push ax - push dx - popfd - pushfd - pop dx - pop ax - xor al,bl ; clear C - je @@bad ; CPUID feature bit changed ? - mov eax,80000001h ; Extended Processor Info and Feature Bits - cpuid - shr edx,1+29 ; LM feature bit ? -@@bad: - p8086 - sbb ax,ax - ret - - endp _cpuhaslm - - -;*************************************************************** -;char *progname(void) -;*************************************************************** - global _progname:near - proc _progname near - - push si di es - mov ah,30h - int 21h - cmp al,3 - jb @@skip - xor di,di - mov es,[cs:2Ch] - mov cx,-1 - mov ax,di -@@loop1: - repne - scasb - scasb - jne @@loop1 - lea si,[di+2] - mov bx, si - extrn strlen:near - call near strlen - xchg ax,cx - inc cx - extrn malloc_or_die:near - call near malloc_or_die - xchg ax,di - push ds - push ds - push es - pop ds - pop es - push di -@@loop2: - lodsb - stosb - or al,al - jnz @@loop2 - pop ax - pop ds -@@skip: - pop es di si - ret - - endp _progname - - -;*************************************************************** -;int chdir(char *path); -;*************************************************************** - global _chdir:near - proc _chdir near - - pop ax - pop dx - push dx - push ax -chdir: - stc - mov ax,713Bh - int 21h - jnc @@end - mov ah,3Bh - int 21h -@@end: - sbb ax,ax - ret - - endp _chdir - - -;*************************************************************** -;int chdirname(char *path) -;*************************************************************** - global _chdirname:near - proc _chdirname near - - pop ax - pop bx - push bx - push ax - - cmp [byte bx+1],3Ah - jne @@nodisk - mov dl,[bx] - or dl,20h - sub dl,61h - mov ah,0Eh - push bx - int 21h - pop bx - inc bx - inc bx -@@nodisk: - mov dx,bx - xor cx,cx -@@next: - mov al,[bx] - cmp al,5Ch - jne @@tsteos - mov cx,bx -@@tsteos: - inc bx - or al,al - jnz @@next - cbw - jcxz @@end - mov bx,cx - push [word bx] - mov [bx],al - push bx - call chdir - pop bx - pop [word bx] -@@end: - ret - - endp _chdirname - - -;*************************************************************** -;char *ultoa(unsigned long n); -;*************************************************************** - global _ultoa:near - proc _ultoa near - - pop ax - pop cx - pop dx - push dx - push cx - push ax ; DX:CX = n - push si - mov si,10 - mov bx,offset ultoabuf+11 -@@loop: - dec bx - xchg ax,dx - xor dx,dx - div si ; DX:AX = 0000:hi(n) - xchg ax,cx ; CX = hi(n)/10 - div si ; DX:AX = hi(n)%10:lo(n) - xchg ax,cx ; CX = lo(n/10) - xchg ax,dx ; DX = hi(n)/10 = hi(n/10) - add al,'0' - mov [bx],al - mov ax,cx - or ax,dx - jnz @@loop - xchg ax,bx - pop si - ret - - endp _ultoa - - -;*************************************************************** -;unsigned long kver2ul(char *kernel_version); -;*************************************************************** - global _kver2ul:near - proc _kver2ul near - - pop bx - pop ax - push ax - push bx - push bp si di - xchg ax,si - xor di,di - push di - push di - mov bp,sp - inc di - inc di - mov cl,4 -@@number: - xor ax,ax -@@digit: - shl al,cl - shl ax,cl - lodsb - sub al,30h - cmp al,9 - jbe @@digit - mov [bp+di],ah - dec di - jns @@number - pop ax - pop dx - pop di si bp -kver2ulret: - ret - - endp _kver2ul - - -;*************************************************************** -;void try_default_args(); -;*************************************************************** - global _try_default_args:near - proc _try_default_args near - - mov bx,offset tazboot_cmd - extrn open:near - call near open - jc kver2ulret - mov cx,4096 - extrn _heap_top:word - mov di,[_heap_top] - push cx - extrn read_cmdline:near - jmp near read_cmdline ; read_cmdline(ax,di,cx) - - endp _try_default_args - -struc isostate ; struct isostate { -fd dw ? ; 0 int fd; -fileofs dd ? ; 2 unsigned long fileofs; -filesize dd ? ; 6 unsigned long filesize; -filemod dw ? ;10 unsigned short filemod; -filename dw ? ;12 char *filename; -dirofs dd ? ;14 unsigned long dirofs; -dirsize dd ? ;16 unsigned long dirsize; -curdirofs dd ? ;20 unsigned long curdirofs; -curdirsize dd ? ;24 unsigned long curdirsize; -curpos dd ? ;28 unsigned long curpos; -ends ; } isostate; -;*************************************************************** -;unsigned long isolseek(unsigned long offset); -;*************************************************************** - global _isolseek:near - proc _isolseek near - - pop ax - pop dx - pop cx - push cx - push dx - push ax - extrn _isostate:isostate - mov bx,[_isostate.fd] - extrn lseekset:near - jmp near lseekset ; (bx=fd, sz=cx:dx) - - endp _isolseek - - ends _TEXT - - end - -;###### END OF FILE ############################################ diff -r 9facff0f7d4e -r 6f494adb2c71 linld/stuff/src/CRTLX.H --- a/linld/stuff/src/CRTLX.H Sat Mar 04 22:10:01 2017 +0100 +++ b/linld/stuff/src/CRTLX.H Sun Mar 05 13:22:08 2017 +0100 @@ -4,11 +4,13 @@ extern "C" int strcmp(const char* a,const char* b); extern "C" int strlen(const char* s); extern "C" char* strstr(const char* a,const char* b); -extern "C" int cpuhaslm(); extern "C" char *progname(void); extern "C" int chdir(char *path); extern "C" int chdirname(char *path); extern "C" unsigned long kver2ul(char *kernel_version); extern "C" char *ultoa(unsigned long n); extern "C" void try_default_args(); - +extern "C" long lseekset(int fd, unsigned long sz); +#define seekset(fd,sz) lseekset(fd,(unsigned long) sz) +extern long cpu_features; +#define cpuhaslm() (((char *)&cpu_features)[3]&(char)0x20) diff -r 9facff0f7d4e -r 6f494adb2c71 linld/stuff/src/ISO9660.CPP --- a/linld/stuff/src/ISO9660.CPP Sat Mar 04 22:10:01 2017 +0100 +++ b/linld/stuff/src/ISO9660.CPP Sun Mar 05 13:22:08 2017 +0100 @@ -8,45 +8,24 @@ static char buffer[SECTORSZ]; struct isostate isostate; -static int readsector(unsigned long offset) +static int readsector(const unsigned long *offset) { return (isolseek(offset) != -1 && read(isostate.fd, buffer, SECTORSZ) == SECTORSZ); } -int isoread(char *data, unsigned size) -{ - int get, n; - - struct isostate *x=&isostate; - if (isolseek(x->fileofs) == -1) - return -1; - if (size < x->filesize) - size = x->filesize; - for (get = size; get; get -= n, data += n) { - n = read(x->fd,data,get); - if (n < 0) - return n; - if (n == 0) - break; - x->fileofs += n; - x->filesize -= n; - } - return size - get; -} - int isoreset(char *name) { + static const unsigned long root = 16UL * 2048; struct isostate *x=&isostate; if (name) //x->fd = open(name, O_RDONLY); x->fd = open(name); - if (!readsector(16UL * 2048) || strhead(buffer+1,"CD001")) { + if (!readsector(&root) || strhead(buffer+1,"CD001")) { //close(x->fd); return -1; } - x->dirofs = * (unsigned long *) (buffer + 0x9E); - x->dirofs <<= SECTORBITS; + x->dirofs = (* (unsigned long *) (buffer + 0x9E)) << SECTORBITS; x->dirsize = * (unsigned long *) (buffer + 0xA6); return 0; } @@ -68,7 +47,7 @@ } if (x->curpos >= SECTORSZ || * (short *) (buffer + x->curpos) == 0) { if (x->curdirsize < SECTORSZ) return -1; - readsector(x->curdirofs); + readsector(&x->curdirofs); x->curdirofs += SECTORSZ; x->curdirsize -= SECTORSZ; x->curpos = 0; @@ -125,52 +104,44 @@ return 0; } -#define IS_DIR(x)( ((x) & ~0777) == 040000) -int isoopen(char *filename) +//#define IS_DIR(x)( ((x) & ~0777) == 040000) +#define IS_DIR(x)( (char)((x) >> 9) == (char)040) +int isoopen(const char *filename) { int restart; - char *name, *s; - int _64bits = cpuhaslm(); + char *name, *s, c; + char _64bits = cpuhaslm(); struct isostate *x=&isostate; retry32: - name = filename; - while (*name == '/') { - name++; + for (s = (char *) filename; *s == '/' ; s++) { isoreset(NULL); } - s = name; - while (1) { - char c; - while (*s && *s != '/') s++; - c = *s; - *s = 0; - for (restart = 1; isoreaddir(restart) == 0; restart = 0) { - const char *n = name, *i = x->filename; - if (_64bits) { - if (strhead(x->filename, name)) continue; - n = "64"; - i += strlen(name); - } - if (strcmp(n, i)) continue; - if (IS_DIR(x->filemod)) { - x->dirofs = x->fileofs; - x->dirsize = x->filesize; - if (c) { - *s++ = c; - name = s; - goto next; - } - } - isolseek(x->fileofs); - return 0; + next: + name = s; + do s++; while (*s && *s != '/'); + c = *s; + *s = 0; + for (restart = 1; isoreaddir(restart) == 0; restart = 0) { + const char *n = name, *i = x->filename; + if (_64bits) { + if (strhead(i, n)) continue; + n = "64"; + i += s - name; // strlen(name); } - if (_64bits) { - _64bits = 0; - *s = c; - goto retry32; + if (strcmp(i, n)) continue; + *s++ = c; + if (IS_DIR(x->filemod)) { + x->dirofs = x->fileofs; + x->dirsize = x->filesize; + if (c) goto next; } - return -1; - next: ; + isolseek(&x->fileofs); + return 0; } + if (_64bits) { + _64bits = 0; + goto retry32; + } + return -1; } diff -r 9facff0f7d4e -r 6f494adb2c71 linld/stuff/src/ISO9660.H --- a/linld/stuff/src/ISO9660.H Sat Mar 04 22:10:01 2017 +0100 +++ b/linld/stuff/src/ISO9660.H Sun Mar 05 13:22:08 2017 +0100 @@ -16,10 +16,9 @@ #define isofilesize isostate.filesize #define isofilemod isostate.filemod #define isofilename isostate.filename -extern "C" unsigned long isolseek(unsigned long offset); +extern "C" unsigned long isolseek(const unsigned long *offset); extern int isoreset(char *name); -extern int isoopen(char *name); +extern int isoopen(const char *name); extern int isoreaddir(int restart); -extern int isoread(char *data, unsigned size); #define isolabel() do { isofileofs=0x8028; isofilesize=32; } while (0) #endif diff -r 9facff0f7d4e -r 6f494adb2c71 linld/stuff/src/JUMP.ASM --- a/linld/stuff/src/JUMP.ASM Sat Mar 04 22:10:01 2017 +0100 +++ b/linld/stuff/src/JUMP.ASM Sun Mar 05 13:22:08 2017 +0100 @@ -42,13 +42,13 @@ push 9000h pop es endif - pop cx ; ip - pop dx ; cs + pop dx ; ip + pop cx ; cs cli ; we start doing destructive things to DOS push es pop ss mov sp,0A000h - push dx cx + push cx dx extrn _rm_size:word mov si,offset _rm_size ; _rm_size, _pm_high, _rm_buf lodsw diff -r 9facff0f7d4e -r 6f494adb2c71 linld/stuff/src/LINKX.CMD --- a/linld/stuff/src/LINKX.CMD Sat Mar 04 22:10:01 2017 +0100 +++ b/linld/stuff/src/LINKX.CMD Sun Mar 05 13:22:08 2017 +0100 @@ -1,1 +1,1 @@ -_beg.obj memcpy32.obj jump.obj vcpi.obj himem.obj crtl.obj crtlx.obj memtop.obj xmm.obj a20.obj load.obj iso9660.obj tazboot.obj _end.obj, tazboot +_beg.obj memcpy32.obj jump.obj vcpi.obj himem.obj crtl.obj memtop.obj xmm.obj a20.obj load.obj iso9660.obj tazboot.obj _end.obj, tazboot diff -r 9facff0f7d4e -r 6f494adb2c71 linld/stuff/src/LINLD.CPP --- a/linld/stuff/src/LINLD.CPP Sat Mar 04 22:10:01 2017 +0100 +++ b/linld/stuff/src/LINLD.CPP Sun Mar 05 13:22:08 2017 +0100 @@ -58,6 +58,7 @@ } if(strhead(s,"image=") == 0) { s+=6; + set_kernel_name: kernel_name=s; } else if(strhead(s,"initrd=") == 0) { @@ -116,8 +117,8 @@ strcatb(_cmdline,*argv); } else if(i == 1 && fileattr(s) != -1) { - kernel_name = s; cmdline = (const char *) _cmdline; + goto set_kernel_name; } else break; diff -r 9facff0f7d4e -r 6f494adb2c71 linld/stuff/src/LOAD.CPP --- a/linld/stuff/src/LOAD.CPP Sat Mar 04 22:10:01 2017 +0100 +++ b/linld/stuff/src/LOAD.CPP Sun Mar 05 13:22:08 2017 +0100 @@ -155,7 +155,7 @@ if(kernelparams->setup_sects == 0) { #if 1 if(* (int *) &first1k->pad10[0x3F-0x24] == 0x3AE8) { - lseekset(pm.fd,rm_seek=0x200); + seekset(pm.fd,rm_seek=0x200); csip+=0xFFE00042; } else diff -r 9facff0f7d4e -r 6f494adb2c71 linld/stuff/src/TAZBOOT.CPP --- a/linld/stuff/src/TAZBOOT.CPP Sat Mar 04 22:10:01 2017 +0100 +++ b/linld/stuff/src/TAZBOOT.CPP Sun Mar 05 13:22:08 2017 +0100 @@ -7,20 +7,23 @@ #include "common.h" #include "iso9660.h" +struct initrd_info { + u32 ofs; + u32 size; +}; #define MAXINITRD 10 static struct initrd_state { - u32 ofs[MAXINITRD]; - u32 size[MAXINITRD]; + struct initrd_info info[MAXINITRD]; u16 cnt; } initrd_state; static void next_chunk(struct image_himem *m) { - struct initrd_state *p = &initrd_state; + struct initrd_info *i = &initrd_state.info[m->state]; m->chunk_size = 0; - if (m->state >= p->cnt) return; - lseekset(m->fd,p->ofs[m->state]); - m->chunk_size = p->size[m->state]; + if (m->state >= initrd_state.cnt) return; + lseekset(m->fd,i->ofs); + m->chunk_size = i->size; m->state++; } @@ -31,11 +34,12 @@ static void addinitrd() { - struct initrd_state *p = &initrd_state; - if (p->cnt >= MAXINITRD) return; - p->size[p->cnt] = isofilesize; - p->ofs[p->cnt] = isofileofs; - p->cnt++; + u16 *pcnt = &initrd_state.cnt; + struct initrd_info *i = &initrd_state.info[*pcnt]; + if (*pcnt >= MAXINITRD) return; + ++*pcnt; + i->size = isofilesize; + i->ofs = isofileofs; initrd.size += isofilesize4round(); } @@ -58,13 +62,14 @@ return load_kernel(); } -char _cmdline[256]; -const char *cmdline = (const char *) _cmdline; +char _cmdline[4096]; +const char *cmdline = (const char *) _cmdline+1; static void bootiso(char **iso) { - char *init = " rdinit=/init.exe", *mode="menu"; - char c, rootfs[16], fallback[16]; - int restart, isknoppix = 0; + const char *init = " rdinit=/init.exe", *mode="menu"; + char c; + static char rootfs[16], fallback[16], isknoppix, noauto; + int restart; unsigned long magic; struct isostate *x=&isostate; @@ -78,15 +83,14 @@ if (iso[1] && !strcmp(mode = iso[1], "text")) init = ""; do { - if (isoopen(mode) >= 0 || // custom - isoopen("bzImage") >= 0 || // SliTaz - isoopen("vmlinuz") >= 0 || // misc + if ((isoopen(mode) >= 0 && ++noauto) || // custom + isoopen("bzImage") >= 0 || // SliTaz + isoopen("vmlinuz") >= 0 || // misc (isoopen("linux") >= 0 && ++isknoppix)) { magic = kver2ul(isokernel()); break; } } while (isoopen("isolinux") >= 0); // Knoppix - fallback[0] = 0; for (c = 0, restart = 1; isoreaddir(restart) == 0; restart = 0) { if (strstr(x->filename, ".gz")) strcpy(fallback, x->filename); @@ -96,13 +100,25 @@ c = x->filename[6]; } - strcpy(_cmdline,"rw root=/dev/null autologin bootfrom="); + strcatb(_cmdline,"rw root=/dev/null autologin bootfrom="); strcat(_cmdline,*iso); if (magic < 0x20630) init = ""; // Does not support multiple initramfs - if (magic > 0) { + if (noauto) { + char *s; + * (int *) _cmdline = 0; + iso++; + while ((s = *++iso) != NULL) { + if (strhead(s,"initrd=")) + strcatb(_cmdline,s); + else if (isoopen(s+7) >= 0) + addinitrd(); + } + } + else if (magic > 0) { char *initrd = fallback; + static const unsigned long initrddesc = 20L; if (rootfs[0]) { initrd = rootfs; @@ -112,27 +128,25 @@ if (isoopen(initrd) >= 0) { addinitrd(); } - if (*init && isolseek(20L) != -1) { - read(x->fd, &x->fileofs, 4); - read(x->fd, &magic, 4); + if (*init && isolseek(&initrddesc) != -1) { + read(x->fd, &x->fileofs, 8); // and x->filesize x->fileofs &= 0xFFFFL; - x->filesize = magic & 0xFFFFL; - x->fileofs -= 0xC0L + x->filesize; - if (x->filesize) addinitrd(); + x->fileofs -= 0xC0L + (x->filesize &= 0xFFFF); + if (((short *) &x->fileofs)[1] == 0) addinitrd(); else init=""; } - load_initrds(); strcat(_cmdline,init); strcatb(_cmdline,"mode="); strcat(_cmdline,mode); strcatb(_cmdline,"magic="); strcat(_cmdline,ultoa(magic)); } + load_initrds(); if (isknoppix) { - char *s; - if (iso[0][1] == ':') - *iso += 2; - for (s = *iso; *s; s++) + char *s = *iso; + if (s[1] == ':') + s += 2; + for (; *s; s++) if (*s == '\\') *s = '/'; } close(x->fd); @@ -172,12 +186,12 @@ i++; if (!s) break; if (strhead(s,"kernel=") == 0) { - s += 7; + s++; set_kernel: + s += 6; kernel_name = s; } else if (strhead(s,"image=") == 0) { - s += 6; goto set_kernel; } else if (strhead(s,"initrd=") == 0) { diff -r 9facff0f7d4e -r 6f494adb2c71 linld/stuff/src/VCPI.ASM --- a/linld/stuff/src/VCPI.ASM Sat Mar 04 22:10:01 2017 +0100 +++ b/linld/stuff/src/VCPI.ASM Sun Mar 05 13:22:08 2017 +0100 @@ -411,9 +411,11 @@ global _vm2rm:near proc _vm2rm near + p8086 extrn _vcpi:byte test [_vcpi],-1 jz @@ret + p386 push si ;;pushf ;;pushad diff -r 9facff0f7d4e -r 6f494adb2c71 linld/stuff/src/_BEG.ASM --- a/linld/stuff/src/_BEG.ASM Sat Mar 04 22:10:01 2017 +0100 +++ b/linld/stuff/src/_BEG.ASM Sun Mar 05 13:22:08 2017 +0100 @@ -12,6 +12,10 @@ segment _TEXT byte public use16 'CODE' + macro cpuid + db 0fh,0A2h + endm + org 100h global _text_start:byte label _text_start byte @@ -46,6 +50,25 @@ js endcpu endif p386 + ifdef EXTRA + pushfd + pop dx + pop ax + mov bl,al + xor al,20h ; toggle CPUID feature bit 21 + push ax + push dx + popfd + pushfd + pop dx + pop ax + xor al,bl ; clear C + je @@check_vm ; CPUID feature bit changed ? + mov eax,80000001h ; Extended Processor Info and Feature Bits + cpuid + mov [_cpu_features],edx +@@check_vm: + endif ; Check for vm smsw ax ;SMSW cannot be trapped! :-) and al,1 ;MSW_PE @@ -58,15 +81,18 @@ label check_vcpi near push ds ; Check whether it is safe to call 67h (we trust only known EMM managers) - push 0 + xor bx,bx + push bx pop ds mov ds,[word 67h*4+2] - cmp [dword 10+4],'0XXX' + cmp [dword bx+10+4],'0XXX' jne skip - mov eax,'XMME' - xor eax,[dword 10] + ;mov eax,'XMME' + ;xor eax,[dword bx+10] ; QMME also works (as told by ) - shl eax,8 + ;shl eax,8 + mov ax,'ME' + xor ax,[word bx+10] skip: pop ds jne no_vcpi @@ -222,6 +248,10 @@ segment _BSS byte public use16 'BSS' global _bss_start:byte label _bss_start byte + ifdef EXTRA + global _cpu_features:dword +_cpu_features dd ? + endif ends _BSS end _text_start