Author: tkreuzer
Date: Wed Oct 14 13:39:59 2009
New Revision: 43448
URL:
http://svn.reactos.org/svn/reactos?rev=43448&view=rev
Log:
[KD64]
- use SEH in KdpSysReadMsr
- use constants for KdpSysReadControlSpace cases (DEBUG_CONTROL_SPACE_KSPECIAL taken from
singularity)
- implement case DEBUG_CONTROL_SPACE_KTHREAD returning a pointer to the current thread
- Implement KdpSysReadIoSpace, KdpSysWriteIoSpace for amd64, can be used for x86, too
Modified:
branches/ros-amd64-bringup/reactos/include/reactos/windbgkd.h
branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/kd64.h
branches/ros-amd64-bringup/reactos/ntoskrnl/kd64/amd64/kdsup.c
Modified: branches/ros-amd64-bringup/reactos/include/reactos/windbgkd.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/inclu…
==============================================================================
--- branches/ros-amd64-bringup/reactos/include/reactos/windbgkd.h [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/include/reactos/windbgkd.h [iso-8859-1] Wed Oct 14
13:39:59 2009
@@ -195,6 +195,16 @@
#define DBGKD_PARTITION_ALTERNATE 0x01
//
+// Control Space types
+//
+#define DEBUG_CONTROL_SPACE_KPCR 0
+#define DEBUG_CONTROL_SPACE_KPRCB 1
+#define DEBUG_CONTROL_SPACE_KSPECIAL 2
+#define DEBUG_CONTROL_SPACE_KTHREAD 3
+#define X86_DEBUG_CONTROL_SPACE_KSPECIAL 716
+
+
+//
// KD Packet Structure
//
typedef struct _KD_PACKET
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/kd64.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/kd64.h [iso-8859-1]
(original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/kd64.h [iso-8859-1] Wed
Oct 14 13:39:59 2009
@@ -374,7 +374,7 @@
IN ULONG BusNumber,
IN ULONG AddressSpace,
IN ULONG64 IoAddress,
- IN PULONG DataValue,
+ IN PVOID DataValue,
IN ULONG DataSize,
OUT PULONG ActualDataSize
);
@@ -386,7 +386,7 @@
IN ULONG BusNumber,
IN ULONG AddressSpace,
IN ULONG64 IoAddress,
- IN PULONG DataValue,
+ IN PVOID DataValue,
IN ULONG DataSize,
OUT PULONG ActualDataSize
);
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/kd64/amd64/kdsup.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/kd64/amd64/kdsup.c [iso-8859-1]
(original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/kd64/amd64/kdsup.c [iso-8859-1] Wed Oct 14
13:39:59 2009
@@ -104,7 +104,17 @@
KdpSysReadMsr(IN ULONG Msr,
OUT PLARGE_INTEGER MsrValue)
{
- MsrValue->QuadPart = __readmsr(Msr);
+ /* Use SEH to protect from invalid MSRs */
+ _SEH2_TRY
+ {
+ MsrValue->QuadPart = __readmsr(Msr);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ _SEH2_YIELD(return STATUS_NO_SUCH_DEVICE);
+ }
+ _SEH2_END
+
return STATUS_SUCCESS;
}
@@ -113,7 +123,17 @@
KdpSysWriteMsr(IN ULONG Msr,
IN PLARGE_INTEGER MsrValue)
{
- __writemsr(Msr, MsrValue->QuadPart);
+ /* Use SEH to protect from invalid MSRs */
+ _SEH2_TRY
+ {
+ __writemsr(Msr, MsrValue->QuadPart);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ _SEH2_YIELD(return STATUS_NO_SUCH_DEVICE);
+ }
+ _SEH2_END
+
return STATUS_SUCCESS;
}
@@ -165,28 +185,35 @@
switch ((ULONG_PTR)BaseAddress)
{
- case 0:
+ case DEBUG_CONTROL_SPACE_KPCR:
/* Copy a pointer to the Pcr */
ControlStart = &Pcr;
RealLength = sizeof(PVOID);
break;
- case 1:
+ case DEBUG_CONTROL_SPACE_KPRCB:
/* Copy a pointer to the Prcb */
ControlStart = &Prcb;
RealLength = sizeof(PVOID);
break;
- case 2:
+ case DEBUG_CONTROL_SPACE_KSPECIAL:
/* Copy SpecialRegisters */
ControlStart = &Prcb->ProcessorState.SpecialRegisters;
RealLength = sizeof(KSPECIAL_REGISTERS);
break;
+ case DEBUG_CONTROL_SPACE_KTHREAD:
+ /* Copy a pointer to the current Thread */
+ ControlStart = &Prcb->CurrentThread;
+ RealLength = sizeof(PVOID);
+ break;
+
default:
RealLength = 0;
ControlStart = NULL;
ASSERT(FALSE);
+ return STATUS_UNSUCCESSFUL;
}
if (RealLength < Length) Length = RealLength;
@@ -225,14 +252,48 @@
IN ULONG BusNumber,
IN ULONG AddressSpace,
IN ULONG64 IoAddress,
- IN PULONG DataValue,
+ OUT PVOID DataValue,
IN ULONG DataSize,
OUT PULONG ActualDataSize)
{
- UNIMPLEMENTED;
- while (TRUE);
- return STATUS_UNSUCCESSFUL;
-}
+ /* Verify parameters */
+ if (InterfaceType != Isa || BusNumber != 0 || AddressSpace != 1)
+ {
+ /* No data was read */
+ *ActualDataSize = 0;
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ switch (DataSize)
+ {
+ case sizeof(UCHAR):
+ /* read one UCHAR */
+ *(PUCHAR)DataValue = READ_PORT_UCHAR((PUCHAR)IoAddress);
+ break;
+
+ case sizeof(USHORT):
+ /* Read one USHORT */
+ *(PUSHORT)DataValue = READ_PORT_USHORT((PUSHORT)IoAddress);
+ break;
+
+ case sizeof(ULONG):
+ /* Read one ULONG */
+ *(PULONG)DataValue = READ_PORT_ULONG((PULONG)IoAddress);
+ break;
+
+ default:
+ /* Invalid data size */
+ *ActualDataSize = 0;
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ /* Return the size of the data */
+ *ActualDataSize = DataSize;
+
+ /* Success! */
+ return STATUS_SUCCESS;
+}
+
NTSTATUS
NTAPI
@@ -240,20 +301,53 @@
IN ULONG BusNumber,
IN ULONG AddressSpace,
IN ULONG64 IoAddress,
- IN PULONG DataValue,
+ IN PVOID DataValue,
IN ULONG DataSize,
OUT PULONG ActualDataSize)
+{
+ /* Verify parameters */
+ if (InterfaceType != Isa || BusNumber != 0 || AddressSpace != 1)
+ {
+ /* No data was written */
+ *ActualDataSize = 0;
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ switch (DataSize)
+ {
+ case sizeof(UCHAR):
+ /* read one UCHAR */
+ WRITE_PORT_UCHAR((PUCHAR)IoAddress, *(PUCHAR)DataValue);
+ break;
+
+ case sizeof(USHORT):
+ /* Read one USHORT */
+ WRITE_PORT_USHORT((PUSHORT)IoAddress, *(PUSHORT)DataValue);
+ break;
+
+ case sizeof(ULONG):
+ /* Read one ULONG */
+ WRITE_PORT_ULONG((PULONG)IoAddress, *(PULONG)DataValue);
+ break;
+
+ default:
+ /* Invalid data size */
+ *ActualDataSize = 0;
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ /* Return the size of the data */
+ *ActualDataSize = DataSize;
+
+ /* Success! */
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+NTAPI
+KdpSysCheckLowMemory(IN ULONG Flags)
{
UNIMPLEMENTED;
while (TRUE);
return STATUS_UNSUCCESSFUL;
}
-
-NTSTATUS
-NTAPI
-KdpSysCheckLowMemory(IN ULONG Flags)
-{
- UNIMPLEMENTED;
- while (TRUE);
- return STATUS_UNSUCCESSFUL;
-}