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 *****************************************************************/
28 #include <ddk/ntddk.h>
29 #include <internal/v86m.h>
32 #include <internal/debug.h>
34 /* GLOBALS *******************************************************************/
36 #define TRAMPOLINE_BASE (0x10000)
38 extern VOID Ki386RetToV86Mode(PKV86M_REGISTERS InRegs,
39 PKV86M_REGISTERS OutRegs);
41 /* FUNCTIONS *****************************************************************/
44 Ke386CallBios(UCHAR Int, PKV86M_REGISTERS Regs)
47 KV86M_REGISTERS ORegs;
51 * Set up a trampoline for executing the BIOS interrupt
53 Ip = (PUCHAR)TRAMPOLINE_BASE;
54 Ip[0] = 0xCD; /* int XX */
56 Ip[2] = 0x63; /* arpl ax, ax */
58 Ip[4] = 0x90; /* nop */
59 Ip[5] = 0x90; /* nop */
65 Regs->Cs = TRAMPOLINE_BASE / 16;
67 Regs->Ss = TRAMPOLINE_BASE / 16;
68 Regs->Eflags = (1 << 1) | (1 << 17) | (1 << 9); /* VM, IF */
69 Regs->RecoveryAddress = TRAMPOLINE_BASE + 2;
70 Regs->RecoveryInstruction[0] = 0x63; /* arpl ax, ax */
71 Regs->RecoveryInstruction[1] = 0xC0;
72 Regs->RecoveryInstruction[2] = 0x90; /* nop */
73 Regs->RecoveryInstruction[3] = 0x90; /* nop */
74 Regs->Flags = KV86M_EMULATE_CLI_STI | KV86M_ALLOW_IO_PORT_ACCESS;
76 Regs->PStatus = &Status;
79 * Execute the BIOS interrupt
81 Ki386RetToV86Mode(Regs, &ORegs);
84 * Copy the return values back to the caller
86 memcpy(Regs, &ORegs, sizeof(KV86M_REGISTERS));