int2f: fix call interface around int2F_12_handler( )

This changes the interface between reloc_call_int2f_handler
(int2f.asm) and int2F_12_handler( ) (inthndlr.c) so that

  - int2F_12_handler( ) will not try to output values to its
    caller by passing "back" input parameter values
  - reloc_call_int2f_handler will switch to an internal
    stack before calling int2F_12_handler( ), so that SS ==
    DGROUP as expected by the latter.

This partly addresses https://github.com/FDOS/kernel/issues/11 .

(The call to syscall_MUX14( ) in int2f.asm seems to have
similar issues, and should probably also be updated.)
This commit is contained in:
Tee-Kiah Chia 2019-12-06 22:30:27 +08:00 committed by Kenneth J Davis
parent 241875a742
commit 0114ab3be4
3 changed files with 61 additions and 5 deletions

View File

@ -31,6 +31,53 @@
%include "segs.inc" %include "segs.inc"
%include "stacks.inc" %include "stacks.inc"
; macro to switch to an internal stack (if necessary), set DS == SS == DGROUP,
; and push the old SS:SP onto the internal stack
;
; destroys AX, SI, BP; turns on IRQs
;
; int2f does not really need to switch to a separate stack for MS-DOS
; compatibility; this is mainly to work around the C code's assumption
; that SS == DGROUP
;
; TODO: remove the need for this hackery -- tkchia
%macro SwitchToInt2fStack 0
mov ax,[cs:_DGROUP_]
mov ds,ax
mov si,ss
mov bp,sp
cmp ax,si
jz %%already
cli
mov ss,ax
extern int2f_stk_top
mov sp,int2f_stk_top
sti
%%already:
; well, GCC does not currently clobber function parameters passed on the
; stack; but just in case it decides to do that in the future, we push _two_
; copies of the old SS:SP:
; - the second copy can be passed as a pointer parameter to a C function
; - the first copy is used to actually restore the user stack later
push si
push bp
push si
push bp
%endmacro
; macro to switch back from an internal stack, i.e. undo SwitchToInt2fStack
;
; destroys BP; turns on IRQs -- tkchia
%macro DoneInt2fStack 0
pop bp
pop bp
pop bp
cli
pop ss
mov sp,bp
sti
%endmacro
segment HMA_TEXT segment HMA_TEXT
extern _cu_psp extern _cu_psp
extern _HaltCpuWhileIdle extern _HaltCpuWhileIdle
@ -135,7 +182,7 @@ DriverSysCal:
; internal dos calls INT2F/12xx and INT2F/4A01,4A02 - handled through C ; internal dos calls INT2F/12xx and INT2F/4A01,4A02 - handled through C
;********************************************************************** ;**********************************************************************
IntDosCal: IntDosCal:
; set up register frame ; set up register structure
;struct int2f12regs ;struct int2f12regs
;{ ;{
; [space for 386 regs] ; [space for 386 regs]
@ -165,9 +212,10 @@ IntDosCal:
%endif %endif
%endif %endif
mov ds,[cs:_DGROUP_] SwitchToInt2fStack
extern _int2F_12_handler extern _int2F_12_handler
call _int2F_12_handler call _int2F_12_handler
DoneInt2fStack
%if XCPU >= 386 %if XCPU >= 386
%ifdef WATCOM %ifdef WATCOM

View File

@ -1734,14 +1734,15 @@ struct int2f12regs {
UWORD callerARG1; /* used if called from INT2F/12 */ UWORD callerARG1; /* used if called from INT2F/12 */
}; };
/* WARNING: modifications in `r' are used outside of int2F_12_handler() /* On input pr->AX==0x12xx, 0x4A01 or 0x4A02
* On input r.AX==0x12xx, 0x4A01 or 0x4A02
*/ */
VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) VOID ASMCFUNC int2F_12_handler(struct int2f12regs FAR *pr)
{ {
COUNT rc; COUNT rc;
long lrc; long lrc;
#define r (*pr)
if (r.AH == 0x4a) if (r.AH == 0x4a)
{ {
size_t size = 0, offs = 0xffff; size_t size = 0, offs = 0xffff;
@ -2111,6 +2112,8 @@ error_exit:
CritErrCode = r.AX; /* Maybe set */ CritErrCode = r.AX; /* Maybe set */
error_carry: error_carry:
r.FLAGS |= FLG_CARRY; r.FLAGS |= FLG_CARRY;
#undef r
} }
/* /*

View File

@ -812,6 +812,11 @@ blk_stk_top:
times 128 dw 0 times 128 dw 0
clk_stk_top: clk_stk_top:
; int2fh private stack
global int2f_stk_top
times 128 dw 0
int2f_stk_top:
; Dynamic data: ; Dynamic data:
; member of the DOS DATA GROUP ; member of the DOS DATA GROUP
; and marks definitive end of all used data in kernel data segment ; and marks definitive end of all used data in kernel data segment