Author: ion
Date: Tue Feb 20 07:38:01 2007
New Revision: 25854
URL:
http://svn.reactos.org/svn/reactos?rev=25854&view=rev
Log:
- Implement KdpWriteControlSpace.
- Fix a bug in KdpSetContext.
- Use DR_MASK and DR7_OVERRIDE_V in KiUpdateDr7, KiRecordDr7 instead of DR_ACTIVE_MASK.
- We now get DbgKdContinueApi2 from WinDBG meaning that the first phase of KD
communication is almost over!
Modified:
branches/alex-kd-branch/reactos/include/ndk/asm.h
branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdapi.c
branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdtrap.c
branches/alex-kd-branch/reactos/ntoskrnl/ke/i386/exp.c
Modified: branches/alex-kd-branch/reactos/include/ndk/asm.h
URL:
http://svn.reactos.org/svn/reactos/branches/alex-kd-branch/reactos/include/…
==============================================================================
--- branches/alex-kd-branch/reactos/include/ndk/asm.h (original)
+++ branches/alex-kd-branch/reactos/include/ndk/asm.h Tue Feb 20 07:38:01 2007
@@ -494,6 +494,7 @@
#define DR6_LEGAL 0xE00F
#define DR7_LEGAL 0xFFFF0155
#define DR7_ACTIVE 0x55
+#define DR7_OVERRIDE_V 0x04
#define DR7_RESERVED_MASK 0xDC00
#define DR7_OVERRIDE_MASK 0xF0000
Modified: branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdapi.c
URL:
http://svn.reactos.org/svn/reactos/branches/alex-kd-branch/reactos/ntoskrnl…
==============================================================================
--- branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdapi.c (original)
+++ branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdapi.c Tue Feb 20 07:38:01 2007
@@ -231,6 +231,55 @@
Data->Length = 0;
State->ReturnStatus = STATUS_UNSUCCESSFUL;
ReadMemory->ActualBytesRead = 0;
+ }
+
+ /* Send the reply */
+ KdSendPacket(PACKET_TYPE_KD_STATE_MANIPULATE,
+ &Header,
+ Data,
+ &KdpContext);
+}
+
+VOID
+NTAPI
+KdpWriteControlSpace(IN PDBGKD_MANIPULATE_STATE64 State,
+ IN PSTRING Data,
+ IN PCONTEXT Context)
+{
+ PDBGKD_WRITE_MEMORY64 WriteMemory = &State->u.WriteMemory;
+ STRING Header;
+ ULONG Length;
+ PVOID ControlStart;
+
+ /* Setup the header */
+ Header.Length = sizeof(DBGKD_MANIPULATE_STATE64);
+ Header.Buffer = (PCHAR)State;
+
+ /* Make sure that this is a valid request */
+ Length = WriteMemory->TransferCount;
+ if ((((ULONG)WriteMemory->TargetBaseAddress + Length) <=
+ sizeof(KPROCESSOR_STATE)) &&
+ (State->Processor < KeNumberProcessors))
+ {
+ /* Set the proper address */
+ ControlStart = (PVOID)((ULONG_PTR)WriteMemory->TargetBaseAddress +
+
(ULONG_PTR)&KiProcessorBlock[State->Processor]->
+ ProcessorState);
+
+ /* Copy the memory */
+ RtlCopyMemory(ControlStart, Data->Buffer, Data->Length);
+ Length = Data->Length;
+
+ /* Finish up */
+ State->ReturnStatus = STATUS_SUCCESS;
+ WriteMemory->ActualBytesWritten = Length;
+ }
+ else
+ {
+ /* Invalid request */
+ Data->Length = 0;
+ State->ReturnStatus = STATUS_UNSUCCESSFUL;
+ WriteMemory->ActualBytesWritten = 0;
}
/* Send the reply */
@@ -335,7 +384,7 @@
/* Setup the header */
Header.Length = sizeof(DBGKD_MANIPULATE_STATE64);
Header.Buffer = (PCHAR)State;
- ASSERT(Data->Length == 0);
+ ASSERT(Data->Length == sizeof(CONTEXT));
/* Make sure that this is a valid request */
if (State->Processor < KeNumberProcessors)
@@ -472,8 +521,7 @@
case DbgKdWriteControlSpaceApi:
/* FIXME: TODO */
- Ke386SetCr2(DbgKdWriteControlSpaceApi);
- while (TRUE);
+ KdpWriteControlSpace(&ManipulateState, &Data, Context);
break;
case DbgKdReadIoSpaceApi:
Modified: branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdtrap.c
URL:
http://svn.reactos.org/svn/reactos/branches/alex-kd-branch/reactos/ntoskrnl…
==============================================================================
--- branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdtrap.c (original)
+++ branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdtrap.c Tue Feb 20 07:38:01 2007
@@ -49,7 +49,6 @@
}
/* Enter the debugger */
- while (TRUE);
Entered = KdEnterDebugger(TrapFrame, ExceptionFrame);
/*
@@ -63,6 +62,7 @@
sizeof(CONTEXT));
/* Report the new state */
+ Ke386SetCr2(TrapFrame->HardwareEsp);
#if 0
Status = KdpReportExceptionStateChange(ExceptionRecord,
&Prcb->ProcessorState.
Modified: branches/alex-kd-branch/reactos/ntoskrnl/ke/i386/exp.c
URL:
http://svn.reactos.org/svn/reactos/branches/alex-kd-branch/reactos/ntoskrnl…
==============================================================================
--- branches/alex-kd-branch/reactos/ntoskrnl/ke/i386/exp.c (original)
+++ branches/alex-kd-branch/reactos/ntoskrnl/ke/i386/exp.c Tue Feb 20 07:38:01 2007
@@ -90,7 +90,7 @@
ULONG DebugMask = KeGetCurrentThread()->DispatcherHeader.DebugActive;
/* Check if debugging is enabled */
- if (DebugMask & DR_ACTIVE_MASK)
+ if (DebugMask & DR_MASK(DR7_OVERRIDE_V))
{
/* Sanity checks */
ASSERT((DebugMask & DR_REG_MASK) != 0);
@@ -133,11 +133,11 @@
Result = FALSE;
/* Check the DR mask */
- NewMask &= 0x7F;
+ NewMask &= ~(DR_MASK(7));
if (NewMask & DR_REG_MASK)
{
/* Set the active mask */
- NewMask |= DR_ACTIVE_MASK;
+ NewMask |= DR_MASK(DR7_OVERRIDE_V);
/* Set DR7 override */
*DrMask = DR7_OVERRIDE_MASK;
@@ -154,8 +154,8 @@
Result = NewMask ? TRUE: FALSE;
/* Update the mask to disable debugging */
- NewMask &= ~DR_ACTIVE_MASK;
- NewMask |= 0x80;
+ NewMask &= ~(DR_MASK(DR7_OVERRIDE_V));
+ NewMask |= DR_MASK(7);
}
/* Check if caller wants the new mask */