/*static char *SCCSID = "@(#)mvdmexp.h	6.3 91/07/17";*/
/***    MVDMEXP.H
 *
 *      SCCSID = @(#)mvdmexp.h	6.3 91/07/17
 *
 *      IBM/Microsoft Confidential
 *
 *      Copyright (c) IBM Corporation 1987, 1989
 *      Copyright (c) Microsoft Corporation 1987, 1989
 *
 *      All Rights Reserved
 *
 *
 *      TITLE
 *
 *      MVDM Exports to the kernel
 *
 *      DESCRIPTION
 *
 *      NOTE
 *
 *      MODIFICATION HISTORY
 *
 *      Created SB  88/12/19
 *
 *      To include this file you must include <basedef.h>.
 */

/* XLATOFF */
/* Start address for resident MVDM Kernel Instance data; 1MB+64k */
#define MVDM_INST_DATA_ADDR     ((1L << 20) + (1L << 16))

/* Start address for swappable MVDM Kernel Instance data; 1MB+128K */
#define MVDM_SINST_DATA_ADDR    ((1L << 20) + (1L << 17))
/* XLATON */


#ifndef FOR_MVDMEXP

/* Maximum number of VDMs in the system */
#define VDMLIMIT        16

/* XLATOFF */
#define BEGIN_MVDM_INIT_CODE            code_seg("CINIT_TEXT", "CODE")
#define END_MVDM_INIT_CODE              code_seg()

#define BEGIN_MVDM_INIT_DATA            data_seg("CINIT_DATA", "CINITDATA")
#define END_MVDM_INIT_DATA              data_seg()

#define BEGIN_MVDM_GLOBAL_CODE          code_seg()
#define END_MVDM_GLOBAL_CODE            code_seg()

#define BEGIN_MVDM_GLOBAL_DATA          data_seg()
#define END_MVDM_GLOBAL_DATA            data_seg()

#define BEGIN_MVDM_SWAP_CODE            code_seg("MVDMSWAP_TEXT","CODE")
#define END_MVDM_SWAP_CODE              code_seg()

#define BEGIN_MVDM_SWAP_DATA            data_seg("CSWAP_DATA","CSWAPDATA")
#define END_MVDM_SWAP_DATA              data_seg()

#define BEGIN_MVDM_INSTANCE_DATA        data_seg("MVDMINSTDATA", "MIDATA")
#define END_MVDM_INSTANCE_DATA          data_seg()

#define BEGIN_MVDM_SWAP_INSTANCE        data_seg("SWAPINSTDATA","SIDATA")
#define END_MVDM_SWAP_INSTANCE          data_seg()
/* XLATON */

/*** VDMM Defines
 */

#define VDMM_INIT_FAILED    1
#define VDMM_MAXV86ADDR     ((1 << 20) + (1 << 16) - 1)

/*
 * MVDM kernel instance data loading address.
 * Boot loader will load the MVDM kernel instance data at this
 * address.
 */

/* XLATOFF */
extern PTCB     vdmid_mphvdmptcb;
extern PPTDA    vdmid_mphvdmpptda;
extern BOOL     fIsMVDMPresent;
extern BOOL     fIsInitTime;
extern ULONG    cbKrnlInstance;      // MVDM kernel instance data size  (Fixed)
extern PVOID    pKrnlInstance;       // Global add of kernel inst data  (Fixed)
extern ULONG    cbKrnlInstSwap;      // MVDM kernel instance data size  (swap)
extern PVOID    pKrnlInstSwap;       // Global add. of kernel inst data (swap)
extern LONG     InterruptLevel;      // Interrupt level
extern PVOID    pBlackHole;          // Black Hole starting address
extern ULONG    cbBlackHole;         // Black Hole size
extern UCHAR    uchLastDrive;        // Last Drive; used by MVDM/FileSystem

#define ISMVDMPRESENT    (fIsMVDMPresent)
#define ISINITTIME       (fIsInitTime)
#define ISTASKTIME       (InterruptLevel == -1 ? TRUE : FALSE)
#define ISVDMTASKTIME    (ISTASKTIME && (pPTDACur->ptda_infoseg.LIS_ProcType == LIS_PT_REALMODE))
#define QUERYPTCB(hvdm)  (REFHVDM(hvdm,PTCB,vdmid_mphvdmptcb))
#define QUERYPPTDA(hvdm) (REFHVDM(hvdm,PPTDA,vdmid_mphvdmpptda))
/* XLATON */

/* ASM
ISMVDMPRESENT   MACRO               ; Test if MVDM is present
        mov     eax,[_fIsMVDMPresent]
        ENDM

                                    ; Test if it is Init time
ISINITTIME      MACRO
        mov     eax,[_fIsInitTime]
        ENDM

                                    ; Test if it is Task time
ISTASKTIME      MACRO
        LOCAL   itt10
        xor     eax,eax             ; eax = FALSE, interrupt time
        cmp     [InterruptLevel],-1
        jne     short itt10
        mov     eax,CTRUE           ; eax = TRUE, task time
itt10:
        ENDM

                                    ; Test if it is VDM Task time
ISVDMTASKTIME   MACRO
        LOCAL   ivt10
        ISTASKTIME
        or      eax,eax             ; If FALSE, interrupt time
        je      short ivt10
        mov     eax,[_pPTDACur]
        cmp     [eax].ptda_infoseg.LIS_ProcType,LIS_PT_REALMODE
        mov     eax,FALSE           ; eax = FALSE, if not VDM task time
        jne     short ivt10
        mov     eax,CTRUE           ; eax = TRUE, if VDM task time
ivt10:
        ENDM

*/

/*** VDMM Export Prototypes
 */

/* XLATOFF */
BOOL  PASCAL VDMMKillVDM(PID);
BOOL  PASCAL VDMMDispatchPageFault(PVOID);
PVOID PASCAL VDMMAssignAddress(ULONG,ULONG,PVOID);
BOOL  PASCAL VDMMDeassignAddress(PVOID,ULONG);
VOID  PASCAL VDMMSwitchBgnd(USHORT);
VOID  PASCAL VDMMSwitchFgnd(USHORT);
BOOL  PASCAL VDMMLoadingVDD(USHORT);
BOOL  PASCAL VDMMUnloadingVDD(USHORT);
VOID  PASCAL VDMMPDBChange(ULONG);
VOID  PASCAL VDMMPDBDestroy(ULONG);
/* XLATON */


/*** 8086 Emulation Defines
 */

/*** 8086 Emulation Export Prototypes
 */

/* XLATOFF */
INT  PASCAL EM86Init(VOID);
INT  PASCAL EM86CreateVDM(VOID);
VOID PASCAL EM86DestroyVDM(VOID);
VOID PASCAL EM86CleanUp(VOID);
/* XLATON */

/***    SVC - V86 mode system trap
 *
 *      This macro is used by the V86 mode DOS emulation code to
 *      execute a protected mode function.
 */

/* ASM
svc   macro   i
      hlt
      db      i
      db      not i
      endm
*/


/*** Dos Emulation Export Prototypes
 */

/* XLATOFF */
INT PASCAL DEMCreateVDM1(VOID);
INT PASCAL DEMCreateVDM2(PSZ, PSZ, PBYTE, ULONG, ULONG, PSZ);
VOID PASCAL DEMDestroyVDM1();
VOID PASCAL DEMDestroyVDM2();
/* XLATON */

#endif      // FOR_MVDMEXP
