ReactOS 0.4.15-dev-7842-g558ab78
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
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];
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];
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 */
unsigned char BOOLEAN
#define DPRINT1
Definition: precomp.h:8
VOID RegisterBop(BYTE BopCode, EMULATOR_BOP_PROC BopHandler)
Definition: bop.c:29
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
#define STACK_IP
Definition: int32.h:33
#define STACK_FLAGS
Definition: int32.h:35
#define STACK_INT_NUM
Definition: int32.h:30
#define STACK_CS
Definition: int32.h:34
VOID WINAPI BiosKeyboardIrq(LPWORD Stack)
Definition: kbdbios32.c:199
#define BOP_KBD_IRQ
Definition: kbdbios.c:26
VOID KbdBiosCleanup(VOID)
Definition: kbdbios.c:93
VOID WINAPI BiosKeyboardService(LPWORD Stack)
Definition: kbdbios32.c:85
static VOID WINAPI KbdBiosINT(LPWORD Stack)
Definition: kbdbios.c:59
BOOLEAN KbdBiosInitialize(VOID)
Definition: kbdbios.c:85
#define BOP_KBD_INT
Definition: kbdbios.c:27
static VOID WINAPI KbdBiosIRQ(LPWORD Stack)
Definition: kbdbios.c:32
#define LOWORD(l)
Definition: pedump.c:82
uint16_t * LPWORD
Definition: typedefs.h:56
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define HIWORD(l)
Definition: typedefs.h:247
USHORT WINAPI getIP(VOID)
Definition: registers.c:464
VOID WINAPI setEFLAGS(ULONG)
Definition: registers.c:687
VOID WINAPI setCS(USHORT)
Definition: registers.c:487
USHORT WINAPI getCS(VOID)
Definition: registers.c:480
ULONG WINAPI getEFLAGS(VOID)
Definition: registers.c:680
VOID WINAPI setIP(USHORT)
Definition: registers.c:471
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639
#define WINAPI
Definition: msvc.h:6
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170