/***	EM86.H
 *
 *       Version 1.10.1.2, for src/dos/mvdm/em86.h, em86, mer.krnl, 960610.1
 *
 *	SCCSID = @(#)em86.h	6.4 91/07/08
 *
 *	Title:
 *
 *	Local 8086 Emulation Header File
 *
 *	Description:
 *
 *	Contains all the local (not exported) defines and
 *	structures for the 8086 emulation component.
 *	
 *	Gordon Kuo    02/24/96                                         149007
 *	Enhance VPMEXC structure to process V86 mode exception handler 149007
 *	
 */

/*INT32*/

/***ET+ Undocumented VDHInstallIntHook options */
#define VDH_PRE_HOOK		0x00000002L // BUGBUG - To be moved to v8086.h
/*end*/

/* WARNING: The INT_* constants can only use bits 0 and 1, because they
 * are stored in the low bits of dword-aligned heap pointers (grin) -JTP
 */
#define INT_BP_HOOK		0x00000001L
#define INT_PRE_HOOK		0x00000002L

//c-begin
#define ALIGNP(p)		((PVOID)((ULONG)(p) & ~0x03))
#define GETBITSP(p)		((ULONG)(p) & 0x03)
#define SETBITSP(p,f)		((PVOID)((ULONG)(p) | f))
//c-end


/* Unchangeable misc. definitions */

#define NUM_OPCODE		256	// number of opcodes in table
#define NUM_INTS		256	// number of software interrupts
#define NBITS_ULONG		32	// number of bits in a ULONG
#define NBITS_BYTE		8	// number of bits in a BYTE
#define MAX_PORT_NUM		0xFFFF	// highest port number
#define ARPL_OPCODE		0x63	// VDM BP instruction
#define CLTS_OPCODE		06	// CLTS instruction (2nd byte)
#define MAX_HOOK_TYPE		6	// max hook type value for VDHAllocHook

/* Adjustable misc. definitions */

#define NUM_VDMBP_ENTRIES	128	// total number of VDM BPs
#define NUM_VDH_REGS		12	// number of reg for PushReg/PopReg
#define NUM_GLOBAL_CONTEXT	16	// number of global context hooks

/*
 * This the port number when direct lookup is no longer used and
 * a port number hash table is used.  The current port number is
 * the highest port used on a PC.  Some of the newer ports on the
 * PS/2's are higher and are hashed.  The initial iopm size is
 * based on the number of local ports for the same reasons.
 */

#define PORT_HASH_START 	0x400	// start of I/O port hashing
#define INITIAL_IOPM_SIZE	(PORT_HASH_START/8)

/*
 * The number of hash table entries is controlled by this
 * definition.	It must be a power of 2 (so a simple mask
 * can be used to index the table).
 */

#define NUM_HASH_ENTRIES	0x20	// number of hash entries
#define PORT_HASH_MASK		(NUM_HASH_ENTRIES - 1)

/* A20 wrapping definitions */

#define A20_WRAP_AT		((PVOID) 0x100000L)
#define A20_WRAP_TO		0
#define NUM_A20_PAGES		16

/* I/O handler flags - determines which entry in the IOH to use */

#define IO_HDLR_SHIFT		0
#define IO_HDLR_MASK		0x000000FF
#define IO_HDLR_BYTE_INPUT	(ioh_pbihByteInput)
#define IO_HDLR_BYTE_OUTPUT	(ioh_pbohByteOutput)
#define IO_HDLR_WORD_INPUT	(ioh_pwihWordInput)
#define IO_HDLR_WORD_OUTPUT	(ioh_pwohWordOutput)
#define IO_HDLR_OTHER		(ioh_pothOther)

/* Instruction prefix flags - must be same as I/O type flags (v8086.h) */

#define PREFIX_OPER32		IO_TYPE_DWORD
#define PREFIX_ADDR32		IO_TYPE_ADDR32
#define PREFIX_SEG32		0x80000000
// For the instructions we decode, the "rep" and "repne" prefixes mean
// the same thing.  The difference would only be significant for decoding
// stos, movs, etc. which will never happen.
#define PREFIX_REP		IO_TYPE_REP
#define PREFIX_REPNE		IO_TYPE_REP
#define PREFIX_SEG		0x00100000L
#define PREFIX_DS		(IO_SEG_DS or PREFIX_SEG)
#define PREFIX_CS		(IO_SEG_CS or PREFIX_SEG)
#define PREFIX_SS		(IO_SEG_SS or PREFIX_SEG)
#define PREFIX_ES		(IO_SEG_ES or PREFIX_SEG)
#define PREFIX_FS		(IO_SEG_FS or PREFIX_SEG)
#define PREFIX_GS		(IO_SEG_GS or PREFIX_SEG)

/* iop_flags values */

#define IOP_ASM_HOOK		0x0001	// assembly language hook
#define IOP_ALWAYS_TRAP 	0x0002	// port will always be trapped
#define IOP_SIMULATE_DWORD	0x0004	// dword I/O is always simulated
#define IOP_TRAP_ENABLED	0x0008	// if set, trapping is enabled
#define IOP_IGNORE		0x0010	// system ignore hook installed
/* V86 and VDM protected mode IDT definations */

#define IDT_START_EXCEPTIONS		0x00
#define IDT_END_EXCEPTIONS		0x1f
#define IDT_START_SOFTWARE_INTS 	0x20
#define IDT_END_SOFTWARE_INTS		0x4f
#define IDT_START_HARDWARE_INTS 	0x50
#define IDT_END_HARDWARE_INTS		0x7f
#define IDT_START_VPM_SOFTWARE_INTS	0x80
#define IDT_END_VPM_SOFTWARE_INTS	0xff
#define IDT_SIZE			0x80	// size of OS/2 PM IDT

/* DPMI private definitions */

//c-begin
#define GATE_SIZE			(sizeof(struct gate))
//c-end
//masm-begin
//GATE_SIZE			equ	(size gate)
//masm-end

#define VPM_NUM_EXCEPTIONS		0x20
#define VPM_NUM_INTS			0x100
#define VPM_IDT_SIZE			(VPM_NUM_INTS * GATE_SIZE)
#define VPM_STACK_SIZE			(_1K * 4)
#define VPM_STACK_ALLOC_FLAGS		(VMAC_VDM | VMAC_LOCANY | \
					 VMAC_ALIGNPAGE | VMAC_ARENAPRV | \
					 PG_R | PG_W | PG_U | PG_SWAPPABLE)

// The static VDM protected mode breakpoint number definitions

#define VPM_INT_BP_START		0
#define VPM_INT_BP_END			(VPM_NUM_INTS - 1)
#define VPM_EXC_BP_START		(VPM_INT_BP_END + 1)
#define VPM_EXC_BP_END			(VPM_INT_BP_END + VPM_NUM_EXCEPTIONS)
#define VPM_V86EXC_BP_START   (VPM_EXC_BP_END + 1)                  /* 149007 */
#define VPM_V86EXC_BP_END     (VPM_EXC_BP_END + VPM_NUM_EXCEPTIONS) /* 149007 */
#define VPM_VDMBP_START 		(VPM_V86EXC_BP_END + 1)               /* 149007 */
#define VPM_VDMBP_END			(VPM_V86EXC_BP_END + NUM_VDMBP_ENTRIES)/* 149007 */
#define VPM_NUM_BPS			(VPM_VDMBP_END + 1)                     /* 149007 */

// The user level VDM protected mode breakpoint table (filled with HLTs)

#define VPM_BP_SIZE			(_1K * 4)
#define VPM_BP_ALLOC_FLAGS		(VMAC_VDM | VMAC_LOCANY | \
					 VMAC_ALIGNPAGE | VMAC_ARENAPRV | \
					 PG_X | PG_R | PG_W | PG_U | \
					 PG_SWAPPABLE)
#define VPM_BP_SET_FLAGS		(PG_X | PG_R | PG_U)

// Sizes of the IDT regions that are the same access all IDTs

#define VPM_EXCEPTION_INTS_SIZE 	(((IDT_END_EXCEPTIONS - \
					 IDT_START_EXCEPTIONS) + 1) * \
					  GATE_SIZE)

#define VPM_HARDWARE_INTS_SIZE		(((IDT_END_HARDWARE_INTS - \
					 IDT_START_HARDWARE_INTS) + 1) * \
					  GATE_SIZE)


/***LP	em86Assert - data structure assertion checking macros
 *
 *	ENTRY	t - typedef name for structure (i.e. INTH, IOP, etc.)
 *		p - pointer to structure to be checked
 *
 *	EXIT	NONE
 *
 *	A define "<t>_SIGNATURE" must be defined for each structure
 *	where "t" is the typedef name used in the assert macros.  This define
 *	is the value for the signature field.  It is a 32 bit value
 *	that should be the typedef name (i.e. 0x48544e49 for "INTH").
 */

#ifdef	EM86STRICT

#define BAD_SIGNATURE		0x53444142

//c-begin
extern	CRI criVSF;

#define em86AssertDef(t)	ULONG t##_sig;
#define em86AssertCreate(t, p)	((p)->t##_sig = t##_SIGNATURE)
#define em86AssertP(t, p)	_assert((p)->t##_sig == t##_SIGNATURE)
#define em86AssertDestroy(t, p) ((p)->t##_sig = BAD_SIGNATURE)
#define em86AssertVSF(ptcb)	_assert((ptcb)->TCB_pcriFrameType == &criVSF)
#define em86AssertTRUE(e)	_assert(e)
#define em86AssertFALSE(e)	_assert(!(e))
//c-end

//masm-begin
//em86AssertDef macro	t
//	ULONG	&t&_sig
//	endm
//
//em86AssertCreate macro t, p
//	mov	[p].&t&_sig,&t&_SIGNATURE
//	endm
//
//em86AssertP	macro	t, p
//	local	l1
//	cmp	[p].&t&_sig,&t&_SIGNATURE	;; check signature
//	je	short l1
//	Panic	<"em86AssertP">
//l1:
//	endm
//
//em86AssertDestroy macro t, p
//	mov	[p].&t&_sig,BAD_SIGNATURE
//	endm
//
//em86AssertVSF macro	ptcb
//	local	l1
//	ReferFlat _criVSF,dword,ifundef
//	push	eax
//	mov	eax,[ptcb]
//	cmp	[eax].TCB_pcriFrameType,offset FLAT:_criVSF
//	je	short l1
//	Panic	<"em86AssertVSF: %08x">, <[eax].TCB_pcriFrameType>
//l1:	pop	eax
//	endm
//
//em86AssertPVSF macro	r
//	local	l1
//	ReferFlat _pTCBCur,dword,ifundef
//	ReferFlat _criVSF,dword,ifundef
//	ifidni	<r>,<eax>
//		%out em86AssertPVSF: can't use eax
//		.err
//	endif
//	push	eax
//	mov	eax,[_pTCBCur]
//	cmp	[eax].TCB_pFrameBase,r
//	je	short l1
//	cmp	[eax].TCB_pcriFrameType,offset FLAT:_criVSF
//	je	short l1
//	Panic	<"em86AssertPVSF: %08x %08x">, <&r&, [eax].TCB_pcriFrameType>
//l1:	pop	eax
//	endm
//masm-end

#else

//c-begin
#define em86AssertDef(t)
#define em86AssertCreate(t, p)
#define em86AssertDestroy(t, p)
#define em86AssertP(t, p)
#define em86AssertVSF(ptcb)
#define em86AssertTRUE(e)
#define em86AssertFALSE(e)
//c-end

//masm-begin
//em86AssertDef 	macro	t
//	endm
//em86AssertCreate	macro	t, p
//	endm
//em86AssertDestroy	macro	t, p
//	endm
//em86AssertP		macro	t, p
//	endm
//em86AssertVSF 	macro	ptcb
//	endm
//em86AssertPVSF	macro	r
//	endm
//masm-end

#endif

//c-begin
#ifdef	VDHSTRICT

#define VDHAssertTRUE(e)	_assert(e)
#define VDHAssertFALSE(e)	_assert(!(e))

#else

#define VDHAssertTRUE(e)
#define VDHAssertFALSE(e)

#endif
//c-end

/***LP	em86InvalidParameter - macro for invalid VDH service parameters
/***LP	em86InternalError - macro for internal consistency errors
 *
 *	ENTRY	s - string to be printed
 *
 *	EXIT	NONE
 */

//c-begin
#define em86InvalidParameter(s) Panic(s)
#define em86InternalError(s)	Panic(s)
//c-end

//masm-begin
//em86InvalidParameter macro s
//	Panic	<s>
//	endm
//
//em86InternalError macro s
//	Panic	<s>
//	endm
//masm-end

/***LT+ IOP - I/O port entry
 *
 *	A per VDM array (apiop) is indexed by port number
 *	(if below the port hash start) containing a pointer
 *	to this structure.  This structure contains a copy
 *	of the VDD's IOH, a pointer to the VDD IOH for validation
 *	during set trapping state and deinstallation and a flag
 *	field.	If I/O hooks were done with "C" interface option
 *	the iop_ioh contains the IOH assembly language stubs that
 *	call the "C" hook routines.  The iop_iohVDD contains the
 *	real VDD handlers.
 */

typedef struct iop_s {
	IOH iop_ioh;			// I/O port hook entry
	IOH iop_iohVDD; 		// VDD's I/O port hook entry
	FLAGS iop_flags;		// I/O hook flags
#ifdef	VDHSTRICT
	PIOH iop_piohVDD;		// Pointer to VDD's ioh
	PORT iop_port;			// starting port
	ULONG iop_cport;		// number of ports
#endif
	em86AssertDef(IOP)		// assertion checking
} IOP;

typedef IOP *PIOP;

#define IOP_SIGNATURE	0x20504f49	// "IOP "
/*end*/

/***LT+ PHA - I/O port hash entry
 *
 *	This is the structure for the hash entry for I/O port
 *	trap handlers above PORT_HASH_START (400H).  It contains
 *	an IOP, the port number for this IOP and a pointer to the
 *	next entry on the linked list.	The heads of the lists
 *	are kept in the "appha" array.
 */

typedef struct pha_s {
	IOP pha_iop;			// I/O port entry
	PORT pha_port;			// port number
	struct pha_s *pha_ppha; 	// ptr to next entry in list
	em86AssertDef(PHA)		// assertion checking
} PHA;

typedef PHA *PPHA;			// ptr to PHA entry

#define PHA_SIGNATURE	0x20414850	// "PHA "
/*end*/

/***LT+ INTH - interrupt hook entry
 *
 *	This structure describes the VDD interrupt handler
 *	list entries.  The head of the list for each interrupt
 *	number is in the apinthHead array.
 */

typedef struct inth_s {
	struct inth_s *inth_pinth;	// ptr to next entry in list
	PFN inth_pfn;			// assembly hook address
	PFNHOOK inth_pfnhook;		// "C" interface hook address
	em86AssertDef(INTH)		// assertion checking
} INTH;

typedef INTH *PINTH;			// pointer to int handler entry

#define INTH_SIGNATURE	0x48544e49	// "INTH"
/*end*/

//masm-begin
//DefType HOOK,hook_s			; define HOOK macro
//masm-end

/***LT+ VDMBP - VDM breakpoint entry
 *
 *	This is the VDM breakpoint table entry structure.  This is
 *	basiclly a hook structure with a few VDMBP specific fields.  The
 *	vdmbp_pfnDispatch address is the routine used to call the
 *	hook function.
 */

typedef struct vdmbp_s {
	HOOK vdmbp_hook;		// hook block
	PFN vdmbp_pfnDispatch;		// VDMBP dispatcher address
	VPVOID vdmbp_vpOldCSIP; 	// original v86 mode CS:IP
	FPFN vdmbp_fpfnOldCSEIP;	// original VDM protected mode CS:EIP
	em86AssertDef(VDMBP)		// assertion checking
} VDMBP;

typedef VDMBP *PVDMBP;			// ptr to VDMBP entry

#define VDMBP_SIGNATURE 0x50424d56	// "VMBP"
/*end*/

/***LT+ RETH - return hook entry
 *
 *	This is the return hook entry structure.  This is basiclly a
 *	hook structure with a few VDMBP specific fields.
 */

typedef struct reth_s {
	VDMBP reth_vdmbp;		// vdm bp hook block
	VPVOID reth_vpvdmbp;		// vdm bp address
	em86AssertDef(RETH)		// assertion checking
} RETH;

typedef RETH *PRETH;			// ptr to VDMBP entry

#define RETH_SIGNATURE	0x48544552	// "RETH"
/*end*/

/***LT+ TIMH - timer hook data structure
 *
 *	This is the data structure used by VDHArmTimerHook and
 *	VDHDisarmTimerHook over the basic hook structure.
 *
 *	The armed timer blocks are kept on a delta list.  The
 *	first entry's ulmsDelta field is the number of milliseconds
 *	until the first entry hits.  The second entry is the number
 *	of milliseconds after the first entry hits until the second
 *	entry hits and so on.
 *
 *	timh_ptcb is either a ptcb or 0 for an automatic local context
 *	arming, -1 for automatic global context hook arming or 1 for the
 *	normal interrupt time call.
 */

typedef struct timh_s {
	HOOK timh_hook; 		// hook block
	ULONG timh_ulmsDelta;		// millisecond delta
	PVOID timh_ptcb;		// flag or ptcb for context hook
	em86AssertDef(TIMH)		// assertion checking
} TIMH;

typedef TIMH *PTIMH;			// ptr to TIMH entry

#define TIMH_SIGNATURE	0x484d4954	// "TIMH"
/*end*/

#define DHD_V86_STACK_SIZE		0x400	   // was x204

//c-begin
#define DHD_VPM_SAVE_START(pvsf)	((PVOID)(((PBYTE)(pvsf))+VSF_ALT_START))
#define DHD_VPM_GEN_START(pvsf) 	((PVOID)(((PBYTE)(pvsf))+VSF_GEN_START))
#define DHD_VPM_EIP_START(pvsf) 	((PVOID)(((PBYTE)(pvsf))+VSF_COPY_START))
#define DHD_VPM_SEG_START(pvsf) 	((PVOID)(((PBYTE)(pvsf))+VSF_SEG_START))
#define DHD_VPM_ALT_SEG_START(pvsf)	((PVOID)(((PBYTE)(pvsf))+VSF_ASEG_START))
//c-end

//masm-begin
//DHD_VPM_SAVE_START		equ	VSF_ALT_START
//masm-end
/*end*/

/***LT+ VPMINT - VDM protected mode interrupt data structure
 *
 *	This structure is shadows the IDT with the VPM applications
 *	handler address and a flags mask to make it easier to setup
 *	the interrupt flag when emulating an interrupt.
 */

typedef struct vpmint_s {
	ULONG vpmint_off;		// app exception handler offset
	SEL vpmint_sel; 		// app exception handler selector
	USHORT vpmint_usFlagMask;	// cpu flag mask (Trace/Interrupt)
	em86AssertDef(VPMINT)		// assertion checking
} VPMINT;

//c-begin
#define VPMINT_TABLE_SIZE		(VPM_NUM_INTS * sizeof(VPMINT))
typedef VPMINT *PVPMINT;		// ptr to VPMINT entry
//c-end

#define VPMINT_SIGNATURE		0x494d5056	// "VPMI"
/*end*/

/***LT+ VPMEXC - VDM protected exception data structure
 *
 *	This is the VDM protected mode application exception
 *	handler data structure.
 */

typedef struct vpmexc_s {
	ULONG vpmexc_off;		// app exception handler offset
	SEL vpmexc_sel; 		// app exception handler selector
	USHORT vpmexc_usFlags;  // flags //GK: This flags never be used???
	USHORT vpmexc_fb; 		// type of exception handler  149007 DPMI 1.0 subset
                           /* 149007 */
	em86AssertDef(VPMEXC)		// assertion checking
} VPMEXC;


/***LT+ EXCST - VDM protected mode 16 bit exception stack structure
 *
 * This is the structure of the stack for a DPMI exception handler for a 16 bit
 * process.  The application exception handler can modify these values.
 */
typedef struct excst_s {
	USHORT excst_errcode;	       // Error code for exception
	USHORT excst_ip;	       // Client IP at time of fault
	SEL    excst_cs;	       // Client CS at fault time
	USHORT excst_flags;	       // Client flags at fault time
	USHORT excst_sp;	       // Client SP at fault time
	SEL    excst_ss;	       // Client SS at fault time
} EXCST;

/***LT+ EXCST - VDM protected mode 32 bit exception stack structure
 *
 * This is the structure of the stack for a DPMI exception handler for a 32 bit
 * process.  The application exception handler can modify these values.
 */
typedef struct exc32_s {
	ULONG  exc32_errcode;	       // Error code for exception
	ULONG  exc32_eip;	       // Client EIP at time of fault
	SEL    exc32_cs;	       // Client CS at time of fault
	USHORT exc32_padcs;
	ULONG  exc32_eflags;	       // Client eflags at time of fault
	ULONG  exc32_esp;	       // Client ESP at time of fault
	SEL    exc32_ss;	       // Client SS at time of fault
	USHORT exc32_padss;
} EXC32;

/***LT+ EXCST - VDM protected mode 16 bit exception stack structure  149007
 *                                                                   149007
 * This is the structure of the stack for a DPMI exception handler for a 16 bit
 * process.  The application exception handler can modify these values. 149007
 */
typedef struct exexcst_s {
   EXC32  oldexc32;           /* 0.9 Stack Frame. fit in 16 bit and 32 Bit */
                              /* 149007 */
   ULONG  exexcst_ret_eip;    /* return EIP, CS:IP for 16 bit        149007 */
   SEL    exexcst_ret_cs;     /* Return CS for 32 bit                149007 */
   USHORT exexcst_ret_cs_pad; /* pad                                 149007 */
   ULONG  exexcst_errcode;    /* Error code                          149007 */
   ULONG  exexcst_eip;        /* eip or ip of VDM                    149007 */
   SEL    exexcst_cs;         /* cs of VDM                           149007 */
   USHORT exexcst_info;       /* Exception Information bits          149007 */
   ULONG  exexcst_eflags;     /* eflags of VDM                       149007 */
   ULONG  exexcst_esp;        /* esp of sp of VDM                    149007 */
   SEL    exexcst_ss;         /* ss of VDM                           149007 */
   USHORT exexcst_ss_pad;     /* pad                                 149007 */
   SEL    exexcst_es;         /* es of VDM                           149007 */
   USHORT exexcst_es_pad;     /* pad                                 149007 */
   SEL    exexcst_ds;         /* ds of VDM                           149007 */
   USHORT exexcst_ds_pad;     /* pad                                 149007 */
   SEL    exexcst_fs;         /* fs of VDM                           149007 */
   USHORT exexcst_fs_pad;     /* pad                                 149007 */
   SEL    exexcst_gs;         /* gs of VDM                           149007 */
   USHORT exexcst_gs_pad;     /* pad                                 149007 */
   ULONG  exexcst_cr2;        /* CR2                                 149007 */
   ULONG  exexcst_pte;        /* PTE                                 149007 */
} EXEXCST;                    /* 149007 */


//c-begin
#define VPMEXC_TABLE_SIZE		(VPM_NUM_INTS * sizeof(VPMEXC))
typedef VPMEXC *PVPMEXC;		// ptr to VPMEXC entry
//c-end

#define VPMEXC_SIGNATURE		0x454d5056	// "VPME"
/*end*/

// Equates for flrestart flag
#define  VPM_RESTART_INST	1	// restart the faulting instruction
#define  VPM_RETV86		2	// return to V86 mode after fault
#define  VPM_RETV86_BIT 	1	// corresponding bit for VPM_RETV86

/***LT+ VDDAPI - VDD API handler data structure
 *
 *	This structure contains the VDD IDs and the hook handles for the V86
 *	or protect mode API handlers the VDD has registered.
 */

typedef struct vddapi_s {
	CHAR   vapi_szVDD[MAXLENXDD+1]; // VDD name
	HHOOK  vapi_hhookV86;		// hook handle for V86 API entry
	HHOOK  vapi_hhookVPM;		// hook handle for VPM API entry
	VPVOID vapi_vpV86BP;		// V86 breakpoint address
	VPVOID vapi_vpVPMBP;		// VPM breakpoint address
	struct vddapi_s *vapi_next;	// ptr to next entry in list
	em86AssertDef(VDDAPI)		// assertion checking
} VDDAPI;

typedef VDDAPI *PVDDAPI;		// ptr to VDDAPI entry
#define VDDAPI_SIGNATURE 0x49504156	// "VAPI"
/*end*/

/* Processor types for VDHDetectProcessor */
#define P_80586 		5
#define P_80486 		4
#define P_80386 		3
#define VME_supported		2      // Processor supports virt. mode ext.

/* External interfaces within 8086 emulation */

//c-begin
extern VOID PASCAL em86VDMBPDefaultDispatcher(VOID);
extern VOID PASCAL em86VDMBPRecursiveDispatcher(VOID);
extern VOID PASCAL em86VDMBPDefaultDispatcher32(VOID);
extern VOID PASCAL em86DefaultIOInHook();
extern VOID PASCAL em86DefaultIOOutHook();
extern VOID PASCAL em86DefaultIgnoreIOHook();
extern VOID PASCAL em86CHookStubINTH();
extern VOID PASCAL em86CHookStubPreINTH();
extern VOID PASCAL em86CHookStubVDMBP();
extern VOID PASCAL em86IntHook();
extern VOID PASCAL em86POPF16(VOID);
extern VOID PASCAL em86LoadTR(VOID);
extern VOID PASCAL em86EndVPMExecution(VOID);
extern VOID PASCAL em86VPMDestroyVDM(VOID);
extern FNARM EM86StartVPMExecution;
extern FNARM em86V86ReflectionHook;
extern VOID PASCAL em86VPMIntBPHdlr(VOID);
extern VOID PASCAL em86VPMExcBPReflect(VOID);   /* 149007 */
extern VOID PASCAL em86VPMExcBPTerminate(VOID);
extern VOID PASCAL em86V86ExcBPTerminate(VOID);
extern VOID PASCAL em86VPMInt21Hdlr(VOID);
extern VOID PASCAL em86VPMInt31Hdlr(VOID);
extern VOID PASCAL em86DispatchVPMVDMBP(VOID);
extern BIH em86ByteInput;
extern BOH em86ByteOutput;
extern WIH em86SimWordInput;
extern WOH em86SimWordOutput;
extern WIH em86DefaultInWordHook;
extern WOH em86DefaultOutWordHook;
extern OTH em86DefaultOtherIOHook;
extern OTH em86SimOtherIO;
extern OTH em86SimDwordIO;
extern OTH em86CSimDwordIO;
extern BIH em86CHookStubBIH;
extern BOH em86CHookStubBOH;
extern WIH em86CHookStubWIH;
extern WOH em86CHookStubWOH;
extern VOID em86LoadVPMIDT(VOID);
extern OTH em86CHookStubOTH;
extern BOOL PASCAL em86GrowIOPM(HVDM, PORT);
extern VOID PASCAL em86SetIOHookState(HVDM,PORT,ULONG,BOOL);
extern BOOL PASCAL em86GetVPMExcept(ULONG,PFPFN,PBYTE);
extern BOOL PASCAL em86SetVPMExcept(ULONG,FPFN,BYTE);
extern BOOL int2fGetVPMSwitchAddr(PVSF);
extern VOID PASCAL em86memcpy(PVOID, PVOID, ULONG);
extern BOOL em86Is32Sel(SEL);
//c-end
