3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/ke/i386/bios.c
6 * PURPOSE: Support for calling the BIOS in v86 mode
8 * PROGRAMMERS: David Welch (welch@cwcom.net)
11 /* INCLUDES *****************************************************************/
15 #include <internal/debug.h>
17 /* GLOBALS *******************************************************************/
19 #define TRAMPOLINE_BASE (0x10000)
21 extern VOID
Ki386RetToV86Mode(PKV86M_REGISTERS InRegs
,
22 PKV86M_REGISTERS OutRegs
);
24 /* FUNCTIONS *****************************************************************/
27 Ke386CallBios(UCHAR Int
, PKV86M_REGISTERS Regs
)
30 KV86M_REGISTERS ORegs
;
34 * Set up a trampoline for executing the BIOS interrupt
36 Ip
= (PUCHAR
)TRAMPOLINE_BASE
;
37 Ip
[0] = 0xCD; /* int XX */
39 Ip
[2] = 0x63; /* arpl ax, ax */
41 Ip
[4] = 0x90; /* nop */
42 Ip
[5] = 0x90; /* nop */
48 Regs
->Cs
= TRAMPOLINE_BASE
/ 16;
50 Regs
->Ss
= TRAMPOLINE_BASE
/ 16;
51 Regs
->Eflags
= (1 << 1) | (1 << 17) | (1 << 9); /* VM, IF */
52 Regs
->RecoveryAddress
= TRAMPOLINE_BASE
+ 2;
53 Regs
->RecoveryInstruction
[0] = 0x63; /* arpl ax, ax */
54 Regs
->RecoveryInstruction
[1] = 0xC0;
55 Regs
->RecoveryInstruction
[2] = 0x90; /* nop */
56 Regs
->RecoveryInstruction
[3] = 0x90; /* nop */
57 Regs
->Flags
= KV86M_EMULATE_CLI_STI
| KV86M_ALLOW_IO_PORT_ACCESS
;
59 Regs
->PStatus
= &Status
;
62 * Execute the BIOS interrupt
64 Ki386RetToV86Mode(Regs
, &ORegs
);
67 * Copy the return values back to the caller
69 memcpy(Regs
, &ORegs
, sizeof(KV86M_REGISTERS
));