wok rev 20632
linld: 32 bits lseeks for tazboot
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Jan 05 17:23:23 2019 +0100 (2019-01-05) |
parents | 15167372e6fe |
children | 251d56fab8e3 |
files | linld/stuff/src/CRTL.ASM linld/stuff/src/CRTL.H linld/stuff/src/CRTLX.H linld/stuff/src/HIMEM.CPP linld/stuff/src/ISO9660.CPP linld/stuff/src/LINLD.CPP linld/stuff/src/LOAD.CPP linld/stuff/src/TAZBOOT.CPP linld/stuff/src/pipehole.awk |
line diff
1.1 --- a/linld/stuff/src/CRTL.ASM Fri Jan 04 04:54:43 2019 -0500 1.2 +++ b/linld/stuff/src/CRTL.ASM Sat Jan 05 17:23:23 2019 +0100 1.3 @@ -180,19 +180,6 @@ 1.4 endp @puts$qpxzc 1.5 1.6 1.7 -;*************************************************************** 1.8 -;_fastcall int fileattr(bx:const char* name); 1.9 -;*************************************************************** 1.10 - global @fileattr$qpxzc:near 1.11 - proc @fileattr$qpxzc near 1.12 - 1.13 - mov ax,4300h 1.14 - call dos_filename 1.15 - xchg ax,cx 1.16 - jmp chkc 1.17 - 1.18 - endp @fileattr$qpxzc 1.19 - 1.20 1.21 ;*************************************************************** 1.22 ;_fastcall int open(bx:const char* name, int flags=O_RDONLY); 1.23 @@ -211,19 +198,18 @@ 1.24 open: 1.25 ifdef LONG_FILENAME 1.26 mov ax,716Ch 1.27 - push bx si di 1.28 - mov di,di ; alias hint 1.29 + push bx di si 1.30 mov si,bx 1.31 xor bx,bx ; R/O 1.32 xor cx,cx ; attributes 1.33 + xor di,di ; alias hint 1.34 cwd ; action = open 1.35 int 21h 1.36 - pop di si bx 1.37 + pop si di bx 1.38 jnc doret 1.39 endif 1.40 mov ax,3d00h ; read-only+compatibility 1.41 ;mov cl,0 ; attribute mask 1.42 -dos_filename: 1.43 mov dx,bx 1.44 dos: 1.45 int 21h 1.46 @@ -244,6 +230,14 @@ 1.47 1.48 1.49 ;*************************************************************** 1.50 +;_fastcall int fileexist(bx:const char* name); 1.51 +;*************************************************************** 1.52 + global @fileexist$qpxzc:near 1.53 +@fileexist$qpxzc: 1.54 + call @open$qpxzc 1.55 + jc fail 1.56 + 1.57 +;*************************************************************** 1.58 ;_fastcall int close(ax:int fd); 1.59 ;*************************************************************** 1.60 global @close$qi:near 1.61 @@ -274,6 +268,7 @@ 1.62 @write$qipvi: 1.63 clc 1.64 endif 1.65 +@read$dxbxax: 1.66 xchg ax,bx ; fd 1.67 xchg ax,dx ; data 1.68 xchg ax,cx ; sz 1.69 @@ -291,36 +286,25 @@ 1.70 endp @read$qipvi 1.71 1.72 ;*************************************************************** 1.73 -;_fastcall long lseekset(ax:int fd, dx:unsigned whence); 1.74 ;_fastcall long lseekcur(ax:int fd, dx:int whence); 1.75 ;*************************************************************** 1.76 1.77 global @lseekcur$qii:near ; fd=ax whence=dx 1.78 proc @lseekcur$qii near 1.79 1.80 + mov cl,1 1.81 xchg ax,bx 1.82 xchg ax,dx 1.83 cwd 1.84 xchg ax,dx 1.85 xchg ax,cx 1.86 - mov al,1 1.87 jmp lseek 1.88 - ifdef EXTRA 1.89 - global @lseekset$qiui:near 1.90 -@lseekset$qiui: 1.91 - mov bl,0 1.92 - jmp lseek0x 1.93 -lseekset: 1.94 - mov bl,0 1.95 - jmp lseekx 1.96 - endif 1.97 rewind: ; rewind(ax) 1.98 mov bl,0 1.99 -lseek0: ; lseek0(bx,ax=dir) 1.100 +lseek0: ; lseek0(ax,bl=dir) 1.101 xor dx,dx 1.102 -lseek0x: 1.103 xor cx,cx 1.104 -lseekx: 1.105 +lseekset: 1.106 xchg ax,bx 1.107 lseek: 1.108 mov ah,42h ; bx=fd cx:dx=offset al=whence 1.109 @@ -346,15 +330,19 @@ 1.110 ends ; } isostate; 1.111 ;*************************************************************** 1.112 ;_fastcall long isolseek(bx:const unsigned long *offset); 1.113 +;_fastcall long lseekset2(ax:int fd, bx:unsigned long* whence); 1.114 ;*************************************************************** 1.115 global @isolseek$qpxul:near 1.116 proc @isolseek$qpxul near 1.117 1.118 isolseek: 1.119 + extrn _isostate:isostate 1.120 + mov ax,[_isostate.fd] 1.121 + global @lseekset2$qipul 1.122 +@lseekset2$qipul: 1.123 mov dx,[bx] 1.124 mov cx,[bx+2] 1.125 - extrn _isostate:isostate 1.126 - mov ax,[_isostate.fd] 1.127 + mov bl,0 1.128 jmp lseekset 1.129 1.130 endp @isolseek$qpxul 1.131 @@ -366,17 +354,11 @@ 1.132 proc @isoreadsector$qpxul near 1.133 1.134 call isolseek 1.135 - and ax,dx 1.136 - inc ax 1.137 - jz @@fail 1.138 - mov cx,2560 1.139 - mov dx,offset _isostate.buffer 1.140 - mov bx,[_isostate.fd] 1.141 - call @read$cxdxbx ; read(fd,buffer,2560) 1.142 -@@fail: 1.143 - cmp ax,2048 1.144 - sbb ax,ax 1.145 - ret 1.146 + jc doret 1.147 + mov dx,2560 1.148 + mov bx,offset _isostate.buffer 1.149 + mov ax,[_isostate.fd] 1.150 + jmp @read$dxbxax ; read(fd,buffer,2560) 1.151 1.152 endp @isoreadsector$qpxul 1.153
2.1 --- a/linld/stuff/src/CRTL.H Fri Jan 04 04:54:43 2019 -0500 2.2 +++ b/linld/stuff/src/CRTL.H Sat Jan 05 17:23:23 2019 +0100 2.3 @@ -10,14 +10,6 @@ 2.4 const unsigned MIN_STACK = 0x400; 2.5 const unsigned MAX_MALLOC = 0xF000; 2.6 2.7 -const char A_RDONLY = 1; // for fileattr() 2.8 -const char A_HIDDEN = 2; 2.9 -const char A_SYSTEM = 4; 2.10 -const char A_LABEL = 8; 2.11 -const char A_DIRECTORY = 16; 2.12 -const char A_ARCHIVE = 32; 2.13 - 2.14 - 2.15 const char O_RDONLY = 0; // for open() 2.16 const char O_BINARY = 0; 2.17 2.18 @@ -30,7 +22,7 @@ 2.19 void parse_cmdline(); 2.20 extern _fastcall void strcatb(const char* a,const char* b); 2.21 extern _fastcall int strhead(const char* a,const char* head); 2.22 -extern _fastcall int fileattr(const char* name); 2.23 +extern _fastcall int fileexist(const char* name); 2.24 //extern "C" int open(const char* name, int flags); 2.25 extern _fastcall int open(const char* name); 2.26 extern _fastcall int close(int fd);
3.1 --- a/linld/stuff/src/CRTLX.H Fri Jan 04 04:54:43 2019 -0500 3.2 +++ b/linld/stuff/src/CRTLX.H Sat Jan 05 17:23:23 2019 +0100 3.3 @@ -1,6 +1,6 @@ 3.4 // This file is distributed under GPL 3.5 // 3.6 -extern _fastcall long lseekset(int fd, unsigned whence); 3.7 +extern _fastcall long lseekset2(int fd, unsigned long* whence); 3.8 extern _fastcall void strcpy(const char* a,const char* b); 3.9 extern _fastcall void strcat(const char* a,const char* b); 3.10 extern _fastcall int strcmp(const char* a,const char* b);
4.1 --- a/linld/stuff/src/HIMEM.CPP Fri Jan 04 04:54:43 2019 -0500 4.2 +++ b/linld/stuff/src/HIMEM.CPP Sat Jan 05 17:23:23 2019 +0100 4.3 @@ -6,7 +6,6 @@ 4.4 #include "crtl.h" 4.5 #include "common.h" 4.6 4.7 -struct image_himem imgs[2]; 4.8 int skip_alloc; 4.9 4.10 void load_image(struct image_himem *m) {
5.1 --- a/linld/stuff/src/ISO9660.CPP Fri Jan 04 04:54:43 2019 -0500 5.2 +++ b/linld/stuff/src/ISO9660.CPP Sat Jan 05 17:23:23 2019 +0100 5.3 @@ -17,8 +17,8 @@ 5.4 //close(x->fd); 5.5 return -1; 5.6 } 5.7 - x->dirofs = (* (unsigned long *) (x->buffer + 0x9E)) << SECTORBITS; 5.8 - x->dirsize = filesize2dirsize(* (unsigned long *) (x->buffer + 0xA6)); 5.9 + x->dirofs = (* (unsigned long *) (isostate.buffer + 0x9E)) << SECTORBITS; 5.10 + x->dirsize = filesize2dirsize(* (unsigned long *) (isostate.buffer + 0xA6)); 5.11 return 0; 5.12 } 5.13
6.1 --- a/linld/stuff/src/LINLD.CPP Fri Jan 04 04:54:43 2019 -0500 6.2 +++ b/linld/stuff/src/LINLD.CPP Sat Jan 05 17:23:23 2019 +0100 6.3 @@ -117,7 +117,7 @@ 6.4 addincmdline: 6.5 strcatb(buf_cmdline,*argv); 6.6 } 6.7 - else if(i == 1 && fileattr(s) != -1) { 6.8 + else if(i == 1 && fileexist(s) != -1) { 6.9 cmdline = (const char *) buf_cmdline + 1; 6.10 goto set_kernel_name; 6.11 }
7.1 --- a/linld/stuff/src/LOAD.CPP Fri Jan 04 04:54:43 2019 -0500 7.2 +++ b/linld/stuff/src/LOAD.CPP Sat Jan 05 17:23:23 2019 +0100 7.3 @@ -115,6 +115,7 @@ 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 u32 base_himem = _1m+_64k; 7.7 +struct image_himem imgs[2]; 7.8 7.9 // register value to launch the kernel real mode code 7.10 #ifdef NO386 7.11 @@ -129,8 +130,15 @@ 7.12 char* load_kernel() { 7.13 7.14 struct image_himem *m = ± 7.15 +#define _base_himem (((u32*)(m))[-1]) 7.16 +#define _rm_buf(m) (((u8**)(m))[-3]) 7.17 +#define _pm_high (((u8*)(m))[-7]) 7.18 +#define _rm_size (*(u16*)((u8*)(m)-9)) 7.19 #ifdef NO386 7.20 +#define _csip (*(u32*)(m+2)) 7.21 *((u16 *)&csip+1)=topseg()+0x20; 7.22 +#else 7.23 +#define _csip csip 7.24 #endif 7.25 // Open kernel, read first kb, check it 7.26 m->errmsg = kernel_file_error; 7.27 @@ -139,7 +147,7 @@ 7.28 char *version_string; 7.29 { 7.30 struct kernelparams_t *kernelparams; 7.31 - kernelparams = &(((first1k_t*) (rm_buf = (u8 *)malloc_or_die(_32k)))->params); 7.32 + kernelparams = &(((first1k_t*) (_rm_buf(m) = (u8 *)malloc_or_die(_32k)))->params); 7.33 #define first1k ((first1k_t*)((u8 *)kernelparams-0x1F1)) 7.34 7.35 do { 7.36 @@ -150,7 +158,7 @@ 7.37 if(kernelparams->setup_sects == 0) { 7.38 #if 1 7.39 if(* (int *) &first1k->pad10[0x3F-0x24] == 0x3AE8) { 7.40 - csip+=0xFFE00042; 7.41 + _csip+=0xFFE00042; 7.42 } 7.43 else 7.44 #endif 7.45 @@ -159,12 +167,12 @@ 7.46 if((kernelparams->setup_sects)>=(_32k/512) || // 0th sector not counted 7.47 kernelparams->boot_flag != 0xAA55) 7.48 die("Not a kernel"); 7.49 - heap_top = rm_buf+(rm_size=0x200*(kernelparams->setup_sects+1)); // <*> 7.50 - m->size -= rm_size; 7.51 - m->chunk_size -= rm_size; 7.52 + heap_top = _rm_buf(m)+(_rm_size=0x200*(kernelparams->setup_sects+1)); // <*> 7.53 + m->size -= _rm_size; 7.54 + m->chunk_size -= _rm_size; 7.55 7.56 // Read remaining rm loader 7.57 - if (read(m->fd, rm_buf, rm_size) == rm_size) break; 7.58 + if (read(m->fd, rm_buf, _rm_size) == _rm_size) break; 7.59 } 7.60 die(kernel_file_error); 7.61 } while (0); 7.62 @@ -220,8 +228,8 @@ 7.63 { 7.64 struct image_himem *m = ± 7.65 if((u16)(((m->fallback=(u32((u16(_CS)+0x1FFF)&0xF000)<<4))+m->size)>>4) > 7.66 - topseg() || pm_high) { 7.67 - m->fallback = base_himem; 7.68 + topseg() || _pm_high) { 7.69 + m->fallback = _base_himem; 7.70 } 7.71 7.72 load_image(m); 7.73 @@ -251,7 +259,7 @@ 7.74 } 7.75 7.76 load_image(m); 7.77 - struct kernelparams_t *kernelparams = &(((first1k_t*) rm_buf)->params); 7.78 + struct kernelparams_t *kernelparams = &(((first1k_t*) _rm_buf(m-1))->params); 7.79 if(kernelparams->header == HdrS) { 7.80 kernelparams->initrd_buf = m->fallback; 7.81 kernelparams->initrd_size = m->size;
8.1 --- a/linld/stuff/src/TAZBOOT.CPP Fri Jan 04 04:54:43 2019 -0500 8.2 +++ b/linld/stuff/src/TAZBOOT.CPP Sat Jan 05 17:23:23 2019 +0100 8.3 @@ -229,7 +229,7 @@ 8.4 base_himem = strtol(*argv); 8.5 goto next; 8.6 default: 8.7 - if(i == 1 && fileattr(s) != -1) { 8.8 + if(i == 1 && fileexist(s) != -1) { 8.9 goto set_kernelz; 8.10 } 8.11 else {
9.1 --- a/linld/stuff/src/pipehole.awk Fri Jan 04 04:54:43 2019 -0500 9.2 +++ b/linld/stuff/src/pipehole.awk Sat Jan 05 17:23:23 2019 +0100 9.3 @@ -1,6 +1,7 @@ 9.4 BEGIN { hold=0 } 9.5 function isnum(n) { return match(n,/^[0-9+-]/) } 9.6 { 9.7 + sub(/segment word public/,"segment byte public") 9.8 if (hold == 0) { 9.9 s=$0 9.10 if (/^ mov .[ix],bx$/ || /^ mov .[ix],.i$/) {