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.

254 lines
4.8 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. kdcom.c
  5. Abstract:
  6. Kernel Debugger HW Extension DLL com port debugger support module
  7. Author:
  8. Eric F. Nelson (enelson) 7-Jan-99
  9. Revision History:
  10. --*/
  11. #include "kdcomp.h"
  12. #define BAUD_OPTION "BAUDRATE"
  13. #define PORT_OPTION "DEBUGPORT"
  14. DEBUG_PARAMETERS KdCompDbgParams = {0, 0};
  15. VOID
  16. SleepResetKd(
  17. VOID
  18. );
  19. NTSTATUS
  20. KdD0Transition(
  21. VOID
  22. )
  23. /*++
  24. Routine Description:
  25. The PCI driver (or relevant bus driver) will call this API after it
  26. processes a D0 IRP for this device
  27. Arguments:
  28. None
  29. Return Value:
  30. STATUS_SUCCESS, or appropriate error status
  31. --*/
  32. {
  33. return STATUS_SUCCESS;
  34. }
  35. NTSTATUS
  36. KdD3Transition(
  37. VOID
  38. )
  39. /*++
  40. Routine Description:
  41. The PCI driver (or relevant bus driver) will call this API before it
  42. processes a D3 IRP for this device
  43. Arguments:
  44. None
  45. Return Value:
  46. STATUS_SUCCESS, or appropriate error status
  47. --*/
  48. {
  49. return STATUS_SUCCESS;
  50. }
  51. NTSTATUS
  52. KdDebuggerInitialize0(
  53. IN PLOADER_PARAMETER_BLOCK LoaderBlock
  54. )
  55. /*++
  56. Routine Description:
  57. This API allows the debugger DLL to parse the boot.ini strings and
  58. perform any initialization. It cannot be assumed that the entire NT
  59. kernel has been initialized at this time. Memory management services,
  60. for example, will not be available. After this call has returned, the
  61. debugger DLL may receive requests to send and receive packets.
  62. Arguments:
  63. LoaderBlock - Supplies a pointer to the loader parameter block
  64. Return Value:
  65. STATUS_SUCCESS, or error
  66. --*/
  67. {
  68. PCHAR Options;
  69. NTSTATUS Status;
  70. PCHAR BaudOption;
  71. PCHAR PortOption;
  72. if (LoaderBlock != NULL) {
  73. if (LoaderBlock->LoadOptions != NULL) {
  74. Options = LoaderBlock->LoadOptions;
  75. _strupr(Options);
  76. PortOption = strstr(Options, PORT_OPTION);
  77. BaudOption = strstr(Options, BAUD_OPTION);
  78. if (PortOption) {
  79. PortOption = strstr(PortOption, "COM");
  80. if (PortOption) {
  81. KdCompDbgParams.CommunicationPort = atol(PortOption + 3);
  82. }
  83. }
  84. if (BaudOption) {
  85. BaudOption += strlen(BAUD_OPTION);
  86. while (*BaudOption == ' ') {
  87. BaudOption++;
  88. }
  89. if (*BaudOption != '\0') {
  90. KdCompDbgParams.BaudRate = atol(BaudOption + 1);
  91. }
  92. }
  93. }
  94. }
  95. Status = KdCompInitialize(&KdCompDbgParams, LoaderBlock);
  96. //
  97. // Initialize ID for NEXT packet to send and Expect ID of next incoming
  98. // packet.
  99. //
  100. if (NT_SUCCESS(Status)) {
  101. KdCompNextPacketIdToSend = INITIAL_PACKET_ID | SYNC_PACKET_ID;
  102. KdCompPacketIdExpected = INITIAL_PACKET_ID;
  103. }
  104. return Status;
  105. }
  106. NTSTATUS
  107. KdDebuggerInitialize1(
  108. IN PLOADER_PARAMETER_BLOCK LoaderBlock
  109. )
  110. /*++
  111. Routine Description:
  112. This API allows the debugger DLL to do any initialization that it needs
  113. to do after the NT kernel services are available. Mm and registry APIs
  114. will be guaranteed to be available at this time. If the specific
  115. debugger DLL implementation uses a PCI device, it will set a registry
  116. key (discussed later) that notifies the PCI driver that a specific PCI
  117. device is being used for debugging.
  118. Arguments:
  119. LoaderBlock - Supplies a pointer to the loader parameter block
  120. Return Value:
  121. STATUS_SUCCESS, or appropriate error status
  122. --*/
  123. {
  124. KdCompInitialize1();
  125. return STATUS_SUCCESS;
  126. }
  127. NTSTATUS
  128. KdSave(
  129. IN BOOLEAN KdSleepTransition
  130. )
  131. /*++
  132. Routine Description:
  133. The HAL calls this function as late as possible before putting the
  134. machine to sleep.
  135. Arguments:
  136. KdSleepTransition - TRUE when transitioning to/from sleep state
  137. Return Value:
  138. STATUS_SUCCESS, or appropriate error status
  139. --*/
  140. {
  141. KdCompSave();
  142. return STATUS_SUCCESS;
  143. }
  144. NTSTATUS
  145. KdRestore(
  146. IN BOOLEAN KdSleepTransition
  147. )
  148. /*++
  149. Routine Description:
  150. The HAL calls this function as early as possible after resuming from a
  151. sleep state.
  152. Arguments:
  153. KdSleepTransition - TRUE when transitioning to/from sleep state
  154. Return Value:
  155. STATUS_SUCCESS, or appropriate error status
  156. --*/
  157. {
  158. //
  159. // Force resync when transitioning to/from sleep state
  160. //
  161. if (KdSleepTransition) {
  162. #ifdef ALPHA
  163. SleepResetKd();
  164. #else
  165. KdCompDbgPortsPresent = FALSE;
  166. #endif
  167. } else {
  168. KdCompRestore();
  169. }
  170. return STATUS_SUCCESS;
  171. }