wok-current rev 19580
linld: add -b switch
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Dec 24 19:16:59 2016 +0100 (2016-12-24) |
parents | baa9bcac7edd |
children | d72895864c7a |
files | linld/stuff/linld.txt linld/stuff/src/A20.ASM linld/stuff/src/COMMON.H linld/stuff/src/CRTL.ASM linld/stuff/src/HIMEM.CPP linld/stuff/src/LINLD.CPP linld/stuff/src/LOAD.CPP linld/stuff/src/TAZBOOT.CPP linld/stuff/src/VCPI.ASM |
line diff
1.1 --- a/linld/stuff/linld.txt Sat Dec 24 14:13:20 2016 +0100 1.2 +++ b/linld/stuff/linld.txt Sat Dec 24 19:16:59 2016 +0100 1.3 @@ -40,3 +40,17 @@ 1.4 Some VCPI comments added 1.5 0.96 Do not lowercase entire command line 1.6 0.97 memtop() must be rounded down to page boundary 1.7 + 1.8 +SliTaz patches 1.9 +-------------- 1.10 +New command line arguments: 1.11 +-f force. Do not ask memory manager for allocation 1.12 +-b base lower buffer address, default 1088k 1.13 +root number root filesystem device 1.14 +mem number higher memory address, default 256m 1.15 + 1.16 +Every arguments can be stored in a separate file and load with @filename, i.e 1.17 +> linld @args.cmd 1.18 + 1.19 +The -f and -b are useful skip XMM (max 64M ?) and VCPI (max 32M ?) limits: 1.20 +> linld -f -b 64m initrd=rootfs4.gz,rootfs3.gz,rootfs2.gz,rootfs1.gz "cl=rw root=/dev/null video=-32"
2.1 --- a/linld/stuff/src/A20.ASM Sat Dec 24 14:13:20 2016 +0100 2.2 +++ b/linld/stuff/src/A20.ASM Sat Dec 24 19:16:59 2016 +0100 2.3 @@ -15,7 +15,7 @@ 2.4 global die:near 2.5 enable_a20_methods: 2.6 dw _enable_a20_fast, _enable_a20_kbd, _enable_a20_xmm, die 2.7 -msg_a20 db "Can't enable A20",0 2.8 +msg_a20 db "Can't use A20",0 2.9 2.10 ends _DATA 2.11 2.12 @@ -51,16 +51,14 @@ 2.13 xor cx,cx ; 64K iterations 2.14 @@loop: 2.15 call @@delay ; 8042 status port 2.16 - in al,64h ; output buffer? 2.17 + in al,64h 2.18 + test al,3 ; is output or input full? 2.19 + jz @@break ; no - break loop 2.20 test al,1 ; 2.21 jz @@no_output 2.22 call @@delay ; yes: read it 2.23 in al,60h ; 2.24 - jmp @@cont ; 2.25 @@no_output: 2.26 - test al,2 ; is input buffer full? 2.27 - jz @@break ; no - break loop 2.28 -@@cont: 2.29 loop @@loop 2.30 @@break: 2.31 ret 2.32 @@ -86,9 +84,24 @@ 2.33 endp _enable_a20_fast 2.34 2.35 ;*************************************************************** 2.36 +;void enable_a20_or_die(); 2.37 +;*************************************************************** 2.38 + global _enable_a20_or_die:near 2.39 + proc _enable_a20_or_die near 2.40 + 2.41 + push si 2.42 + mov si,offset enable_a20_methods 2.43 + jmp @@check 2.44 +@@loop: 2.45 + lodsw 2.46 + mov bx,offset msg_a20 2.47 + call ax 2.48 +@@check: 2.49 + ;call _check_a20 2.50 +;*************************************************************** 2.51 ;int check_a20(); 2.52 ;*************************************************************** 2.53 - proc _check_a20 near 2.54 + ;proc _check_a20 near 2.55 2.56 ; From linux kernel setup.S: 2.57 ; wait until a20 really *is* enabled; it can take a fair amount of 2.58 @@ -113,25 +126,10 @@ 2.59 loopne a20lp 2.60 xchg ax,cx 2.61 pop es ds 2.62 - ret 2.63 + ;ret 2.64 2.65 - endp _check_a20 2.66 + ;endp _check_a20 2.67 2.68 -;*************************************************************** 2.69 -;void enable_a20_or_die(); 2.70 -;*************************************************************** 2.71 - global _enable_a20_or_die:near 2.72 - proc _enable_a20_or_die near 2.73 - 2.74 - push si 2.75 - mov si,offset enable_a20_methods 2.76 - jmp @@check 2.77 -@@loop: 2.78 - lodsw 2.79 - mov bx,offset msg_a20 2.80 - call ax 2.81 -@@check: 2.82 - call _check_a20 2.83 jne @@loop 2.84 pop si 2.85 ret
3.1 --- a/linld/stuff/src/COMMON.H Sat Dec 24 14:13:20 2016 +0100 3.2 +++ b/linld/stuff/src/COMMON.H Sat Dec 24 19:16:59 2016 +0100 3.3 @@ -22,6 +22,8 @@ 3.4 const u16 _32k = 32*1024u; 3.5 const u32 _64k = 64*1024ul; 3.6 const u32 _1m = 1024ul*1024ul; 3.7 +const u32 _32m = 32*1024ul*1024ul; 3.8 +const u32 _64m = 64*1024ul*1024ul; 3.9 3.10 const PAGE_BITS = 12; 3.11 const PAGE_SIZE = 1<<PAGE_BITS; 3.12 @@ -49,6 +51,9 @@ 3.13 u16 fd2close; 3.14 } pm, initrd; 3.15 3.16 +extern int skip_alloc; 3.17 +extern u32 base_himem; 3.18 + 3.19 extern "C" void memcpy_image(struct image_himem *m); 3.20 extern "C" void storepage(u32 *dst, u16 src); 3.21 #ifdef LARGE_IMAGES
4.1 --- a/linld/stuff/src/CRTL.ASM Sat Dec 24 14:13:20 2016 +0100 4.2 +++ b/linld/stuff/src/CRTL.ASM Sat Dec 24 19:16:59 2016 +0100 4.3 @@ -38,11 +38,16 @@ 4.4 4.5 ;*************************************************************** 4.6 ;char* strcpy(const char* a, const char* b); 4.7 +;char* strcat(const char* a, const char* b); 4.8 ;*************************************************************** 4.9 global _strcpy:near 4.10 proc _strcpy near 4.11 4.12 mov dl,0 4.13 + db 0bbh ; mov bx,imm opcode 4.14 + global _strcat:near 4.15 +_strcat: 4.16 + mov dl,1 4.17 cat: 4.18 pop ax ;caller return address 4.19 pop cx ; a 4.20 @@ -81,19 +86,7 @@ 4.21 4.22 4.23 ;*************************************************************** 4.24 -;char* strcat(const char* a,const char* b); 4.25 -;*************************************************************** 4.26 - global _strcat:near 4.27 - proc _strcat near 4.28 - 4.29 - mov dl,1 4.30 - jmp cat 4.31 - 4.32 - endp _strcat 4.33 - 4.34 - 4.35 -;*************************************************************** 4.36 -;char* strcatb(const char* a,const char* b); 4.37 +;char* strcatb(const char* a, const char* b); 4.38 ;*************************************************************** 4.39 global _strcatb:near 4.40 proc _strcatb near 4.41 @@ -244,51 +237,33 @@ 4.42 4.43 ;*************************************************************** 4.44 ;int read(int fd, void* data, int sz); 4.45 +;int write(int fd, const void* data, int sz); 4.46 ;*************************************************************** 4.47 global _read:near 4.48 proc _read near 4.49 4.50 - mov ah,3fh 4.51 -rwio: 4.52 - ifndef NO386 4.53 - pop dx ;caller return address 4.54 - pop ebx ; fd & data 4.55 + stc 4.56 + db 73h ; jnc 4.57 + global _write:near 4.58 + clc 4.59 + pop ax ;caller return address 4.60 + pop bx ; fd 4.61 + pop dx ; data 4.62 pop cx ; sz 4.63 push cx 4.64 - push ebx 4.65 push dx 4.66 - else 4.67 - mov bx,sp 4.68 - mov cx,[bx+6] 4.69 - mov dx,[bx+4] 4.70 - mov bx,[bx+2] 4.71 - endif 4.72 + push bx 4.73 + push ax 4.74 + mov ah,40h 4.75 + sbb ah,0 4.76 clc 4.77 jcxz fail 4.78 -rwioz: 4.79 - ifndef NO386 4.80 - push ebx 4.81 - pop bx 4.82 - pop dx 4.83 - endif 4.84 jmp dos 4.85 4.86 endp _read 4.87 4.88 4.89 ;*************************************************************** 4.90 -;int write(int fd, const void* data, int sz); 4.91 -;*************************************************************** 4.92 - global _write:near 4.93 - proc _write near 4.94 - 4.95 - mov ah,40h 4.96 - jmp rwio 4.97 - 4.98 - endp _write 4.99 - 4.100 - 4.101 -;*************************************************************** 4.102 ;long lseekset(int fd, long sz); 4.103 ;*************************************************************** 4.104 global _lseekset:near
5.1 --- a/linld/stuff/src/HIMEM.CPP Sat Dec 24 14:13:20 2016 +0100 5.2 +++ b/linld/stuff/src/HIMEM.CPP Sat Dec 24 19:16:59 2016 +0100 5.3 @@ -8,6 +8,7 @@ 5.4 5.5 struct image_himem pm; 5.6 struct image_himem initrd; 5.7 +int skip_alloc; 5.8 5.9 // Called from inside kernel just before rm->pm 5.10 // _loadds _saveregs: done by hand 5.11 @@ -29,14 +30,14 @@ 5.12 #endif 5.13 } 5.14 struct image_himem *m = ± 5.15 + vm2rm(); 5.16 if(((u16 *)&m->fallback)[1] >= 0x10) m->fallback = _1m; // >= _1m ? 5.17 - if(vcpi==0) { 5.18 + if(m->bufv==0) { 5.19 // Move kernel 5.20 memcpy_image(m); 5.21 // Move initrd 5.22 memcpy_image(&initrd); 5.23 } else { //vcpi 5.24 - vm2rm(); 5.25 // Move kernel 5.26 // 'Gathering' copy in chunks of PAGE_SIZE 5.27 // No risk of overlapping: kernel is copied from above to 1m mark 5.28 @@ -81,18 +82,17 @@ 5.29 } 5.30 } 5.31 5.32 -int skip_xmmalloc; 5.33 void load_image(struct image_himem *m) { 5.34 no_exit++; // die() won't return to DOS 5.35 m->remaining = m->size; 5.36 m->buf = m->fallback; 5.37 u32 buf; 5.38 u32* bufv= &buf; 5.39 - if(((u16 *)&m->fallback)[1] >= 0x10) { // >= _1m ? 5.40 + if(((u16 *)&m->fallback)[1] >= 0x10 && !skip_alloc) { // >= _1m ? 5.41 if(vcpi) { 5.42 bufv = malloc_bufv_or_die(m); // update m->bufv 5.43 } 5.44 - else if (!skip_xmmalloc) { 5.45 + else { 5.46 xmm_alloc(m); // update m->buf 5.47 } 5.48 }
6.1 --- a/linld/stuff/src/LINLD.CPP Sat Dec 24 14:13:20 2016 +0100 6.2 +++ b/linld/stuff/src/LINLD.CPP Sat Dec 24 19:16:59 2016 +0100 6.3 @@ -24,11 +24,12 @@ 6.4 "\tinitrd,vga,root=(void)" NL 6.5 "\tmem=256m" NL 6.6 "\tcl=auto" NL 6.7 + "\t-b 1088k" NL 6.8 "Use quotes: \"cl=...\" if you need spaces in cmdline" NL 6.9 "Use cl=@filename to get it from a file" 6.10 #if 1 6.11 NL NL "Examples:" NL 6.12 - "\tlinld initrd=rootfs4.gz,rootfs3.gz,rootfs2.gz,rootfs1.gz \"cl=rw root=/dev/null video=-32\"" 6.13 + "\tlinld -f -b 64m initrd=rootfs4.gz,rootfs3.gz,rootfs2.gz,rootfs1.gz \"cl=rw root=/dev/null video=-32\"" 6.14 NL NL "\tlinld image=memtest" 6.15 #endif 6.16 ); 6.17 @@ -46,6 +47,7 @@ 6.18 // Parse command line 6.19 if (argv[1]) {for (char i=0;;) { 6.20 char *s; 6.21 + next: 6.22 argv++; 6.23 s=*argv; 6.24 i++; 6.25 @@ -62,15 +64,20 @@ 6.26 s+=7; 6.27 initrd_name=s; 6.28 } 6.29 - else if((*(u16 *)s|0x2002) == 0x662F) { // -F /f 6.30 - extern int skip_xmmalloc; 6.31 - skip_xmmalloc++; 6.32 - } 6.33 else if(strhead(s,"vga=") == 0) { 6.34 s+=4; 6.35 vid_mode = strtol(s); // support normal, extended & ask 6.36 } 6.37 - else if(strhead(s,"cl=") == 0) { 6.38 + else switch (*(u16 *)s|0x2002) { 6.39 + case 0x662F: // -F /f 6.40 + skip_alloc++; 6.41 + goto next; 6.42 + case 0x622F: // -B /b 6.43 + argv++; 6.44 + base_himem = strtol(*argv); 6.45 + goto next; 6.46 + default: 6.47 + if(strhead(s,"cl=") == 0) { 6.48 cmdline=s+=3; 6.49 if (*s == '@') { 6.50 static struct image_himem image; 6.51 @@ -114,6 +121,7 @@ 6.52 } 6.53 else 6.54 break; 6.55 + } 6.56 }} 6.57 syntax(); 6.58
7.1 --- a/linld/stuff/src/LOAD.CPP Sat Dec 24 14:13:20 2016 +0100 7.2 +++ b/linld/stuff/src/LOAD.CPP Sat Dec 24 19:16:59 2016 +0100 7.3 @@ -113,6 +113,7 @@ 7.4 u8* rm_buf; 7.5 u16 rm_size; 7.6 u8 pm_high; 7.7 +u32 base_himem = _1m+_64k; 7.8 extern struct image_himem pm, initrd; 7.9 7.10 // register value to launch the kernel real mode code 7.11 @@ -232,7 +233,7 @@ 7.12 m->size -= rm_size; 7.13 m->chunk_size -= rm_size; 7.14 if(m->fallback+m->size > (((u32)topseg())<<4) || pm_high) { 7.15 - m->fallback = _1m+_64k; 7.16 + m->fallback = base_himem; 7.17 } 7.18 7.19 load_image(m);
8.1 --- a/linld/stuff/src/TAZBOOT.CPP Sat Dec 24 14:13:20 2016 +0100 8.2 +++ b/linld/stuff/src/TAZBOOT.CPP Sat Dec 24 19:16:59 2016 +0100 8.3 @@ -59,7 +59,6 @@ 8.4 8.5 char _cmdline[256]; 8.6 const char *cmdline = (const char *) _cmdline; 8.7 -extern int skip_xmmalloc; 8.8 static void bootiso(char **iso) 8.9 { 8.10 char *init = " rdinit=/init.exe", *mode="menu"; 8.11 @@ -69,7 +68,9 @@ 8.12 struct isostate *x=&isostate; 8.13 8.14 if (!*iso || isoreset(*iso) < 0) return; 8.15 - skip_xmmalloc++; 8.16 + skip_alloc++; 8.17 + base_himem = memtop() /2; 8.18 + if (base_himem > _64m) base_himem = _64m; 8.19 isoopen("boot") >= 0 || 8.20 isoopen("live") >= 0 || // debian 8.21 isoopen("casper") >= 0; // ubuntu 8.22 @@ -150,7 +151,7 @@ 8.23 if (argc < 2) { 8.24 try_default_args(); 8.25 dousage: 8.26 - die("Usage: tazboot [[@commands]|[-f][kernel=<bzimage>] \ 8.27 + die("Usage: tazboot [[@commands]|[-f][-b base_himem][kernel=<bzimage>] \ 8.28 [initrd=<rootfs>[,<rootfs2>...]] [bootfrom=<isofile>] ...]\r\n\n\ 8.29 Defaults: tazboot kernel=bzImage auto\r\n\n\ 8.30 Examples for tazboot.cmd:\r\n\n\ 8.31 @@ -165,7 +166,7 @@ 8.32 chdirname(*argv); 8.33 for (int i=0;;) { 8.34 char *s; 8.35 - argv++; 8.36 + next: argv++; 8.37 s=*argv; 8.38 i++; 8.39 if (!s) break; 8.40 @@ -195,10 +196,20 @@ 8.41 s += 4; 8.42 vid_mode = strtol(s); // support normal, extended & ask 8.43 } 8.44 - else if((*(u16 *)s|0x2002) == 0x662F) { // -F /f 8.45 - skip_xmmalloc++; 8.46 - } 8.47 - else if(i == 1 && fileattr(s) != -1) { 8.48 + else switch (*(u16 *)s|0x2002) { 8.49 + case 0x662F: // -F /f 8.50 + skip_alloc++; 8.51 + goto next; 8.52 + case 0x652F: // -E /e 8.53 + argv++; 8.54 + topmem = strtol(*argv); 8.55 + goto next; 8.56 + case 0x622F: // -B /b 8.57 + argv++; 8.58 + base_himem = strtol(*argv); 8.59 + goto next; 8.60 + default: 8.61 + if(i == 1 && fileattr(s) != -1) { 8.62 goto set_kernel; 8.63 } 8.64 else { 8.65 @@ -211,7 +222,7 @@ 8.66 topmem = strtol(s); 8.67 } 8.68 strcatb(_cmdline,*argv); 8.69 - } 8.70 + }} 8.71 } 8.72 if (iso && isoreset(iso) >= 0) { 8.73 char *s = (char *) initrd_name;
9.1 --- a/linld/stuff/src/VCPI.ASM Sat Dec 24 14:13:20 2016 +0100 9.2 +++ b/linld/stuff/src/VCPI.ASM Sat Dec 24 19:16:59 2016 +0100 9.3 @@ -407,6 +407,9 @@ 9.4 global _vm2rm:near 9.5 proc _vm2rm near 9.6 9.7 + extrn _vcpi:byte 9.8 + test [_vcpi],-1 9.9 + jz @@ret 9.10 push esi 9.11 ;;pushf 9.12 ;;cli 9.13 @@ -452,6 +455,7 @@ 9.14 ;;popad 9.15 ;;popf 9.16 pop esi 9.17 +@@ret: 9.18 ret ; We don't care much about rest (FS/GS) 9.19 9.20 endp _vm2rm