3 * Copyright (C) 2000 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 * PROJECT: ReactOS kernel
21 * FILE: ntoskrnl/ke/i386/bios.c
22 * PURPOSE: Support for calling the BIOS in v86 mode
23 * PROGRAMMER: David Welch (welch@cwcom.net)
26 /* INCLUDES *****************************************************************/
30 #include <internal/debug.h>
32 /* GLOBALS *******************************************************************/
34 #define TRAMPOLINE_BASE (0x10000)
36 extern VOID
Ki386RetToV86Mode(PKV86M_REGISTERS InRegs
,
37 PKV86M_REGISTERS OutRegs
);
39 /* FUNCTIONS *****************************************************************/
42 Ke386CallBios(UCHAR Int
, PKV86M_REGISTERS Regs
)
45 KV86M_REGISTERS ORegs
;
49 * Set up a trampoline for executing the BIOS interrupt
51 Ip
= (PUCHAR
)TRAMPOLINE_BASE
;
52 Ip
[0] = 0xCD; /* int XX */
54 Ip
[2] = 0x63; /* arpl ax, ax */
56 Ip
[4] = 0x90; /* nop */
57 Ip
[5] = 0x90; /* nop */
63 Regs
->Cs
= TRAMPOLINE_BASE
/ 16;
65 Regs
->Ss
= TRAMPOLINE_BASE
/ 16;
66 Regs
->Eflags
= (1 << 1) | (1 << 17) | (1 << 9); /* VM, IF */
67 Regs
->RecoveryAddress
= TRAMPOLINE_BASE
+ 2;
68 Regs
->RecoveryInstruction
[0] = 0x63; /* arpl ax, ax */
69 Regs
->RecoveryInstruction
[1] = 0xC0;
70 Regs
->RecoveryInstruction
[2] = 0x90; /* nop */
71 Regs
->RecoveryInstruction
[3] = 0x90; /* nop */
72 Regs
->Flags
= KV86M_EMULATE_CLI_STI
| KV86M_ALLOW_IO_PORT_ACCESS
;
74 Regs
->PStatus
= &Status
;
77 * Execute the BIOS interrupt
79 Ki386RetToV86Mode(Regs
, &ORegs
);
82 * Copy the return values back to the caller
84 memcpy(Regs
, &ORegs
, sizeof(KV86M_REGISTERS
));