# HG changeset patch # User Pascal Bellard # Date 1541777875 -3600 # Node ID f0d71e920c5a0b1b3e8c09acc5730679469c197b # Parent 17c0ad41f5bfe01843338489a502356e76b880ce linld: pascal convention calls diff -r 17c0ad41f5bf -r f0d71e920c5a linld/stuff/src/COMMON.H --- a/linld/stuff/src/COMMON.H Thu Nov 08 23:37:09 2018 +0100 +++ b/linld/stuff/src/COMMON.H Fri Nov 09 16:37:55 2018 +0100 @@ -56,10 +56,10 @@ extern int skip_alloc; extern u32 base_himem; -extern "C" void memcpy_image(struct image_himem *m); -extern "C" void storepage(u32 *dst, u16 src); +extern pascal void memcpy_image(struct image_himem *m); +extern pascal void storepage(u32 *dst, u16 src); #ifdef LARGE_IMAGES -extern "C" void reset_bufv(unsigned long *p); +extern pascal void reset_bufv(unsigned long *p); extern "C" unsigned long* prev_bufv(); extern "C" unsigned long* next_bufv(); #define next(p) p = next_bufv() @@ -73,10 +73,10 @@ extern const char* kernel_name; extern const char* initrd_name; extern const char* cmdline; -extern u16 root_dev; -extern u16 vid_mode; +extern u32 root_dev; +extern u32 vid_mode; // External asm helpers -extern "C" void xmm_alloc(struct image_himem *m); +extern pascal void xmm_alloc(struct image_himem *m); extern u32 topmem; extern "C" u32 memtop(); extern "C" void enable_a20_or_die(); @@ -89,8 +89,8 @@ #endif void load_image(struct image_himem *m); -extern "C" void open_image(const char *name, struct image_himem *m); -extern "C" int read_image(struct image_himem *m, void* data, int sz); +extern pascal void open_image(const char *name, struct image_himem *m); +extern pascal int read_image(struct image_himem *m, void* data, int sz); char* load_kernel(); void load_initrd(); extern "C" void boot_kernel(); diff -r 17c0ad41f5bf -r f0d71e920c5a linld/stuff/src/CRTL.ASM --- a/linld/stuff/src/CRTL.ASM Thu Nov 08 23:37:09 2018 +0100 +++ b/linld/stuff/src/CRTL.ASM Fri Nov 09 16:37:55 2018 +0100 @@ -47,29 +47,27 @@ segment _TEXT byte public use16 'CODE' ;*************************************************************** -;char* strcpy(const char* a, const char* b); -;char* strcat(const char* a, const char* b); -;char* strcatb(const char* a, const char* b); +;pascal void strcpy(const char* a, const char* b); +;pascal void strcat(const char* a, const char* b); +;pascal void strcatb(const char* a, const char* b); ;*************************************************************** - global _strcatb:near - proc _strcatb near + global @strcatb$qpxzct1:near + proc @strcatb$qpxzct1 near ifdef EXTRA mov cl,7Fh db 0bbh ; mov bx,imm opcode - global _strcat:near -_strcat: + global @strcat$qpxzct1:near +@strcat$qpxzct1: mov cl,80h db 0bbh ; mov bx,imm opcode - global _strcpy:near -_strcpy: + global @strcpy$qpxzct1:near +@strcpy$qpxzct1: xor cx,cx endif pop ax ;caller return address + pop bx ; b pop dx ; a - pop bx ; b - push bx - push dx push ax push si mov si,dx @@ -102,22 +100,20 @@ pop si ret - endp _strcatb + endp @strcatb$qpxzct1 ifdef EXTRA p8086 ;*************************************************************** -;char strstr(const char* a,const char* b); +;pascal char strstr(const char* a,const char* b); ;*************************************************************** - global _strstr:near - proc _strstr near + global @strstr$qpxzct1:near + proc @strstr$qpxzct1 near pop ax ;caller return address + pop cx ; b pop dx ; a - pop cx ; b - push cx - push dx push ax push si @@loop: @@ -136,20 +132,18 @@ inc dx jmp @@loop - endp _strstr + endp @strstr$qpxzct1 ;*************************************************************** -;int strcmp(const char* a,const char* b); +;pascal int strcmp(const char* a,const char* b); ;*************************************************************** - global _strcmp:near - proc _strcmp near + global @strcmp$qpxzct1:near + proc @strcmp$qpxzct1 near pop cx ;caller return address + pop ax ; b pop bx ; a - pop ax ; b - push ax - push bx push cx push si xchg ax,si @@ -166,19 +160,18 @@ pop si ret - endp _strcmp + endp @strcmp$qpxzct1 endif ;*************************************************************** -;void puts(const char* s): +;pascal void puts(const char* s): ;*************************************************************** - global _puts:near - proc _puts near + global @puts$qpxzc:near + proc @puts$qpxzc near pop ax ;caller return address pop bx ; s - push bx push ax ; global puts:near ; puts(bx) puts: @@ -195,36 +188,34 @@ jne @@putcz ; ZF=1 (for malloc failure) ret - endp _puts + endp @puts$qpxzc ;*************************************************************** -;int fileattr(const char* name); +;pascal int fileattr(const char* name); ;*************************************************************** - global _fileattr:near - proc _fileattr near + global @fileattr$qpxzc:near + proc @fileattr$qpxzc near pop ax ;caller return address pop dx ; name - push dx push ax mov ax,4300h int 21h xchg ax,cx jmp chkc - endp _fileattr + endp @fileattr$qpxzc ;*************************************************************** -;int open(const char* name, int flags=O_RDONLY); +;pascal int open(const char* name, int flags=O_RDONLY); ;*************************************************************** - global _open:near - proc _open near + global @open$qpxzc:near + proc @open$qpxzc near pop ax ;caller return address pop bx ; name - push bx push ax global open:near ; open(bx) open: @@ -246,18 +237,25 @@ endif ret - endp _open + global openargs:near ; openargs(bx) +openargs: + cmp [byte bx],'@' + stc + jne fail + inc bx + jmp open + + endp @open$qpxzc ;*************************************************************** -;int close(int fd); +;pascal int close(int fd); ;*************************************************************** - global _close:near - proc _close near + global @close$qi:near + proc @close$qi near pop ax ;caller return address pop bx ; fd - push bx push ax global close:near ; close(bx) close: @@ -266,56 +264,53 @@ jnz dos ret - endp _close + endp @close$qi ;*************************************************************** -;int read(int fd, void* data, int sz); -;int write(int fd, const void* data, int sz); +;pascal int read(int fd, void* data, int sz); +;pascal int write(int fd, const void* data, int sz); ;*************************************************************** - global _read:near - proc _read near + global @read$qipvi:near + proc @read$qipvi near ifdef WRITE stc db 0B0h ; mov al,im - global _write:near + global @write$qipvi:near +@write$qipvi: clc endif pop ax ;caller return address + pop cx ; sz + pop dx ; data pop bx ; fd - pop dx ; data - pop cx ; sz - push cx - push dx - push bx push ax ifdef WRITE mov ah,40h sbb ah,0 else + global @read$cxdxbx:near +@read$cxdxbx: mov ah,3Fh endif jcxz fail jmp dos - endp _read + endp @read$qipvi - proc _lseekset near ;ifdef EXTRA ;*************************************************************** -;long lseekset(int fd, unsigned long sz); +;pascal long lseekset(int fd, unsigned long sz); ;*************************************************************** - global _lseekset:near + global @lseekset$qiul:near + proc @lseekset$qiul near pop ax ;caller return address - pop bx ; fd pop dx ; sz lo pop cx ; sz hi - push cx - push dx - push bx + pop bx ; fd push ax ;endif ; global lseekset:near @@ -332,7 +327,7 @@ xor cx,cx jmp dos - endp _lseekset + endp @lseekset$qiul ifdef EXTRA struc isostate ; struct isostate { @@ -348,36 +343,36 @@ curpos dd ? ;28 unsigned long curpos; ends ; } isostate; ;*************************************************************** -;unsigned long isolseek(const unsigned long *offset); +;pascal int isolseek(const unsigned long *offset); ;*************************************************************** - global _isolseek:near - proc _isolseek near + global @isolseek$qpxul:near + proc @isolseek$qpxul 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) + call lseekset ; (bx=fd, sz=cx:dx) + and ax,dx + inc ax + ret - endp _isolseek + endp @isolseek$qpxul endif ;*************************************************************** -;int strhead(const char* a,const char* b); +;pascal int strhead(const char* a,const char* b); ;*************************************************************** - global _strhead:near - proc _strhead near + global @strhead$qpxzct1:near + proc @strhead$qpxzct1 near pop cx ;caller return address + pop ax ; b pop bx ; a - pop ax ; b - push ax - push bx push cx @@loop: xchg ax,bx @@ -392,18 +387,17 @@ jz @@loop ret ; return b (is not 0) - endp _strhead + endp @strhead$qpxzct1 ;*************************************************************** -;char* malloc_or_die(unsigned size); +;pascal char* malloc_or_die(unsigned size); ;*************************************************************** - global _malloc_or_die:near - proc _malloc_or_die near + global @malloc_or_die$qui:near + proc @malloc_or_die$qui near pop ax ;caller return address pop cx ; size - push cx push ax global malloc_or_die:near ; malloc_or_die(cx) malloc_or_die: @@ -417,20 +411,19 @@ add [_heap_top],cx ; _BEG has zero'd heap ret - endp _malloc_or_die + endp @malloc_or_die$qui ;*************************************************************** -;int die(const char* msg); +;pascal int die(const char* msg); ;int exit(); ;int abort(); ;*************************************************************** - global _die:near - proc _die near - + global @die$qpxzc:near + proc @die$qpxzc near +@die$qpxzc: pop ax ;caller return address pop bx ; s - ;push bx ;push ax global die:near ; die(bx) die: @@ -453,7 +446,7 @@ hlt jmp @@stop - endp _die + endp @die$qpxzc struc image_himem ;struct image_himem { fd dw ? ; 0 int fd; @@ -546,15 +539,14 @@ endif ;*************************************************************** -;u32* malloc_bufv_or_die(struct image_himem *m); +;pascal u32* malloc_bufv_or_die(struct image_himem *m); ;*************************************************************** - global _malloc_bufv_or_die:near - proc _malloc_bufv_or_die near + global @malloc_bufv_or_die$qp11image_himem:near + proc @malloc_bufv_or_die$qp11image_himem near p386 pop bx ;caller return address pop ax - push ax push bx push si xchg ax,si @@ -666,18 +658,17 @@ p8086 endif - endp _malloc_bufv_or_die + endp @malloc_bufv_or_die$qp11image_himem ;*************************************************************** -; void memcpy_image(struct image_himem *m); +;pascal void memcpy_image(struct image_himem *m); ;*************************************************************** - global _memcpy_image:near - proc _memcpy_image near + global @memcpy_image$qp11image_himem:near + proc @memcpy_image$qp11image_himem near pop ax ;caller return address pop bx - push bx push ax ifndef NO386 mov edx,[(image_himem bx).fallback] @@ -727,25 +718,22 @@ endif endif @@memcpy: - extrn _memcpy32:near - call near _memcpy32 - add sp,14 + extrn memcpy32:near + call near memcpy32 @@skip: ret - endp _memcpy_image + endp @memcpy_image$qp11image_himem ;*************************************************************** -;void storepage(u32 *dst, u16 src); +;pascal void storepage(u32 *dst, u16 src); ;*************************************************************** - global _storepage:near - proc _storepage near + global @storepage$qpulus:near + proc @storepage$qpulus near pop ax ;caller return address + pop cx pop bx - pop cx - push cx - push bx push ax ifndef NO386 mov edx,[bx] @@ -770,26 +758,25 @@ push ds jmp call_memcpy32 - endp _storepage + endp @storepage$qpulus ifdef LARGE_IMAGES p386 ;*************************************************************** -;void reset_bufv(u32 *p); +;pascal void reset_bufv(u32 *p); ;*************************************************************** - global _reset_bufv:near - proc _reset_bufv near + global @reset_bufv$qpul:near + proc @reset_bufv$qpul near pop ax ;caller return address pop bx - push bx push ax mov [curdata],bx and [dword (data_himem bx).cacheidx],0 ret - endp _reset_bufv + endp @reset_bufv$qpul ;*************************************************************** ;u32* prev_bufv(); @@ -803,12 +790,12 @@ db 73h ; jnc _next_bufv: clc + push si + mov si,[curdata] sbb ax,ax cmc adc ax,[(data_himem si).cacheidx] ; -1/+1 xor ecx,ecx - push si - mov si,[curdata] test ax,0fc00h jz @@gotpage push ax ; FFFF / 0400 @@ -854,16 +841,14 @@ endif ;*************************************************************** -;void open_image(const char *name, struct image_himem *m); +;pascal void open_image(const char *name, struct image_himem *m); ;*************************************************************** - global _open_image:near - proc _open_image near + global @open_image$qpxzcp11image_himem:near + proc @open_image$qpxzcp11image_himem near pop cx ;caller return address + pop ax ; m pop bx ; name - pop ax ; m - push ax - push bx push cx push di xchg ax,di @@ -891,37 +876,34 @@ pop di ret - endp _open_image + endp @open_image$qpxzcp11image_himem ;*************************************************************** -;int read_image(struct image_himem *m, char* data, int sz); +;pascal int read_image(struct image_himem *m, char* data, int sz); ;*************************************************************** - global _read_image:near - proc _read_image near + global @read_image$qp11image_himempvi:near + proc @read_image$qp11image_himempvi near - arg m :word, \ + arg sz :word, \ data :word, \ - sz :word = PARAM_SIZE + m :word = PARAM_SIZE push bp mov bp,sp - push di - ifndef NO386 - push 0 ; return value - else - xor ax,ax - push ax - endif + push si di mov di,[m] + mov si,[data] + mov bp,[sz] + push bp ; original size @@loop: ifndef NO386 - movzx ecx,[word sz] + movzx ecx,bp mov eax,[(image_himem di).chunk_size] cmp ecx,eax jb @@szok else - mov cx,[word sz] + mov cx,bp mov ax,[word (image_himem di).chunk_size] cmp cx,ax jb @@szok @@ -931,15 +913,11 @@ xchg ax,cx @@szok: jcxz image_done - push cx - push [word data] - push [word di] - call _read - pop dx - pop bx - pop cx + mov dx,si + mov bx,[word di] + call @read$cxdxbx jc image_done - add bx,ax + add si,ax xor cx,cx ifndef NO386 cwde ; ax < 8000h @@ -952,12 +930,12 @@ cmp [word (image_himem di).chunk_size],dx endif jnz @@fill - dec cx + inc cx @@fill: test al,3 je @@filled - mov [bx],dh - inc bx + mov [si],ch + inc si inc ax jmp @@fill @@filled: @@ -967,9 +945,7 @@ sub [word (image_himem di).remaining],ax sbb [word ((image_himem di).remaining)+2],dx endif - add [bp-2-2],ax - add [word data],ax - sub [word sz],ax + sub bp,ax pushf jcxz @@same_chunk call [(image_himem di).next_chunk] @@ -977,24 +953,24 @@ popf jnz @@loop image_done: - pop ax - pop di bp - ret + pop ax ; original size + sub ax,bp + pop di si bp + ret 6 - endp _read_image + endp @read_image$qp11image_himempvi ;*************************************************************** -;unsigned long strtol(const char *s); +;pascal unsigned long strtol(const char *s); ;*************************************************************** - global _strtol:near - proc _strtol near + global @strtol$qpxzc:near + proc @strtol$qpxzc near - ifndef NO386 pop ax ;caller return address pop cx ; s - push cx push ax + ifndef NO386 xor ebx,ebx push si jcxz @@end @@ -1080,10 +1056,6 @@ @@popsiret: pop si else - pop ax ;caller return address - pop cx ; s - push cx - push ax push si push di xor ax,ax @@ -1189,9 +1161,10 @@ pop di pop si endif +strtol_ret: ret - endp _strtol + endp @strtol$qpxzc ifdef NO386 @@ -1262,14 +1235,13 @@ ;*************************************************************** -;void chdirname(char *path) +;pascal void chdirname(char *path) ;*************************************************************** - global _chdirname:near - proc _chdirname near + global @chdirname$qpzc:near + proc @chdirname$qpzc near pop ax pop bx - push bx push ax cmp [byte bx+1],3Ah ; ':' @@ -1308,54 +1280,50 @@ @@end: ret - endp _chdirname + endp @chdirname$qpzc ;*************************************************************** -;char *ultoa(unsigned long n); +;pascal char *ultoa(unsigned long n); ;*************************************************************** - global _ultoa:near - proc _ultoa near + global @ultoa$qul:near + proc @ultoa$qul near + pop dx + pop cx pop ax - pop cx - pop dx - push dx - push cx - push ax ; DX:CX = n + push dx ; AX: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 + ; AX = hi(n)/10 = hi(n/10) + mov [byte bx],'0' + add [bx],dl ; DL = n%10 + mov dx,ax + or dx,cx jnz @@loop xchg ax,bx pop si ret - endp _ultoa + endp @ultoa$qul ;*************************************************************** -;unsigned long kver2ul(char *kernel_version); +;pascal unsigned long kver2ul(char *kernel_version); ;*************************************************************** - global _kver2ul:near - proc _kver2ul near + global @kver2ul$qpzc:near + proc @kver2ul$qpzc near pop bx pop ax - push ax push bx push si xchg ax,si @@ -1381,12 +1349,16 @@ kver2ulret: ret - endp _kver2ul + endp @kver2ul$qpzc + endif ;*************************************************************** ;void try_default_args(); +;pascal void set_cmdline(const char *filename); ;*************************************************************** + ifdef EXTRA + global _try_default_args:near proc _try_default_args near @@ -1395,13 +1367,12 @@ 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 + endif ends _TEXT diff -r 17c0ad41f5bf -r f0d71e920c5a linld/stuff/src/CRTL.H --- a/linld/stuff/src/CRTL.H Thu Nov 08 23:37:09 2018 +0100 +++ b/linld/stuff/src/CRTL.H Fri Nov 09 16:37:55 2018 +0100 @@ -5,6 +5,7 @@ #define MK_FP(seg,ofs) ((void _seg *)(seg) + (void near *)(ofs)) #define FP_SEG(fp) ((unsigned) (void _seg*) (void far*)(fp)) #define FP_OFF(fp) ((unsigned) (fp)) +#define NULL 0 const unsigned MIN_STACK = 0x400; const unsigned MAX_MALLOC = 0xF000; @@ -26,16 +27,16 @@ extern char* heap_top; void parse_cmdline(); -extern "C" char* strcatb(const char* a,const char* b); -extern "C" int strhead(const char* a,const char* b); -extern "C" int fileattr(const char* name); +extern pascal void strcatb(const char* a,const char* b); +extern pascal int strhead(const char* a,const char* head); +extern pascal int fileattr(const char* name); //extern "C" int open(const char* name, int flags); -extern "C" int open(const char* name); -extern "C" int close(int fd); -extern "C" int read(int fd, void* data, int sz); -extern "C" long lseekset(int fd, unsigned long sz); -extern "C" int puts(const char* s); -extern "C" unsigned long strtol(const char *s); +extern pascal int open(const char* name); +extern pascal int close(int fd); +extern pascal int read(int fd, void* data, int sz); +extern pascal long lseekset(int fd, unsigned long sz); +extern pascal int puts(const char* s); +extern pascal unsigned long strtol(const char *s); // Extensions #define cli() do { asm { cli } } while(0) @@ -43,6 +44,9 @@ #define int3() do { asm { db 0cch } } while(0) #define nop() do { asm { db 90h } } while(0) extern char no_exit; -extern "C" int die(const char* msg); -extern "C" char* malloc_or_die(unsigned size); -extern "C" unsigned long* malloc_bufv_or_die(struct image_himem *m); +extern pascal int die(const char* msg); +//extern "C" char* malloc_or_die(unsigned size); +//extern "C" unsigned long* malloc_bufv_or_die(struct image_himem *m); +extern pascal int malloc_or_die(unsigned size); +extern pascal int malloc_bufv_or_die(struct image_himem *m); +extern pascal void set_cmdline(const char *filename); diff -r 17c0ad41f5bf -r f0d71e920c5a linld/stuff/src/CRTLX.H --- a/linld/stuff/src/CRTLX.H Thu Nov 08 23:37:09 2018 +0100 +++ b/linld/stuff/src/CRTLX.H Fri Nov 09 16:37:55 2018 +0100 @@ -1,14 +1,16 @@ // This file is distributed under GPL // -#define NULL 0 -extern "C" char* strcpy(const char* a,const char* b); -extern "C" char* strcat(const char* a,const char* b); -extern "C" int strcmp(const char* a,const char* b); -extern "C" char* strstr(const char* a,const char* b); +extern pascal void strcpy(const char* a,const char* b); +extern pascal void strcat(const char* a,const char* b); +extern pascal int strcmp(const char* a,const char* b); +//extern "C" char* strstr(const char* a,const char* b); +extern pascal int strstr(const char* a,const char* b); extern "C" char *progname(void); -extern "C" void chdirname(char *path); -extern "C" unsigned long kver2ul(char *kernel_version); -extern "C" char *ultoa(unsigned long n); +extern pascal void chdirname(char *path); +extern pascal unsigned long kver2ul(char *kernel_version); +//extern "C" char *ultoa(unsigned long n); +extern pascal int ultoa(unsigned long n); extern "C" void try_default_args(); extern char cpu_features[]; -#define cpuhaslm() (cpu_features[3]&0x20) +#define CPUMASKLM (0x20) +#define cpuhaslm() (cpu_features[3]&CPUMASKLM) diff -r 17c0ad41f5bf -r f0d71e920c5a linld/stuff/src/HIMEM.CPP --- a/linld/stuff/src/HIMEM.CPP Thu Nov 08 23:37:09 2018 +0100 +++ b/linld/stuff/src/HIMEM.CPP Fri Nov 09 16:37:55 2018 +0100 @@ -61,7 +61,7 @@ u32* bufv= &buf; if(((u16 *)&m->fallback)[1] >= 0x10 && !skip_alloc) { // >= _1m ? if(vcpi) { - bufv = malloc_bufv_or_die(m); // update m->bufv + bufv = (u32 *)malloc_bufv_or_die(m); // update m->bufv } else { xmm_alloc(m); // update m->buf diff -r 17c0ad41f5bf -r f0d71e920c5a linld/stuff/src/ISO9660.CPP --- a/linld/stuff/src/ISO9660.CPP Thu Nov 08 23:37:09 2018 +0100 +++ b/linld/stuff/src/ISO9660.CPP Fri Nov 09 16:37:55 2018 +0100 @@ -10,7 +10,7 @@ static int readsector(const unsigned long *offset) { - return (isolseek(offset) != -1 + return (isolseek(offset) != 0 && read(isostate.fd, buffer, sizeof(buffer)) >= SECTORSZ); } @@ -113,7 +113,7 @@ char _64bits = cpuhaslm(); struct isostate *x=&isostate; - retry32: + do { for (s = (char *) filename; *s == '/' ; s++) { isoreset(NULL); } @@ -138,9 +138,6 @@ isolseek(&x->fileofs); return 0; } - if (_64bits) { - _64bits = 0; - goto retry32; - } + } while ((_64bits ^= CPUMASKLM) == 0); return -1; } diff -r 17c0ad41f5bf -r f0d71e920c5a linld/stuff/src/ISO9660.H --- a/linld/stuff/src/ISO9660.H Thu Nov 08 23:37:09 2018 +0100 +++ b/linld/stuff/src/ISO9660.H Fri Nov 09 16:37:55 2018 +0100 @@ -22,7 +22,7 @@ #define isofilesize isostate.filesize #define isofilemod isostate.filemod #define isofilename isostate.filename -extern "C" unsigned long isolseek(const unsigned long *offset); +extern pascal int isolseek(const unsigned long *offset); extern int isoreset(char *name); extern int isoopen(const char *name); extern int isoreaddir(int restart); diff -r 17c0ad41f5bf -r f0d71e920c5a linld/stuff/src/JUMP.ASM --- a/linld/stuff/src/JUMP.ASM Thu Nov 08 23:37:09 2018 +0100 +++ b/linld/stuff/src/JUMP.ASM Fri Nov 09 16:37:55 2018 +0100 @@ -196,9 +196,8 @@ push 1 ; dst ofs hi endif push di ; dst ofs lo : 64k - extrn _memcpy32:near - call _memcpy32 - add sp,14 + extrn memcpy32:near + call memcpy32 ifndef noelks ifndef NO386 diff -r 17c0ad41f5bf -r f0d71e920c5a linld/stuff/src/LINLD.CPP --- a/linld/stuff/src/LINLD.CPP Thu Nov 08 23:37:09 2018 +0100 +++ b/linld/stuff/src/LINLD.CPP Fri Nov 09 16:37:55 2018 +0100 @@ -8,11 +8,12 @@ const char* kernel_name = "bzImage"; const char* initrd_name; const char* cmdline = "auto"; -u16 root_dev; -u16 vid_mode; // -3 = ask - // -2 = Extended VGA - // -1 = Normal VGA - // n = as "n" was pressed +u32 root_dev; +u32 vid_mode; // -3 = ask + // -2 = Extended VGA + // -1 = Normal VGA + // n = as "n" was pressed +u32 topmem; inline void syntax() { die("Syntax:" NL diff -r 17c0ad41f5bf -r f0d71e920c5a linld/stuff/src/LOAD.CPP --- a/linld/stuff/src/LOAD.CPP Thu Nov 08 23:37:09 2018 +0100 +++ b/linld/stuff/src/LOAD.CPP Fri Nov 09 16:37:55 2018 +0100 @@ -140,7 +140,7 @@ { struct first1k_t *first1k; struct kernelparams_t *kernelparams; - kernelparams = &(((first1k_t*) (rm_buf = malloc_or_die(_32k)))->params); + kernelparams = &(((first1k_t*) (rm_buf = (u8 *)malloc_or_die(_32k)))->params); #define first1k ((first1k_t*)((u8 *)kernelparams-0x1F1)) { u16 rm_seek; @@ -177,8 +177,8 @@ // Tell rm loader some info - if(vid_mode) kernelparams->vid_mode = vid_mode; - if(root_dev) kernelparams->root_dev = root_dev; + if((int)vid_mode) kernelparams->vid_mode = vid_mode; + if((int)root_dev) kernelparams->root_dev = root_dev; version_string = ""; #if 1 diff -r 17c0ad41f5bf -r f0d71e920c5a linld/stuff/src/MEMCPY32.ASM --- a/linld/stuff/src/MEMCPY32.ASM Thu Nov 08 23:37:09 2018 +0100 +++ b/linld/stuff/src/MEMCPY32.ASM Fri Nov 09 16:37:55 2018 +0100 @@ -21,8 +21,8 @@ ;*************************************************************** ;****** Uses: Flags ;*************************************************************** - global _memcpy32:near - proc _memcpy32 near + global memcpy32:near + proc memcpy32 near ; rm32,imm16 helper macro addzx_e rm,i @@ -91,9 +91,8 @@ xor si,si mov ax,[srcseg] xor dx,dx - mov cl,4 - extrn N_LXLSH@:near - call near N_LXLSH@ + extrn N_LXLSH@4:near + call near ptr N_LXLSH@4 add [word srcofs],ax adc [word srcofs+2],dx @@2flat: @@ -213,7 +212,7 @@ mov sp,bp pop bp endif - ret + ret 14 ;****** Const data ********************************************* org $-8 ;save 8 bytes - they are unused anyway @@ -226,7 +225,7 @@ ; base_med P S D A G ??l_hi base_hi ; Pl E W D - endp _memcpy32 + endp memcpy32 ends _TEXT diff -r 17c0ad41f5bf -r f0d71e920c5a linld/stuff/src/MEMTOP.ASM --- a/linld/stuff/src/MEMTOP.ASM Thu Nov 08 23:37:09 2018 +0100 +++ b/linld/stuff/src/MEMTOP.ASM Fri Nov 09 16:37:55 2018 +0100 @@ -90,6 +90,10 @@ shld dx,ax,cl shl ax,cl ; (kbytes -> bytes) else + db 0A9h ; test ax,04B1h + global N_LXLSH@4:near +N_LXLSH@4: + mov cl,4 global N_LXLSH@:near N_LXLSH@: mov ch,0 @@ -153,7 +157,11 @@ cmp dx,cx jb @@set extrn _topmem:dword - mov cx,[word _topmem+2] ; max 256m ? + mov cx,[word _topmem+2] + inc cx ; jcxnz + loop @@topmemset + mov ch,10h ; default = max 256m +@@topmemset: ; Kernel can have trouble with initrd at very high addr: ; limit mem top to 256m cmp dh,ch diff -r 17c0ad41f5bf -r f0d71e920c5a linld/stuff/src/TAZBOOT.CPP --- a/linld/stuff/src/TAZBOOT.CPP Thu Nov 08 23:37:09 2018 +0100 +++ b/linld/stuff/src/TAZBOOT.CPP Fri Nov 09 16:37:55 2018 +0100 @@ -129,7 +129,7 @@ if (isoopen(initrdfilename) >= 0) { addinitrd(); } - if (*init && isolseek(&initrddesc) != -1) { + if (*init && isolseek(&initrddesc) != 0) { read(x->fd, &x->filemod, 10); // + x->fileofs & x->filesize magic = x->filemod; x->fileofs &= 0xFFFFL; @@ -143,7 +143,7 @@ strcatb(buf_cmdline,"mode="); strcat(buf_cmdline,mode); strcatb(buf_cmdline,"magic="); - strcat(buf_cmdline,ultoa(magic)); + strcat(buf_cmdline,(char *)ultoa(magic)); } load_initrds(); if (isknoppix) { @@ -157,13 +157,15 @@ boot_kernel(); } -u16 root_dev; -u16 vid_mode; +u32 root_dev; +u32 vid_mode; +u32 topmem; const char* kernel_name = "bzImage"; const char* initrd_name; +char* iso; + int main(int argc, char *argv[]) { - char *iso = NULL; argv[0] = progname(); bootiso(argv); // iso ? parsing is /init.exe stuff ! diff -r 17c0ad41f5bf -r f0d71e920c5a linld/stuff/src/XMM.ASM --- a/linld/stuff/src/XMM.ASM Thu Nov 08 23:37:09 2018 +0100 +++ b/linld/stuff/src/XMM.ASM Fri Nov 09 16:37:55 2018 +0100 @@ -93,16 +93,15 @@ ends ;}; ;*************************************************************** -;void xmm_alloc(struct image_himem *m) +;pascal void xmm_alloc(struct image_himem *m) ;*************************************************************** - global _xmm_alloc:near - proc _xmm_alloc near + global @xmm_alloc$qp11image_himem:near + proc @xmm_alloc$qp11image_himem near - ret ; TO BE FIXED pop ax pop bx - push bx push ax + ret ; TO BE FIXED ifndef NO386 mov edx,[(image_himem bx).size] ; m->size ;dec edx @@ -138,7 +137,7 @@ @@err: ret - endp _xmm_alloc + endp @xmm_alloc$qp11image_himem ends _TEXT diff -r 17c0ad41f5bf -r f0d71e920c5a linld/stuff/src/_BEG.ASM --- a/linld/stuff/src/_BEG.ASM Thu Nov 08 23:37:09 2018 +0100 +++ b/linld/stuff/src/_BEG.ASM Fri Nov 09 16:37:55 2018 +0100 @@ -21,9 +21,7 @@ endif global _vcpi:byte _vcpi db 0 -msg_badmapping db "VCPI: low 640k need 1:1 mapping" - global _topmem:dword -_topmem dd 10000000h ; max 256m +msg_badmapping db "VCPI: low 640k need 1:1 mapping",0 ends _DATA @@ -230,25 +228,22 @@ push bx ; argc ifndef filearg mov bx,[di+2] ; argv[1] - cmp [byte bx],'@' - jne argend - inc bx - extrn open:near - call near open + extrn openargs:near + call near openargs jc argend pop bx ; trash argc, argv >> 1Kb ! - ifdef EXTRA global read_cmdline:near - endif + pop cx ; sizemax=argv read_cmdline: - push di + mov dx,di + push dx push ax - extrn _read:near - call near _read + xchg ax,bx + extrn @read$cxdxbx:near ; read(fd=bx,buffer=dx,size=cx) + call near @read$cxdxbx pop bx ; fd for close pop si ; si=buffer=argv add di,ax - pop ax ; trash sizemax=argv extrn close:near call near close jmp argbuild diff -r 17c0ad41f5bf -r f0d71e920c5a linld/stuff/src/pipehole.awk --- a/linld/stuff/src/pipehole.awk Thu Nov 08 23:37:09 2018 +0100 +++ b/linld/stuff/src/pipehole.awk Fri Nov 09 16:37:55 2018 +0100 @@ -59,6 +59,11 @@ print " call near ptr N_LXURSH@4" next } + if (/^ call near ptr N_LXLSH@$/) { + print " extrn N_LXLSH@4:near" + print " call near ptr N_LXLSH@4" + next + } print s } s=$0