From 0ba60c4b62658fd0da853535f176f095bfa68a2d Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Mon, 21 Aug 2006 03:49:02 +0000 Subject: [PATCH] - Delete bios.c and usertrap.c - Add Ke entries to KernelFun! svn path=/trunk/; revision=23637 --- reactos/ntoskrnl/KrnlFun.c | 14 ++++++ reactos/ntoskrnl/ke/i386/bios.c | 78 ----------------------------- reactos/ntoskrnl/ke/i386/trap.s | 11 ---- reactos/ntoskrnl/ke/i386/usertrap.c | 1 - reactos/ntoskrnl/ke/i386/v86m.c | 51 +++++++++++++++++++ reactos/ntoskrnl/ntoskrnl.rbuild | 2 - 6 files changed, 65 insertions(+), 92 deletions(-) delete mode 100644 reactos/ntoskrnl/ke/i386/bios.c delete mode 100644 reactos/ntoskrnl/ke/i386/usertrap.c diff --git a/reactos/ntoskrnl/KrnlFun.c b/reactos/ntoskrnl/KrnlFun.c index a9aa4abc50d..cd8b0b04656 100644 --- a/reactos/ntoskrnl/KrnlFun.c +++ b/reactos/ntoskrnl/KrnlFun.c @@ -24,6 +24,20 @@ // - Add Directory Lock. // - Use Object Type Mutex/Lock. // +// Ke: +// - Make sure IRQ trap code is synchronized with current trap code. +// - Reimplement the V86 support using a mode that will be compatible with +// VDM and the future and use ABIOS gates. +// - Implement Invalid Opcode and GPD handlers for V86-mode. +// - Implement stack fault and segment fault handlers. +// - Implement kernel-mode GPF handler, possibly fixing below: +// - Figure out why ES/DS gets messed up in VMWare, when doing KiServiceExit only, +// and only when called from user-mode, and returning to user-mode. +// - Figure out what the DEBUGEIP hack is for and how it can be moved away. +// - Add DR macro/save and VM macro/save. +// - Implement KiCallbackReturn, KiGetTickCount, KiRaiseAssertion. +// +// // Ex: // - Use pushlocks for handle implementation. // diff --git a/reactos/ntoskrnl/ke/i386/bios.c b/reactos/ntoskrnl/ke/i386/bios.c deleted file mode 100644 index 58cb5bbf4d4..00000000000 --- a/reactos/ntoskrnl/ke/i386/bios.c +++ /dev/null @@ -1,78 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: ntoskrnl/ke/i386/bios.c - * PURPOSE: Support for calling the BIOS in v86 mode - * - * PROGRAMMERS: David Welch (welch@cwcom.net) - */ - -/* INCLUDES *****************************************************************/ - -#include -#define NDEBUG -#include - -/* GLOBALS *******************************************************************/ - -#define TRAMPOLINE_BASE (0x10000) - -extern VOID Ki386RetToV86Mode(PKV86M_REGISTERS InRegs, - PKV86M_REGISTERS OutRegs); - -/* FUNCTIONS *****************************************************************/ - -NTSTATUS STDCALL -Ke386CallBios(ULONG Int, PCONTEXT regs) -{ - PUCHAR Ip; - KV86M_REGISTERS ORegs; - NTSTATUS Status; - PKV86M_REGISTERS Regs = (PKV86M_REGISTERS)regs; - - /* - * Set up a trampoline for executing the BIOS interrupt - */ - Ip = (PUCHAR)TRAMPOLINE_BASE; - Ip[0] = 0xCD; /* int XX */ - Ip[1] = Int; - Ip[2] = 0x63; /* arpl ax, ax */ - Ip[3] = 0xC0; - Ip[4] = 0x90; /* nop */ - Ip[5] = 0x90; /* nop */ - - /* - * Munge the registers - */ - Regs->Eip = 0; - Regs->Cs = TRAMPOLINE_BASE / 16; - Regs->Esp = 0xFFFF; - Regs->Ss = TRAMPOLINE_BASE / 16; - Regs->Eflags = (1 << 1) | (1 << 17) | (1 << 9); /* VM, IF */ - Regs->RecoveryAddress = TRAMPOLINE_BASE + 2; - Regs->RecoveryInstruction[0] = 0x63; /* arpl ax, ax */ - Regs->RecoveryInstruction[1] = 0xC0; - Regs->RecoveryInstruction[2] = 0x90; /* nop */ - Regs->RecoveryInstruction[3] = 0x90; /* nop */ - Regs->Flags = KV86M_EMULATE_CLI_STI | KV86M_ALLOW_IO_PORT_ACCESS; - Regs->Vif = 1; - Regs->PStatus = &Status; - - /* - * Execute the BIOS interrupt - */ - Ki386RetToV86Mode(Regs, &ORegs); - - /* - * Copy the return values back to the caller - */ - memcpy(Regs, &ORegs, sizeof(KV86M_REGISTERS)); - - return(Status); -} - - - - - diff --git a/reactos/ntoskrnl/ke/i386/trap.s b/reactos/ntoskrnl/ke/i386/trap.s index 425f18be320..62c77ee933b 100644 --- a/reactos/ntoskrnl/ke/i386/trap.s +++ b/reactos/ntoskrnl/ke/i386/trap.s @@ -12,17 +12,6 @@ #include .intel_syntax noprefix -/* - * FIXMEs: - * - Implement kernel-mode GPF handler, possibly fixing below: - * - Figure out why ES/DS gets messed up in VMWare, when doing KiServiceExit only, - * and only when called from user-mode, and returning to user-mode. - * - Implement Invalid Opcode handler. - * - Figure out what the DEBUGEIP hack is for and how it can be moved away. - * - Add DR macro/save and VM macro/save. - * - Implement KiCallbackReturn, KiGetTickCount, KiRaiseAssertion. - */ - /* GLOBALS ******************************************************************/ .globl _KiIdt diff --git a/reactos/ntoskrnl/ke/i386/usertrap.c b/reactos/ntoskrnl/ke/i386/usertrap.c deleted file mode 100644 index 8b137891791..00000000000 --- a/reactos/ntoskrnl/ke/i386/usertrap.c +++ /dev/null @@ -1 +0,0 @@ - diff --git a/reactos/ntoskrnl/ke/i386/v86m.c b/reactos/ntoskrnl/ke/i386/v86m.c index df5e988a5fc..6391d93aa40 100644 --- a/reactos/ntoskrnl/ke/i386/v86m.c +++ b/reactos/ntoskrnl/ke/i386/v86m.c @@ -23,6 +23,10 @@ #define VALID_FLAGS (0xDFF) +#define TRAMPOLINE_BASE (0x10000) + +VOID Ki386RetToV86Mode(KV86M_REGISTERS* InRegs, + KV86M_REGISTERS* OutRegs); /* FUNCTIONS *****************************************************************/ ULONG @@ -807,5 +811,52 @@ KeV86Exception(ULONG ExceptionNr, PKTRAP_FRAME Tf, ULONG address) } } +NTSTATUS STDCALL +Ke386CallBios(ULONG Int, PCONTEXT regs) +{ + PUCHAR Ip; + KV86M_REGISTERS ORegs; + NTSTATUS Status; + PKV86M_REGISTERS Regs = (PKV86M_REGISTERS)regs; + /* + * Set up a trampoline for executing the BIOS interrupt + */ + Ip = (PUCHAR)TRAMPOLINE_BASE; + Ip[0] = 0xCD; /* int XX */ + Ip[1] = Int; + Ip[2] = 0x63; /* arpl ax, ax */ + Ip[3] = 0xC0; + Ip[4] = 0x90; /* nop */ + Ip[5] = 0x90; /* nop */ + + /* + * Munge the registers + */ + Regs->Eip = 0; + Regs->Cs = TRAMPOLINE_BASE / 16; + Regs->Esp = 0xFFFF; + Regs->Ss = TRAMPOLINE_BASE / 16; + Regs->Eflags = (1 << 1) | (1 << 17) | (1 << 9); /* VM, IF */ + Regs->RecoveryAddress = TRAMPOLINE_BASE + 2; + Regs->RecoveryInstruction[0] = 0x63; /* arpl ax, ax */ + Regs->RecoveryInstruction[1] = 0xC0; + Regs->RecoveryInstruction[2] = 0x90; /* nop */ + Regs->RecoveryInstruction[3] = 0x90; /* nop */ + Regs->Flags = KV86M_EMULATE_CLI_STI | KV86M_ALLOW_IO_PORT_ACCESS; + Regs->Vif = 1; + Regs->PStatus = &Status; + + /* + * Execute the BIOS interrupt + */ + Ki386RetToV86Mode(Regs, &ORegs); + + /* + * Copy the return values back to the caller + */ + memcpy(Regs, &ORegs, sizeof(KV86M_REGISTERS)); + + return(Status); +} diff --git a/reactos/ntoskrnl/ntoskrnl.rbuild b/reactos/ntoskrnl/ntoskrnl.rbuild index c88613b5b8d..54aa934f475 100644 --- a/reactos/ntoskrnl/ntoskrnl.rbuild +++ b/reactos/ntoskrnl/ntoskrnl.rbuild @@ -27,7 +27,6 @@ main_asm.S - bios.c cpu.S ctxswitch.S exp.c @@ -41,7 +40,6 @@ trap.s tss.c usercall_asm.S - usertrap.c v86m.c v86m_sup.S vdm.c