Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

201 lines
4.6 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. dbgio.c
  5. Abstract:
  6. This module implements the boot debugger print and prompt functions.
  7. Author:
  8. Mark Lucovsky (markl) 31-Aug-1990
  9. Revision History:
  10. --*/
  11. #include "bd.h"
  12. LOGICAL
  13. BdPrintString (
  14. IN PSTRING Output
  15. )
  16. /*++
  17. Routine Description:
  18. This routine prints a string.
  19. Arguments:
  20. Output - Supplies a pointer to a string descriptor for the output string.
  21. Return Value:
  22. TRUE if Control-C present in input buffer after print is done.
  23. FALSE otherwise.
  24. --*/
  25. {
  26. ULONG Length;
  27. STRING MessageData;
  28. STRING MessageHeader;
  29. DBGKD_DEBUG_IO DebugIo;
  30. //
  31. // Move the output string to the message buffer.
  32. //
  33. Length = BdMoveMemory((PCHAR)BdMessageBuffer,
  34. (PCHAR)Output->Buffer,
  35. Output->Length);
  36. //
  37. // If the total message length is greater than the maximum packet size,
  38. // then truncate the output string.
  39. //
  40. if ((sizeof(DBGKD_DEBUG_IO) + Length) > PACKET_MAX_SIZE) {
  41. Length = PACKET_MAX_SIZE - sizeof(DBGKD_DEBUG_IO);
  42. }
  43. //
  44. // Construct the print string message and message descriptor.
  45. //
  46. DebugIo.ApiNumber = DbgKdPrintStringApi;
  47. DebugIo.ProcessorLevel = 0;
  48. DebugIo.Processor = 0;
  49. DebugIo.u.PrintString.LengthOfString = Length;
  50. MessageHeader.Length = sizeof(DBGKD_DEBUG_IO);
  51. MessageHeader.Buffer = (PCHAR)&DebugIo;
  52. //
  53. // Construct the print string data and data descriptor.
  54. //
  55. MessageData.Length = (USHORT)Length;
  56. MessageData.Buffer = (PCHAR)(&BdMessageBuffer[0]);
  57. //
  58. // Send packet to the kernel debugger on the host machine.
  59. //
  60. BdSendPacket(PACKET_TYPE_KD_DEBUG_IO,
  61. &MessageHeader,
  62. &MessageData);
  63. return BdPollBreakIn();
  64. }
  65. LOGICAL
  66. BdPromptString (
  67. IN PSTRING Output,
  68. IN OUT PSTRING Input
  69. )
  70. /*++
  71. Routine Description:
  72. This routine prints a string, then reads a reply string.
  73. Arguments:
  74. Output - Supplies a pointer to a string descriptor for the output string.
  75. Input - Supplies a pointer to a string descriptor for the input string.
  76. (Length stored/returned in Input->Length)
  77. Return Value:
  78. TRUE - A Breakin sequence was seen, caller should breakpoint and retry
  79. FALSE - No Breakin seen.
  80. --*/
  81. {
  82. ULONG Length;
  83. STRING MessageData;
  84. STRING MessageHeader;
  85. DBGKD_DEBUG_IO DebugIo;
  86. ULONG ReturnCode;
  87. //
  88. // Move the output string to the message buffer.
  89. //
  90. Length = BdMoveMemory((PCHAR)BdMessageBuffer,
  91. (PCHAR)Output->Buffer,
  92. Output->Length);
  93. //
  94. // If the total message length is greater than the maximum packet size,
  95. // then truncate the output string.
  96. //
  97. if ((sizeof(DBGKD_DEBUG_IO) + Length) > PACKET_MAX_SIZE) {
  98. Length = PACKET_MAX_SIZE - sizeof(DBGKD_DEBUG_IO);
  99. }
  100. //
  101. // Construct the prompt string message and message descriptor.
  102. //
  103. DebugIo.ApiNumber = DbgKdGetStringApi;
  104. DebugIo.ProcessorLevel = 0;
  105. DebugIo.Processor = 0;
  106. DebugIo.u.GetString.LengthOfPromptString = Length;
  107. DebugIo.u.GetString.LengthOfStringRead = Input->MaximumLength;
  108. MessageHeader.Length = sizeof(DBGKD_DEBUG_IO);
  109. MessageHeader.Buffer = (PCHAR)&DebugIo;
  110. //
  111. // Construct the prompt string data and data descriptor.
  112. //
  113. MessageData.Length = (USHORT)Length;
  114. MessageData.Buffer = (PCHAR)(&BdMessageBuffer[0]);
  115. //
  116. // Send packet to the kernel debugger on the host machine.
  117. //
  118. BdSendPacket(PACKET_TYPE_KD_DEBUG_IO,
  119. &MessageHeader,
  120. &MessageData);
  121. //
  122. // Receive packet from the kernel debugger on the host machine.
  123. //
  124. MessageHeader.MaximumLength = sizeof(DBGKD_DEBUG_IO);
  125. MessageData.MaximumLength = BD_MESSAGE_BUFFER_SIZE;
  126. do {
  127. ReturnCode = BdReceivePacket(PACKET_TYPE_KD_DEBUG_IO,
  128. &MessageHeader,
  129. &MessageData,
  130. &Length);
  131. if (ReturnCode == BD_PACKET_RESEND) {
  132. return TRUE;
  133. }
  134. } while (ReturnCode != BD_PACKET_RECEIVED);
  135. Length = min(Length, Input->MaximumLength);
  136. Input->Length = (USHORT)BdMoveMemory((PCHAR)Input->Buffer,
  137. (PCHAR)BdMessageBuffer,
  138. Length);
  139. return FALSE;
  140. }
  141.