Author: tkreuzer
Date: Mon Jan 26 19:57:35 2009
New Revision: 39126
URL:
http://svn.reactos.org/svn/reactos?rev=39126&view=rev
Log:
Increment rip in KiBreakPointTrap and reenable decrement in KiDispatchException. (Do we
really need it, first inc then dec? At least x86 does it that way) Setup fs selector in
KiSystemStartupReal, pass a pointer to FrLdrDbgPrint to kdcom, fix some typos. Finally
breaking into the debugger and continuing really works.
Modified:
branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/except.c
branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/kiinit.c
branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/trap.S
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/except.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/except.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/except.c [iso-8859-1] Mon Jan 26
19:57:35 2009
@@ -120,7 +120,7 @@
/* Decrement RIP by one */
// FIXME: that doesn't work, why?
-// Context.Rip--;
+ Context.Rip--;
break;
/* Internal exception */
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/kiinit.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/kiinit.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/kiinit.c [iso-8859-1] Mon Jan 26
19:57:35 2009
@@ -372,7 +372,7 @@
// Pcr->Irql = PASSIVE_LEVEL;
KeSetCurrentIrql(PASSIVE_LEVEL);
- /* Set the GDI, IDT, TSS and DPC Stack */
+ /* Set the GDT, IDT, TSS and DPC Stack */
Pcr->GdtBase = (PVOID)Gdt;
Pcr->IdtBase = Idt;
Pcr->TssBase = Tss;
@@ -645,6 +645,7 @@
KiRosPrepareForSystemStartup(Dummy, LoaderBlock);
}
+
VOID
NTAPI
KiSystemStartupReal(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
@@ -723,7 +724,7 @@
/* 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);
+ Ke386SetFs(KGDT_32_R3_TEB | RPL_MASK);
/* LDT is unused */
__sldt(0);
@@ -770,10 +771,13 @@
/* Check for break-in */
// if (KdPollBreakIn()) DbgBreakPointWithStatus(1);
}
-FrLdrDbgPrint("after KdInitSystem\n");
+
+ /* HACK: misuse this function to pass a function pointer to kdcom */
+ KdDebuggerInitialize1((PVOID)FrLdrDbgPrint);
/* Hack! Wait for the debugger! */
while (!KdPollBreakIn());
+
DbgBreakPointWithStatus(0);
/* Display separator + ReactOS version at start of the debug log */
@@ -787,8 +791,6 @@
/* Raise to HIGH_LEVEL */
KfRaiseIrql(HIGH_LEVEL);
-
-FrLdrDbgPrint("before KiSetupStackAndInitializeKernel\n");
/* Switch to new kernel stack and start kernel bootstrapping */
KiSetupStackAndInitializeKernel(&KiInitialProcess.Pcb,
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/trap.S
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/trap.S [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/trap.S [iso-8859-1] Mon Jan 26
19:57:35 2009
@@ -34,6 +34,9 @@
#define TRAPFLAG_SYSTEMSERVICE 1
+/*
+ * ENTER_TRAP_FRAME - Allocate SIZE_KTRAP_FRAME and save registers to it
+ */
.macro ENTER_TRAP_FRAME AllocSize Flags
.set SIZE_INITIAL_FRAME, 7 * 8
//.set SIZE_LOCAL_DATA, SIZE_EXCEPTION_RECORD + 0x28
@@ -133,6 +136,10 @@
cld
.endm
+
+/*
+ * LEAVE_TRAP_FRAME - Restore registers and free stack space
+ */
.macro LEAVE_TRAP_FRAME
/* Restore segment selectors */
@@ -178,6 +185,10 @@
add rsp, SIZE_TRAP_FRAME_ALLOC + 0x10
.endm
+
+/*
+ * DISPATCH_EXCEPTION - prepare EXCEPTION_RECORD and call KiDispatchException
+ */
.macro DISPATCH_EXCEPTION Code, NumParams, p1, p2, p3
/* rsp+0x28 points to EXCEPTION_RECORD, set it up */
@@ -253,9 +264,11 @@
ENTER_TRAP_FRAME (SIZE_EXCEPTION_RECORD + 0x28), 0
lea rcx, _MsgBreakpointTrap[rip]
- mov rdx, [rbp + KTRAP_FRAME_Rip]
- lea rax, _FrLdrDbgPrint[rip]
- call [rax]
+ mov rdx, rbp
+ call _FrLdrDbgPrint[rip]
+
+ /* Increase Rip to skip the int3 */
+ inc qword ptr [rbp + KTRAP_FRAME_Rip]
DISPATCH_EXCEPTION STATUS_BREAKPOINT, 3, 0, 0, 0
@@ -368,13 +381,18 @@
.pushframe 1
/* We have an error code */
- mov rdx, 0
- mov dx, ss
+ ENTER_TRAP_FRAME (SIZE_EXCEPTION_RECORD + 0x28), 0
+
+// DISPATCH_EXCEPTION STATUS_BREAKPOINT, 3, 0, 0, 0
+
+ mov rdx, [rbp + KTRAP_FRAME_Rip]
lea rcx, _MsgGeneralProtFault[rip]
- lea rax, _FrLdrDbgPrint[rip]
- call [rax]
-
- jmp $
+ call _FrLdrDbgPrint[rip]
+ jmp $
+
+ /* Return */
+ LEAVE_TRAP_FRAME
+ iretq
.endproc
@@ -386,8 +404,7 @@
mov rdx, [rsp]
mov r8, [rsp+8]
mov r9, rsp
- lea rax, _FrLdrDbgPrint[rip]
- call [rax]
+ call _FrLdrDbgPrint[rip]
jmp $
@@ -474,9 +491,9 @@
inc qword ptr [rbp + KTRAP_FRAME_Rip]
/* Call KiDispatchException */
- mov r8, [ebp+KTRAP_FRAME_Rax] // Service
- mov rcx, [ebp+KTRAP_FRAME_Rcx] // Buffer
- mov rdx, [ebp+KTRAP_FRAME_Rdx] // Length
+ mov r8, [rbp+KTRAP_FRAME_Rax] // Service
+ mov rcx, [rbp+KTRAP_FRAME_Rcx] // Buffer
+ mov rdx, [rbp+KTRAP_FRAME_Rdx] // Length
DISPATCH_EXCEPTION STATUS_BREAKPOINT, 3, r8, rcx, rdx
LEAVE_TRAP_FRAME;
@@ -502,11 +519,10 @@
.allocstack 0x8
lea rcx, _MsgUnexpectedInterrupt[rip]
- lea rax, _FrLdrDbgPrint[rip]
- call [rax]
-
- jmp $
-.endproc
-
-
-
+ call _FrLdrDbgPrint[rip]
+
+ jmp $
+.endproc
+
+
+