[NTVDM]
[reactos.git] / reactos / subsystems / ntvdm / cpu / callback.h
1 /*
2 * COPYRIGHT: GPL - See COPYING in the top level directory
3 * PROJECT: ReactOS Virtual DOS Machine
4 * FILE: callback.h
5 * PURPOSE: 32-bit Interrupt Handlers
6 * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
7 * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
8 */
9
10 #ifndef _CALLBACK_H_
11 #define _CALLBACK_H_
12
13 /* DEFINES ********************************************************************/
14
15 #define BOP(num) LOBYTE(EMULATOR_BOP), HIBYTE(EMULATOR_BOP), (num)
16 #define UnSimulate16(trap) \
17 do { \
18 *(PUSHORT)(trap) = EMULATOR_BOP; \
19 (trap) += sizeof(USHORT); \
20 *(trap) = BOP_UNSIMULATE; \
21 } while(0)
22 // #define UnSimulate16 MAKELONG(EMULATOR_BOP, BOP_UNSIMULATE) // BOP(BOP_UNSIMULATE)
23
24 typedef struct _CALLBACK16
25 {
26 ULONG TrampolineFarPtr; // Where the trampoline zone is placed
27 ULONG TrampolineSize; // Size of the trampoline zone
28 USHORT Segment;
29 USHORT NextOffset;
30 } CALLBACK16, *PCALLBACK16;
31
32 //
33 // WARNING WARNING!!
34 // If you're changing the indices here, you then need to
35 // also fix the BOP code in callback.c !!!!!!!!!!!!!!!!!
36 //
37 #define STACK_INT_NUM 0
38 #define STACK_IP 1
39 #define STACK_CS 2
40 #define STACK_FLAGS 3
41
42 /* FUNCTIONS ******************************************************************/
43
44 VOID
45 InitializeContextEx(IN PCALLBACK16 Context,
46 IN ULONG TrampolineSize,
47 IN USHORT Segment,
48 IN USHORT Offset);
49
50 VOID
51 InitializeContext(IN PCALLBACK16 Context,
52 IN USHORT Segment,
53 IN USHORT Offset);
54
55 VOID
56 Call16(IN USHORT Segment,
57 IN USHORT Offset);
58
59 VOID
60 RunCallback16(IN PCALLBACK16 Context,
61 IN ULONG FarPtr);
62
63 ULONG
64 RegisterCallback16(IN ULONG FarPtr,
65 IN LPBYTE CallbackCode,
66 IN SIZE_T CallbackSize,
67 OUT PSIZE_T CodeSize OPTIONAL);
68
69 #endif // _CALLBACK_H_
70
71 /* EOF */