;       SCCSID = @(#)api.asm    6.10 92/03/20
;      SCCSID = @(#)api.asm     6.10 92/03/20

PAGE ,132
;***    api.asm
;
;       IBM/Microsoft Confidential
;
;       Copyright (c) IBM Corporation 1987, 1989
;       Copyright (c) Microsoft Corporation 1987, 1989
;
;       All Rights Reserved
;
;       Applications Program Interface, in particular, the protected mode,
;       dynamic link, PLM calling convention used in OS/2.
;
;       PLEASE ADD NEW ENTRIES IN ALPHABETICAL ORDER!  THANKS
;
;       IS      6/12/88         moved DOSGETRESOURCE to here from v1api.asm
;                               (1.2 PTM 223)
;
;       MLM     11/27/95        72417
;               reduce fscrit serialization

.xlist
include dosseg.inc
include basemaca.inc
include fnotask.inc
include osmaca.inc
include curdir.inc
include error.inc
include protmode.inc
include seldesc.inc
include mi.inc
include dossymc.inc
include ordinals.inc
include selxport.inc
include ostypes.inc
include osconst.inc
include pgexport.inc
include vmexport.inc
include sigdef.inc
include kmode.inc
include sysentry.inc
include tkexport.inc
include virtsym.inc
include ldrxport.inc
include infoseg.inc
include mmpha.inc
include dirent.inc
include find.inc
include screen.inc
include sem.inc
include except.inc
include tkptda.inc
.list

        CpuMode 286
        ModName api,FNO_API_ASM

        EXTRN           DOSIODELAYCNT:ABS

        ReferGDT        GDT_FPEM,WORD
        ReferGDT        GDT_R3DS,WORD
        ReferGDT        GDT_R3CS,WORD
        ReferGDT        GDT_TIB,WORD

;       Add entries into DOSCALLS entry table for absolute symbols

GenEntryTbl DOSHUGEINCR,   ORD_DOSHUGEINCR,   IS_ABSOLUTE, HUGEINCR
GenEntryTbl DOSHUGESHIFT,  ORD_DOSHUGESHIFT,  IS_ABSOLUTE, HUGESHIFT
GenEntryTbl DOSMAXPATHLEN, ORD_DOSMAXPATHLEN, IS_ABSOLUTE, MAXPATHLEN
GenEntryTbl DOSPAGESIZE,   ORD_DOSPAGESIZE,   IS_ABSOLUTE, PAGESIZE
GenEntryTbl DOS32R3THKDS,  ORD_THK32R3DS,  IS_ABSOLUTE, R3THKDS
GenEntryTbl DOSFPDATAAREA, ORD_DOSFPDATAAREA, IS_ABSOLUTE, <GSEL GDT_FPEM>
GenEntryTbl DOSLDTSEL,     ORD_DOSLDTSEL,     IS_ABSOLUTE, USERLDTSEL
GenEntryTbl DOSIODELAYCNT, ORD_DOSIODELAYCNT, IS_ABSOLUTE, DOSIODELAYCNT

GenEntryIndirect DOSLOCALINFO,ORD_DOSLOCALINFO,AUXORD_DOSLOCALINFO,IND_RING0,IS_INDABSOLUTE,0
GenEntryIndirect DOSLOCALINFO,ORD_DOSLOCALINFO,AUXORD_DOSLOCALINFO,IND_RING3,IS_INDABSOLUTE,SEL_TASKINFOSEG
CpuMode 386
GenEntryIndirect DOSGLOBALINFO,ORD_DOSGLOBALINFO,AUXORD_DOSGLOBALINFO,IND_RING0,IS_INDABSOLUTE,0
GenEntryIndirect DOSGLOBALINFO,ORD_DOSGLOBALINFO,AUXORD_DOSGLOBALINFO,IND_RING3,IS_INDABSOLUTE,SEL_SYSINFOSEG
GenEntryIndirect DOS32FLATDS,ORD_DOS32FLATDS,AUXORD_DOSFLATDS,IND_RING0,IS_INDABSOLUTE,<seg FLAT:_DATA>
GenEntryIndirect DOS32FLATDS,ORD_DOS32FLATDS,AUXORD_DOSFLATDS,IND_RING3,IS_INDABSOLUTE,<GSEL GDT_R3DS + SEL_RPL3>
GenEntryIndirect DOS32FLATCS,ORD_DOS32FLATCS,AUXORD_DOSFLATCS,IND_RING0,IS_INDABSOLUTE,<seg FLAT:_TEXT>
GenEntryIndirect DOS32FLATCS,ORD_DOS32FLATCS,AUXORD_DOSFLATCS,IND_RING3,IS_INDABSOLUTE,<GSEL GDT_R3CS + SEL_RPL3>
GenEntryIndirect DOS32TIB,ORD_DOS32TIB,AUXORD_DOSTIB,IND_RING0,IS_INDABSOLUTE,0
GenEntryIndirect DOS32TIB,ORD_DOS32TIB,AUXORD_DOSTIB,IND_RING3,IS_INDABSOLUTE,<GSEL GDT_TIB + SEL_RPL3>
CpuMode 286


        FARCODE HIGH3
HIGH3CODE SEGMENT


;***    DOSALLOCHUGE - Allocate a huge private data segment
;
;       INVOKE  push    word numseg             (1 word)
;               push    word size               (1 word)
;               push@   word selector           (2 word)
;               push    word maxnumseg          (1 word)
;               push    word flags              (1 word)
;               call    DOSALLOCHUGE
;
;       RETURN  (ax) = return code
;                       0 - success

SysEntry DOSALLOCHUGE, ORD_DOSALLOCHUGE, 6

        ld_dx                           ; flags
        ld_cx                           ; maxnumseg
        skip_ptr                        ; skip return pointer
        ld_bx                           ; size
        ld_ax                           ; numseg

;***DT  preDOSALLOCHUGE - DosAllocHuge pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSALLOCHUGE>,
;          TP    = .preDOSALLOCHUGE,
;          TYPE  = (PRE,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosAllocHuge Pre-Invocation",
;          <LOG_AX>,
;          <LOG_BX>,
;          <LOG_CX>,
;          FMT   = "Initial size=<FMT_AX><FMT_BX>  Max size = <FMT_CX>0000"

        RASpretrace                     ; RAS pre-invocation trace

        farcall         w_AllocHuge, ORD_DOSALLOCHUGE                     ;@SEC
        skip_word                       ; skip flags
        skip_word                       ; skip maxnumseg
        st_ax                           ; return selector

;***DT  postDOSALLOCHUGE - DosAllocHuge post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSALLOCHUGE>,
;          TP    = .postDOSALLOCHUGE,
;          TYPE  = (POST,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosAllocHuge Post-Invocation",
;          <LOG_AX>,
;          <LOG_RETVAL>,
;          FMT   = "Base selector = <FMT_AX>  Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSALLOCHUGE


;***    DOSALLOCSEG - Allocate a private data segment
;
;       INVOKE  push    word size               (1 word)
;               push@   word selector           (2 word)
;               push    word flags              (1 word)
;               call    DOSALLOCSEG
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSALLOCSEG, ORD_DOSALLOCSEG, 4, GDT_DOSALLOCSEG

        ld_ax                           ; flags
        skip_ptr                        ; skip return pointer
        ld_bx                           ; size

;***DT  preDOSALLOCSEG - DosAllocSeg pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSALLOCSEG>,
;          TP    = .preDOSALLOCSEG,
;          TYPE  = (PRE,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosAllocSeg Pre-Invocation",
;          <LOG_AX>,
;          <LOG_BX>,
;          FMT   = "Flags=<FMT_AX>  Size=<FMT_BX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall         w_AllocSeg, ORD_DOSALLOCSEG                       ;@SEC
        skip_word                       ; skip flags
        st_ax                           ; return selector

;***DT  postDOSALLOCSEG - DosAllocSeg post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSALLOCSEG>,
;          TP    = .postDOSALLOCSEG,
;          TYPE  = (POST,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosAllocSeg Post-Invocation",
;          <LOG_AX>,
;          <LOG_RETVAL>,
;          FMT   = "Selector = <FMT_AX>  Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSALLOCSEG


;***    DOSALLOCSHRSEG - Allocate a shared data segment
;
;       INVOKE  push    word size               (1 word)
;               push@   asciiz name             (2 word)
;               push@   word selector           (2 word)
;               call    DOSALLOCSHRSEG
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSALLOCSHRSEG, ORD_DOSALLOCSHRSEG, 5

        enterfscrit
        skip_ptr                        ; skip return pointer
        getusrbufz                      ; copy asciiz string to kernel buffer
        ld_dsdx_norpl                   ; name pointer
        ld_bx                           ; size

;***DT  preDOSALLOCSHRSEG - DosAllocShrSeg pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSALLOCSHRSEG>,
;          TP    = .preDOSALLOCSHRSEG,
;          TYPE  = (PRE,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosAllocShrSeg Pre-Invocation",
;          ASCIIZ=(<KSTK_ARGS>+<SKIP_PTR>,INDIRECT,<MAXPATHLEN>),
;          <LOG_BX>,
;          FMT   = "Name = <FMT_ASCIIZ>"
;          FMT   = "Size = <FMT_BX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall         w_AllocShrSeg, ORD_DOSALLOCSHRSEG                 ;@SEC
        st_ax                           ; return selector

;***DT  postDOSALLOCSHRSEG - DosAllocShrSeg post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSALLOCSHRSEG>,
;          TP    = .postDOSALLOCSHRSEG,
;          TYPE  = (POST,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosAllocShrSeg Post-Invocation",
;          <LOG_AX>,
;          <LOG_RETVAL>,
;          FMT   = "Selector = <FMT_AX>  Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

        exitfscrit

EndEntry DOSALLOCSHRSEG


;***    DOSALLOCPROTHUGE - Allocate a protected huge data segment
;
;       INVOKE  push    word numseg             (1 word)
;               push    word size               (1 word)
;               push@   word selector           (2 word)
;               push    word maxnumseg          (1 word)
;               push    word flags              (1 word)
;               call    DOSALLOCHUGE
;
;       RETURN  (ax) = return code
;                       0 - success
;
;
SysEntry DOSALLOCPROTHUGE, ORD_DOSALLOCPROTHUGE, 6

        ld_dx                           ; flags
        ld_cx                           ; maxnumseg
        skip_ptr                        ; skip return pointer
        ld_bx                           ; size
        ld_ax                           ; numseg

;***DT  preDOSALLOCPROTHUGE - DosAllocProtHuge pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSALLOCPROTHUGE>,
;          TP    = .preDOSALLOCPROTHUGE,
;          TYPE  = (PRE,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosAllocProtHuge Pre-Invocation",
;          <LOG_AX>,
;          <LOG_BX>,
;          <LOG_CX>,
;          FMT   = "Initial size=<FMT_AX><FMT_BX>  Max size = <FMT_CX>0000"

        RASpretrace                     ; RAS pre-invocation trace

        farcall         w_AllocProtHuge, ORD_DOSALLOCPROTHUGE             ;@SEC
        skip_word                       ; skip flags
        skip_word                       ; skip maxnumseg
        st_ax                           ; return selector

;***DT  postDOSALLOCPROTHUGE - DosAllocProtHuge post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSALLOCPROTHUGE>,
;          TP    = .postDOSALLOCPROTHUGE,
;          TYPE  = (POST,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosAllocProtHuge Post-Invocation",
;          <LOG_AX>,
;          <LOG_RETVAL>,
;          FMT   = "Base selector = <FMT_AX>  Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSALLOCPROTHUGE


;***    DOSALLOCPROTSEG - Allocate a protected data segment
;
;       INVOKE  push    word size               (1 word)
;               push@   word selector           (2 word)
;               push    word flags              (1 word)
;               call    DOSALLOCSEG
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSALLOCPROTSEG, ORD_DOSALLOCPROTSEG, 4, GDT_DOSALLOCPROTSEG

        ld_ax                           ; flags
        skip_ptr                        ; skip return pointer
        ld_bx                           ; size

;***DT  preDOSALLOCPROTSEG - DosAllocProtSeg pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSALLOCPROTSEG>,
;          TP    = .preDOSALLOCPROTSEG,
;          TYPE  = (PRE,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosAllocProtSeg Pre-Invocation",
;          <LOG_AX>,
;          <LOG_BX>,
;          FMT   = "Flags=<FMT_AX>  Size=<FMT_BX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall         w_AllocProtSeg, ORD_DOSALLOCPROTSEG               ;@SEC
        skip_word                       ; skip flags
        st_ax                           ; return selector

;***DT  postDOSALLOCPROTSEG - DosAllocProtSeg post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSALLOCPROTSEG>,
;          TP    = .postDOSALLOCPROTSEG,
;          TYPE  = (POST,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosAllocProtSeg Post-Invocation",
;          <LOG_AX>,
;          <LOG_RETVAL>,
;          FMT   = "Selector = <FMT_AX>  Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSALLOCPROTSEG


;***    DOSALLOCSHRPROTSEG - Allocate a protected shared data segment
;
;       INVOKE  push    word size               (1 word)
;               push@   asciiz name             (2 word)
;               push@   word selector           (2 word)
;               call    DOSALLOCSHRPROTSEG
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSALLOCSHRPROTSEG, ORD_DOSALLOCSHRPROTSEG, 5

        enterfscrit
        skip_ptr                        ; skip return pointer
        getusrbufz                      ; copy asciiz string to kernel buffer
        ld_dsdx_norpl                   ; name pointer
        ld_bx                           ; size

;***DT  preDOSALLOCSHRPROTSEG - DosAllocShrProtSeg pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSALLOCSHRPROTSEG>,
;          TP    = .preDOSALLOCSHRPROTSEG,
;          TYPE  = (PRE,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosAllocShrProtSeg Pre-Invocation",
;          ASCIIZ=(<KSTK_ARGS>+<SKIP_PTR>,INDIRECT,<MAXPATHLEN>),
;          <LOG_BX>,
;          FMT   = "Name = <FMT_ASCIIZ>",
;          FMT   = "Size = <FMT_BX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall         w_AllocShrProtSeg, ORD_DOSALLOCSHRPROTSEG         ;@SEC
        st_ax                           ; return selector

;***DT  postDOSALLOCSHRPROTSEG - DosAllocShrProtSeg post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSALLOCSHRPROTSEG>,
;          TP    = .postDOSALLOCSHRPROTSEG,
;          TYPE  = (POST,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosAllocShrProtSeg Post-Invocation",
;          <LOG_AX>,
;          <LOG_RETVAL>,
;          FMT   = "Selector = <FMT_AX>  Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

        exitfscrit

EndEntry DOSALLOCSHRPROTSEG


;***    DOSCLOSESEM - Close a system semaphore
;
;       INVOKE  push    dword SemHandle ; Semaphore handle      (2 words)
;               call    DOSCLOSESEM
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSCLOSESEM, ORD_DOSCLOSESEM, 2

        ld_bx                           ; Semaphore handle
        ld_ax                           ; . . . passed in ax:bx

;***DT  preDOSCLOSESEM - DosCloseSem pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSCLOSESEM>,
;          TP    = .preDOSCLOSESEM,
;          TYPE  = (PRE,API),
;          GROUP = SEM,
;          DESC  = "(OS) DosCloseSem Pre-Invocation",
;          <LOG_AX>,
;          <LOG_BX>,
;          FMT   = "Semaphore handle = <FMT_AX><FMT_BX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall w_CloseSem, ORD_DOSCLOSESEM                               ;@SEC

;***DT  postDOSCLOSESEM - DosCloseSem post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSCLOSESEM>,
;          TP    = .postDOSCLOSESEM,
;          TYPE  = (POST,API),
;          GROUP = SEM,
;          DESC  = "(OS) DosCloseSem Post-Invocation",
;          <LOG_RETVAL>,
;          FMT   = "Return value = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSCLOSESEM


;***    DOSCREATECSALIAS - Create an executable alias to a data segment
;
;       INVOKE  push    word data selector      (1 word)
;               push@   word code selector      (2 word)
;               call    DOSCREATECSALIAS
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSCREATECSALIAS, ORD_DOSCREATECSALIAS, 3

        skip_ptr                        ; skip return pointer
        ld_ax                           ; data selector

;***DT  preDOSCREATECSALIAS - DosCreateCSAlias pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSCREATECSALIAS>,
;          TP    = .preDOSCREATECSALIAS,
;          TYPE  = (PRE,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosCreateCSAlias Pre-Invocation",
;          <LOG_AX>,
;          FMT   = "Data selector = <FMT_AX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall         w_CreateCSAlias, ORD_DOSCREATECSALIAS             ;@SEC
        st_ax                           ; return selector

;***DT  postDOSCREATECSALIAS - DosCreateCSAlias post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSCREATECSALIAS>,
;          TP    = .postDOSCREATECSALIAS,
;          TYPE  = (POST,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosCreateCSAlias Post-Invocation",
;          <LOG_AX>,
;          <LOG_RETVAL>,
;          FMT   = "Code selector = <FMT_AX>  Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSCREATECSALIAS


;***    DOSCREATESEM - Create a system semaphore
;
;       INVOKE  push    word NoExclusive ; Exclusive ownership flag
;               push@   dword SemHandle ; Semaphore handle      (2 words)
;               push@   ASCIIZ SemName  ; Semaphore Name        (2 words)
;               call    DOSCREATESEM
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSCREATESEM, ORD_DOSCREATESEM, 5

        enterfscrit                     ; Entering kernel
        getusrbufz
        ld_si                           ; Semaphore Name in DS:SI
        ld_ds_norpl
        skip_ptr
        ld_ax                           ; NoExclusive flag in AX

;***DT  preDOSCREATESEM - DosCreateSem pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSCREATESEM>,
;          TP    = .preDOSCREATESEM,
;          TYPE  = (PRE,API),
;          GROUP = SEM,
;          DESC  = "(OS) DosCreateSem Pre-Invocation",
;          ASCIIZ=(<KSTK_ARGS>,INDIRECT,<MAXPATHLEN>),
;          FMT   = "Name = <FMT_ASCIIZ>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall w_CreateSem, ORD_DOSCREATESEM                             ;@SEC
        skip_ptr                        ; Skip SemName
        st_dxax                         ; Handle returned in DX:AX

;***DT  postDOSCREATESEM - DosCreateSem post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSCREATESEM>,
;          TP    = .postDOSCREATESEM,
;          TYPE  = (POST,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosCreateSem Post-Invocation",
;          <LOG_DX>,
;          <LOG_AX>,
;          <LOG_RETVAL>,
;          FMT   = "Handle = <FMT_DX><FMT_AX> Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

        exitfscrit                      ; Exiting Kernel

EndEntry DOSCREATESEM


;***    DOSCWAIT - Wait for child termination
;
;       INVOKE  push    0 = Wait for task AND it's children     (2 bytes)
;                       1 = Wait for task OR it's children
;               push    0 = Wait for termination                (2 bytes)
;                       1 = Don't wait for termination
;               push    @pointer to place result codes          (4 bytes)
;               push    @pointer to place PID of result code    (4 bytes)
;               push    PID of desired task                     (2 bytes)
;               call    DOSCWAIT
;
;       RETURN  (AX) = 0 = no error
;                    > 0 = error code
;

SysEntry DOSCWAIT, ORD_DOSCWAIT,7

        ld_cx                           ; (CX) = PID
        skip_ptr
        skip_ptr
        ld_bx                           ; (BX) = Wait or return flag
        ld_ax                           ; (AX) = Action code

;***DT  preDOSCWAIT - DosCWait pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSCWAIT>,
;          TP    = .preDOSCWAIT,
;          TYPE  = (PRE,API),
;          GROUP = TK,
;          DESC  = "(OS) DosCWait Pre-Invocation",
;          <LOG_CX>,
;          <LOG_BX>,
;          <LOG_AX>,
;          FMT   = "Pid = <FMT_CX>  Wait = <FMT_BX>  Action = <FMT_AX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall w_CWait, ORD_DOSCWAIT                                     ;@SEC
        skip_word
        st_bx                           ; save PID
        st_dxax                         ; save result code and termination code

;***DT  postDOSCWAIT - DosCWait post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSCWAIT>,
;          TP    = .postDOSCWAIT,
;          TYPE  = (POST,API),
;          GROUP = TK,
;          DESC  = "(OS) DosCWait Post-Invocation",
;          <LOG_BX>,
;          <LOG_RETVAL>,
;          FMT   = "Pid = <FMT_BX> Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSCWAIT


;***    DOSDEVCONFIG - Get device configuration.
;
;       INVOKE  PUSH@   OTHER   DeviceInfo      (2 words)
;               PUSH    WORD    ITEM            (1 word)
;               PUSH    WORD    PARM            (1 word)
;               CALL DOSDEVCONFIG
;
;       RETURN  (ax) = return code
;                       0 - success
;                       nonzero - error_invalid_parameter
;
;

SysEntry DOSDEVCONFIG, ORD_DOSDEVCONFIG, 4

        ld_cx                           ; reserve parameter
        ld_bx                           ; item

;***DT  preDOSDEVCONFIG - DosDevConfig pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSDEVCONFIG>,
;          TP    = .preDOSDEVCONFIG,
;          TYPE  = (PRE,API),
;          GROUP = FS,
;          DESC  = "(OS) DosDevConfig Pre-Invocation",
;          <LOG_CX>,
;          <LOG_BX>,
;          FMT   = "Parm = <FMT_CX> Item = <FMT_BX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall    w_DevConfig, ORD_DOSDEVCONFIG          ; call the worker @SEC
        skip_word                       ; skip over para
        skip_word                       ; skip over item
        st_al                           ; return information needed

;***DT  postDOSDEVCONFIG - DosDevConfig post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSDEVCONFIG>,
;          TP    = .postDOSDEVCONFIG,
;          TYPE  = (POST,API),
;          GROUP = FS,
;          DESC  = "(OS) DosDevConfig Post-Invocation",
;          <LOG_RETVAL>,
;          FMT   = "Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSDEVCONFIG


;***    DOSDYNAMICTRACE - Set/remove dynaminc RAS trace points.
;
;       The DOSDYNAMICTRACE system function provides the ability to
;       set and remove dynamic RAS trace points.  This function
;       performs three subfunctions, set trace points for a module,
;       remove trace points for a module and clear all trace points.
;
;       SubFunction defines the type of request to be performed.
;               0 = insert a module's trace points
;               1 = remove a module's trace points
;               2 = clear all trace points
;
;       Request Packet is a pointer to a buffer containing the
;       information required for the specified subfunction.
;
;       Result Packet is a pointer to a buffer where result or
;       return information may be placed.  (not currently used)
;
;       ENTRY   PUSH    WORD    SubFunction     [1 words]
;               PUSH@   OTHER   Request Packet  [2 words]
;               PUSH@   OTHER   Result Packet   [2 words]
;               CALL    DOSDYNAMICTRACE
;
;       EXIT    (AX) = return code
;                   0 [success]
;                   non-zero [error]
;

SysEntry DOSDYNAMICTRACE,ORD_DOSDYNAMICTRACE,5,GDT_DOSDYNAMICTRACE

if RAS
        enterfscrit                     ; Entering Kernel
        rplstampptr                     ; RPL stamp buffer pointer
        ld_di
        ld_cx                           ; (CX:DI) -> result packet selector
        rplstampptr                     ; RPL stamp buffer pointer
        ld_si
        ld_dx                           ; (DX:SI) -> request packet selector
        ld_bx                           ; (BX) = subfunction

        farcall w_DynamicTrace, ORD_DOSDYNAMICTRACE                       ;@SEC

        exitfscrit                      ; Exiting Kernel
endif
EndEntry        DOSDYNAMICTRACE


;***    DOSERROR - enable/disable hard error processing
;
;       INVOKE  push    WORD Flag       (1 word)
;               call    DOSERROR
;
;       RETURN  (ax) = return code
;                       0 - success
;                       nonzero - error
;                               error_invalid_parameter
;

SysEntry DOSERROR, ORD_DOSERROR, 1, GDT_DOSERROR

        ld_ax                           ; error setting

;***DT  preDOSERROR - DosError pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSERROR>,
;          TP    = .preDOSERROR,
;          TYPE  = (PRE,API),
;          GROUP = TK,
;          DESC  = "(OS) DosError Pre-Invocation",
;          <LOG_AX>,
;          FMT   = "Error setting = <FMT_AX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall w_Error, ORD_DOSERROR                 ; call the worker    @SEC

;***DT  postDOSERROR - DosError post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSERROR>,
;          TP    = .postDOSERROR,
;          TYPE  = (POST,API),
;          GROUP = TK,
;          DESC  = "(OS) DosError Pre-Invocation",
;          <LOG_RETVAL>,
;          FMT   = "Return value = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSERROR


;***    DOSFLAGPROCESS - Send a user-defined signal
;
;       INVOKE  push    word ProcessID          (1 word)
;               push    word Action             (1 word)
;               push    word Flagnum            (1 word)
;               push    word Flagarg            (1 word)
;               call    DOSFLAGPROCESS
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSFLAGPROCESS, ORD_DOSFLAGPROCESS, 4

        ld_cx                           ; sig arg
        ld_ax                           ; sig number
        ld_bx                           ; sig action
        ld_dx                           ; process i.d.

;***DT  preDOSFLAGPROCESS - DosFlagProcess pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSFLAGPROCESS>,
;          TP    = .preDOSFLAGPROCESS,
;          TYPE  = (PRE,API),
;          GROUP = SIG,
;          DESC  = "(OS) DosFlagProcess Pre-Invocation",
;          <LOG_DX>,
;          <LOG_BX>,
;          <LOG_AX>,
;          <LOG_CX>,
;          FMT   = "Pid = <FMT_DX>  Action = <FMT_BX>",
;          FMT   = "Signal = <FMT_AX>  Arg = <FMT_CX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall         w_FlagProcess, ORD_DOSFLAGPROCESS                 ;@SEC

;***DT  postDOSFLAGPROCESS - DosFlagProcess post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSFLAGPROCESS>,
;          TP    = .postDOSFLAGPROCESS,
;          TYPE  = (POST,API),
;          GROUP = SIG,
;          DESC  = "(OS) DosFlagProcess Post-Invocation",
;          <LOG_RETVAL>,
;          FMT   = "Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSFLAGPROCESS


;***    DOSFREERESOURCE - Free a resource
;
;       INVOKE  PUSH@   Address of far pointer  (2 words)
;               call    DOSFREERESOURCE
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSFREERESOURCE, ORD_DOSFREERESOURCE, 2,GDT_DOSFREERESOURCE

        skip_word                       ; skip over the offset part
        ld_ax                           ; load selector into ax
        ld_dx_0                         ; indicate current ptda
        ld_bx_1                         ; indicate an external call
        .errnz (WFS_EXTERNAL - 1)


;***DT  preDOSFREERESOURCE - DosFreeResource pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSFREERESOURCE>,
;          TP    = .preDOSFREERESOURCE,
;          TYPE  = (PRE,API),
;          GROUP = LDR,
;          DESC  = "(OS) DosFreeResource Pre-Invocation",
;          <LOG_AX>,
;          FMT   = "Selector = <FMT_AX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall         w_FreeResource, ORD_DOSFREERESOURCE               ;@SEC

;       farcall         w_FreeSeg    loader needs notification


;***DT  postDOSFREERESOURCE - DosFreeResource post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSFREERESOURCE>,
;          TP    = .postDOSFREERESOURCE,
;          TYPE  = (POST,API),
;          GROUP = LDR,
;          DESC  = "(OS) DosFreeResource Post-Invocation",
;          <LOG_RETVAL>,
;          FMT   = "Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSFREERESOURCE



;***    DOSQUERYABIOSSUPPORT
;
;       INVOKE  PUSH    reserved dword 0
;               call    DOSQUERYABIOSSUPPORT
;
;       RETURN  (ax) = flags
;

SysEntry DOSQUERYABIOSSUPPORT, ORD_DOSQUERYABIOSSUPPORT, 2,GDT_DOSQUERYABIOSSUPPORT

        skip_word                       ; skip the dword reserved
        skip_word

        farcall         w_QueryABIOSSupport, ORD_DOSQUERYABIOSSUPPORT     ;@SEC

EndEntry DOSQUERYABIOSSUPPORT



;***    DOS16LDRDIRTYWORKER
;
;       INVOKE  push    word command            (1 word)
;               push@   word selector           (2 word)
;               call    DOS16LDRDIRTYWORKER
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOS16LDRDIRTYWORKER, ORD_DOS16LDRDIRTYWORKER, 3, GDT_DOS16LDRDIRTYWORKER

        ld_cx
        ld_bx
        ld_ax      ; command code in ax

        farcall w_ldrDirtyWorker, ORD_DOS16LDRDIRTYWORKER                 ;@SEC

EndEntry DOS16LDRDIRTYWORKER





;***    DOSFREESEG - Free a segment
;
;       INVOKE  push    word selector           (1 word)
;               call    DOSFREESEG
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSFREESEG, ORD_DOSFREESEG, 1,GDT_DOSFREESEG

        ld_ax                           ; selector
        ld_dx_0                         ; indicate current ptda
        ld_bx_1                         ; indicate an external call
        .errnz (WFS_EXTERNAL - 1)

;***DT  preDOSFREESEG - DosFreeSeg pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSFREESEG>,
;          TP    = .preDOSFREESEG,
;          TYPE  = (PRE,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosFreeSeg Pre-Invocation",
;          <LOG_AX>,
;          FMT   = "Selector = <FMT_AX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall         w_FreeSeg, ORD_DOSFREESEG                         ;@SEC

;***DT  postDOSFREESEG - DosFreeSeg post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSFREESEG>,
;          TP    = .postDOSFREESEG,
;          TYPE  = (POST,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosFreeSeg Post-Invocation",
;          <LOG_RETVAL>,
;          FMT   = "Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSFREESEG


;***    DOSGETENV - Get address of process' environment string
;
;       Return handle of process' environment string and start of
;       command line.
;
;       INVOKE  push    @Address to put EnvHandle       (4 bytes)
;               push    @Address to put Command Offset  (4 bytes)
;               call    DOSGETENV
;
;       RETURN  (AX) = 0 = no error
;

SysEntry DOSGETENV, ORD_DOSGETENV, 4

        farcall w_GetEnv, ORD_DOSGETENV                                   ;@SEC
        st_bx
        st_ax

EndEntry DOSGETENV


;***    DOSGETHUGESHIFT - Get the huge selector increment shift count
;
;       INVOKE  push@   word incrshift          (2 word)
;               call    DOSGETHUGESHIFT
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSGETHUGESHIFT, ORD_DOSGETHUGESHIFT, 2

        farcall         w_GetHugeShift, ORD_DOSGETHUGESHIFT               ;@SEC
        st_ax                           ; return selector

EndEntry DOSGETHUGESHIFT


;***    DOSGETINFOSEG - Return pointers to Sys and Local InfoSegs's (M000)
;
;       INVOKE  PUSH@   WORD    GlobalSeg       (2 word)
;               PUSH@   WORD    LocalSeg        (2 word)
;               call    DOSGETINFOSEG
;
;       RETURN  (ax) = return code
;                       0 - success
;                       nonzero - error
;

SysEntry DOSGETINFOSEG, ORD_DOSGETINFOSEG,4,,,AUXORD_DOSGETINFOSEG,IND_RING3

        farcall w_GetInfoSeg, ORD_DOSGETINFOSEG            ; In getset.asm  @SEC
        st_bx
        st_ax

EndEntry DOSGETINFOSEG

SysEntry DOSGETINFOSEG, ORD_DOSGETINFOSEG,4,,,AUXORD_DOSGETINFOSEG,IND_RING0

        farcall w_R0GetInfoSeg, ORD_DOSGETINFOSEG          ; In getset.asm  @SEC
        st_bx
        st_ax

EndEntry DOSGETINFOSEG


;***    DOSGETMACHINEMODE - Get current mode of processor (alway protected).
;
;       INVOKE  PUSH@   BUTE    MachineMode     (2 words)
;               CALL DOSGETMACHINEMODE
;
;       RETURN  (ax) = return code
;                       0 - success -- no error possible
;
;

SysEntry DOSGETMACHINEMODE, ORD_DOSGETMACHINEMODE, 2

        farcall    w_GetMachineMode, ORD_DOSGETMACHINEMODE     ; call the worker @SEC
        st_al                           ; return information needed

EndEntry DOSGETMACHINEMODE


;***    DOSGETMODHANDLE - Get dynamic link library module handle.
;
;       DOSGETMODHANDLE returns the handle to a library
;       module that was previously loaded.
;
;       ENTRY   PUSH@ ASCIIZ ModuleName         [2 words]
;               PUSH@ WORD ModuleHandle         [2 words]
;               CALL  DOSGETMODHANDLE
;
;               where   ModuleName is the address of an ASCIIZ name
;               string containing the library module name.
;
;               ModuleHandle is the address of a WORD to return the
;               handle for the library module.
;
;       EXIT    (AX) = return code
;                       0 [success]
;                       ModuleHandle is filled in with the
;                       library module handle.
;
;                       non-zero [error]

SysEntry DOSGETMODHANDLE, ORD_DOSGETMODHANDLE, 4

        enterfscrit                     ; Entering kernel
        skip_ptr                        ; skip ptr to module handle
        getusrbufz                      ; copy asciiz string to kernel buffer
        ld_di                           ; (DI) = offset to ModuleName
        ld_es_norpl                     ; (ES) = selector to ModuleName

;***DT  preDOSGETMODHANDLE - DosGetModHandle pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSGETMODHANDLE>,
;          TP    = .preDOSGETMODHANDLE,
;          TYPE  = (PRE,API),
;          GROUP = LDR,
;          DESC  = "(OS) DosGetModHandle Pre-Invocation",
;          ASCIIZ= (<KSTK_ARGS>+<SKIP_PTR>,INDIRECT,<MAXPATHLEN>),
;          FMT   = "Module name = <FMT_ASCIIZ>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall w_getmodhandle, ORD_DOSGETMODHANDLE                       ;@SEC
        st_bx                           ; store module handle

;***DT  postDOSGETMODHANDLE - DosGetModHandle post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSGETMODHANDLE>,
;          TP    = .postDOSGETMODHANDLE,
;          TYPE  = (POST,API),
;          GROUP = LDR,
;          DESC  = "(OS) DosGetModHandle Post-Invocation",
;          <LOG_BX>,
;          <LOG_RETVAL>,
;          FMT   = "Module handle = <FMT_BX>  Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

        exitfscrit                      ; Exiting Kernel

EndEntry        DOSGETMODHANDLE


;***    DOSGETMODNAME - Get dynamic link library module pathname
;
;       DOSGETMODNAME returns the fully qualified
;       pathname associated with the referenced module handle.
;
;       ENTRY   PUSH WORD ModuleHandle          [1 word]
;               PUSH WORD BufferLength          [1 word]
;               PUSH@ ASCIIZ ModuleName         [2 words]
;               CALL  DOSGETMODNAME
;
;               where   ModuleHandle is the handle to the library
;               module to return the pathname to.
;
;               BufferLength is the maximum length of the pathname
;               buffer.
;
;               ModuleName is the address of the buffer where the null
;               terminated module pathname will be returned.
;
;       EXIT    (AX) = return code
;                       0 [success]
;                       ModuleName buffer is filled in.
;
;                       non-zero [error]

SysEntry DOSGETMODNAME, ORD_DOSGETMODNAME, 4

        enterfscrit                     ; Entering kernel
        ld_di                           ; (DI) = offset to modulename
        ld_es                           ; (ES) = selector to modulename
        ld_bx                           ; (BX) = buffer length
        ld_ax                           ; (AX) = module_handle

;***DT  preDOSGETMODNAME - DosGetModName pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSGETMODNAME>,
;          TP    = .preDOSGETMODNAME,
;          TYPE  = (PRE,API),
;          GROUP = LDR,
;          DESC  = "(OS) DosGetModName Pre-Invocation",
;          <LOG_AX>,
;          FMT   = "Module handle = <FMT_AX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall w_getmodname, ORD_DOSGETMODNAME                           ;@SEC

;***DT  postDOSGETMODNAME - DosGetModName post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSGETMODNAME>,
;          TP    = .postDOSGETMODNAME,
;          TYPE  = (POST,API),
;          GROUP = LDR,
;          DESC  = "(OS) DosGetModName Post-Invocation",
;          ASCIIZ= (<KSTK_ARGS>,INDIRECT,<MAXPATHLEN>),
;          <LOG_RETVAL>,
;          FMT   = "Module name = <FMT_ASCIIZ>",
;          FMT   = "Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

        exitfscrit                      ; Exiting Kernel

EndEntry        DOSGETMODNAME


;***    DOSGETPID - Return process ID
;
;       Return process ID into the pointer passed in.
;
;       INVOKE  push    @Address to put process ID's    (4 bytes)
;               call    DOSGETPID
;
;       RETURN  (AX) = 0 = no error
;

SysEntry DOSGETPID, ORD_DOSGETPID, 2

;***DT  preDOSGETPID - DosGetPid pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSGETPID>,
;          TP    = .preDOSGETPID,
;          TYPE  = (PRE,API),
;          GROUP = TK,
;          DESC  = "(OS) DosGetPid Pre-Invocation",

        RASpretrace                     ; RAS pre-invocation trace

        farcall w_GetPid, ORD_DOSGETPID                                   ;@SEC
        st_axbxcx

;***DT  postDOSGETPID - DosGetPid post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSGETPID>,
;          TP    = .postDOSGETPID,
;          TYPE  = (POST,API),
;          GROUP = TK,
;          DESC  = "(OS) DosGetPid Post-Invocation",
;          <LOG_AX>,
;          <LOG_BX>,
;          <LOG_CX>,
;          FMT   = "PID = <FMT_AX>  TID = <FMT_BX>  PPID = <FMT_CX>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSGETPID


;*** DOSGETPPID - Get Parent Process ID
;
;       INVOKE  push    PID:word
;               push@   PPID:word
;               call    DOSGETPPID
;
;       RETURN  (ax) = return code
;                       0 - success
;
;       NOTE: DOSGETPPID pre and post trace points do not have a DT comment
;             This is because these are not currently traced.

SysEntry DOSGETPPID, ORD_DOSGETPPID, 3

        enterfscrit                     ; Entering kernel
        skip_ptr                        ; skip over @PPID
        ld_ax                           ; ax = PID

;***    preDOSGETPPID - DosGetPPid pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSGETPPID>,
;          TP    = .preDOSGETPPID,
;          TYPE  = (PRE,API),
;          GROUP = TK,
;          <LOG_AX>,
;          DESC  = "(OS) DosGetPPid  Pre-Invocation",
;          FMT   = "PID = <FMT_AX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall w_GetPPID, ORD_DOSGETPPID               ; see tkv1api.asm  @SEC
        st_dx                           ; dx = PPID


;***    postDOSGETPPID - DosGetPPid post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSGETPPID>,
;          TP    = .postDOSGETPPID,
;          TYPE  = (POST,API),
;          GROUP = TK,
;          DESC  = "(OS) DosGetPPid  Post-Invocation",
;          <LOG_DX>,
;          FMT   = "Parent PID = <FMT_DX>"

        RASposttrace                    ; RAS pre-invocation trace

        exitfscrit                      ; Exiting Kernel

EndEntry DOSGETPPID


;***    DOSGETPROCADDR - Get dynamic link procedure address.
;
;       DOSGETPROCADDR returns a far address to the desired
;       procedure within a dynamic link library module.
;
;
;       ENTRY   PUSH  WORD ModuleHandle         [1 word]
;               PUSH@ ASCIIZ ProcName           [2 words]
;               PUSH@ DWORD ProcAddress         [2 words]
;               CALL  DOSGETPROCADDR
;
;               where   ModuleHandle is the handle to the library
;               module to find the procedure in.
;
;               ProcName is the address of an ASCIIZ name string
;               containing the procedure name that is being referenced
;               in the library module file.  Alternately if the selector
;               portion of the pointer is null, then the offset portion
;               of the pointer is an explicit entry number within the
;               library module.
;
;               ProcAddress is the address of a DWORD where the
;               procedure address will be returned.
;
;       EXIT    (AX) = return code
;                       0 [success]
;                       ProcAddress is filled in
;
;                       non-zero [error]

SysEntry DOSGETPROCADDR, ORD_DOSGETPROCADDR,5,GDT_DOSGETPROCADDR

        enterfscrit                     ; Entering kernel
        skip_ptr                        ; skip over ProcAddress DWORD
        getusrnzbuf                     ; copy asciiz string to kernel buffer
        ld_di                           ; ProcName offset into DI
        ld_es_norpl                     ; ProcName selector into ES
        ld_ax                           ; (AX) = module handle

;***DT  preDOSGETPROCADDR - DosGetProcAddr pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSGETPROCADDR>,
;          TP    = .preDOSGETPROCADDR,
;          TYPE  = (PRE,API),
;          GROUP = LDR,
;          DESC  = "(OS) DosGetProcAddr Pre-Invocation",
;          <LOG_AX>,
;          FMT   = "Module handle = <FMT_AX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall w_getprocaddr, ORD_DOSGETPROCADDR                         ;@SEC
        st_dxax                         ; store ProcAddress

;***DT  postDOSGETPROCADDR - DosGetProcAddr post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSGETPROCADDR>,
;          TP    = .postDOSGETPROCADDR,
;          TYPE  = (POST,API),
;          GROUP = LDR,
;          DESC  = "(OS) DosGetProcAddr Post-Invocation",
;          <LOG_DX>,
;          <LOG_AX>,
;          <LOG_RETVAL>,
;          FMT   = "Proc addr = <FMT_DX>:<FMT_AX>  Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

        exitfscrit                      ; Exiting Kernel

EndEntry        DOSGETPROCADDR


;***    DOSGETRESOURCE - get resource selector
;
;       DOSGETRESOURCE returns the segment selector associated with
;       the passed type/name ID pair in the passed module.
;
;       ENTRY   PUSH    WORD ModHandle          [1 word]
;               PUSH    WORD TypeID             [1 word]
;               PUSH    WORD NameID             [1 word]
;               PUSH@   WORD Selector           [2 words]
;               CALL    DOSGETRESOURCE
;
;               where   ModHandle is the handle of the module to get the
;                       resource from.  Zero means to get it from the
;                       current process's executable.  Non-zero is a
;                       module handle that was returned by DosLoadModule
;                       or was available through register after module
;                       initialization.
;
;                       TypeID and NameID are two integers that uniquely
;                       identify which resource is to be accessed.
;
;                       Selector is the address of a word in which the selector
;                       associated with the resource will be returned.
;
;       EXIT    (AX) = return code
;                       0 [success]
;                       selector is filled in.
;
;                       non-zero [error]

SysEntry DOSGETRESOURCE, ORD_DOSGETRESOURCE, 5
        enterfscrit                     ; Entering kernel
        skip_ptr                        ; skip over address to selector
        ld_dx                           ; (DX) = NameID
        ld_ax                           ; (AX) = TypeID
        ld_si                           ; (SI) = module_handle

;***DT  preDOSGETRESOURCE - DosGetResource pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSGETRESOURCE>,
;          TP    = .preDOSGETRESOURCE,
;          TYPE  = (PRE,API),
;          GROUP = LDR,
;          DESC  = "(OS) DosGetResource Pre-Invocation",
;          <LOG_DX>,
;          <LOG_AX>,
;          <LOG_SI>,
;          FMT   = "NameID = <FMT_DX>  Type = <FMT_AX>",
;          FMT   = "Module handle = <FMT_SI>"

        RASpretrace                     ; RAS pre-invocation trace

        ld_bx_0                         ; indicate who called
        farcall w_getresource, ORD_DOSGETRESOURCE                         ;@SEC
        st_ax                           ; fill in the selector

;***DT  postDOSGETRESOURCE - DosGetResource post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSGETRESOURCE>,
;          TP    = .postDOSGETRESOURCE,
;          TYPE  = (POST,API),
;          GROUP = LDR,
;          DESC  = "(OS) DosGetResource Post-Invocation",
;          <LOG_AX>,
;          <LOG_RETVAL>,
;          FMT   = "Selector = <FMT_AX> Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

        exitfscrit                      ; Exiting Kernel
EndEntry DOSGETRESOURCE


;***    DOSGETRESOURCE2 - get far pointer to resource
;
;       DOSGETRESOURCE2 returns a far pointer associated with
;       the passed type/name ID pair in the passed module.
;
;       ENTRY   PUSH    WORD ModHandle          [1 word]
;               PUSH    WORD TypeID             [1 word]
;               PUSH    WORD NameID             [1 word]
;               PUSH@   WORD Far Pointer        [2 words]
;               CALL    DOSGETRESOURCE2
;
;               where   ModHandle is the handle of the module to get the
;                       resource from.  Zero means to get it from the
;                       current process's executable.  Non-zero is a
;                       module handle that was returned by DosLoadModule
;                       or was available through register after module
;                       initialization.
;
;                       TypeID and NameID are two integers that uniquely
;                       identify which resource is to be accessed.
;
;                       Far Pointer is the address of the dword in which the
;                       far pointer (selector:offset) associated with the
;                       resource will be returned.
;
;       EXIT    (AX) = return code
;                       0 [success]
;                       selector is filled in.
;
;                       non-zero [error]

SysEntry DOSGETRESOURCE2, ORD_DOSGETRESOURCE2, 5
        enterfscrit                     ; Entering kernel
        skip_ptr                        ; skip over address to selector
        ld_dx                           ; (DX) = NameID
        ld_ax                           ; (AX) = TypeID
        ld_si                           ; (SI) = module_handle

;***DT  preDOSGETRESOURCE2 - DosGetResource2 pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSGETRESOURCE2>,
;          TP    = .preDOSGETRESOURCE2,
;          TYPE  = (PRE,API),
;          GROUP = LDR,
;          DESC  = "(OS) DosGetResource2 Pre-Invocation",
;          <LOG_DX>,
;          <LOG_AX>,
;          <LOG_SI>,
;          FMT   = "NameID = <FMT_DX>  Type = <FMT_AX>",
;          FMT   = "Module handle = <FMT_SI>"

        RASpretrace                     ; RAS pre-invocation trace

        ld_bx_1                         ; indicate who called
        farcall w_getresource, ORD_DOSGETRESOURCE2                        ;@SEC
        st_axdx                         ; fill in the selector:offset

;***DT  postDOSGETRESOURCE2 - DosGetResource2 post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSGETRESOURCE2>,
;          TP    = .postDOSGETRESOURCE2,
;          TYPE  = (POST,API),
;          GROUP = LDR,
;          DESC  = "(OS) DosGetResource2 Post-Invocation",
;          <LOG_AX>,
;          <LOG_DX>,
;          <LOG_RETVAL>,
;          FMT   = "Address = <FMT_AX>:<FMT_DX> Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

        exitfscrit                      ; Exiting Kernel
EndEntry DOSGETRESOURCE2


;***    DOSGETSEG - Get access to segment
;
;       INVOKE  push    word selector           (1 word)
;               call    DOSGETSEG
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSGETSEG, ORD_DOSGETSEG, 1

        ld_ax                           ; selector

;***DT  preDOSGETSEG - DosGetSeg pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSGETSEG>,
;          TP    = .preDOSGETSEG,
;          TYPE  = (PRE,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosGetSeg Pre-Invocation",
;          <LOG_AX>,
;          FMT   = "Selector = <FMT_AX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall         w_GetSeg, ORD_DOSGETSEG                           ;@SEC

;***DT  postDOSGETSEG - DosGetSeg post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSGETSEG>,
;          TP    = .postDOSGETSEG,
;          TYPE  = (POST,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosGetSeg Post-Invocation",
;          <LOG_RETVAL>,
;          FMT   = "Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSGETSEG


;***    DOSGETSHRSEG - Gain access to a shared data segment
;
;       INVOKE  push@   asciiz name             (2 word)
;               push@   word selector           (2 word)
;               call    DOSGETSHRSEG
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSGETSHRSEG, ORD_DOSGETSHRSEG, 4

        enterfscrit
        skip_ptr                        ; skip return pointer
        getusrbufz                      ; copy asciiz string to kernel buffer
        ld_dsdx_norpl                   ; name pointer

;***DT  preDOSGETSHRSEG - DosGetShrSeg pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSGETSHRSEG>,
;          TP    = .preDOSGETSHRSEG,
;          TYPE  = (PRE,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosGetShrSeg Pre-Invocation",
;          ASCIIZ=(<KSTK_ARGS>+<SKIP_PTR>,INDIRECT,<MAXPATHLEN>),
;          FMT   = "Name = <FMT_ASCIIZ>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall         w_GetShrSeg, ORD_DOSGETSHRSEG                     ;@SEC
        st_ax                           ; return selector

;***DT  postDOSGETSHRSEG - DosGetShrSeg post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSGETSHRSEG>,
;          TP    = .postDOSGETSHRSEG,
;          TYPE  = (POST,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosGetShrSeg Post-Invocation",
;          <LOG_AX>,
;          <LOG_RETVAL>,
;          FMT   = "Selector = <FMT_AX>  Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

        exitfscrit

EndEntry DOSGETSHRSEG


;***    DOSGETVERSION - Get the version of DOS we're running
;
;       INVOKE  push@   word VersionWord        (2 words)
;               call    DOSGETVERSION
;
;       RETURN  (ax) = return code
;                       0 - success
;                       No error is possible on this call
;

SysEntry DOSGETVERSION, ORD_DOSGETVERSION, 2

;***DT  preDOSGETVERSION - DosGetVersion pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSGETVERSION>,
;          TP    = .preDOSGETVERSION,
;          TYPE  = (PRE,API),
;          GROUP = TK,
;          DESC  = "(OS) DosGetVersion Pre-Invocation",

        RASpretrace                     ; RAS pre-invocation trace
        farcall w_Get_Version, ORD_DOSGETVERSION                          ;@SEC
        st_ax                           ; save the major/minor version number

;***DT  postDOSGETVERSION - DosGetVersion post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSGETVERSION>,
;          TP    = .postDOSGETVERSION,
;          TYPE  = (POST,API),
;          GROUP = TK,
;          DESC  = "(OS) DosGetVersion Post-Invocation",
;          <LOG_AX>,
;          FMT   = "Major/minor version = <FMT_AX>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSGETVERSION


;***    DOSGIVESEG - Give access to segment
;
;       INVOKE  push    word selector           (1 word)
;               push    word processid          (1 word)
;               push@   word selector           (2 word)
;               call    DOSGIVESEG
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSGIVESEG, ORD_DOSGIVESEG, 4

        skip_ptr                        ; skip return pointer
        ld_bx                           ; process id
        ld_ax                           ; caller's selector

;***DT  preDOSGIVESEG - DosGiveSeg pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSGIVESEG>,
;          TP    = .preDOSGIVESEG,
;          TYPE  = (PRE,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosGiveSeg Pre-Invocation",
;          <LOG_AX>,
;          <LOG_BX>,
;          FMT   = "Selector = <FMT_AX>  Pid = <FMT_BX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall         w_GiveSeg, ORD_DOSGIVESEG                         ;@SEC
        st_ax                           ; return recipient's selector

;***DT  postDOSGIVESEG - DosGiveSeg post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSGIVESEG>,
;          TP    = .postDOSGIVESEG,
;          TYPE  = (POST,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosGiveSeg Post-Invocation",
;          <LOG_AX>,
;          <LOG_RETVAL>,
;          FMT   = "Selector = <FMT_AX>  Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSGIVESEG


;***    DOSICANONICALIZE - Convert a path name into a standard format
;
;       INTERNAL ONLY API.  Used by a couple of dynamic link libraries.
;       The worker routine does NO error checking or memory protection
;       checks.  It is possible to general an internal error if used
;       incorrectly.  DO NOT PUBLISH.
;
;       INVOKE  PUSH@   ASCIIZ  Source          (2 words)
;               PUSH@   ASCIIZ  Dest            (2 words)
;               PUSH    WORD    BackupOffset    (1 word)
;               PUSH    WORD    DestEnd         (1 word)
;               PUSH    WORD    Flags           (1 word)
;               call    DOSICANONICALIZE
;
;       RETURN  (ax) = error code
;

SysEntry DOSICANONICALIZE, ORD_DOSICANONICALIZE, 7

;       72417 removed fscrit
;       enterfscrit                     ; Entering kernel
        ld_dx                           ; get flags
        ld_ax                           ; get destination end
        ld_bx                           ; get backup limit
        ld_di                           ; get offset of dest
        ld_es                           ; get seg of dest
        getusrbufz                      ; copy asciiz string to kernel buffer
        ld_si                           ; get offset of src
        ld_ds_norpl                     ; get seg of src
        farcall w_Canon, ORD_DOSICANONICALIZE                             ;@SEC
;       72417 removed fscrit
;       exitfscrit                      ; Exiting Kernel

EndEntry    DOSICANONICALIZE


;***    DOSIEXECPGM - Execute a program
;
;       INVOKE
;               PUSH@ ObjNameBuf                [2 words]
;               PUSH  WORD ObjNameBufL          [1 words]
;               push    0 = start sync process
;                       1 = start async process, discard result code
;                       2 = start async process, save result code for CWait
;                       3 = start async process, trace
;               PUSH@   Address to argument string
;               PUSH@   Address to environment string
;               PUSH@   Address to place result codes of new program
;               PUSH@   Address of filename string to execute
;               call    DOSIEXECPGM
;
;       RETURN  (AX) = error code
;
;       w_ExecPgm is located in exec.asm

SysEntry DOSIEXECPGM, ORD_DOSIEXECPGM,12, GDT_DOSIEXECPGM

        getusrbufz                      ; copy asciiz string to kernel buffer
        ld_dsdx_norpl                   ; load pointer to kernel buffer
        skip_ptr
        ld_bx
        ld_es                           ; (ES:BX) = environment string
        ld_disi                         ; (DI:SI) = argument string
        ld_ax                           ; exec flag
        ld_tcb TCB_ObjNameBufL          ; move obj buffer length into tcb
        ld_tcb_ptr TCB_ObjNameBuf       ; move obj buffer length into tcb

;***DT  preDOSIEXECPGM - DosIExecPgm pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSIEXECPGM>,
;          TP    = .preDOSIEXECPGM,
;          TYPE  = (PRE,API),
;          GROUP = TK,
;          DESC  = "(OS) DosIExecPgm Pre-Invocation",
;          ASCIIZ= (<KSTK_ARGS>,INDIRECT,<MAXPATHLEN>),
;          <LOG_AX>,
;          FMT   = "Program name = <FMT_ASCIIZ>"
;          FMT   = "Exec flag = <FMT_AX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall w_ExecPgm, ORD_DOSIEXECPGM                                ;@SEC
        skip_ptr
        st_dxax                         ; save result codes

;***DT  postDOSIEXECPGM - DosIExecPgm post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSIEXECPGM>,
;          TP    = .postDOSIEXECPGM,
;          TYPE  = (POST,API),
;          GROUP = TK,
;          DESC  = "(OS) DosIExecPgm Post-Invocation",
;          <LOG_DX>,
;          <LOG_AX>,
;          <LOG_RETVAL>,
;          FMT   = "Pid/Term Code = <FMT_DX>  Result Code = <FMT_AX>",
;          FMT   = "Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSIEXECPGM


;***    DOSIQAPPTYPE - Determine application type
;
;       INVOKE
;               PUSH@   Address of filename string to check
;               PUSH@   Address to place application type code
;               call    DOSIQAPPTYPE
;
;       RETURN  (AX) = error code

SysEntry DOSIQAPPTYPE, ORD_DOSIQAPPTYPE,4, GDT_DOSIQAPPTYPE

        skip_ptr                        ; skip return value pointer
        getusrbufz                      ; copy asciiz string to kernel buffer
        ld_dsdx_norpl                   ; load name pointer

        farcall w_QAppType, ORD_DOSIQAPPTYPE                              ;@SEC
        st_ax                           ; save application type
EndEntry DOSIQAPPTYPE


;***    DOSIRAMSEMREQUEST - requests a ram semaphore
;
;       INVOKE  push    word  OldOwner  ; Previous Owner state
;               push    dword SemHandle ; Semaphore handle      (2 words)
;               push    dword Timeout   ; Timeout value         (2 words)
;               call    DOSIRAMSEMREQUEST
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSIRAMSEMREQUEST, ORD_DOSIRAMSEMREQUEST, 5

        ld_dx                           ; old owner flag
        ld_cx                           ; double word timeout
        ld_di                           ; . . . in di:cx
        ld_bx                           ; Semaphore handle
        ld_ax                           ; . . . passed in ax:bx
        farcall w_RamSemRequest, ORD_DOSIRAMSEMREQUEST                  ;@SEC

EndEntry DOSIRAMSEMREQUEST


;***    DOSIRAMSEMWAKE - Wake up process waiting on a ram semaphore
;
;       INVOKE  push    dword RamSemAddr (2 words)
;               push    word RamSemFlag (1 word)
;               call    DOSIRAMSEMWAKE
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSIRAMSEMWAKE, ORD_DOSIRAMSEMWAKE, 3

        ld_dl                           ; Ram semaphore flag
        ld_bx                           ; Ram semaphore address
        ld_ax                           ; . . . passed in ax:bx
        farcall w_RamSemWake, ORD_DOSIRAMSEMWAKE                        ;@SEC

EndEntry DOSIRAMSEMWAKE


;***    DOSISEMWAIT - Wait for a semaphore to be cleared
;
;       INVOKE  push    dword SemHandle ; Semaphore handle      (2 words)
;               push    dword Timeout   ; Timeout value         (2 words)
;               call    DOSISEMWAIT
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSISEMWAIT, ORD_DOSISEMWAIT, 4, GDT_DOSISEMWAIT

        ld_cx                           ; double word timeout
        ld_di                           ; . . . in di:cx
        ld_bx                           ; Semaphore handle
        ld_ax                           ; . . . passed in ax:bx
        farcall w_SemWait, ORD_DOSISEMWAIT                                ;@SEC

EndEntry DOSISEMWAIT


;***    DOSKILLPROCESS - Terminate a process
;
;       Terminates specified process and decendents (if any).
;
;       INVOKE  push    0 = Terminate process and children      (2 bytes)
;                       1 = Terminate process only
;               push    PID of desired process                  (2 bytes)
;               call    DOSKILLPROCESS
;
;       RETURN  (AX) = 0 = no error
;                    > 0 = error code, invalid PID
;

SysEntry DOSKILLPROCESS, ORD_DOSKILLPROCESS, 2

        ld_bx                                   ; (BX) = PID
        ld_ax                                   ; (AX) = termination flag

;***DT  preDOSKILLPROCESS - DosKillProcess pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSKILLPROCESS>,
;          TP    = .preDOSKILLPROCESS,
;          TYPE  = (PRE,API),
;          GROUP = SIG,
;          DESC  = "(OS) DosKillProcess Pre-Invocation",
;          <LOG_BX>,
;          FMT   = "PID = <FMT_BX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall w_KillProcess, ORD_DOSKILLPROCESS                         ;@SEC

;***DT  postDOSKILLPROCESS - DosKillProcess post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSKILLPROCESS>,
;          TP    = .postDOSKILLPROCESS,
;          TYPE  = (POST,API),
;          GROUP = SIG,
;          DESC  = "(OS) DosKillProcess Post-Invocation",
;          <LOG_RETVAL>,
;          FMT   = "Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSKILLPROCESS


;***    DOSLOADMODULE - Load dynamic link library module.
;
;       DOSLOADMODULE loads a dynamic link library module
;       and returns a handle for the library module.
;
;       ENTRY   PUSH@ ObjNameBuf                [2 words]
;               PUSH  WORD ObjNameBufL          [1 words]
;               PUSH@ ASCIIZ ModuleName         [2 words]
;               PUSH@ WORD ModuleHandle         [2 words]
;               CALL  DOSLOADMODULE
;
;               where ObjNameBuf is the address of a buffer in which
;               the name of an object which contributed to the failure
;               of DOSLOADMODULE call is to be placed.
;
;               where ObjNameBufL is the length, in bytes, of the
;               buffer described by ObjNameBuf.
;
;               where   ModuleName is the address of an ASCIIZ name
;               string containing the pathname for the library module
;               file.
;
;               ModuleHandle is the address of a WORD to return the
;               handle for the library module loaded.
;
;       EXIT    (AX) = return code
;                       0 [success]
;                       ModuleHandle is filled in with the
;                       library module handle.
;
;                       non-zero [error]
;                       ObjNameBuf is filled in with the name of the Object
;                       that caused the error.

SysEntry DOSLOADMODULE, ORD_DOSLOADMODULE,7,GDT_DOSLOADMODULE

;       enterfscrit                     ; Entering kernel
        skip_ptr                        ; skip ptr for handle
        getusrbufz                      ; copy asciiz string to kernel buffer
        ld_di                           ; offset into DI
        ld_es_norpl                     ; selector into ES
        ld_ax                           ; (AX) = length of ObjNameBuf
        ld_si
        ld_ds                           ; (DS:SI) -> obj name buffer

;***DT  preDOSLOADMODULE - DosLoadModule pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSLOADMODULE>,
;          TP    = .preDOSLOADMODULE,
;          TYPE  = (PRE,API),
;          GROUP = LDR,
;          DESC  = "(OS) DosLoadModule Pre-Invocation",
;          ASCIIZ= (<KSTK_ARGS>+<SKIP_PTR>,INDIRECT,<MAXPATHLEN>),
;          FMT   = "Module name = <FMT_ASCIIZ>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall w_loadmodule, ORD_DOSLOADMODULE                           ;@SEC
        st_bx                           ; fill in the module handle

;***DT  postDOSLOADMODULE - DosLoadModule post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSLOADMODULE>,
;          TP    = .postDOSLOADMODULE,
;          TYPE  = (POST,API),
;          GROUP = LDR,
;          DESC  = "(OS) DosLoadModule Post-Invocation",
;          <LOG_BX>,
;          <LOG_RETVAL>,
;          FMT   = "Module handle = <FMT_BX> Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

;       exitfscrit                      ; Exiting Kernel

EndEntry DOSLOADMODULE


;***    DOSLOCKSEG - Discard-lock a segment
;
;       INVOKE  push    word selector           (1 word)
;               call    DOSLOCKSEG
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSLOCKSEG, ORD_DOSLOCKSEG, 1

        ld_ax                           ; selector
        farcall         w_LockSeg, ORD_DOSLOCKSEG                         ;@SEC

EndEntry DOSLOCKSEG


;***    DOSMAKEPIPE - Create a Pipe
;
;       INVOKE  push@   word ReadHandle ; Address of Read handle  (2 words)
;               push@   word WriteHandle; Address of Write handle (2 words)
;               push    word PipeSize   ; Size of Pipe            (1 words)
;               call    DOSMAKEPIPE
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSMAKEPIPE, ORD_DOSMAKEPIPE, 5, GDT_DOSMAKEPIPE

;       72417 removed fscrit
;       enterfscrit                     ; Entering kernel
        ld_cx                           ; size of bufr in cx

;***DT  preDOSMAKEPIPE - DosMakePipe pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSMAKEPIPE>,
;          TP    = .preDOSMAKEPIPE,
;          TYPE  = (PRE,API),
;          GROUP = PIP,
;          DESC  = "(OS) DosMakePipe Pre-Invocation",
;          <LOG_CX>,
;          FMT   = "Size of pipe = <FMT_CX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall w_MakePipe, ORD_DOSMAKEPIPE                               ;@SEC
        skip_word
        st_bx                           ; pass back the write handle
        st_ax                           ; pass back the read handle

;***DT  postDOSMAKEPIPE - DosMakePipe post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSMAKEPIPE>,
;          TP    = .postDOSMAKEPIPE,
;          TYPE  = (POST,API),
;          GROUP = PIP,
;          DESC  = "(OS) DosMakePipe Post-Invocation",
;          <LOG_AX>,
;          <LOG_BX>,
;          <LOG_RETVAL>,
;          FMT   = "Read handle = <FMT_AX> Write handle = <FMT_BX>",
;          FMT   = "Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

;       72417 removed fscrit
;       exitfscrit                      ; Exiting Kernel

EndEntry DOSMAKEPIPE


;***    DOSMEMAVAIL  - return size of largest available block
;                      of memory (approximation only).
;
;       INVOKE  push@   dword availSize         (2 words)
;               call    DOSMEMAVAIL
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSMEMAVAIL, ORD_DOSMEMAVAIL, 2

        farcall         w_MemAvail, ORD_DOSMEMAVAIL                       ;@SEC
        st_dxax                         ; return availSize

EndEntry DOSMEMAVAIL


;***    DOSOPENSEM - Open an existing system semaphore
;
;       INVOKE  push@   dword SemHandle ; Semaphore handle      (2 words)
;               push@   ASCIIZ SemName  ; Semaphore Name        (2 words)
;               call    DOSOPENSEM
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSOPENSEM, ORD_DOSOPENSEM, 4

        enterfscrit                     ; Entering kernel
        getusrbufz
        ld_si                           ; Semaphore Name in DS:SI
        ld_ds_norpl

;***DT  preDOSOPENSEM - DosOpenSem pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSOPENSEM>,
;          TP    = .preDOSOPENSEM,
;          TYPE  = (PRE,API),
;          GROUP = SEM,
;          DESC  = "(OS) DosOpenSem Pre-Invocation",
;          ASCIIZ=(<KSTK_ARGS>,INDIRECT,<MAXPATHLEN>),
;          FMT   = "Name = <FMT_ASCIIZ>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall w_OpenSem, ORD_DOSOPENSEM                                 ;@SEC
        skip_ptr                        ; skip SemName
        st_dxax                         ; Handle returned in DX:AX

;***DT  postDOSOPENSEM - DosOpenSem post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSOPENSEM>,
;          TP    = .postDOSOPENSEM,
;          TYPE  = (POST,API),
;          GROUP = SEM,
;          DESC  = "(OS) DosOpenSem Post-Invocation",
;          <LOG_DX>,
;          <LOG_AX>,
;          <LOG_RETVAL>,
;          FMT   = "Handle = <FMT_DX><FMT_AX>  Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

        exitfscrit                      ; Exiting Kernel

EndEntry DOSOPENSEM


;***    DOSPHYSICALDISK - Dynamic Link Call for Partitionable Disk Support
;
;       FUNCTION: Set up dynamic link entry and exit for worker routine
;                 w_PhysicalDisk which provides information and access
;                 to partitionable media.
;
;       NOTES:  The handle returned for the specified partitionable
;               disk can ONLY be used with the Category 9 Generic IOCtl.
;
;       INVOKE
;
;       ENTRY POINT:  DosPhysicalDisk
;          LINKAGE:   Call Far
;
;       INPUT:  Caller pushes onto stack
;              WORD  Function   = Type of information on the
;                                 partitionable disk(s) to obtain:
;                                  1 = Obtain the total number of
;                                      partitionable disks
;                                  2 = Obtain a handle to use with
;                                      Category 9 IOCtls
;                                  3 = Release a handle for a
;                                      partitionable disk
;              DWORD DataPtr    =  Pointer to the return buffer
;              WORD  DataLen    =  Length of the return buffer
;              DWORD ParmPtr    =  Pointer to the user-supplied info
;              WORD  ParmLen    =  Length of user-supplied info
;
;       EXIT-NORMAL: AX = Zero
;
;       EXIT-ERROR:  AX = ERROR_INVALID_PARAMETER
;                         ERROR_ACCESS_DENIED
;                         ERROR_INVALID_HANDLE
;
;       EFFECTS:  AX is destroyed
;
;       INTERNAL REFERENCES:
;          ROUTINES:
;
;          DATA AREA:
;
;       EXTERNAL REFERENCES:
;          ROUTINES:   System Call Interpreter (SCI)
;                      w_PhysicalDisk
;
;          DATA AREA:
;

SysEntry DOSPHYSICALDISK, ORD_DOSPHYSICALDISK, 7

        skip_word                       ; skip over ParmLen
        rplstampptr                     ;stamp user info buf ptr
        skip_ptr                        ;  and skip over it
        skip_word                       ; skip over Retbuffer length
        rplstampptr                     ; stamp RetBuffer ptr
        skip_ptr                        ; skip over it
        ld_ax                          ;  Load AX with Function off the stack
        ld_parampkt_bx                  ; BX = ptr to argframe

;***DT  preDOSPHYSICALDISK - DosPhysicalDisk pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSPHYSICALDISK>,
;          TP    = .preDOSPHYSICALDISK,
;          TYPE  = (PRE,API),
;          GROUP = FS,
;          DESC  = "(OS) DosPhysicalDisk Pre-Invocation",
;          <LOG_AX>,
;          <LOG_BX>,
;          <LOG_CX>,
;          FMT   = "Function = <FMT_AX>  Data Len = <FMT_BX>",
;          FMT   = "Parm Len = <FMT_CX>",

        RASpretrace                     ; RAS pre-invocation trace

        farcall w_PhysicalDisk, ORD_DOSPHYSICALDISK                       ;@SEC

;***DT  postDOSPHYSICALDISK - DosPhysicalDisk post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSPHYSICALDISK>,
;          TP    = .postDOSPHYSICALDISK,
;          TYPE  = (POST,API),
;          GROUP = FS,
;          DESC  = "(OS) DosPhysicalDisk Post-Invocation",
;          <LOG_RETVAL>,
;          FMT   = "Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSPHYSICALDISK


IFDEF   PROFILE

;***    DOSPROFILE - perform kernel profiling
;
;       INVOKE  push    WORD  Function          (1 word)
;               push    WORD  Type              (1 word)
;               push    WORD  Parameter         (1 word)
;               push@   OTHER DataBuf           (2 words)
;               push@   OTHER NameBuf           (2 words)
;               push@   WORD  SegmentNumber     (2 words)
;               call    DBPROFILE
;
;       RETURN  (ax) = return code
;                       0 - success
;                       nonzero - error
;
;       NOTE    Worker does protection validation.

SysEntry    DOSPROFILE, ORD_DOSPROFILE, 9
        skip_ptr                ; Skip ptr to return segment number
        ld_di
        ld_es                   ; get name buffer pointer
        ld_si
        ld_ds                   ; get data buffer pointer
        ld_dx                   ; get parameter
        ld_cx                   ; get profile type
        ld_ax                   ; get function number
        farcall w_DosProfile, ORD_DOSPROFILE                              ;@SEC
        st_bx                   ; Store segment number
EndEntry    DOSPROFILE

ENDIF ; PROFILE

;***    DOSPTRACE - 16 bit debugger interface
;
;       INVOKE  push@   Trace Buffer            (2 words)
;               call    DOSPTRACE
;
;       RETURN  (ax) = return code
;                       0 - success
;                       nonzero - error
;

SysEntry DOSPTRACE, ORD_DOSPTRACE, 2

        rplstampptr                     ; RPL stamp buffer pointer
        ld_si                           ; (bx:si) -> uPTB
        ld_bx

        farcall w_Ptrace, ORD_DOSPTRACE                ; call the worker @SEC

EndEntry DOSPTRACE

;***    DOSR2STACKREALLOC - Reallocate ring 2 stack
;
;       INVOKE
;               push    WORD SIZE
;               call    DOSR2STACKREALLOC
;
;       RETURN  (ax) = return code
;                       0 - success
;                       nonzero - error
;
SysEntry DOSR2STACKREALLOC, ORD_DOSR2STACKREALLOC,1

        ld_bx                           ; size

        RASpretrace                     ; RAS pre-invocation trace   ;AA03898

        farcall w_R2StackRealloc, ORD_DOSR2STACKREALLOC                   ;@SEC

        RASposttrace                    ; RAS post-invocation trace  ;AA03898

EndEntry DOSR2STACKREALLOC

;***    DOSQPROCSTATUS - get process status info
;
;       DOSQPROCSTATUS returns process status information.
;
;       ENTRY   PUSH@ Buffer                    [2 words]
;               PUSH  WORD Length               [1 word]
;               CALL  DOSQPROCSTATUS
;
;               where Buffer is the address of a buffer in which
;               the status information will be placed.
;                   Word 0: first record
;                      .
;                      .
;                      .
;
;               where Length is the length, in bytes, of the
;               buffer described by Buffer.
;
;       EXIT    (AX) = return code
;                       0 [success]
;                       Buffer is filled in with the requested
;                       status information
;
;                       non-zero [error]
;                           ERROR_NOT_ENOUGH_MEMORY - buffer not big enough
;                           to contain all data.  Word 0 of Buffer is invalid
;                           (will be set to 0).
;                           Caller may increase Length and try again.
;                           ERROR_INTERRUPT

SysEntry DOSQPROCSTATUS, ORD_DOSQPROCSTATUS, 3
        enterfscrit                     ; Entering kernel
        ld_ax                           ; (AX) = Length
        ld_di                           ; (DI) = offset to Buffer
        ld_es                           ; (ES) = selector to Buffer
        farcall w_DosQProcStatus, ORD_DOSQPROCSTATUS                      ;@SEC
        exitfscrit                      ; Exiting Kernel
EndEntry        DOSQPROCSTATUS

;***    DOSREALLOCHUGE - Reallocate a huge private data segment
;
;       INVOKE  push    word numseg             (1 word)
;               push    word size               (1 word)
;               push    word selector           (1 word)
;               call    DOSREALLOCHUGE
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSREALLOCHUGE, ORD_DOSREALLOCHUGE, 3

        ld_cx                           ; selector
        ld_bx                           ; size
        ld_ax                           ; numseg

;***DT  preDOSREALLOCHUGE - DosReallocHuge pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSREALLOCHUGE>,
;          TP    = .preDOSREALLOCHUGE,
;          TYPE  = (PRE,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosReallocHuge Pre-Invocation",
;          <LOG_AX>,
;          <LOG_BX>,
;          <LOG_CX>,
;          FMT   = "New size = <FMT_AX><FMT_BX>  Selector = <FMT_CX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall         w_ReallocHuge, ORD_DOSREALLOCHUGE                 ;@SEC

;***DT  postDOSREALLOCHUGE - DosReallocHuge post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSREALLOCHUGE>,
;          TP    = .postDOSREALLOCHUGE,
;          TYPE  = (POST,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosReallocHuge Post-Invocation",
;          <LOG_RETVAL>,
;          FMT   = "Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSREALLOCHUGE


;***    DOSREALLOCSEG - Reallocate a segment
;
;       INVOKE  push    word size               (1 word)
;               push    word selector           (1 word)
;               call    DOSREALLOCSEG
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSREALLOCSEG, ORD_DOSREALLOCSEG, 2, GDT_DOSREALLOCSEG

        ld_ax                           ; selector
        ld_bx                           ; size

;***DT  preDOSREALLOCSEG - DosReallocSeg pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSREALLOCSEG>,
;          TP    = .preDOSREALLOCSEG,
;          TYPE  = (PRE,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosReallocSeg Pre-Invocation",
;          <LOG_AX>,
;          <LOG_BX>,
;          FMT   = "Selector = <FMT_AX>  New size = <FMT_BX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall         w_ReallocSeg, ORD_DOSREALLOCSEG                   ;@SEC

;***DT  postDOSREALLOCSEG - DosAllocSeg post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSREALLOCSEG>,
;          TP    = .postDOSREALLOCSEG,
;          TYPE  = (POST,API),
;          GROUP = SEL,
;          DESC  = "(OS) DosReallocSeg Post-Invocation",
;          <LOG_RETVAL>,
;          FMT   = "Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSREALLOCSEG


;***    DOSSEMSETWAIT - Set a semaphore and wait for next clear
;
;       INVOKE  push    dword SemHandle ; Semaphore handle      (2 words)
;               push    dword Timeout   ; Timeout value         (2 words)
;               call    DOSSEMSETWAIT
;
;       RETUR(ax) = return code
;                       0 - success
;

SysEntry DOSSEMSETWAIT, ORD_DOSSEMSETWAIT, 4

        ld_cx                           ; double word timeout
        ld_di                           ; . . . in di:cx
        ld_bx                           ; Semaphore handle
        ld_ax                           ; . . . passed in ax:bx

;***DT  preDOSSEMSETWAIT - DosSemSetWait pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSSEMSETWAIT>,
;          TP    = .preDOSSEMSETWAIT,
;          TYPE  = (PRE,API),
;          GROUP = SEM,
;          DESC  = "(OS) DosSemSetWait Pre-Invocation",
;          <LOG_AX>,
;          <LOG_BX>,
;          FMT   = "Handle = <FMT_AX><FMT_BX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall w_SemSetWait, ORD_DOSSEMSETWAIT                           ;@SEC

;***DT  postDOSSEMSETWAIT - DosSemSetWait post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSSEMSETWAIT>,
;          TP    = .postDOSSEMSETWAIT,
;          TYPE  = (POST,API),
;          GROUP = SEM,
;          DESC  = "(OS) DosSemSetWait Post-Invocation",
;          <LOG_RETVAL>,
;          FMT   = "Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSSEMSETWAIT


;***    DOSSENDSIGNAL - Send CTL-C or CTL-Break within Command Tree
;
;       INVOKE  push    word CSID               (1 word)
;               push    word Signal_Id          (1 word)
;               call    DOSSENDSIGNAL
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSSENDSIGNAL, ORD_DOSSENDSIGNAL, 2

        ld_ax                           ; sig number
        ld_cx                           ; CSID

;***DT  preDOSSENDSIGNAL - DosSendSignal pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSSENDSIGNAL>,
;          TP    = .preDOSSENDSIGNAL,
;          TYPE  = (PRE,API),
;          GROUP = SIG,
;          DESC  = "(OS) DosSendSignal Pre-Invocation",
;          <LOG_AX>,
;          <LOG_CX>,
;          FMT   = "Signal number = <FMT_AX>  CSID = <FMT_CX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall         w_SendSignal, ORD_DOSSENDSIGNAL                   ;@SEC

;***DT  postDOSSENDSIGNAL - DosSendSignal post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSSENDSIGNAL>,
;          TP    = .postDOSSENDSIGNAL,
;          TYPE  = (POST,API),
;          GROUP = SIG,
;          DESC  = "(OS) DosSendSignal Post-Invocation",
;          <LOG_RETVAL>,
;          FMT   = "Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSSENDSIGNAL


;***    DOSSETSIGHANDLER - Handle signals
;
;       INVOKE  push    dword RoutineAddress    (2 words)
;               push@   dword PrevAddress       (2 words)
;               push@   word PrevAction         (2 words)
;               push    word Action             (1 word)
;               push    word SigNumber          (1 word)
;               call    DOSSETSIGHANDLER
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSSETSIGHANDLER, ORD_DOSSETSIGHANDLER, 8

        ld_ax                           ; signal number into ax
        ld_bx                           ; action into bl
        skip_ptr                        ; skip pointer for previous action
        skip_ptr                        ; skip pointer for previous address

;*  The following pointer is not used by the ring 0 code, so it does not have
;   to be rpl-stamped.  It is used later for signal handling.

        ld_cx                           ; offset of handler
        ld_dx                           ; segment of handler

;***DT  preDOSSETSIGHANDLER - DosSetSigHandler pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSSETSIGHANDLER>,
;          TP    = .preDOSSETSIGHANDLER,
;          TYPE  = (PRE,API),
;          GROUP = SIG,
;          DESC  = "(OS) DosSetSigHandler Pre-Invocation",
;          <LOG_AX>,
;          <LOG_BX>,
;          FMT   = "Signal number = <FMT_AX> Action = <FMT_BX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall         w_SetSigHandler, ORD_DOSSETSIGHANDLER             ;@SEC
        skip_word                       ; skip signal number
        cmp_je          4,ssh1          ; If action was 4, don't return the
        skip_word                       ; skip action parameter
        stnz_cx                         ; return previous action
        stnz_dxax                       ; return previous address
ssh1:

;***DT  postDOSSETSIGHANDLER - DosSetSigHandler post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSSETSIGHANDLER>,
;          TP    = .postDOSSETSIGHANDLER,
;          TYPE  = (POST,API),
;          GROUP = SIG,
;          DESC  = "(OS) DosSetSigHandler Post-Invocation",
;          <LOG_RETVAL>,
;          FMT   = "Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSSETSIGHANDLER


;***    DOSSETVEC - set exception handler
;
;       INVOKE  push    WORD VecNum             (1 word)
;               push    DWORD RtnAddress        (2 words)
;               push@   DWORD PrevAddress       (2 words)
;               call    DOSSETVEC
;
;       RETURN  (ax) = return code
;                       0 - success
;                       nonzero - error
;                               Invalid vector number
;

SysEntry DOSSETVEC, ORD_DOSSETVEC, 5

        skip_ptr                        ; Skip PrevAddress for now
        ld_bx                           ; Put RtnAddress in CX:BX
        ld_cx
        ld_ax                           ; Put VecNum in AX

;***DT  preDOSSETVEC - DosSetVec pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSSETVEC>,
;          TP    = .preDOSSETVEC,
;          TYPE  = (PRE,API),
;          GROUP = SIG,
;          DESC  = "(OS) DosSetVec Pre-Invocation",
;          <LOG_CX>,
;          <LOG_BX>,
;          <LOG_AX>,
;          FMT   = "Return address = <FMT_CX><FMT_BX> Vector = <FMT_AX>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall w_SetVec, ORD_DOSSETVEC                ; Call the worker  @SEC
        st_dxax                         ; Store previous address

;***DT  postDOSSETVEC - DosSetVec post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSSETVEC>,
;          TP    = .postDOSSETVEC,
;          TYPE  = (POST,API),
;          GROUP = SIG,
;          DESC  = "(OS) DosSetVec Post-Invocation",
;          <LOG_RETVAL>,
;          FMT   = "Return code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSSETVEC


;***    DOSSICG - SysInit's Call Gate
;
;       INVOKE  push@   other buffer            (2 words)
;               call    DOSSICG
;
;       RETURN  (ax) = 0 = return code
;

SysEntry DOSSICG,0,2,GDT_DOSSICG

        ld_si                           ; Load pointer into DS:SI
        ld_ds
        farcall         w_SICG, 0       ; in msinit.asm                   ;@SEC

EndEntry    DOSSICG




;***    DOSSIZESEG - Return size of a segment
;
;       INVOKE  push    word selector           (1 word)
;               push@   dword segSize           (2 words)
;               call    DOSSIZESEG
;
;       RETURN  (ax) = return code
;                       0 - success
;
SysEntry DOSSIZESEG, ORD_DOSSIZESEG, 3

        skip_ptr                        ; skip return pointer
        ld_ax                           ; selector
        farcall w_SizeSeg, ORD_DOSSIZESEG               ; see v1wrk.asm   @SEC
        st_dxax                         ; return segSize

EndEntry DOSSIZESEG


;***    DOSSYSTEMSERVICE - respond to/wait for a system event
;
;       INVOKE  push    WORD Function           (1 word)
;               push@   OTHER ActionPacket      (2 words)
;               push@   OTHER ResponsePacket    (2 words)
;               call    DOSSYSTEMSERVICE
;
;       RETURN  (ax) = return code
;                       0 - success
;                       nonzero - error
;                               Invalid function number
;                               Server already exists
;

SysEntry DOSSYSTEMSERVICE, ORD_DOSSYSTEMSERVICE, 5

        ld_ax                           ; (DX:AX) = ResponsePacket address
        rplstampsel
        ld_dx
        ld_si                           ; (BX:SI) =  ActionPacket address
        rplstampsel
        ld_bx
        ld_di                           ; (DI) = Function


;***DT preDOSSYSTEMSERVICE - DosSystemService pre-invocation trace point
;
;    TRACE MINOR = <RAS_PRE_DOSSYSTEMSERVICE>,
;          TP    = .preDOSSYSTEMSERVICE,
;          TYPE  = (PRE, API),
;          GROUP = TK,
;          DESC  = "(OS) DosSystemService Pre-Invocation",
;          <LOG_DI>,
;          FMT   = "Function = <FMT_DI>"

        RASpretrace                     ; RAS pre-invocation trace

        farcall         w_SystemService, ORD_DOSSYSTEMSERVICE ; call the worker  @SEC


;***DT postDOSSYSTEMSERVICE - DosSystemService post-invocation trace point
;
;    TRACE MINOR = <RAS_POST_DOSSYSTEMSERVICE>,
;          TP    = .postDOSSYSTEMSERVICE,
;          TYPE  = (POST, API),
;          GROUP = TK,
;          DESC  = "(OS) DosSystemService Post-Invocation",
;          <LOG_RETVAL>
;          FMT   = "Return Code = <FMT_RETVAL>"

        RASposttrace                    ; RAS post-invocation trace

EndEntry DOSSYSTEMSERVICE


;***    DOSUNLOCKSEG - Discard-unlock a segment
;
;       INVOKE  push    word selector           (1 word)
;               call    DOSUNLOCKSEG
;
;       RETURN  (ax) = return code
;                       0 - success
;

SysEntry DOSUNLOCKSEG, ORD_DOSUNLOCKSEG, 1

        ld_ax                           ; selector
        farcall         w_UnlockSeg, ORD_DOSUNLOCKSEG                     ;@SEC

EndEntry DOSUNLOCKSEG


;***    PANICWRITE - Write a string to the console NOW
;
;       INVOKE  push    WORD FileHandle         (1 word)
;               push@   OTHER BufferArea        (2 words)
;               push    WORD BufferLength       (1 word)
;               push@   WORD BytesWritten       (2 words)
;               call    DOSPANICWRITE
;
;       RETURN  (ax) = return code
;
;       BUGBUG  The ver_dxcx_buf thop is a noop, so we do *NO* protection
;               validation in this call.

SysEntry PANICWRITE,0,6,GDT_PANICWRITE

        enterfscrit                     ; Entering kernel
        skip_ptr                        ; return value point, skip for now
        ld_cx                           ; put count in CX
        ld_dsdx                         ; load pointer to buffer
        ld_bx                           ; put handle in BX
        farcall WrtToScrn16, 0          ; blast string to con             ;@SEC
        exitfscrit                      ; Exiting Kernel

EndEntry PANICWRITE

HIGH3CODE ENDS

        END
