ReactOS  0.4.14-dev-358-gbef841c
kbdbios.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: GPL - See COPYING in the top level directory
3  * PROJECT: ReactOS Virtual DOS Machine
4  * FILE: subsystems/mvdm/ntvdm/bios/kbdbios.c
5  * PURPOSE: VDM 32-bit PS/2 Keyboard BIOS Support Library
6  * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca@sfr.fr)
7  */
8 
9 /* INCLUDES *******************************************************************/
10 
11 #include "ntvdm.h"
12 
13 #define NDEBUG
14 #include <debug.h>
15 
16 #include "emulator.h"
17 #include "cpu/bop.h"
18 #include "int32.h"
19 
20 #include "bios.h"
21 // #include "kbdbios.h"
22 
23 /* DEFINES ********************************************************************/
24 
25 /* BOP Identifiers */
26 #define BOP_KBD_IRQ 0x09
27 #define BOP_KBD_INT 0x16
28 
29 /* PUBLIC FUNCTIONS ***********************************************************/
30 
31 extern VOID WINAPI BiosKeyboardIrq(LPWORD Stack);
33 {
34  /*
35  * Set up a false stack to hardwire the BOP function (that can directly
36  * manipulate CPU registers) to the 32-bit interrupt function (which uses
37  * the stack to be able to modify the original CS:IP and FLAGS).
38  *
39  * See int32.h stack codes.
40  */
41  WORD EmuStack[4];
42  DWORD Flags = getEFLAGS();
43 
44  DPRINT1("Calling BOP KbdBiosIRQ\n");
45 
46  EmuStack[STACK_FLAGS] = LOWORD(Flags);
47  EmuStack[STACK_CS] = getCS();
48  EmuStack[STACK_IP] = getIP();
49  EmuStack[STACK_INT_NUM] = BOP_KBD_IRQ;
50 
51  BiosKeyboardIrq(EmuStack);
52 
53  setIP(EmuStack[STACK_IP]);
54  setCS(EmuStack[STACK_CS]);
56 }
57 
60 {
61  /*
62  * Set up a false stack to hardwire the BOP function (that can directly
63  * manipulate CPU registers) to the 32-bit interrupt function (which uses
64  * the stack to be able to modify the original CS:IP and FLAGS).
65  *
66  * See int32.h stack codes.
67  */
68  WORD EmuStack[4];
69  DWORD Flags = getEFLAGS();
70 
71  DPRINT1("Calling BOP KbdBiosINT\n");
72 
73  EmuStack[STACK_FLAGS] = LOWORD(Flags);
74  EmuStack[STACK_CS] = getCS();
75  EmuStack[STACK_IP] = getIP();
76  EmuStack[STACK_INT_NUM] = BOP_KBD_IRQ;
77 
78  BiosKeyboardService(EmuStack);
79 
80  setIP(EmuStack[STACK_IP]);
81  setCS(EmuStack[STACK_CS]);
83 }
84 
86 {
87  /* Register the BIOS support BOPs */
88  RegisterBop(BOP_KBD_IRQ, KbdBiosIRQ); // BiosKeyboardIrq in kbdbios32.c
89  RegisterBop(BOP_KBD_INT, KbdBiosINT); // BiosKeyboardService in kbdbios32.c
90  return TRUE;
91 }
92 
94 {
95  /* Unregister the BIOS support BOPs */
98 }
99 
100 /* EOF */
#define STACK_INT_NUM
Definition: int32.h:30
VOID WINAPI setIP(USHORT)
Definition: registers.c:471
#define TRUE
Definition: types.h:120
VOID RegisterBop(BYTE BopCode, EMULATOR_BOP_PROC BopHandler)
Definition: bop.c:29
VOID WINAPI BiosKeyboardService(LPWORD Stack)
Definition: kbdbios32.c:85
BOOLEAN KbdBiosInitialize(VOID)
Definition: kbdbios.c:85
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
ULONG WINAPI getEFLAGS(VOID)
Definition: registers.c:680
#define BOP_KBD_INT
Definition: kbdbios.c:27
#define MAKELONG(a, b)
Definition: typedefs.h:248
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define STACK_FLAGS
Definition: int32.h:35
USHORT WINAPI getIP(VOID)
Definition: registers.c:464
#define WINAPI
Definition: msvc.h:8
VOID WINAPI BiosKeyboardIrq(LPWORD Stack)
Definition: kbdbios32.c:199
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
VOID WINAPI setEFLAGS(ULONG)
Definition: registers.c:687
#define STACK_CS
Definition: int32.h:34
uint16_t * LPWORD
Definition: typedefs.h:54
VOID WINAPI setCS(USHORT)
Definition: registers.c:487
static VOID WINAPI KbdBiosIRQ(LPWORD Stack)
Definition: kbdbios.c:32
#define DPRINT1
Definition: precomp.h:8
#define HIWORD(l)
Definition: typedefs.h:246
VOID KbdBiosCleanup(VOID)
Definition: kbdbios.c:93
#define STACK_IP
Definition: int32.h:33
USHORT WINAPI getCS(VOID)
Definition: registers.c:480
#define LOWORD(l)
Definition: pedump.c:82
static VOID WINAPI KbdBiosINT(LPWORD Stack)
Definition: kbdbios.c:59
#define BOP_KBD_IRQ
Definition: kbdbios.c:26