wok-current rev 20538
linld: _fastcall calls
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Wed Nov 28 19:46:10 2018 +0100 (2018-11-28) |
parents | 91b11cc25f3d |
children | 5211cefde1e4 |
files | linld/stuff/src/COMMON.H 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/ISO9660.H linld/stuff/src/LOAD.CPP linld/stuff/src/XMM.ASM |
line diff
1.1 --- a/linld/stuff/src/COMMON.H Mon Nov 26 10:53:27 2018 +0200 1.2 +++ b/linld/stuff/src/COMMON.H Wed Nov 28 19:46:10 2018 +0100 1.3 @@ -52,14 +52,15 @@ 1.4 } imgs[2]; 1.5 #define pm (imgs[0]) 1.6 #define initrd (imgs[1]) 1.7 +#define pm2initrd(p) (p+1) 1.8 1.9 extern int skip_alloc; 1.10 extern u32 base_himem; 1.11 1.12 -extern pascal void memcpy_image(struct image_himem *m); 1.13 -extern pascal void storepage(u32 *dst, u16 src); 1.14 +extern _fastcall void memcpy_image(struct image_himem *m); 1.15 +extern _fastcall void storepage(u32 *dst); 1.16 #ifdef LARGE_IMAGES 1.17 -extern pascal void reset_bufv(unsigned long *p); 1.18 +extern _fastcall void reset_bufv(unsigned long *p); 1.19 extern "C" unsigned long* prev_bufv(); 1.20 extern "C" unsigned long* next_bufv(); 1.21 #define next(p) p = next_bufv() 1.22 @@ -76,7 +77,7 @@ 1.23 extern u32 root_dev; 1.24 extern u32 vid_mode; 1.25 // External asm helpers 1.26 -extern pascal void xmm_alloc(struct image_himem *m); 1.27 +extern _fastcall void xmm_alloc(struct image_himem *m); 1.28 extern u32 topmem; 1.29 extern "C" u32 memtop(); 1.30 extern "C" void enable_a20_or_die(); 1.31 @@ -89,8 +90,8 @@ 1.32 #endif 1.33 1.34 void load_image(struct image_himem *m); 1.35 -extern pascal void open_image(const char *name, struct image_himem *m); 1.36 -extern pascal int read_image(struct image_himem *m, void* data, int sz); 1.37 +extern _fastcall void open_image(const char *name, struct image_himem *m); 1.38 +extern _fastcall int read_image(struct image_himem *m); 1.39 char* load_kernel(); 1.40 void load_initrd(); 1.41 extern "C" void boot_kernel();
2.1 --- a/linld/stuff/src/CRTL.ASM Mon Nov 26 10:53:27 2018 +0200 2.2 +++ b/linld/stuff/src/CRTL.ASM Wed Nov 28 19:46:10 2018 +0100 2.3 @@ -31,6 +31,7 @@ 2.4 2.5 segment _BSS byte public use16 'BSS' 2.6 2.7 +_xfer_buf db 4096 dup (?) 2.8 global _no_exit:byte 2.9 _no_exit db ? 2.10 filecnt db ? ; in fact 0 minus file count... 2.11 @@ -47,9 +48,9 @@ 2.12 segment _TEXT byte public use16 'CODE' 2.13 2.14 ;*************************************************************** 2.15 -;pascal void strcpy(const char* a, const char* b); 2.16 -;pascal void strcat(const char* a, const char* b); 2.17 -;pascal void strcatb(const char* a, const char* b); 2.18 +;_fastcall void strcpy(const char* a, const char* b); 2.19 +;_fastcall void strcat(const char* a, const char* b); 2.20 +;_fastcall void strcatb(const char* a, const char* b); 2.21 ;*************************************************************** 2.22 global @strcatb$qpxzct1:near 2.23 proc @strcatb$qpxzct1 near 2.24 @@ -65,12 +66,9 @@ 2.25 @strcpy$qpxzct1: 2.26 xor cx,cx 2.27 endif 2.28 - pop ax ;caller return address 2.29 - pop bx ; b 2.30 - pop dx ; a 2.31 - push ax 2.32 push si 2.33 - mov si,dx 2.34 + mov si,bx ; a 2.35 + xchg ax,dx ; b 2.36 ifdef EXTRA 2.37 jcxz @@nocat 2.38 endif 2.39 @@ -106,15 +104,13 @@ 2.40 ifdef EXTRA 2.41 p8086 2.42 ;*************************************************************** 2.43 -;pascal char strstr(const char* a,const char* b); 2.44 +;_fastcall char strstr(const char* a,const char* b); 2.45 ;*************************************************************** 2.46 global @strstr$qpxzct1:near 2.47 proc @strstr$qpxzct1 near 2.48 2.49 - pop ax ;caller return address 2.50 - pop cx ; b 2.51 - pop dx ; a 2.52 - push ax 2.53 + xchg ax,cx ; b 2.54 + mov dx,bx ; a 2.55 push si 2.56 @@loop: 2.57 xor ax,ax 2.58 @@ -136,15 +132,11 @@ 2.59 2.60 2.61 ;*************************************************************** 2.62 -;pascal int strcmp(const char* a,const char* b); 2.63 +;_fastcall int strcmp(const char* a,const char* b); 2.64 ;*************************************************************** 2.65 global @strcmp$qpxzct1:near 2.66 proc @strcmp$qpxzct1 near 2.67 2.68 - pop cx ;caller return address 2.69 - pop ax ; b 2.70 - pop bx ; a 2.71 - push cx 2.72 push si 2.73 xchg ax,si 2.74 dec bx 2.75 @@ -165,14 +157,11 @@ 2.76 2.77 2.78 ;*************************************************************** 2.79 -;pascal void puts(const char* s): 2.80 +;_fastcall void puts(const char* s): 2.81 ;*************************************************************** 2.82 global @puts$qpxzc:near 2.83 proc @puts$qpxzc near 2.84 2.85 - pop ax ;caller return address 2.86 - pop bx ; s 2.87 - push ax 2.88 ; global puts:near ; puts(bx) 2.89 puts: 2.90 call @@putsz 2.91 @@ -192,16 +181,13 @@ 2.92 2.93 2.94 ;*************************************************************** 2.95 -;pascal int fileattr(const char* name); 2.96 +;_fastcall int fileattr(const char* name); 2.97 ;*************************************************************** 2.98 global @fileattr$qpxzc:near 2.99 proc @fileattr$qpxzc near 2.100 2.101 - pop ax ;caller return address 2.102 - pop dx ; name 2.103 - push ax 2.104 mov ax,4300h 2.105 - int 21h 2.106 + call dos_filename 2.107 xchg ax,cx 2.108 jmp chkc 2.109 2.110 @@ -209,19 +195,24 @@ 2.111 2.112 2.113 ;*************************************************************** 2.114 -;pascal int open(const char* name, int flags=O_RDONLY); 2.115 +;_fastcall int open(const char* name, int flags=O_RDONLY); 2.116 ;*************************************************************** 2.117 + global openargs:near ; openargs(bx) 2.118 +openargs: 2.119 + cmp [byte bx],'@' 2.120 + stc 2.121 + jne fail 2.122 + inc bx 2.123 + 2.124 global @open$qpxzc:near 2.125 proc @open$qpxzc near 2.126 2.127 - pop ax ;caller return address 2.128 - pop bx ; name 2.129 - push ax 2.130 global open:near ; open(bx) 2.131 open: 2.132 + mov ax,3d00h ; read-only+compatibility 2.133 + ;mov cl,0 ; attribute mask 2.134 +dos_filename: 2.135 mov dx,bx 2.136 - ;mov cl,0 ; attribute mask 2.137 - mov ax,3d00h ; read-only+compatibility 2.138 dos: 2.139 int 21h 2.140 chkc: 2.141 @@ -237,26 +228,15 @@ 2.142 endif 2.143 ret 2.144 2.145 - global openargs:near ; openargs(bx) 2.146 -openargs: 2.147 - cmp [byte bx],'@' 2.148 - stc 2.149 - jne fail 2.150 - inc bx 2.151 - jmp open 2.152 - 2.153 endp @open$qpxzc 2.154 2.155 2.156 ;*************************************************************** 2.157 -;pascal int close(int fd); 2.158 +;_fastcall int close(int fd); 2.159 ;*************************************************************** 2.160 global @close$qi:near 2.161 proc @close$qi near 2.162 2.163 - pop ax ;caller return address 2.164 - pop bx ; fd 2.165 - push ax 2.166 global close:near ; close(bx) 2.167 close: 2.168 mov ah,3Eh 2.169 @@ -268,8 +248,8 @@ 2.170 2.171 2.172 ;*************************************************************** 2.173 -;pascal int read(int fd, void* data, int sz); 2.174 -;pascal int write(int fd, const void* data, int sz); 2.175 +;_fastcall int read(int fd, void* data, int sz); 2.176 +;_fastcall int write(int fd, const void* data, int sz); 2.177 ;*************************************************************** 2.178 global @read$qipvi:near 2.179 proc @read$qipvi near 2.180 @@ -281,11 +261,9 @@ 2.181 @write$qipvi: 2.182 clc 2.183 endif 2.184 - pop ax ;caller return address 2.185 - pop cx ; sz 2.186 - pop dx ; data 2.187 - pop bx ; fd 2.188 - push ax 2.189 + xchg ax,bx ; fd 2.190 + xchg ax,dx ; data 2.191 + xchg ax,cx ; sz 2.192 ifdef WRITE 2.193 mov ah,40h 2.194 sbb ah,0 2.195 @@ -299,21 +277,15 @@ 2.196 2.197 endp @read$qipvi 2.198 2.199 - ;ifdef EXTRA 2.200 ;*************************************************************** 2.201 -;pascal long lseekset(int fd, unsigned long sz); 2.202 +;_fastcall long lseekset(int fd, unsigned sz); 2.203 ;*************************************************************** 2.204 2.205 - global @lseekset$qiul:near 2.206 - proc @lseekset$qiul near 2.207 + global @lseekset$qiui:near 2.208 + proc @lseekset$qiui near 2.209 2.210 - pop ax ;caller return address 2.211 - pop dx ; sz lo 2.212 - pop cx ; sz hi 2.213 - pop bx ; fd 2.214 - push ax 2.215 - ;endif 2.216 -; global lseekset:near 2.217 + xchg ax,bx ; fd 2.218 + xor cx,cx ; sz hi 2.219 lseekset: 2.220 clc 2.221 db 0B0h ; mov al,im 2.222 @@ -327,9 +299,10 @@ 2.223 xor cx,cx 2.224 jmp dos 2.225 2.226 - endp @lseekset$qiul 2.227 + endp @lseekset$qiui 2.228 2.229 - ifdef EXTRA 2.230 + ifdef EXTRA 2.231 + 2.232 ;typedef unsigned dirsizetype; 2.233 struc isostate ; struct isostate { 2.234 fd dw ? ; 0 int fd; 2.235 @@ -345,33 +318,26 @@ 2.236 buffer db 2560 dup(?) ;28 char buffer[2048+512]; 2.237 ends ; } isostate; 2.238 ;*************************************************************** 2.239 -;pascal long isolseek(const unsigned long *offset); 2.240 +;_fastcall long isolseek(const unsigned long *offset); 2.241 ;*************************************************************** 2.242 global @isolseek$qpxul:near 2.243 proc @isolseek$qpxul near 2.244 2.245 - pop ax 2.246 - pop bx 2.247 - push ax 2.248 isolseek: 2.249 mov dx,[bx] 2.250 mov cx,[bx+2] 2.251 extrn _isostate:isostate 2.252 mov bx,[_isostate.fd] 2.253 - jmp lseekset ; (bx=fd, sz=cx:dx) 2.254 - 2.255 - endp @isolseek$qpxul 2.256 + jmp lseekset 2.257 2.258 + endp @isolseek$qpxul 2.259 2.260 ;*************************************************************** 2.261 -;pascal int isoreadsector(const unsigned long *offset); 2.262 +;_fastcall int isoreadsector(const unsigned long *offset); 2.263 ;*************************************************************** 2.264 global @isoreadsector$qpxul:near 2.265 proc @isoreadsector$qpxul near 2.266 2.267 - pop ax 2.268 - pop bx 2.269 - push ax 2.270 call isolseek 2.271 and ax,dx 2.272 inc ax 2.273 @@ -391,15 +357,11 @@ 2.274 2.275 2.276 ;*************************************************************** 2.277 -;pascal int strhead(const char* a,const char* b); 2.278 +;_fastcall int strhead(const char* a,const char* b); 2.279 ;*************************************************************** 2.280 global @strhead$qpxzct1:near 2.281 proc @strhead$qpxzct1 near 2.282 2.283 - pop cx ;caller return address 2.284 - pop ax ; b 2.285 - pop bx ; a 2.286 - push cx 2.287 @@loop: 2.288 xchg ax,bx 2.289 mov cl,[bx] ; cl = *b++ 2.290 @@ -417,14 +379,12 @@ 2.291 2.292 2.293 ;*************************************************************** 2.294 -;pascal char* malloc_or_die(unsigned size); 2.295 +;_fastcall char* malloc_or_die(unsigned size); 2.296 ;*************************************************************** 2.297 global @malloc_or_die$qui:near 2.298 proc @malloc_or_die$qui near 2.299 2.300 - pop ax ;caller return address 2.301 - pop cx ; size 2.302 - push ax 2.303 + mov cx,bx ; size 2.304 global malloc_or_die:near ; malloc_or_die(cx) 2.305 malloc_or_die: 2.306 mov ax,[_heap_top] ; return value 2.307 @@ -441,16 +401,13 @@ 2.308 2.309 2.310 ;*************************************************************** 2.311 -;pascal int die(const char* msg); 2.312 +;_fastcall int die(const char* msg); 2.313 ;int exit(); 2.314 ;int abort(); 2.315 ;*************************************************************** 2.316 global @die$qpxzc:near 2.317 proc @die$qpxzc near 2.318 @die$qpxzc: 2.319 - pop ax ;caller return address 2.320 - pop bx ; s 2.321 - ;push ax 2.322 global die:near ; die(bx) 2.323 die: 2.324 call puts 2.325 @@ -565,17 +522,14 @@ 2.326 endif 2.327 2.328 ;*************************************************************** 2.329 -;pascal u32* malloc_bufv_or_die(struct image_himem *m); 2.330 +;_fastcall u32* malloc_bufv_or_die(struct image_himem *m); 2.331 ;*************************************************************** 2.332 global @malloc_bufv_or_die$qp11image_himem:near 2.333 proc @malloc_bufv_or_die$qp11image_himem near 2.334 2.335 p386 2.336 - pop bx ;caller return address 2.337 - pop ax 2.338 - push bx 2.339 push si 2.340 - xchg ax,si 2.341 + mov si,bx 2.342 ifdef LARGE_IMAGES 2.343 movzx ecx,[word ((image_himem si).size) + 2] 2.344 shr cx,4 ; pages index size = size >> 20 2.345 @@ -688,14 +642,11 @@ 2.346 2.347 2.348 ;*************************************************************** 2.349 -;pascal void memcpy_image(struct image_himem *m); 2.350 +;_fastcall void memcpy_image(struct image_himem *m); 2.351 ;*************************************************************** 2.352 global @memcpy_image$qp11image_himem:near 2.353 proc @memcpy_image$qp11image_himem near 2.354 2.355 - pop ax ;caller return address 2.356 - pop bx 2.357 - push ax 2.358 ifndef NO386 2.359 mov edx,[(image_himem bx).fallback] 2.360 mov eax,[(image_himem bx).buf] 2.361 @@ -752,21 +703,18 @@ 2.362 endp @memcpy_image$qp11image_himem 2.363 2.364 ;*************************************************************** 2.365 -;pascal void storepage(u32 *dst, u16 src); 2.366 +;_fastcall void storepage(u32 *dst); 2.367 ;*************************************************************** 2.368 - global @storepage$qpulus:near 2.369 - proc @storepage$qpulus near 2.370 + global @storepage$qpul:near 2.371 + proc @storepage$qpul near 2.372 2.373 - pop ax ;caller return address 2.374 - pop cx 2.375 - pop bx 2.376 - push ax 2.377 ifndef NO386 2.378 mov edx,[bx] 2.379 else 2.380 mov ax,[bx] 2.381 mov dx,[bx+2] 2.382 endif 2.383 + mov cx,offset _xfer_buf 2.384 storepage: ; storepage(edx,cx) 2.385 ifndef NO386 2.386 push 0 2.387 @@ -784,20 +732,17 @@ 2.388 push ds 2.389 jmp call_memcpy32 2.390 2.391 - endp @storepage$qpulus 2.392 + endp @storepage$qpul 2.393 2.394 2.395 ifdef LARGE_IMAGES 2.396 p386 2.397 ;*************************************************************** 2.398 -;pascal void reset_bufv(u32 *p); 2.399 +;_fastcall void reset_bufv(u32 *p); 2.400 ;*************************************************************** 2.401 global @reset_bufv$qpul:near 2.402 proc @reset_bufv$qpul near 2.403 2.404 - pop ax ;caller return address 2.405 - pop bx 2.406 - push ax 2.407 mov [curdata],bx 2.408 and [dword (data_himem bx).cacheidx],0 2.409 ret 2.410 @@ -867,23 +812,22 @@ 2.411 endif 2.412 2.413 ;*************************************************************** 2.414 -;pascal void open_image(const char *name, struct image_himem *m); 2.415 +;_fastcall void open_image(const char *name, struct image_himem *m); 2.416 ;*************************************************************** 2.417 global @open_image$qpxzcp11image_himem:near 2.418 proc @open_image$qpxzcp11image_himem near 2.419 2.420 - pop cx ;caller return address 2.421 - pop ax ; m 2.422 - pop bx ; name 2.423 - push cx 2.424 push di 2.425 xchg ax,di 2.426 + ifdef EXTRA 2.427 + cmp [(image_himem di).fd],0 ; iso image/kernel ? 2.428 + jnz @@alreadydone 2.429 + endif 2.430 mov [(image_himem di).state],bx 2.431 push bx 2.432 ifdef EXTRA 2.433 - xor ax,ax 2.434 - or ax,[(image_himem di).next_chunk] 2.435 - jne @@next 2.436 + cmp [(image_himem di).next_chunk],0 ; iso image/initrd ? 2.437 + jnz @@next 2.438 endif 2.439 mov [(image_himem di).next_chunk],offset next_chunk 2.440 @@next: 2.441 @@ -904,6 +848,7 @@ 2.442 jnz @@next 2.443 pop [(image_himem di).state] 2.444 call [(image_himem di).next_chunk] ; m->next_chunk() 2.445 +@@alreadydone: 2.446 pop di 2.447 ret 2.448 2.449 @@ -911,21 +856,15 @@ 2.450 2.451 2.452 ;*************************************************************** 2.453 -;pascal int read_image(struct image_himem *m, char* data, int sz); 2.454 +;_fastcall int read_image(struct image_himem *m); 2.455 ;*************************************************************** 2.456 - global @read_image$qp11image_himempvi:near 2.457 - proc @read_image$qp11image_himempvi near 2.458 + global @read_image$qp11image_himem:near 2.459 + proc @read_image$qp11image_himem near 2.460 2.461 - arg sz :word, \ 2.462 - data :word, \ 2.463 - m :word = PARAM_SIZE 2.464 - 2.465 - push bp 2.466 - mov bp,sp 2.467 - push si di 2.468 - mov di,[m] 2.469 - mov si,[data] 2.470 - mov bp,[sz] 2.471 + push bp si di 2.472 + mov di,bx 2.473 + mov si,offset _xfer_buf 2.474 + mov bp,4096 2.475 push bp ; original size 2.476 @@loop: 2.477 ifndef NO386 2.478 @@ -945,7 +884,7 @@ 2.479 @@szok: 2.480 jcxz image_done 2.481 mov dx,si 2.482 - mov bx,[word di] 2.483 + mov bx,[di] 2.484 call @read$cxdxbx 2.485 jc image_done 2.486 add si,ax 2.487 @@ -987,9 +926,9 @@ 2.488 pop ax ; original size 2.489 sub ax,bp 2.490 pop di si bp 2.491 - ret 6 2.492 + ret 2.493 2.494 - endp @read_image$qp11image_himempvi 2.495 + endp @read_image$qp11image_himem 2.496 2.497 2.498 ;*************************************************************** 2.499 @@ -998,8 +937,8 @@ 2.500 global @strtol$qpxzc:near 2.501 proc @strtol$qpxzc near 2.502 2.503 - pop ax ;caller return address 2.504 - pop cx ; s 2.505 + pop ax 2.506 + pop bx ; s 2.507 push ax 2.508 ifndef NO386 2.509 xor ebx,ebx 2.510 @@ -1266,15 +1205,11 @@ 2.511 2.512 2.513 ;*************************************************************** 2.514 -;pascal void chdirname(char *path) 2.515 +;_fastcall void chdirname(char *path) 2.516 ;*************************************************************** 2.517 global @chdirname$qpzc:near 2.518 proc @chdirname$qpzc near 2.519 2.520 - pop ax 2.521 - pop bx 2.522 - push ax 2.523 - 2.524 cmp [byte bx+1],3Ah ; ':' 2.525 jne @@nodisk 2.526 mov dl,20h 2.527 @@ -1315,15 +1250,13 @@ 2.528 2.529 2.530 ;*************************************************************** 2.531 -;pascal char *ultoa(unsigned long n); 2.532 +;_fastcall char *ultoa(unsigned long n); 2.533 ;*************************************************************** 2.534 global @ultoa$qul:near 2.535 proc @ultoa$qul near 2.536 2.537 - pop dx 2.538 - pop cx 2.539 - pop ax 2.540 - push dx ; AX:CX = n 2.541 + xchg ax,cx 2.542 + xchg ax,dx ; AX:CX = n 2.543 push si 2.544 mov si,10 2.545 mov bx,offset ultoabuf+11 2.546 @@ -1348,16 +1281,13 @@ 2.547 2.548 2.549 ;*************************************************************** 2.550 -;pascal unsigned long kver2ul(char *kernel_version); 2.551 +;_fastcall unsigned long kver2ul(char *kernel_version); 2.552 ;*************************************************************** 2.553 global @kver2ul$qpzc:near 2.554 proc @kver2ul$qpzc near 2.555 2.556 - pop bx 2.557 - pop ax 2.558 - push bx 2.559 push si 2.560 - xchg ax,si 2.561 + mov si,bx 2.562 xor bx,bx 2.563 mov cx,304h 2.564 @@number: 2.565 @@ -1386,7 +1316,7 @@ 2.566 2.567 ;*************************************************************** 2.568 ;void try_default_args(); 2.569 -;pascal void set_cmdline(const char *filename); 2.570 +;_fastcall void set_cmdline(const char *filename); 2.571 ;*************************************************************** 2.572 ifdef EXTRA 2.573
3.1 --- a/linld/stuff/src/CRTL.H Mon Nov 26 10:53:27 2018 +0200 3.2 +++ b/linld/stuff/src/CRTL.H Wed Nov 28 19:46:10 2018 +0100 3.3 @@ -25,17 +25,18 @@ 3.4 extern char data_start; extern char data_end; 3.5 extern char bss_start; extern char bss_end; 3.6 extern char* heap_top; 3.7 +extern char xfer_buf[4096]; 3.8 3.9 void parse_cmdline(); 3.10 -extern pascal void strcatb(const char* a,const char* b); 3.11 -extern pascal int strhead(const char* a,const char* head); 3.12 -extern pascal int fileattr(const char* name); 3.13 +extern _fastcall void strcatb(const char* a,const char* b); 3.14 +extern _fastcall int strhead(const char* a,const char* head); 3.15 +extern _fastcall int fileattr(const char* name); 3.16 //extern "C" int open(const char* name, int flags); 3.17 -extern pascal int open(const char* name); 3.18 -extern pascal int close(int fd); 3.19 -extern pascal int read(int fd, void* data, int sz); 3.20 -extern pascal long lseekset(int fd, unsigned long sz); 3.21 -extern pascal int puts(const char* s); 3.22 +extern _fastcall int open(const char* name); 3.23 +extern _fastcall int close(int fd); 3.24 +extern _fastcall int read(int fd, void* data, int sz); 3.25 +extern _fastcall long lseekset(int fd, unsigned sz); 3.26 +extern _fastcall int puts(const char* s); 3.27 extern pascal unsigned long strtol(const char *s); 3.28 3.29 // Extensions 3.30 @@ -44,9 +45,9 @@ 3.31 #define int3() do { asm { db 0cch } } while(0) 3.32 #define nop() do { asm { db 90h } } while(0) 3.33 extern char no_exit; 3.34 -extern pascal int die(const char* msg); 3.35 +extern _fastcall int die(const char* msg); 3.36 //extern "C" char* malloc_or_die(unsigned size); 3.37 //extern "C" unsigned long* malloc_bufv_or_die(struct image_himem *m); 3.38 -extern pascal int malloc_or_die(unsigned size); 3.39 -extern pascal int malloc_bufv_or_die(struct image_himem *m); 3.40 -extern pascal void set_cmdline(const char *filename); 3.41 +extern _fastcall int malloc_or_die(unsigned size); 3.42 +extern _fastcall int malloc_bufv_or_die(struct image_himem *m); 3.43 +extern _fastcall void set_cmdline(const char *filename);
4.1 --- a/linld/stuff/src/CRTLX.H Mon Nov 26 10:53:27 2018 +0200 4.2 +++ b/linld/stuff/src/CRTLX.H Wed Nov 28 19:46:10 2018 +0100 4.3 @@ -1,15 +1,15 @@ 4.4 // This file is distributed under GPL 4.5 // 4.6 -extern pascal void strcpy(const char* a,const char* b); 4.7 -extern pascal void strcat(const char* a,const char* b); 4.8 -extern pascal int strcmp(const char* a,const char* b); 4.9 +extern _fastcall void strcpy(const char* a,const char* b); 4.10 +extern _fastcall void strcat(const char* a,const char* b); 4.11 +extern _fastcall int strcmp(const char* a,const char* b); 4.12 //extern "C" char* strstr(const char* a,const char* b); 4.13 -extern pascal int strstr(const char* a,const char* b); 4.14 +extern _fastcall int strstr(const char* a,const char* b); 4.15 extern "C" char *progname(void); 4.16 -extern pascal void chdirname(char *path); 4.17 -extern pascal unsigned long kver2ul(char *kernel_version); 4.18 +extern _fastcall void chdirname(char *path); 4.19 +extern _fastcall unsigned long kver2ul(char *kernel_version); 4.20 //extern "C" char *ultoa(unsigned long n); 4.21 -extern pascal int ultoa(unsigned long n); 4.22 +extern _fastcall int ultoa(unsigned long n); 4.23 extern "C" void try_default_args(); 4.24 extern char cpu_features[]; 4.25 #define CPUMASKLM (0x20)
5.1 --- a/linld/stuff/src/HIMEM.CPP Mon Nov 26 10:53:27 2018 +0200 5.2 +++ b/linld/stuff/src/HIMEM.CPP Wed Nov 28 19:46:10 2018 +0100 5.3 @@ -9,50 +9,6 @@ 5.4 struct image_himem imgs[2]; 5.5 int skip_alloc; 5.6 5.7 -// Called just before rm->pm 5.8 -void last_ditch() { 5.9 - struct image_himem *m = ± 5.10 - vm2rm(); 5.11 - if(((u16 *)&m->fallback)[1] >= 0x10) m->fallback = _1m; // >= _1m ? 5.12 - if(m->bufv==0) { 5.13 - // Move kernel 5.14 - memcpy_image(m); 5.15 - // Move initrd 5.16 - memcpy_image(&initrd); 5.17 - } else { //vcpi 5.18 - // Move kernel 5.19 - // 'Gathering' copy in chunks of PAGE_SIZE 5.20 - // No risk of overlapping: kernel is copied from above to 1m mark 5.21 - m->size = initrd.size = PAGE_SIZE; 5.22 - u32 *p = m->bufv; 5.23 - reset_bufv(p); 5.24 - if (p) do { 5.25 - m->buf = *p; 5.26 - memcpy_image(m); 5.27 - next(p); m->fallback+=PAGE_SIZE; 5.28 - } while(*p); 5.29 - // Move initrd 5.30 - m = &initrd; 5.31 - if(m->fallback) { 5.32 - // This is tricky: copy initrd backwards to reduce 5.33 - // risk of overlapping: use the fact that initrd is copied 5.34 - // to the very top of ram 5.35 - // (overlapping still can happen with more than 256mb ram) 5.36 - // (generic solution for this overwrite problem, anyone?) 5.37 - p=m->bufv; 5.38 - reset_bufv(p); 5.39 - do { 5.40 - next(p); m->fallback+=PAGE_SIZE; 5.41 - } while(*p); 5.42 - do { 5.43 - prev(p); m->fallback-=PAGE_SIZE; 5.44 - m->buf = *p; 5.45 - memcpy_image(m); 5.46 - } while(p != m->bufv); 5.47 - } 5.48 - } 5.49 -} 5.50 - 5.51 void load_image(struct image_himem *m) { 5.52 no_exit++; // die() won't return to DOS 5.53 m->remaining = m->size; 5.54 @@ -69,13 +25,63 @@ 5.55 } 5.56 buf = m->buf; 5.57 do { 5.58 - u8 xfer_buf[PAGE_SIZE]; 5.59 u16 size; 5.60 - if(s16(size = read_image(m, xfer_buf, PAGE_SIZE)) <= 0) break; 5.61 - storepage(bufv, ofs(xfer_buf)); 5.62 + if(s16(size = read_image(m)) <= 0) break; 5.63 + storepage(bufv); 5.64 if (bufv != &buf) next(bufv); 5.65 buf += size; 5.66 } while (*bufv); 5.67 if(m->remaining) die("Read error"); 5.68 close(m->fd2close); 5.69 } 5.70 + 5.71 +// Called just before rm->pm 5.72 +void last_ditch() { 5.73 + struct image_himem *m = ± 5.74 + u32 *q; 5.75 + vm2rm(); 5.76 + if(((u16 *)&m->fallback)[1] >= 0x10) m->fallback = _1m; // >= _1m ? 5.77 + q = m->bufv; 5.78 + if(q==0) { 5.79 + // Move kernel 5.80 + memcpy_image(m); 5.81 + // Move initrd 5.82 + memcpy_image(pm2initrd(m)); 5.83 + } else { //vcpi 5.84 +#if defined(__BORLANDC__) && defined(NO386) 5.85 +#pragma option -3 5.86 + asm{ 5.87 + .386p 5.88 + } 5.89 +#endif 5.90 + // Move kernel 5.91 + // 'Gathering' copy in chunks of PAGE_SIZE 5.92 + // No risk of overlapping: kernel is copied from above to 1m mark 5.93 + m->size = pm2initrd(m)->size = PAGE_SIZE; 5.94 + reset_bufv(q); 5.95 + do { 5.96 + m->buf = *q; 5.97 + memcpy_image(m); 5.98 + next(q); m->fallback+=PAGE_SIZE; 5.99 + } while(*q); 5.100 + // Move initrd 5.101 + m = pm2initrd(m); 5.102 + if(((u16 *)&m->fallback)[1]) { 5.103 + // This is tricky: copy initrd backwards to reduce 5.104 + // risk of overlapping: use the fact that initrd is copied 5.105 + // to the very top of ram 5.106 + // (overlapping still can happen with more than 256mb ram) 5.107 + // (generic solution for this overwrite problem, anyone?) 5.108 + q=m->bufv; 5.109 + reset_bufv(q); 5.110 + do { 5.111 + next(q); m->fallback+=PAGE_SIZE; 5.112 + } while(*q); 5.113 + do { 5.114 + prev(q); m->fallback-=PAGE_SIZE; 5.115 + m->buf = *q; 5.116 + memcpy_image(m); 5.117 + } while(q != m->bufv); 5.118 + } 5.119 + } 5.120 +}
6.1 --- a/linld/stuff/src/ISO9660.CPP Mon Nov 26 10:53:27 2018 +0200 6.2 +++ b/linld/stuff/src/ISO9660.CPP Wed Nov 28 19:46:10 2018 +0100 6.3 @@ -9,9 +9,10 @@ 6.4 { 6.5 static const unsigned long root = 16UL * 2048; 6.6 struct isostate *x=&isostate; 6.7 - if (name) 6.8 + if (name) { 6.9 //x->fd = open(name, O_RDONLY); 6.10 x->fd = open(name); 6.11 + } 6.12 if (isoreadsector(&root) < 0 || strhead(x->buffer+1,"CD001")) { 6.13 //close(x->fd); 6.14 return -1; 6.15 @@ -36,8 +37,8 @@ 6.16 goto restarted; 6.17 } 6.18 if (x->curpos >= SECTORSZ || * (short *) (x->buffer + x->curpos) == 0) { 6.19 + restarted: 6.20 if (x->curdirsize < DIRSECTORSZ) return -1; 6.21 - restarted: 6.22 isoreadsector(&x->curdirofs); 6.23 //x->curdirofs += SECTORSZ; 6.24 *(int *)((char *) &x->curdirofs+1) += SECTORSZ/256; 6.25 @@ -45,8 +46,9 @@ 6.26 x->curpos = 0; 6.27 } 6.28 p = x->buffer; p += x->curpos; 6.29 - if ((size = * (short *) p) == 0) 6.30 + if ((size = * (short *) p) == 0) { 6.31 return -1; 6.32 + } 6.33 x->fileofs = (* (unsigned long *) (p + 2)) << SECTORBITS; 6.34 x->filesize = * (unsigned long *) (p + 10); 6.35 x->filemod = (p[25] & 2) ? 0040755 : 0100755;
7.1 --- a/linld/stuff/src/ISO9660.H Mon Nov 26 10:53:27 2018 +0200 7.2 +++ b/linld/stuff/src/ISO9660.H Wed Nov 28 19:46:10 2018 +0100 7.3 @@ -25,8 +25,8 @@ 7.4 #define isofilesize isostate.filesize 7.5 #define isofilemod isostate.filemod 7.6 #define isofilename isostate.filename 7.7 -extern pascal long isolseek(const unsigned long *offset); 7.8 -extern pascal int isoreadsector(const unsigned long *offset); 7.9 +extern _fastcall long isolseek(const unsigned long *offset); 7.10 +extern _fastcall int isoreadsector(const unsigned long *offset); 7.11 extern int isoreset(char *name); 7.12 extern int isoopen(const char *name); 7.13 extern int isoreaddir(int restart);
8.1 --- a/linld/stuff/src/LOAD.CPP Mon Nov 26 10:53:27 2018 +0200 8.2 +++ b/linld/stuff/src/LOAD.CPP Wed Nov 28 19:46:10 2018 +0100 8.3 @@ -242,6 +242,12 @@ 8.4 void load_initrd() { 8.5 struct image_himem *m = &initrd; 8.6 if (!initrd_name && !m->fd) return; 8.7 +#if defined(__BORLANDC__) && defined(NO386) 8.8 +#pragma option -3 8.9 + asm{ 8.10 + .386p 8.11 + } 8.12 +#endif 8.13 m->errmsg = "Can't use initrd file"; 8.14 8.15 open_image(initrd_name, m);
9.1 --- a/linld/stuff/src/XMM.ASM Mon Nov 26 10:53:27 2018 +0200 9.2 +++ b/linld/stuff/src/XMM.ASM Wed Nov 28 19:46:10 2018 +0100 9.3 @@ -93,14 +93,11 @@ 9.4 ends ;}; 9.5 9.6 ;*************************************************************** 9.7 -;pascal void xmm_alloc(struct image_himem *m) 9.8 +;_fastcall void xmm_alloc(struct image_himem *m) 9.9 ;*************************************************************** 9.10 global @xmm_alloc$qp11image_himem:near 9.11 proc @xmm_alloc$qp11image_himem near 9.12 9.13 - pop ax 9.14 - pop bx 9.15 - push ax 9.16 ret ; TO BE FIXED 9.17 ifndef NO386 9.18 mov edx,[(image_himem bx).size] ; m->size