diff --git a/reactos/ntoskrnl/amd64stubs.c b/reactos/ntoskrnl/amd64stubs.c index 603d082b802..94b8ba197f3 100644 --- a/reactos/ntoskrnl/amd64stubs.c +++ b/reactos/ntoskrnl/amd64stubs.c @@ -1,17 +1,13 @@ +unsigned long (*FrLdrDbgPrint)(const char *Format, ...); + -#define STUB(x) void x() {} + +#define STUB(x) void x() {FrLdrDbgPrint("Sorry, %s is only a stub!\n", __FUNCTION__);} STUB(KdpEnableSafeMem) -STUB(KfLowerIrql) -STUB(KeRaiseIrql) -STUB(KeLowerIrql) -STUB(KeRaiseIrqlToSynchLevel) -STUB(KeRaiseIrqlToDpcLevel) STUB(KiIdleLoop) -STUB(KeGetCurrentIrql) STUB(KeAcquireInStackQueuedSpinLockRaiseToSynch) -STUB(KeNumberProcessors) STUB(KeBugcheckCallbackListHead) STUB(ExpInterlockedPushEntrySList) STUB(NtContinue) @@ -173,7 +169,6 @@ STUB(KeUpdateRunTime) STUB(KeUpdateSystemTime) STUB(KeUserModeCallback) STUB(KeWaitForMutexObject) -STUB(KfRaiseIrql) STUB(KiBugCheckData) STUB(KiCpuId) STUB(MmCommitSessionMappedView) diff --git a/reactos/ntoskrnl/ke/amd64/cpu.c b/reactos/ntoskrnl/ke/amd64/cpu.c new file mode 100644 index 00000000000..4e49b13e67c --- /dev/null +++ b/reactos/ntoskrnl/ke/amd64/cpu.c @@ -0,0 +1,59 @@ +/* + * PROJECT: ReactOS Kernel + * LICENSE: GPL - See COPYING in the top level directory + * FILE: ntoskrnl/ke/amd64/cpu.c + * PURPOSE: Routines for CPU-level support + * PROGRAMMERS: Timo Kreuzer (timo.kreuzer@reactos.org) + */ + +/* INCLUDES *****************************************************************/ + +#include +#define NDEBUG +#include + +/* GLOBALS *******************************************************************/ + +/* The Boot TSS */ +KTSS64 KiBootTss; + +/* The TSS to use for Double Fault Traps (INT 0x9) */ +UCHAR KiDoubleFaultTSS[KTSS_IO_MAPS]; + +/* The TSS to use for NMI Fault Traps (INT 0x2) */ +UCHAR KiNMITSS[KTSS_IO_MAPS]; + +/* CPU Features and Flags */ +ULONG KeI386MachineType; + +CHAR KeNumberProcessors = 0; + +/* FUNCTIONS *****************************************************************/ + + +VOID +FASTCALL +Ki386InitializeTss(IN PKTSS Tss, + IN PKIDTENTRY Idt, + IN PKGDTENTRY Gdt) +{ + // UNIMPLEMENTED; +} + +VOID +NTAPI +KeFlushCurrentTb(VOID) +{ + /* Flush the TLB by resetting CR3 */ + __writecr3(__readcr3()); +} + +VOID +NTAPI +KiInitializeMachineType(VOID) +{ + /* Set the Machine Type we got from NTLDR */ + KeI386MachineType = KeLoaderBlock->u.I386.MachineType & 0x000FF; +} + + diff --git a/reactos/ntoskrnl/ke/amd64/except.c b/reactos/ntoskrnl/ke/amd64/except.c new file mode 100644 index 00000000000..1de3a70a6b6 --- /dev/null +++ b/reactos/ntoskrnl/ke/amd64/except.c @@ -0,0 +1,90 @@ +/* + * PROJECT: ReactOS Kernel + * LICENSE: GPL - See COPYING in the top level directory + * FILE: ntoskrnl/ke/i386/exp.c + * PURPOSE: Exception Dispatching and Context<->Trap Frame Conversion + * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) + * Gregor Anich + * Skywing (skywing@valhallalegends.com) + */ + +/* INCLUDES ******************************************************************/ + +#include +#define NDEBUG +#include + +/* GLOBALS *******************************************************************/ + +KIDT_INIT KiInterruptInitTable[] = +{ + {0x00, 0x00, 0x00, KiDivideErrorFault}, + {0x01, 0x00, 0x00, KiDebugTrapOrFault}, + {0x02, 0x00, 0x03, KiNmiInterrupt}, + {0x03, 0x03, 0x00, KiBreakpointTrap}, + {0x04, 0x03, 0x00, KiOverflowTrap}, + {0x05, 0x00, 0x00, KiBoundFault}, + {0x06, 0x00, 0x00, KiInvalidOpcodeFault}, + {0x07, 0x00, 0x00, KiNpxNotAvailableFault}, + {0x08, 0x00, 0x01, KiDoubleFaultAbort}, + {0x09, 0x00, 0x00, KiNpxSegmentOverrunAbort}, + {0x0A, 0x00, 0x00, KiInvalidTssFault}, + {0x0B, 0x00, 0x00, KiSegmentNotPresentFault}, + {0x0C, 0x00, 0x00, KiStackFault}, + {0x0D, 0x00, 0x00, KiGeneralProtectionFault}, + {0x0E, 0x00, 0x00, KiPageFault}, + {0x10, 0x00, 0x00, KiFloatingErrorFault}, + {0x11, 0x00, 0x00, KiAlignmentFault}, + {0x12, 0x00, 0x02, KiMcheckAbort}, + {0x13, 0x00, 0x00, KiXmmException}, + {0x1F, 0x00, 0x00, KiApcInterrupt}, + {0x2C, 0x03, 0x00, KiRaiseAssertion}, + {0x2D, 0x03, 0x00, KiDebugServiceTrap}, + {0x2F, 0x00, 0x00, KiDpcInterrupt}, + {0xE1, 0x00, 0x00, KiIpiInterrupt}, + {0, 0} +}; + +KIDTENTRY64 KiIdt[256]; +KDESCRIPTOR KiIdtDescriptor = {{0}, sizeof(KiIdt) - 1, KiIdt}; + +/* FUNCTIONS *****************************************************************/ + + + +VOID +INIT_FUNCTION +NTAPI +KeInitExceptions(VOID) +{ + int i, j; + + /* Initialize the Idt */ + for (j = i = 0; i < 256; i++) + { + ULONG64 Offset; + + if (KiInterruptInitTable[j].InterruptId == i) + { + Offset = (ULONG64)KiInterruptInitTable[j].ServiceRoutine; + KiIdt[i].Dpl = KiInterruptInitTable[j].Dpl; + j++; + } + else + { + Offset = (ULONG64)KiUnexpectedInterrupt; + KiIdt[i].Dpl = 0; + } + KiIdt[i].OffsetLow = Offset & 0xffff; + KiIdt[i].Selector = KGDT_64_R0_CODE; + KiIdt[i].Type = 0x0e; + KiIdt[i].IstIndex = 0; + KiIdt[i].Reserved0 = 0; + KiIdt[i].Present = 1; + KiIdt[i].OffsetMiddle = (Offset >> 16) & 0xffff; + KiIdt[i].OffsetHigh = (Offset >> 32); + KiIdt[i].Reserved1 = 0; + } + +} + diff --git a/reactos/ntoskrnl/ke/amd64/irql.c b/reactos/ntoskrnl/ke/amd64/irql.c new file mode 100644 index 00000000000..7a511eda2d1 --- /dev/null +++ b/reactos/ntoskrnl/ke/amd64/irql.c @@ -0,0 +1,70 @@ +/* + * PROJECT: ReactOS Kernel + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Routines for IRQL-level support + * PROGRAMMERS: Timo Kreuzer + */ + +/* INCLUDES *****************************************************************/ + +#include +#define NDEBUG +#include + +#undef UNIMPLEMENTED + +#define UNIMPLEMENTED \ + FrLdrDbgPrint("Sorry, %s is unimplemented!\n", __FUNCTION__) + +/* FUNCTIONS ****************************************************************/ + +#undef KeGetCurrentIrql +NTKERNELAPI +KIRQL +KeGetCurrentIrql(VOID) +{ + UNIMPLEMENTED; + return 0; +} + + +NTKERNELAPI +VOID +KfLowerIrql(IN KIRQL NewIrql) +{ + UNIMPLEMENTED; +} + +NTKERNELAPI +KIRQL +KfRaiseIrql(IN KIRQL NewIrql) +{ + UNIMPLEMENTED; + return 0; +} + +NTKERNELAPI +KIRQL +KeRaiseIrqlToDpcLevel(VOID) +{ + UNIMPLEMENTED; + return 0; +} + +NTKERNELAPI +KIRQL +KeRaiseIrqlToSynchLevel(VOID) +{ + UNIMPLEMENTED; + return 0; +} + +NTKERNELAPI +VOID +KeLowerIrql(IN KIRQL NewIrql) +{ + UNIMPLEMENTED; + return 0; +} + +/* EOF */ diff --git a/reactos/ntoskrnl/ke/amd64/kiinit.c b/reactos/ntoskrnl/ke/amd64/kiinit.c index 9247b445f4e..f1e7bd6757c 100644 --- a/reactos/ntoskrnl/ke/amd64/kiinit.c +++ b/reactos/ntoskrnl/ke/amd64/kiinit.c @@ -22,6 +22,8 @@ KSPIN_LOCK Ki486CompatibilityLock; extern ULONG KeMemoryMapRangeCount; extern ADDRESS_RANGE KeMemoryMap[64]; +KIPCR KiInitialPcr; + /* FUNCTIONS *****************************************************************/ VOID @@ -331,57 +333,48 @@ KiInitializePcr(IN ULONG ProcessorNumber, IN PKTHREAD IdleThread, IN PVOID DpcStack) { -#if 0 - /* Setup the TIB */ - Pcr->NtTib.ExceptionList = EXCEPTION_CHAIN_END; - Pcr->NtTib.StackBase = 0; - Pcr->NtTib.StackLimit = 0; - Pcr->NtTib.Self = NULL; - /* Set the Current Thread */ - Pcr->PrcbData.CurrentThread = IdleThread; + Pcr->Prcb.CurrentThread = IdleThread; /* Set pointers to ourselves */ Pcr->Self = (PKPCR)Pcr; - Pcr->Prcb = &Pcr->PrcbData; + Pcr->CurrentPrcb = &Pcr->Prcb; /* Set the PCR Version */ Pcr->MajorVersion = PCR_MAJOR_VERSION; Pcr->MinorVersion = PCR_MINOR_VERSION; /* Set the PCRB Version */ - Pcr->PrcbData.MajorVersion = 1; - Pcr->PrcbData.MinorVersion = 1; + Pcr->Prcb.MajorVersion = 1; + Pcr->Prcb.MinorVersion = 1; /* Set the Build Type */ - Pcr->PrcbData.BuildType = 0; + Pcr->Prcb.BuildType = 0; #ifndef CONFIG_SMP - Pcr->PrcbData.BuildType |= PRCB_BUILD_UNIPROCESSOR; + Pcr->Prcb.BuildType |= PRCB_BUILD_UNIPROCESSOR; #endif #ifdef DBG - Pcr->PrcbData.BuildType |= PRCB_BUILD_DEBUG; + Pcr->Prcb.BuildType |= PRCB_BUILD_DEBUG; #endif /* Set the Processor Number and current Processor Mask */ - Pcr->PrcbData.Number = (UCHAR)ProcessorNumber; - Pcr->PrcbData.SetMember = 1 << ProcessorNumber; + Pcr->Prcb.Number = (UCHAR)ProcessorNumber; + Pcr->Prcb.SetMember = 1 << ProcessorNumber; /* Set the PRCB for this Processor */ - KiProcessorBlock[ProcessorNumber] = Pcr->Prcb; + KiProcessorBlock[ProcessorNumber] = &Pcr->Prcb; /* Start us out at PASSIVE_LEVEL */ - Pcr->Irql = PASSIVE_LEVEL; +// Pcr->Irql = PASSIVE_LEVEL; /* Set the GDI, IDT, TSS and DPC Stack */ - Pcr->GDT = (PVOID)Gdt; - Pcr->IDT = Idt; - Pcr->TSS = Tss; - Pcr->TssCopy = Tss; - Pcr->PrcbData.DpcStack = DpcStack; + Pcr->GdtBase = (PVOID)Gdt; + Pcr->IdtBase = Idt; + Pcr->TssBase = Tss; + Pcr->Prcb.DpcStack = DpcStack; /* Setup the processor set */ - Pcr->PrcbData.MultiThreadProcessorSet = Pcr->PrcbData.SetMember; -#endif + Pcr->Prcb.MultiThreadProcessorSet = Pcr->Prcb.SetMember; } VOID @@ -616,14 +609,20 @@ KiGetMachineBootPointers(IN PKGDTENTRY *Gdt, IN PKIPCR *Pcr, IN PKTSS *Tss) { -#if 0 - KDESCRIPTOR GdtDescriptor = {0}, IdtDescriptor = {0}; - KGDTENTRY TssSelector, PcrSelector; - USHORT Tr = 0, Fs; + KDESCRIPTOR GdtDescriptor = {{0},0,0}, IdtDescriptor = {{0},0,0}; + KGDTENTRY64 TssSelector; + USHORT Tr = 0; /* Get GDT and IDT descriptors */ - Ke386GetGlobalDescriptorTable(*(PKDESCRIPTOR)&GdtDescriptor.Limit); - Ke386GetInterruptDescriptorTable(*(PKDESCRIPTOR)&IdtDescriptor.Limit); + Ke386GetGlobalDescriptorTable(GdtDescriptor.Limit); + Ke386GetInterruptDescriptorTable(IdtDescriptor.Limit); + + // FIXME: for some strange reason the gdt needs some time before it's finished... + if (!GdtDescriptor.Base) + { + FrLdrDbgPrint("1. Base = %p, Limit = 0x%x\n", GdtDescriptor.Base, GdtDescriptor.Limit); + } + FrLdrDbgPrint("2. Base = %p, Limit = 0x%x\n", GdtDescriptor.Base, GdtDescriptor.Limit); /* Save IDT and GDT */ *Gdt = (PKGDTENTRY)GdtDescriptor.Base; @@ -632,24 +631,15 @@ KiGetMachineBootPointers(IN PKGDTENTRY *Gdt, /* Get TSS and FS Selectors */ Ke386GetTr(Tr); if (Tr != KGDT_TSS) Tr = KGDT_TSS; // FIXME: HACKHACK - Fs = Ke386GetFs(); - - /* Get PCR Selector, mask it and get its GDT Entry */ - PcrSelector = *(PKGDTENTRY)((ULONG_PTR)*Gdt + (Fs & ~RPL_MASK)); - - /* Get the KPCR itself */ - *Pcr = (PKIPCR)(ULONG_PTR)(PcrSelector.BaseLow | - PcrSelector.HighWord.Bytes.BaseMid << 16 | - PcrSelector.HighWord.Bytes.BaseHi << 24); /* Get TSS Selector, mask it and get its GDT Entry */ TssSelector = *(PKGDTENTRY)((ULONG_PTR)*Gdt + (Tr & ~RPL_MASK)); /* Get the KTSS itself */ *Tss = (PKTSS)(ULONG_PTR)(TssSelector.BaseLow | - TssSelector.HighWord.Bytes.BaseMid << 16 | - TssSelector.HighWord.Bytes.BaseHi << 24); -#endif + TssSelector.Bytes.BaseMiddle << 16 | + TssSelector.Bytes.BaseHigh << 24 | + (ULONG64)TssSelector.BaseUpper << 32); } VOID @@ -657,26 +647,30 @@ NTAPI KiSystemStartupReal(IN PLOADER_PARAMETER_BLOCK LoaderBlock) { FrLdrDbgPrint("Enter KiSystemStartupReal()\n"); - for(;;); -#if 0 ULONG Cpu; PKTHREAD InitialThread; - ULONG InitialStack; + ULONG64 InitialStack; PKGDTENTRY Gdt; PKIDTENTRY Idt; - KIDTENTRY NmiEntry, DoubleFaultEntry; +// KIDTENTRY NmiEntry, DoubleFaultEntry; PKTSS Tss; PKIPCR Pcr; /* Save the loader block and get the current CPU */ KeLoaderBlock = LoaderBlock; + + /* Get Pcr from loader block */ +// Pcr = CONTAINING_RECORD(LoaderBlock->Prcb, KIPCR, Prcb); + Pcr = &KiInitialPcr; + Cpu = KeNumberProcessors; - if (!Cpu) + if (Cpu == 0) { - /* If this is the boot CPU, set FS and the CPU Number*/ - Ke386SetFs(KGDT_R0_PCR); - __writefsdword(KPCR_PROCESSOR_NUMBER, Cpu); + /* If this is the boot CPU, set GS base and the CPU Number*/ + __writemsr(X86_MSR_GSBASE, (ULONG64)Pcr); + __writemsr(X86_MSR_KERNEL_GSBASE, (ULONG64)Pcr); + Pcr->Prcb.Number = Cpu; /* Set the initial stack and idle thread as well */ LoaderBlock->KernelStack = (ULONG_PTR)P0BootStack; @@ -684,7 +678,7 @@ KiSystemStartupReal(IN PLOADER_PARAMETER_BLOCK LoaderBlock) } /* Save the initial thread and stack */ - InitialStack = LoaderBlock->KernelStack; + InitialStack = LoaderBlock->KernelStack; // Chekme InitialThread = (PKTHREAD)LoaderBlock->Thread; /* Clean the APC List Head */ @@ -694,53 +688,59 @@ KiSystemStartupReal(IN PLOADER_PARAMETER_BLOCK LoaderBlock) KiInitializeMachineType(); /* Skip initial setup if this isn't the Boot CPU */ - if (Cpu) goto AppCpuInit; + if (Cpu == 0) + { + /* Get GDT, IDT, PCR and TSS pointers */ + KiGetMachineBootPointers(&Gdt, &Idt, &Pcr, &Tss); - /* Get GDT, IDT, PCR and TSS pointers */ - KiGetMachineBootPointers(&Gdt, &Idt, &Pcr, &Tss); +FrLdrDbgPrint("Gdt = %p, Idt = %p, Pcr = %p, Tss = %p\n", Gdt, Idt, Pcr, Tss); - /* Setup the TSS descriptors and entries */ - Ki386InitializeTss(Tss, Idt, Gdt); + /* Setup the TSS descriptors and entries */ + Ki386InitializeTss(Tss, Idt, Gdt); - /* Initialize the PCR */ - RtlZeroMemory(Pcr, PAGE_SIZE); - KiInitializePcr(Cpu, - Pcr, - Idt, - Gdt, - Tss, - InitialThread, - KiDoubleFaultStack); + /* Initialize the PCR */ + RtlZeroMemory(Pcr, PAGE_SIZE); + KiInitializePcr(Cpu, + Pcr, + Idt, + Gdt, + Tss, + InitialThread, + KiDoubleFaultStack); - /* Set us as the current process */ - InitialThread->ApcState.Process = &KiInitialProcess.Pcb; + /* Set us as the current process */ + InitialThread->ApcState.Process = &KiInitialProcess.Pcb; - /* Clear DR6/7 to cleanup bootloader debugging */ - __writefsdword(KPCR_TEB, 0); - __writefsdword(KPCR_DR6, 0); - __writefsdword(KPCR_DR7, 0); + /* Clear DR6/7 to cleanup bootloader debugging */ + Pcr->Prcb.ProcessorState.SpecialRegisters.KernelDr6 = 0; + Pcr->Prcb.ProcessorState.SpecialRegisters.KernelDr7 = 0; - /* Setup the IDT */ - KeInitExceptions(); + /* Setup the IDT */ + KeInitExceptions(); - /* Load Ring 3 selectors for DS/ES */ - Ke386SetDs(KGDT_R3_DATA | RPL_MASK); - Ke386SetEs(KGDT_R3_DATA | RPL_MASK); + /* Load Ring 3 selectors for DS/ES/FS */ + Ke386SetDs(KGDT_64_DATA | RPL_MASK); + Ke386SetEs(KGDT_64_DATA | RPL_MASK); +// Ke386SetFs(KGDT_32_R3_TEB | RPL_MASK); - /* Save NMI and double fault traps */ - RtlCopyMemory(&NmiEntry, &Idt[2], sizeof(KIDTENTRY)); - RtlCopyMemory(&DoubleFaultEntry, &Idt[8], sizeof(KIDTENTRY)); + /* LDT is unused */ + Ke386SetLocalDescriptorTable(0); - /* Copy kernel's trap handlers */ - RtlCopyMemory(Idt, - (PVOID)KiIdtDescriptor.Base, - KiIdtDescriptor.Limit + 1); + /* Save NMI and double fault traps */ +// RtlCopyMemory(&NmiEntry, &Idt[2], sizeof(KIDTENTRY)); +// RtlCopyMemory(&DoubleFaultEntry, &Idt[8], sizeof(KIDTENTRY)); + + /* Copy kernel's trap handlers */ +// RtlCopyMemory(Idt, +// (PVOID)KiIdtDescriptor.Base, +// KiIdtDescriptor.Limit + 1); + + /* Restore NMI and double fault */ +// RtlCopyMemory(&Idt[2], &NmiEntry, sizeof(KIDTENTRY)); +// RtlCopyMemory(&Idt[8], &DoubleFaultEntry, sizeof(KIDTENTRY)); + } - /* Restore NMI and double fault */ - RtlCopyMemory(&Idt[2], &NmiEntry, sizeof(KIDTENTRY)); - RtlCopyMemory(&Idt[8], &DoubleFaultEntry, sizeof(KIDTENTRY)); -AppCpuInit: /* Loop until we can release the freeze lock */ do { @@ -749,26 +749,24 @@ AppCpuInit: } while(InterlockedBitTestAndSet((PLONG)&KiFreezeExecutionLock, 0)); /* Setup CPU-related fields */ - __writefsdword(KPCR_NUMBER, Cpu); - __writefsdword(KPCR_SET_MEMBER, 1 << Cpu); - __writefsdword(KPCR_SET_MEMBER_COPY, 1 << Cpu); - __writefsdword(KPCR_PRCB_SET_MEMBER, 1 << Cpu); + Pcr->Prcb.Number = Cpu; + Pcr->Prcb.SetMember = 1 << Cpu; /* Initialize the Processor with HAL */ - HalInitializeProcessor(Cpu, KeLoaderBlock); +// HalInitializeProcessor(Cpu, KeLoaderBlock); /* Set active processors */ - KeActiveProcessors |= __readfsdword(KPCR_SET_MEMBER); + KeActiveProcessors |= 1 << Cpu; KeNumberProcessors++; /* Check if this is the boot CPU */ - if (!Cpu) + if (Cpu == 0) { /* Initialize debugging system */ - KdInitSystem(0, KeLoaderBlock); +// KdInitSystem(0, KeLoaderBlock); /* Check for break-in */ - if (KdPollBreakIn()) DbgBreakPointWithStatus(1); +// if (KdPollBreakIn()) DbgBreakPointWithStatus(1); } /* Raise to HIGH_LEVEL */ @@ -777,12 +775,14 @@ AppCpuInit: /* Align stack and make space for the trap frame and NPX frame */ InitialStack &= ~(KTRAP_FRAME_ALIGN - 1); +FrLdrDbgPrint("Before KiSetupStackAndInitializeKernel\n"); +for(;;); + /* Switch to new kernel stack and start kernel bootstrapping */ KiSetupStackAndInitializeKernel(&KiInitialProcess.Pcb, InitialThread, (PVOID)InitialStack, - (PKPRCB)__readfsdword(KPCR_PRCB), + &Pcr->Prcb, (CCHAR)Cpu, KeLoaderBlock); -#endif } diff --git a/reactos/ntoskrnl/ke/amd64/trap.S b/reactos/ntoskrnl/ke/amd64/trap.S new file mode 100644 index 00000000000..5c43aae70ca --- /dev/null +++ b/reactos/ntoskrnl/ke/amd64/trap.S @@ -0,0 +1,131 @@ +/* + * FILE: ntoskrnl/ke/amd64/trap.S + * COPYRIGHT: See COPYING in the top level directory + * PURPOSE: System Traps, Entrypoints and Exitpoints + * PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org) + * NOTE: See asmmacro.S for the shared entry/exit code. + */ + +/* INCLUDES ******************************************************************/ + +//#include +//#include +.intel_syntax noprefix +.code64 + +/* GLOBALS *******************************************************************/ + +.data + +_MsgGeneralProtFault: +.ascii "General protection fault at %p!\n\0" + +_MsgBreakpointTrap: +.ascii "BreakpointTrap at %p\n\0" + +_MsgUnexpectedInterrupt: +.ascii "UnexpectedInterrupt\n\0" + + +/* SOFTWARE INTERRUPT SERVICES ***********************************************/ +.text +.code64 + +.global _KiDivideErrorFault +_KiDivideErrorFault: + +.global _KiDebugTrapOrFault +_KiDebugTrapOrFault: + +.global _KiNmiInterrupt +_KiNmiInterrupt: + +.global _KiBreakpointTrap +_KiBreakpointTrap: +// mov rdx, [rsp] + sub rsp, 0x10 +// movabs rcx, offset _MsgBreakpointTrap +// movabs rax, offset _FrLdrDbgPrint +// call [rax] + add rsp, 0x10 + iret + +.global _KiOverflowTrap +_KiOverflowTrap: + +.global _KiBoundFault +_KiBoundFault: + +.global _KiInvalidOpcodeFault +_KiInvalidOpcodeFault: + +.global _KiNpxNotAvailableFault +_KiNpxNotAvailableFault: + +.global _KiDoubleFaultAbort +_KiDoubleFaultAbort: + +.global _KiNpxSegmentOverrunAbort +_KiNpxSegmentOverrunAbort: + +.global _KiInvalidTssFault +_KiInvalidTssFault: + +.global _KiSegmentNotPresentFault +_KiSegmentNotPresentFault: + +.global _KiStackFault +_KiStackFault: + +jmp $ + + +.global _KiGeneralProtectionFault +_KiGeneralProtectionFault: + mov rdx, 0 + mov dx, ss + movabs rcx, offset _MsgGeneralProtFault + movabs rax, offset _FrLdrDbgPrint + call [rax] + jmp $ + + +.global _KiPageFault +_KiPageFault: + +.global _KiFloatingErrorFault +_KiFloatingErrorFault: + +.global _KiAlignmentFault +_KiAlignmentFault: + +.global _KiMcheckAbort +_KiMcheckAbort: + +.global _KiXmmException +_KiXmmException: + +.global _KiApcInterrupt +_KiApcInterrupt: + + +.global _KiRaiseAssertion +_KiRaiseAssertion: + +.global _KiDebugServiceTrap +_KiDebugServiceTrap: + +.global _KiDpcInterrupt +_KiDpcInterrupt: + + +.global _KiIpiInterrupt +_KiIpiInterrupt: + iret + +.global _KiUnexpectedInterrupt +_KiUnexpectedInterrupt: + movabs rcx, offset _MsgUnexpectedInterrupt + movabs rax, offset _FrLdrDbgPrint + call [rax] + jmp $ diff --git a/reactos/ntoskrnl/ntoskrnl-amd64hack.rbuild b/reactos/ntoskrnl/ntoskrnl-amd64hack.rbuild index a8e6365861f..3c010044f10 100644 --- a/reactos/ntoskrnl/ntoskrnl-amd64hack.rbuild +++ b/reactos/ntoskrnl/ntoskrnl-amd64hack.rbuild @@ -91,7 +91,11 @@ boot.S + cpu.c + except.c + irql.c kiinit.c + trap.S apc.c diff --git a/reactos/ntoskrnl/ntoskrnl_amd64.def b/reactos/ntoskrnl/ntoskrnl_amd64.def index 0a82a805bbd..828417e6603 100644 --- a/reactos/ntoskrnl/ntoskrnl_amd64.def +++ b/reactos/ntoskrnl/ntoskrnl_amd64.def @@ -6,7 +6,6 @@ EXPORTS ; KfAcquireSpinLock KfReleaseSpinLock -KeRaiseIrql KefAcquireSpinLockAtDpcLevel KefReleaseSpinLockFromDpcLevel KeInitializeSpinLock