https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5730394bd09aa411bcf3a…
commit 5730394bd09aa411bcf3af0868e47772113f59a1
Author: Hervé Poussineau <hpoussin(a)reactos.org>
AuthorDate: Sat Mar 7 23:33:57 2020 +0100
Commit: Hervé Poussineau <hpoussin(a)reactos.org>
CommitDate: Mon Nov 16 08:55:03 2020 +0100
[NTOS:KD] Merge KdpPrintString()/KdpPromptString() with kd64 version
---
ntoskrnl/kd/kdio.c | 126 ++++++++++++++++++++++++------------------------
ntoskrnl/kd64/kdprint.c | 4 +-
2 files changed, 65 insertions(+), 65 deletions(-)
diff --git a/ntoskrnl/kd/kdio.c b/ntoskrnl/kd/kdio.c
index 21d98615fe6..d76e3f55860 100644
--- a/ntoskrnl/kd/kdio.c
+++ b/ntoskrnl/kd/kdio.c
@@ -508,43 +508,59 @@ KdpScreenInit(PKD_DISPATCH_TABLE DispatchTable,
BOOLEAN
NTAPI
KdpPrintString(
- _In_ PSTRING Output)
-{
- PLIST_ENTRY CurrentEntry;
- PKD_DISPATCH_TABLE CurrentTable;
+ _In_ PSTRING Output);
- if (!KdpDebugMode.Value) return FALSE;
+extern STRING KdbPromptString;
- /* Call the registered handlers */
- CurrentEntry = KdProviders.Flink;
- while (CurrentEntry != &KdProviders)
+VOID
+NTAPI
+KdSendPacket(
+ IN ULONG PacketType,
+ IN PSTRING MessageHeader,
+ IN PSTRING MessageData,
+ IN OUT PKD_CONTEXT Context)
+{
+ if (PacketType == PACKET_TYPE_KD_DEBUG_IO)
{
- /* Get the current table */
- CurrentTable = CONTAINING_RECORD(CurrentEntry,
- KD_DISPATCH_TABLE,
- KdProvidersList);
+ PSTRING Output = MessageData;
+ PLIST_ENTRY CurrentEntry;
+ PKD_DISPATCH_TABLE CurrentTable;
- /* Call it */
- CurrentTable->KdpPrintRoutine(Output->Buffer, Output->Length);
+ if (!KdpDebugMode.Value) return;
- /* Next Table */
- CurrentEntry = CurrentEntry->Flink;
- }
+ /* Call the registered handlers */
+ CurrentEntry = KdProviders.Flink;
+ while (CurrentEntry != &KdProviders)
+ {
+ /* Get the current table */
+ CurrentTable = CONTAINING_RECORD(CurrentEntry,
+ KD_DISPATCH_TABLE,
+ KdProvidersList);
- /* Call the Wrapper Routine */
- if (WrapperTable.KdpPrintRoutine)
- WrapperTable.KdpPrintRoutine(Output->Buffer, Output->Length);
+ /* Call it */
+ CurrentTable->KdpPrintRoutine(Output->Buffer, Output->Length);
- return FALSE;
-}
+ /* Next Table */
+ CurrentEntry = CurrentEntry->Flink;
+ }
-extern STRING KdbPromptString;
+ /* Call the Wrapper Routine */
+ if (WrapperTable.KdpPrintRoutine)
+ WrapperTable.KdpPrintRoutine(Output->Buffer, Output->Length);
-BOOLEAN
+ return;
+ }
+ UNIMPLEMENTED;
+}
+
+KDSTATUS
NTAPI
-KdpPromptString(
- _In_ PSTRING PromptString,
- _In_ PSTRING ResponseString)
+KdReceivePacket(
+ IN ULONG PacketType,
+ OUT PSTRING MessageHeader,
+ OUT PSTRING MessageData,
+ OUT PULONG DataLength,
+ IN OUT PKD_CONTEXT Context)
{
#ifdef KDBG
KIRQL OldIrql;
@@ -552,12 +568,21 @@ KdpPromptString(
CHAR Response;
USHORT i;
ULONG DummyScanCode;
+ CHAR MessageBuffer[100];
+ STRING ResponseString;
+#endif
+ if (PacketType != PACKET_TYPE_KD_DEBUG_IO)
+ return KdPacketTimedOut;
+
+#ifdef KDBG
+ ResponseString.Buffer = MessageBuffer;
+ ResponseString.Length = 0;
+ ResponseString.MaximumLength = min(sizeof(MessageBuffer),
MessageData->MaximumLength);
StringChar.Buffer = &Response;
StringChar.Length = StringChar.MaximumLength = sizeof(Response);
/* Display the string and print a new line for log neatness */
- KdpPrintString(PromptString);
*StringChar.Buffer = '\n';
KdpPrintString(&StringChar);
@@ -573,7 +598,7 @@ KdpPromptString(
KbdDisableMouse();
/* Loop the whole string */
- for (i = 0; i < ResponseString->MaximumLength; i++)
+ for (i = 0; i < ResponseString.MaximumLength; i++)
{
/* Check if this is serial debugging mode */
if (KdbDebugState & KD_DEBUG_KDSERIAL)
@@ -618,19 +643,24 @@ KdpPromptString(
* Null terminate the output string -- documentation states that
* DbgPrompt does not null terminate, but it does
*/
- *(PCHAR)(ResponseString->Buffer + i) = 0;
+ *(PCHAR)(ResponseString.Buffer + i) = 0;
break;
}
/* Write it back and print it to the log */
- *(PCHAR)(ResponseString->Buffer + i) = Response;
+ *(PCHAR)(ResponseString.Buffer + i) = Response;
KdpReleaseLock(&KdpSerialSpinLock, OldIrql);
KdpPrintString(&StringChar);
OldIrql = KdpAcquireLock(&KdpSerialSpinLock);
}
+ /* Print a new line */
+ *StringChar.Buffer = '\n';
+ KdpPrintString(&StringChar);
+
/* Return the length */
- ResponseString->Length = i;
+ RtlCopyMemory(MessageData->Buffer, ResponseString.Buffer, i);
+ *DataLength = i;
if (!(KdbDebugState & KD_DEBUG_KDSERIAL))
KbdEnableMouse();
@@ -638,38 +668,8 @@ KdpPromptString(
/* Release the spinlock */
KdpReleaseLock(&KdpSerialSpinLock, OldIrql);
- /* Print a new line */
- *StringChar.Buffer = '\n';
- KdpPrintString(&StringChar);
#endif
-
- /* Success; we don't need to resend */
- return FALSE;
-}
-
-VOID
-NTAPI
-KdSendPacket(
- IN ULONG PacketType,
- IN PSTRING MessageHeader,
- IN PSTRING MessageData,
- IN OUT PKD_CONTEXT Context)
-{
- UNIMPLEMENTED;
- return;
-}
-
-KDSTATUS
-NTAPI
-KdReceivePacket(
- IN ULONG PacketType,
- OUT PSTRING MessageHeader,
- OUT PSTRING MessageData,
- OUT PULONG DataLength,
- IN OUT PKD_CONTEXT Context)
-{
- UNIMPLEMENTED;
- return 0;
+ return KdPacketReceived;
}
/* EOF */
diff --git a/ntoskrnl/kd64/kdprint.c b/ntoskrnl/kd64/kdprint.c
index 81da68b7ec1..1d9caa87cea 100644
--- a/ntoskrnl/kd64/kdprint.c
+++ b/ntoskrnl/kd64/kdprint.c
@@ -15,8 +15,6 @@
/* FUNCTIONS *****************************************************************/
-#ifdef _WINKD_
-
BOOLEAN
NTAPI
KdpPrintString(
@@ -132,6 +130,8 @@ KdpPromptString(
return FALSE;
}
+#ifdef _WINKD_
+
VOID
NTAPI
KdpCommandString(IN PSTRING NameString,