;/*static char *SCCSID = "@(#)farwrap.asm       6.4 92/01/31";*/
;***    FARWRAP.ASM - far wrappers
;
; FARWRAP FUNC,ARG_SPACE,SEG,FMINI

; Wrappers are generated by the lines that appear after the ENDM statement:
;
; FARWRAP <name>,<args>,<mod>,<mini>
;
; <name> - Function name
; <args> - Number of stack bytes used by function arguments.
; <mod>  - Function module name.
; <mini> - MINI: Function included in mini-fsd, NOMINI: Otherwise

.286

.MODEL MEDIUM, PASCAL

ifdef MEDIUM_MODEL
CALLTYPE    equ <far>
else
CALLTYPE    equ <near>
endif

FARWRAP macro   FUNC,ARG_SPACE,SEG,FMINI


FMINI&FUNC  equ 1

ifndef MINIFSD
GEN&FUNC    equ 1
else
ifdef MINI&FUNC
GEN&FUNC    equ 1
endif
endif

ifdef GEN&FUNC
; Not MINIFSD or function is defined for MINIFSD

.CODE SEG

extrn FUNC : CALLTYPE

public FUNC&_FAR

FUNC&_FAR  PROC    FAR

if      ARG_SPACE
    ; Function has arguments.

    ; Move the far return address down over the first paramter (extra ULONG)

        mov     bx,sp

ifdef   MEDIUM_MODEL
    ; Deubg version only.

        mov     ax,ss:[bx] + ARG_SPACE + 4
        or      ax,ss:[bx] + ARG_SPACE + 6

    ; do something if not 0.

endif ; MEDIUM_MODEL

        pop     ss:[bx] + ARG_SPACE + 4
        pop     ss:[bx] + ARG_SPACE + 6

    ; Now the parameters are set up for a normal call to FUNC
    ;
    ;   (ss:sp)    -> par N
    ;   .......
    ;   .......
    ;   (ss:sp + FUNC&_ARG_SPACE) -> far return address (was ULONG Dummy)
    ;

endif ; ARG_SPACE

    ; We now call FUNC, which will pop the paramters when it returns

        call    FUNC

    ; We just do the far return.
    ;
    ;           (ss:sp) -> far return address

        retf

FUNC&_FAR  endp

endif ; GEN FUNC

ENDM

FARWRAP AddExt,          30,    ASWAP0,   NOMINI
FARWRAP AddHash,          2,    _TEXT,    MINI
FARWRAP AFB,             16,    ASWAP0,   NOMINI
FARWRAP AllocDB,         12,    _TEXT,    NOMINI
FARWRAP BufWrit,          6,    _TEXT,    MINI
FARWRAP CBR,              8,    ASWAP0,   NOMINI
FARWRAP CCH,              8,    _TEXT,    MINI
FARWRAP CCS,              8,    _TEXT,    MINI
FARWRAP ClrBit,          14,    _TEXT,    NOMINI
FARWRAP ClrLzRdBit,      10,    _TEXT,    NOMINI
FARWRAP CrackPath,       14,    ASWAP1,   MINI
FARWRAP DelEntry,        14,    _TEXT,    NOMINI
FARWRAP DelSBDIR,        12,    BSWAP1,    MINI
FARWRAP EFA,             14,    ASWAP0,   NOMINI
FARWRAP FindAnyVol,       2,    ASWAP1,   MINI
FARWRAP FindDir,         20,    _TEXT,    MINI
FARWRAP FindFromName,    30,    _BTXT,    NOMINI
FARWRAP FlushVol,        10,    BSWAP1,   MINI
FARWRAP FreeDB,           8,    _TEXT,    NOMINI
FARWRAP FreeSubdir,       4,    _TEXT,    MINI
FARWRAP GFB,              4,    _TEXT,    MINI
FARWRAP GFBWait,          4,    _TEXT,    MINI
FARWRAP GHS,              6,    _TEXT,    MINI
FARWRAP HashFind,         4,    _TEXT,    MINI
FARWRAP InitLzRd,        12,    _BTXT,    NOMINI
FARWRAP LazyRead,         6,    _BTXT,    NOMINI
FARWRAP LDE,             32,    _TEXT,    MINI
FARWRAP LSD,             14,    _TEXT,    MINI
FARWRAP LSDDB,           14,    _TEXT,    MINI
FARWRAP MetaMatch,       10,    _TEXT,    MINI
FARWRAP OFTFromFNode,     4,    _BTXT,    MINI
FARWRAP PlaceBuf,         4,    _TEXT,    MINI
FARWRAP ProbeAddress,    12,    _TEXT,    MINI
FARWRAP RdBufOrGetInBuf, 26,    _TEXT,    MINI
FARWRAP RDE,             12,    _BTXT,    MINI
FARWRAP RelVerDB,         4,    _TEXT,    NOMINI
FARWRAP SCR,             10,    _TEXT,    MINI
FARWRAP SelFlush,         6,    _TEXT,    MINI
FARWRAP SetBit,          12,    _TEXT,    NOMINI
FARWRAP SetDBDirt,        8,    _TEXT,    NOMINI
FARWRAP SetDEDirt,       12,    _TEXT,    NOMINI
FARWRAP SetDirt,         12,    _TEXT,    NOMINI
FARWRAP SFB,             12,    ASWAP0,   NOMINI
FARWRAP TFA,             14,    ASWAP0,   NOMINI
FARWRAP UpdateDisk,      10,    _TEXT,    NOMINI
FARWRAP VerifyDB,         4,    _TEXT,    NOMINI
FARWRAP WBU,              6,    _TEXT,    MINI

end
