mirror of https://github.com/FDOS/kernel.git
Use the pascal calling convention for most intr.asm functions, and let
them pop the stack (smaller code than using bx). Tell Watcom which registers are clobbered; save some more registers for intr() -- especially for intr() this helps. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@849 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
parent
a7ca14c46c
commit
950078ad08
|
@ -44,6 +44,7 @@ extern struct _KernelConfig InitKernelConfig;
|
||||||
#define strcpy init_strcpy
|
#define strcpy init_strcpy
|
||||||
#define strlen init_strlen
|
#define strlen init_strlen
|
||||||
#define fstrlen init_fstrlen
|
#define fstrlen init_fstrlen
|
||||||
|
#define open init_DosOpen
|
||||||
|
|
||||||
/* execrh.asm */
|
/* execrh.asm */
|
||||||
WORD ASMPASCAL execrh(request FAR *, struct dhdr FAR *);
|
WORD ASMPASCAL execrh(request FAR *, struct dhdr FAR *);
|
||||||
|
@ -133,18 +134,32 @@ unsigned ebdasize(void);
|
||||||
|
|
||||||
/* intr.asm */
|
/* intr.asm */
|
||||||
|
|
||||||
void ASMCFUNC init_call_intr(int nr, iregs * rp);
|
unsigned ASMPASCAL init_call_intr(int nr, iregs * rp);
|
||||||
UCOUNT ASMCFUNC read(int fd, void *buf, UCOUNT count);
|
unsigned ASMPASCAL read(int fd, void *buf, unsigned count);
|
||||||
int ASMCFUNC open(const char *pathname, int flags);
|
int ASMPASCAL open(const char *pathname, int flags);
|
||||||
int ASMCFUNC close(int fd);
|
int ASMPASCAL close(int fd);
|
||||||
int ASMCFUNC dup2(int oldfd, int newfd);
|
int ASMPASCAL dup2(int oldfdk, int newfd);
|
||||||
int ASMCFUNC allocmem(UWORD size, seg * segp);
|
int ASMPASCAL allocmem(UWORD size, seg * segp);
|
||||||
VOID ASMCFUNC init_PSPSet(seg psp_seg);
|
void ASMPASCAL init_PSPSet(seg psp_seg);
|
||||||
COUNT ASMCFUNC init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp);
|
int ASMPASCAL init_DosExec(int mode, exec_blk * ep, char * lp);
|
||||||
int ASMCFUNC init_setdrive(int drive);
|
int ASMPASCAL init_setdrive(int drive);
|
||||||
int ASMCFUNC init_switchar(int chr);
|
int ASMPASCAL init_switchar(int chr);
|
||||||
VOID ASMCFUNC keycheck(VOID);
|
void ASMPASCAL keycheck(void);
|
||||||
void ASMCFUNC set_DTA(void far *dta);
|
void ASMPASCAL set_DTA(void far *dta);
|
||||||
|
#ifdef __WATCOMC__
|
||||||
|
#pragma aux (pascal) init_call_intr modify exact [ax]
|
||||||
|
#pragma aux (pascal) read modify exact [ax bx cx dx]
|
||||||
|
#pragma aux (pascal) init_DosOpen modify exact [ax bx dx]
|
||||||
|
#pragma aux (pascal) close modify exact [ax bx]
|
||||||
|
#pragma aux (pascal) dup2 modify exact [ax bx cx]
|
||||||
|
#pragma aux (pascal) allocmem modify exact [ax bx dx]
|
||||||
|
#pragma aux (pascal) init_PSPSet modify exact [ax bx]
|
||||||
|
#pragma aux (pascal) init_DosExec modify exact [ax bx dx es]
|
||||||
|
#pragma aux (pascal) init_setdrive modify exact [ax bx dx]
|
||||||
|
#pragma aux (pascal) init_switchar modify exact [ax bx dx]
|
||||||
|
#pragma aux (pascal) keycheck modify exact [ax]
|
||||||
|
#pragma aux (pascal) set_DTA modify exact [ax bx dx]
|
||||||
|
#endif
|
||||||
|
|
||||||
/* irqstack.asm */
|
/* irqstack.asm */
|
||||||
VOID ASMCFUNC init_stacks(VOID FAR * stack_base, COUNT nStacks,
|
VOID ASMCFUNC init_stacks(VOID FAR * stack_base, COUNT nStacks,
|
||||||
|
|
191
kernel/intr.asm
191
kernel/intr.asm
|
@ -33,13 +33,18 @@
|
||||||
mov bp,sp
|
mov bp,sp
|
||||||
push si
|
push si
|
||||||
push di
|
push di
|
||||||
push ds
|
%ifdef WATCOM
|
||||||
|
push bx
|
||||||
|
push cx
|
||||||
|
push dx
|
||||||
push es
|
push es
|
||||||
|
%endif
|
||||||
|
push ds
|
||||||
|
|
||||||
mov ax, [bp+4] ; interrupt number
|
mov ax, [bp+6] ; interrupt number
|
||||||
mov [cs:%%intr_1-1], al
|
mov [cs:%%intr_1-1], al
|
||||||
jmp short %%intr_2 ; flush the instruction cache
|
jmp short %%intr_2 ; flush the instruction cache
|
||||||
%%intr_2 mov bx, [bp+6] ; regpack structure
|
%%intr_2 mov bx, [bp+4] ; regpack structure
|
||||||
mov ax, [bx]
|
mov ax, [bx]
|
||||||
mov cx, [bx+4]
|
mov cx, [bx+4]
|
||||||
mov dx, [bx+6]
|
mov dx, [bx+6]
|
||||||
|
@ -57,8 +62,12 @@
|
||||||
push ds
|
push ds
|
||||||
push bx
|
push bx
|
||||||
mov bx, sp
|
mov bx, sp
|
||||||
mov ds, [ss:bx+8]
|
mov ds, [ss:bx+6]
|
||||||
mov bx, [ss:bx+20] ; address of REGPACK
|
%ifdef WATCOM
|
||||||
|
mov bx, [ss:bx+24] ; address of REGPACK
|
||||||
|
%else
|
||||||
|
mov bx, [ss:bx+16] ; address of REGPACK
|
||||||
|
%endif
|
||||||
mov [bx], ax
|
mov [bx], ax
|
||||||
pop word [bx+2]
|
pop word [bx+2]
|
||||||
mov [bx+4], cx
|
mov [bx+4], cx
|
||||||
|
@ -70,39 +79,46 @@
|
||||||
mov [bx+16], es
|
mov [bx+16], es
|
||||||
pop word [bx+22]
|
pop word [bx+22]
|
||||||
|
|
||||||
pop es
|
|
||||||
pop ds
|
pop ds
|
||||||
|
%ifdef WATCOM
|
||||||
|
pop es
|
||||||
|
pop dx
|
||||||
|
pop cx
|
||||||
|
pop bx
|
||||||
|
%endif
|
||||||
pop di
|
pop di
|
||||||
pop si
|
pop si
|
||||||
pop bp
|
pop bp
|
||||||
ret
|
ret 4
|
||||||
%endmacro
|
%endmacro
|
||||||
|
|
||||||
segment HMA_TEXT
|
segment HMA_TEXT
|
||||||
|
|
||||||
;; COUNT ASMCFUNC res_DosExec(COUNT mode, exec_blk * ep, BYTE * lp)
|
;; COUNT ASMPASCAL res_DosExec(COUNT mode, exec_blk * ep, BYTE * lp)
|
||||||
global _res_DosExec
|
global RES_DOSEXEC
|
||||||
_res_DosExec:
|
RES_DOSEXEC:
|
||||||
|
pop es ; ret address
|
||||||
|
pop dx ; filename
|
||||||
|
pop bx ; exec block
|
||||||
|
pop ax ; mode
|
||||||
|
push es ; ret address
|
||||||
mov ah, 4bh
|
mov ah, 4bh
|
||||||
mov bx, sp
|
|
||||||
mov al, [bx+2]
|
|
||||||
push ds
|
push ds
|
||||||
pop es
|
pop es ; es = ds
|
||||||
mov dx, [bx+6] ; filename
|
|
||||||
mov bx, [bx+4] ; exec block
|
|
||||||
int 21h
|
int 21h
|
||||||
jc short no_exec_error
|
jc short no_exec_error
|
||||||
xor ax, ax
|
xor ax, ax
|
||||||
no_exec_error:
|
no_exec_error:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;; UCOUNT ASMCFUNC res_read(int fd, void *buf, UCOUNT count);
|
;; UCOUNT ASMPASCAL res_read(int fd, void *buf, UCOUNT count);
|
||||||
global _res_read
|
global RES_READ
|
||||||
_res_read:
|
RES_READ:
|
||||||
mov bx, sp
|
pop ax ; ret address
|
||||||
mov cx, [bx+6]
|
pop cx ; count
|
||||||
mov dx, [bx+4]
|
pop dx ; buf
|
||||||
mov bx, [bx+2]
|
pop bx ; fd
|
||||||
|
push ax ; ret address
|
||||||
mov ah, 3fh
|
mov ah, 3fh
|
||||||
int 21h
|
int 21h
|
||||||
jnc no_read_error
|
jnc no_read_error
|
||||||
|
@ -116,8 +132,8 @@ segment INIT_TEXT
|
||||||
; REG int nr
|
; REG int nr
|
||||||
; REG struct REGPACK *rp
|
; REG struct REGPACK *rp
|
||||||
;
|
;
|
||||||
global _init_call_intr
|
global INIT_CALL_INTR
|
||||||
_init_call_intr:
|
INIT_CALL_INTR:
|
||||||
INTR
|
INTR
|
||||||
|
|
||||||
;
|
;
|
||||||
|
@ -161,25 +177,25 @@ detected:
|
||||||
pop es
|
pop es
|
||||||
ret
|
ret
|
||||||
|
|
||||||
global _keycheck
|
global KEYCHECK
|
||||||
_keycheck:
|
KEYCHECK:
|
||||||
mov ah, 1
|
mov ah, 1
|
||||||
int 16h
|
int 16h
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;; int open(const char *pathname, int flags);
|
;; int open(const char *pathname, int flags);
|
||||||
global _open
|
global INIT_DOSOPEN
|
||||||
_open:
|
INIT_DOSOPEN:
|
||||||
;; first implementation of init calling DOS through ints:
|
;; init calling DOS through ints:
|
||||||
mov bx, sp
|
pop bx ; ret address
|
||||||
|
pop ax ; flags
|
||||||
|
pop dx ; pathname
|
||||||
|
push bx ; ret address
|
||||||
mov ah, 3dh
|
mov ah, 3dh
|
||||||
;; we know that SS=DS during init stage.
|
;; AX will have the file handle
|
||||||
mov al, [bx+4]
|
|
||||||
mov dx, [bx+2]
|
|
||||||
int 21h
|
|
||||||
;; AX has file handle
|
|
||||||
|
|
||||||
common_exit:
|
common_int21:
|
||||||
|
int 21h
|
||||||
jnc common_no_error
|
jnc common_no_error
|
||||||
common_error:
|
common_error:
|
||||||
mov ax, -1
|
mov ax, -1
|
||||||
|
@ -187,54 +203,56 @@ common_no_error:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;; int close(int fd);
|
;; int close(int fd);
|
||||||
global _close
|
global CLOSE
|
||||||
_close:
|
CLOSE:
|
||||||
mov bx, sp
|
pop ax ; ret address
|
||||||
mov bx, [bx+2]
|
pop bx ; fd
|
||||||
|
push ax ; ret address
|
||||||
mov ah, 3eh
|
mov ah, 3eh
|
||||||
int 21h
|
jmp short common_int21
|
||||||
jmp short common_exit
|
|
||||||
|
|
||||||
;; UCOUNT read(int fd, void *buf, UCOUNT count);
|
;; UCOUNT read(int fd, void *buf, UCOUNT count);
|
||||||
global _read
|
global READ
|
||||||
_read:
|
READ:
|
||||||
mov bx, sp
|
pop ax ; ret address
|
||||||
mov cx, [bx+6]
|
pop cx ; count
|
||||||
mov dx, [bx+4]
|
pop dx ; buf
|
||||||
mov bx, [bx+2]
|
pop bx ; fd
|
||||||
|
push ax ; ret address
|
||||||
mov ah, 3fh
|
mov ah, 3fh
|
||||||
int 21h
|
jmp short common_int21
|
||||||
jmp short common_exit
|
|
||||||
|
|
||||||
;; int dup2(int oldfd, int newfd);
|
;; int dup2(int oldfd, int newfd);
|
||||||
global _dup2
|
global DUP2
|
||||||
_dup2:
|
DUP2:
|
||||||
mov bx, sp
|
pop ax ; ret address
|
||||||
mov cx, [bx+4]
|
pop cx ; newfd
|
||||||
mov bx, [bx+2]
|
pop bx ; oldfd
|
||||||
|
push ax ; ret address
|
||||||
mov ah, 46h
|
mov ah, 46h
|
||||||
int 21h
|
jmp short common_int21
|
||||||
jmp short common_exit
|
|
||||||
|
|
||||||
;; VOID init_PSPSet(seg psp_seg)
|
;; VOID init_PSPSet(seg psp_seg)
|
||||||
global _init_PSPSet
|
global INIT_PSPSET
|
||||||
_init_PSPSet:
|
INIT_PSPSET:
|
||||||
|
pop ax ; ret address
|
||||||
|
pop bx ; psp_seg
|
||||||
|
push ax ; ret_address
|
||||||
mov ah, 50h
|
mov ah, 50h
|
||||||
mov bx, sp
|
|
||||||
mov bx, [bx+2]
|
|
||||||
int 21h
|
int 21h
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;; COUNT init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp)
|
;; COUNT init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp)
|
||||||
global _init_DosExec
|
global INIT_DOSEXEC
|
||||||
_init_DosExec:
|
INIT_DOSEXEC:
|
||||||
|
pop es ; ret address
|
||||||
|
pop dx ; filename
|
||||||
|
pop bx ; exec block
|
||||||
|
pop ax ; mode
|
||||||
|
push es ; ret address
|
||||||
mov ah, 4bh
|
mov ah, 4bh
|
||||||
mov bx, sp
|
|
||||||
mov al, [bx+2]
|
|
||||||
push ds
|
push ds
|
||||||
pop es
|
pop es ; es = ds
|
||||||
mov dx, [bx+6] ; filename
|
|
||||||
mov bx, [bx+4] ; exec block
|
|
||||||
int 21h
|
int 21h
|
||||||
jc short exec_no_error
|
jc short exec_no_error
|
||||||
xor ax, ax
|
xor ax, ax
|
||||||
|
@ -242,42 +260,47 @@ exec_no_error:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;; int init_setdrive(int drive)
|
;; int init_setdrive(int drive)
|
||||||
global _init_setdrive
|
global INIT_SETDRIVE
|
||||||
_init_setdrive:
|
INIT_SETDRIVE:
|
||||||
mov ah, 0x0e
|
mov ah, 0x0e
|
||||||
common_dl_int21:
|
common_dl_int21:
|
||||||
mov bx, sp
|
pop bx ; ret address
|
||||||
mov dl, [bx+2]
|
pop dx ; drive/char
|
||||||
|
push bx
|
||||||
int 21h
|
int 21h
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;; int init_switchar(int char)
|
;; int init_switchar(int char)
|
||||||
global _init_switchar
|
global INIT_SWITCHAR
|
||||||
_init_switchar:
|
INIT_SWITCHAR:
|
||||||
mov ax, 0x3701
|
mov ax, 0x3701
|
||||||
jmp short common_dl_int21
|
jmp short common_dl_int21
|
||||||
|
|
||||||
;; int allocmem(UWORD size, seg *segp)
|
;; int allocmem(UWORD size, seg *segp)
|
||||||
global _allocmem
|
global ALLOCMEM
|
||||||
_allocmem:
|
ALLOCMEM:
|
||||||
|
pop ax ; ret address
|
||||||
|
pop dx ; segp
|
||||||
|
pop bx ; size
|
||||||
|
push ax ; ret address
|
||||||
mov ah, 48h
|
mov ah, 48h
|
||||||
mov bx, sp
|
|
||||||
mov bx, [bx+2]
|
|
||||||
int 21h
|
int 21h
|
||||||
jc short common_error
|
jc short common_error
|
||||||
mov bx, sp
|
mov bx, dx ; segp
|
||||||
mov bx, [bx+4]
|
|
||||||
mov [bx], ax
|
mov [bx], ax
|
||||||
xor ax, ax
|
xor ax, ax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;; void set_DTA(void far *dta)
|
;; void set_DTA(void far *dta)
|
||||||
global _set_DTA
|
global SET_DTA
|
||||||
_set_DTA
|
SET_DTA:
|
||||||
|
pop ax ; ret address
|
||||||
|
pop bx ; seg(dta)
|
||||||
|
pop dx ; off(dta)
|
||||||
|
push ax ; ret address
|
||||||
mov ah, 1ah
|
mov ah, 1ah
|
||||||
mov bx, sp
|
|
||||||
push ds
|
push ds
|
||||||
lds dx, [bx+2]
|
mov ds, bx
|
||||||
int 21h
|
int 21h
|
||||||
pop ds
|
pop ds
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -123,6 +123,9 @@ COUNT DosTruename(const char FAR * src, char FAR * dest);
|
||||||
|
|
||||||
/*dosidle.asm */
|
/*dosidle.asm */
|
||||||
VOID ASMCFUNC DosIdle_int(void);
|
VOID ASMCFUNC DosIdle_int(void);
|
||||||
|
#ifdef __WATCOMC__
|
||||||
|
#pragma aux (cdecl) DosIdle_int modify exact []
|
||||||
|
#endif
|
||||||
|
|
||||||
/* dosnames.c */
|
/* dosnames.c */
|
||||||
int ParseDosName(const char *, char *, BOOL);
|
int ParseDosName(const char *, char *, BOOL);
|
||||||
|
@ -222,8 +225,12 @@ void FcbCloseAll(void);
|
||||||
UBYTE FcbFindFirstNext(xfcb FAR * lpXfcb, BOOL First);
|
UBYTE FcbFindFirstNext(xfcb FAR * lpXfcb, BOOL First);
|
||||||
|
|
||||||
/* intr.asm */
|
/* intr.asm */
|
||||||
COUNT ASMCFUNC res_DosExec(COUNT mode, exec_blk * ep, BYTE * lp);
|
COUNT ASMPASCAL res_DosExec(COUNT mode, exec_blk * ep, BYTE * lp);
|
||||||
UCOUNT ASMCFUNC res_read(int fd, void *buf, UCOUNT count);
|
UCOUNT ASMPASCAL res_read(int fd, void *buf, UCOUNT count);
|
||||||
|
#ifdef __WATCOMC__
|
||||||
|
#pragma aux (pascal) res_DosExec modify exact [ax bx dx es]
|
||||||
|
#pragma aux (pascal) res_read modify exact [ax bx cx dx]
|
||||||
|
#endif
|
||||||
|
|
||||||
/* ioctl.c */
|
/* ioctl.c */
|
||||||
COUNT DosDevIOctl(lregs * r);
|
COUNT DosDevIOctl(lregs * r);
|
||||||
|
@ -398,6 +405,35 @@ COUNT ASMCFUNC remote_printredir(UCOUNT dx, UCOUNT ax);
|
||||||
COUNT ASMCFUNC remote_commit(sft FAR * s);
|
COUNT ASMCFUNC remote_commit(sft FAR * s);
|
||||||
COUNT ASMCFUNC remote_close(sft FAR * s);
|
COUNT ASMCFUNC remote_close(sft FAR * s);
|
||||||
COUNT ASMCFUNC QRemote_Fn(char FAR * d, const char FAR * s);
|
COUNT ASMCFUNC QRemote_Fn(char FAR * d, const char FAR * s);
|
||||||
|
#ifdef __WATCOMC__
|
||||||
|
/* bx, cx, and es not used or clobbered for all remote functions,
|
||||||
|
* except lock_unlock and process_end */
|
||||||
|
#pragma aux cdecl_axdx "_*" parm caller [] modify exact [ax dx]
|
||||||
|
#pragma aux (cdecl_axdx) remote_doredirect
|
||||||
|
#pragma aux (cdecl_axdx) remote_printset
|
||||||
|
#pragma aux (cdecl_axdx) remote_rename
|
||||||
|
#pragma aux (cdecl_axdx) remote_delete
|
||||||
|
#pragma aux (cdecl_axdx) remote_chdir
|
||||||
|
#pragma aux (cdecl_axdx) remote_mkdir
|
||||||
|
#pragma aux (cdecl_axdx) remote_rmdir
|
||||||
|
#pragma aux (cdecl_axdx) remote_close_all
|
||||||
|
#pragma aux (cdecl_axdx) remote_flushall
|
||||||
|
#pragma aux (cdecl_axdx) remote_findfirst
|
||||||
|
#pragma aux (cdecl_axdx) remote_findnext
|
||||||
|
#pragma aux (cdecl_axdx) remote_getfattr
|
||||||
|
#pragma aux (cdecl_axdx) remote_getfree
|
||||||
|
#pragma aux (cdecl_axdx) remote_open
|
||||||
|
#pragma aux (cdecl_axdx) remote_extopen
|
||||||
|
#pragma aux (cdecl_axdx) remote_lseek
|
||||||
|
#pragma aux (cdecl_axdx) remote_read
|
||||||
|
#pragma aux (cdecl_axdx) remote_write
|
||||||
|
#pragma aux (cdecl_axdx) remote_creat
|
||||||
|
#pragma aux (cdecl_axdx) remote_setfattr
|
||||||
|
#pragma aux (cdecl_axdx) remote_printredir
|
||||||
|
#pragma aux (cdecl_axdx) remote_commit
|
||||||
|
#pragma aux (cdecl_axdx) remote_close
|
||||||
|
#pragma aux (cdecl_axdx) QRemote_Fn
|
||||||
|
#endif
|
||||||
|
|
||||||
UWORD get_machine_name(BYTE FAR * netname);
|
UWORD get_machine_name(BYTE FAR * netname);
|
||||||
VOID set_machine_name(BYTE FAR * netname, UWORD name_num);
|
VOID set_machine_name(BYTE FAR * netname, UWORD name_num);
|
||||||
|
|
Loading…
Reference in New Issue