[FAST486]
[reactos.git] / reactos / subsystems / ntvdm / cpu / bop.c
1 /*
2 * COPYRIGHT: GPL - See COPYING in the top level directory
3 * PROJECT: ReactOS Virtual DOS Machine
4 * FILE: bop.c
5 * PURPOSE: BIOS Operation Handlers
6 * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
7 * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
8 */
9
10 /* INCLUDES *******************************************************************/
11
12 // #define NDEBUG
13
14 #include "emulator.h"
15 #include "bop.h"
16
17 /* PRIVATE VARIABLES **********************************************************/
18
19 /*
20 * This is the list of registered BOP handlers.
21 */
22 static EMULATOR_BOP_PROC BopProc[EMULATOR_MAX_BOP_NUM] = { NULL };
23
24 /* PUBLIC FUNCTIONS ***********************************************************/
25
26 VOID RegisterBop(BYTE BopCode, EMULATOR_BOP_PROC BopHandler)
27 {
28 BopProc[BopCode] = BopHandler;
29 }
30
31 VOID WINAPI EmulatorBiosOperation(PFAST486_STATE State, UCHAR BopCode)
32 {
33 WORD StackSegment, StackPointer;
34 LPWORD Stack;
35
36 /* Get the SS:SP */
37 StackSegment = State->SegmentRegs[FAST486_REG_SS].Selector;
38 StackPointer = State->GeneralRegs[FAST486_REG_ESP].LowWord;
39
40 /* Get the stack */
41 Stack = (LPWORD)SEG_OFF_TO_PTR(StackSegment, StackPointer);
42
43 /* Call the BOP handler */
44 if (BopProc[BopCode] != NULL)
45 BopProc[BopCode](Stack);
46 else
47 DPRINT("Invalid BOP code: 0x%02X\n", BopCode);
48 }
49
50 /* EOF */