Third stage for int2f callers: split int2f.asm functions, don't let them

preserve as many registers, use pascal calling convention for the
"open" (but really: multiplex) function.


git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@892 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2004-04-21 00:53:45 +00:00
parent ebbd6b8336
commit 4dc4ae8be8
4 changed files with 104 additions and 148 deletions

View File

@ -233,7 +233,8 @@ long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode)
lpCurSft = s;
current_filepos = s->sft_posit; /* needed for MSCDEX */
dta = bp;
XferCount = (mode == XFR_READ ? remote_read : remote_write)(s, n, &err);
XferCount = network_redirector_rw(mode == XFR_READ ? REM_READ : REM_WRITE,
s, n, &err);
dta = save_dta;
return err == SUCCESS ? (long)XferCount : err;
}
@ -546,22 +547,26 @@ long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib)
if (result & IS_NETWORK)
{
int status;
unsigned cmd;
if ((flags & (O_TRUNC | O_CREAT)) == O_CREAT)
attrib |= 0x100;
lpCurSft = sftp;
cmd = REM_CREATE;
if (!(flags & O_LEGACY))
{
extern UWORD ASM ext_open_mode, ASM ext_open_attrib, ASM ext_open_action;
ext_open_mode = flags & 0x70ff;
ext_open_attrib = attrib & 0xff;
ext_open_action = ((flags & 0x0300) >> 8) | ((flags & O_CREAT) >> 6);
status = remote_extopen(sftp, attrib);
cmd = REM_EXTOC;
}
else if (flags & O_CREAT)
status = remote_creat(sftp, attrib);
else
status = remote_open(sftp, (BYTE)flags);
else if (!(flags & O_CREAT))
{
cmd = REM_OPEN;
attrib = (BYTE)flags;
}
status = network_redirector_open(cmd, sftp, attrib);
if (status >= SUCCESS)
{
if (sftp->sft_count == 0)

View File

@ -271,109 +271,66 @@ SHARE_LOCK_UNLOCK:
;
; assume ss == ds after setup of stack in entry
; sumtimes return data *ptr is the push stack word
;
;
global NETWORK_REDIRECTOR_FP
NETWORK_REDIRECTOR_FP:
global _remote_printredir
_remote_printredir:
push bp
mov bp, sp
mov al, [bp+8]
pop bp
call call_int2f
ret 6
global _remote_read
_remote_read: mov al, 08h
jmp short call_int2f
global _remote_write
_remote_write: mov al, 09h
jmp short call_int2f
global _remote_getfree
_remote_getfree:
mov al, 0ch
jmp short call_int2f
mov bp,sp
push si
push di
mov ax, 1125h
mov dx, [bp+4]
push word [bp+6]
jmp short int2f_call
global _remote_setfattr
_remote_setfattr:
mov al, 0eh
jmp short call_int2f
global _remote_open
_remote_open:
mov al, 16h
jmp short call_int2f
global _remote_creat
_remote_creat:
mov al, 17h
jmp short call_int2f
global _remote_doredirect
_remote_doredirect:
mov al, 1eh
jmp short call_int2f
global _remote_printset
_remote_printset:
mov al, 1fh
jmp short call_int2f
push bp
mov bp,sp
push si
push di
mov ax, 110eh
push word [bp+4]
jmp short int2f_call
global _remote_lseek
_remote_lseek:
mov al, 21h
jmp short call_int2f
global _QRemote_Fn
_QRemote_Fn
mov al, 23h
jmp short call_int2f
global _remote_printredir
_remote_printredir:
mov al, 25h
jmp short call_int2f
global _remote_extopen
_remote_extopen:
mov al, 2eh
call_int2f:
mov ah, 11h
push bp
mov bp,sp
push es
push si
push di
push cx
push bx
cmp al, 0eh
je remote_setfattr
mov ax, 1121h ; 21h, Lseek from eof
les di, [bp+4]
mov dx, [bp+8]
mov cx, [bp+10]
; "fall through"
remote_getfattr:
clc ; set to succeed
int 2fh
jc no_clear_ax
jmp short no_neg_ax
;int ASMPASCAL network_redirector_open(unsigned cmd, void far *s, unsigned arg)
global NETWORK_REDIRECTOR_OPEN
NETWORK_REDIRECTOR_OPEN:
pop bx ; ret address
pop cx ; stack value (arg)
pop dx ; off s
pop es ; seg s
pop ax ; cmd (ax)
push bx ; ret address
call_int2f:
push bp
push si
push di
mov di, dx ; es:di -> s
cmp al, 0fh
je remote_getfattr
cmp al, 1eh
je print_doredir
cmp al, 1fh
je print_doredir
cmp al, 25h
je remote_printredir
push cx ; arg
les di, [bp+4]
cmp al, 08h
je remote_rw
cmp al, 09h
je remote_rw
cmp al, 0ch
je remote_getfree
cmp al, 21h ; 21h, Lseek from eof
je lseekeof
cmp al, 23h
je qremote_fn
int2f_call_push:
push word [bp+8] ; very fakey, HaHa ;)
int2f_call:
xor cx, cx ; set to succeed; clear carry and CX
int 2fh
@ -386,31 +343,26 @@ clear_ax:
xchg ax, cx ; extended open -> status from CX in AX
; otherwise CX was set to zero above
no_neg_ax:
pop bx
pop cx
pop di
pop si
pop es
pop bp
ret
lseekeof:
mov dx, [bp+8]
mov cx, [bp+10]
; "fall through"
remote_getfattr:
clc ; set to succeed
int 2fh
jc no_clear_ax
jmp short no_neg_ax
remote_setfattr:
push word [bp+4]
jmp short int2f_call
global _remote_doredirect
_remote_doredirect:
mov al, 1eh
jmp short print_doredir
global _remote_printset
_remote_printset:
mov al, 1fh
print_doredir:
push bp
mov bp,sp
push si
push di
push ds
mov ah, 11h
mov si,[bp+14]
les di,[bp+10]
mov dx,[bp+8]
@ -427,7 +379,14 @@ print_doredir:
xor cx, cx
jmp short clear_ax
remote_getfree:
global _remote_getfree
_remote_getfree:
push bp
mov bp,sp
push si
push di
mov ax, 110ch
les di, [bp+4]
clc ; set to succeed
int 2fh
jc no_clear_ax
@ -439,15 +398,15 @@ remote_getfree:
xor cx, cx
jmp short clear_ax
remote_printredir:
mov dx, [bp+4]
push word [bp+6]
jmp short int2f_call
remote_rw: jmp short remote_rw1
qremote_fn:
global _QRemote_Fn
_QRemote_Fn:
push bp
mov bp,sp
push si
push di
push ds
mov ax, 1123h
les di, [bp+4]
lds si,[bp+8]
clc
int 2fh
@ -457,13 +416,21 @@ qremote_fn:
xor cx, cx
jmp short clear_ax
remote_rw1: mov cx, [bp+8]
global _network_redirector_rw
_network_redirector_rw:
push bp
mov bp, sp
push si
push di
mov ax, [bp+4]
les di, [bp+6]
mov cx, [bp+10]
clc ; set to succeed
int 2fh
jc int2f_carry
xor ax, ax
int2f_carry: neg ax
mov di, [bp+10]
mov di, [bp+12]
mov [di], ax
mov ax, cx
jmp no_neg_ax
@ -471,7 +438,7 @@ int2f_carry: neg ax
global _remote_process_end
_remote_process_end: ; Terminate process
mov ds, [_cu_psp]
mov al, 22h
mov ax, 1122h
call call_int2f
push ss
pop ds

View File

@ -51,8 +51,12 @@ VOID set_machine_name(BYTE FAR * netname, UWORD name_num)
net_set_count++;
}
int network_redirector_fp(unsigned cmd, void far *s)
{
return network_redirector_open(cmd, s, 0);
}
int network_redirector(unsigned cmd)
{
return network_redirector_fp(cmd, NULL);
}

View File

@ -380,40 +380,20 @@ COUNT truename(const char FAR * src, char * dest, COUNT t);
/* network.c */
int network_redirector(unsigned cmd);
int ASMPASCAL network_redirector_fp(unsigned cmd, void far *s);
int network_redirector_fp(unsigned cmd, void far *s);
int ASMPASCAL network_redirector_open(unsigned cmd, void far *s, unsigned arg);
unsigned ASMCFUNC network_redirector_rw(unsigned cmd, void far *s,
unsigned n, int *err);
COUNT ASMCFUNC remote_doredirect(UWORD b, UCOUNT n, UWORD d, VOID FAR * s,
UWORD i, VOID FAR * data);
COUNT ASMCFUNC remote_printset(UWORD b, UCOUNT n, UWORD d, VOID FAR * s,
UWORD i, VOID FAR * data);
COUNT ASMCFUNC remote_process_end(VOID);
COUNT ASMCFUNC remote_getfree(VOID FAR * s, VOID * d);
COUNT ASMCFUNC remote_open(sft FAR * s, COUNT mode);
int ASMCFUNC remote_extopen(sft FAR * s, unsigned attr);
LONG ASMCFUNC remote_lseek(sft FAR * s, LONG new_pos);
UCOUNT ASMCFUNC remote_read(sft FAR * s, UCOUNT n, COUNT * err);
UCOUNT ASMCFUNC remote_write(sft FAR * s, UCOUNT n, COUNT * err);
COUNT ASMCFUNC remote_creat(sft FAR * s, COUNT attr);
COUNT ASMCFUNC remote_setfattr(COUNT attr);
COUNT ASMCFUNC remote_printredir(UCOUNT dx, UCOUNT ax);
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_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) QRemote_Fn
#pragma aux (pascal) network_redirector_fp modify exact [ax dx]
#endif
UWORD get_machine_name(BYTE FAR * netname);
VOID set_machine_name(BYTE FAR * netname, UWORD name_num);