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.

428 lines
7.1 KiB

  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. bd.h
  5. Abstract:
  6. This module contains the data structures and function prototypes for the
  7. boot debugger.
  8. Author:
  9. David N. Cutler (davec) 27-Nov-1996
  10. Revision History:
  11. --*/
  12. #ifndef _BD_
  13. #define _BD_
  14. #include "bldr.h"
  15. #define NOEXTAPI
  16. #include "wdbgexts.h"
  17. #include "ntdbg.h"
  18. #include "ki.h"
  19. #include "string.h"
  20. #include "stdlib.h"
  21. #include "stdio.h"
  22. #include "cpu.h"
  23. #include "ntverp.h"
  24. //
  25. // Define message buffer size in bytes.
  26. //
  27. // N.B. This must be 0 mod 8.
  28. //
  29. #define BD_MESSAGE_BUFFER_SIZE 4096
  30. //
  31. // Define the maximum number of retries for packet sends.
  32. //
  33. #define MAXIMUM_RETRIES 20
  34. //
  35. // Define packet waiting status codes.
  36. //
  37. #define BD_PACKET_RECEIVED 0
  38. #define BD_PACKET_TIMEOUT 1
  39. #define BD_PACKET_RESEND 2
  40. //
  41. // Define break point table entry structure.
  42. //
  43. #define BD_BREAKPOINT_IN_USE 0x1
  44. #define BD_BREAKPOINT_NEEDS_WRITE 0x2
  45. #define BD_BREAKPOINT_SUSPENDED 0x4
  46. #define BD_BREAKPOINT_NEEDS_REPLACE 0x8
  47. typedef struct _BREAKPOINT_ENTRY {
  48. ULONG Flags;
  49. ULONG64 Address;
  50. BD_BREAKPOINT_TYPE Content;
  51. } BREAKPOINT_ENTRY, *PBREAKPOINT_ENTRY;
  52. extern ULONG BdFileId;
  53. //
  54. // Define function prototypes.
  55. //
  56. LOGICAL
  57. BdPollBreakIn (
  58. VOID
  59. );
  60. VOID
  61. BdReboot (
  62. VOID
  63. );
  64. //
  65. // Breakpoint functions (break.c).
  66. //
  67. ULONG
  68. BdAddBreakpoint (
  69. IN ULONG64 Address
  70. );
  71. LOGICAL
  72. BdDeleteBreakpoint (
  73. IN ULONG Handle
  74. );
  75. LOGICAL
  76. BdDeleteBreakpointRange (
  77. IN ULONG64 Lower,
  78. IN ULONG64 Upper
  79. );
  80. VOID
  81. BdRestoreBreakpoint(
  82. IN PDBGKD_MANIPULATE_STATE64 m,
  83. IN PSTRING AdditionalData,
  84. IN PCONTEXT Context
  85. );
  86. VOID
  87. BdWriteBreakpoint(
  88. IN PDBGKD_MANIPULATE_STATE64 m,
  89. IN PSTRING AdditionalData,
  90. IN PCONTEXT Context
  91. );
  92. VOID
  93. BdSuspendBreakpoint (
  94. ULONG Handle
  95. );
  96. VOID
  97. BdSuspendAllBreakpoints (
  98. VOID
  99. );
  100. VOID
  101. BdRestoreAllBreakpoints (
  102. VOID
  103. );
  104. //
  105. // Memory check functions (check.c)
  106. //
  107. PVOID
  108. BdReadCheck (
  109. IN PVOID Address
  110. );
  111. PVOID
  112. BdWriteCheck (
  113. IN PVOID Address
  114. );
  115. PVOID
  116. BdTranslatePhysicalAddress (
  117. IN PHYSICAL_ADDRESS Address
  118. );
  119. //
  120. // Debugger initialization routine (port.c)
  121. //
  122. LOGICAL
  123. BdPortInitialize(
  124. IN ULONG BaudRate,
  125. IN ULONG PortNumber,
  126. OUT PULONG BdFileId
  127. );
  128. //
  129. // Communication functions (comio.c)
  130. //
  131. ULONG
  132. BdComputeChecksum (
  133. IN PUCHAR Buffer,
  134. IN ULONG Length
  135. );
  136. USHORT
  137. BdReceivePacketLeader (
  138. IN ULONG PacketType,
  139. OUT PULONG PacketLeader
  140. );
  141. VOID
  142. BdSendControlPacket (
  143. IN USHORT PacketType,
  144. IN ULONG PacketId OPTIONAL
  145. );
  146. ULONG
  147. BdReceivePacket (
  148. IN ULONG ExpectedPacketType,
  149. OUT PSTRING MessageHeader,
  150. OUT PSTRING MessageData,
  151. OUT PULONG DataLength
  152. );
  153. VOID
  154. BdSendPacket (
  155. IN ULONG PacketType,
  156. IN PSTRING MessageHeader,
  157. IN PSTRING MessageData OPTIONAL
  158. );
  159. ULONG
  160. BdReceiveString (
  161. OUT PCHAR Destination,
  162. IN ULONG Length
  163. );
  164. VOID
  165. BdSendString (
  166. IN PCHAR Source,
  167. IN ULONG Length
  168. );
  169. VOID
  170. BdSendControlPacket (
  171. IN USHORT PacketType,
  172. IN ULONG PacketId OPTIONAL
  173. );
  174. //
  175. // State change message functions (message.c)
  176. //
  177. LOGICAL
  178. BdReportExceptionStateChange (
  179. IN PEXCEPTION_RECORD ExceptionRecord,
  180. IN OUT PCONTEXT ContextRecord
  181. );
  182. LOGICAL
  183. BdReportLoadSymbolsStateChange (
  184. IN PSTRING PathName,
  185. IN PKD_SYMBOLS_INFO SymbolInfo,
  186. IN LOGICAL UnloadSymbols,
  187. IN OUT PCONTEXT ContextRecord
  188. );
  189. //
  190. // Platform independent debugger APIs (xxapi.c)
  191. //
  192. VOID
  193. BdGetVersion(
  194. IN PDBGKD_MANIPULATE_STATE64 m
  195. );
  196. VOID
  197. BdRestoreBreakPointEx(
  198. IN PDBGKD_MANIPULATE_STATE64 m,
  199. IN PSTRING AdditionalData,
  200. IN PCONTEXT Context
  201. );
  202. NTSTATUS
  203. BdWriteBreakPointEx(
  204. IN PDBGKD_MANIPULATE_STATE64 m,
  205. IN PSTRING AdditionalData,
  206. IN PCONTEXT Context
  207. );
  208. VOID
  209. BdReadPhysicalMemory(
  210. IN PDBGKD_MANIPULATE_STATE64 m,
  211. IN PSTRING AdditionalData,
  212. IN PCONTEXT Context
  213. );
  214. VOID
  215. BdWritePhysicalMemory(
  216. IN PDBGKD_MANIPULATE_STATE64 m,
  217. IN PSTRING AdditionalData,
  218. IN PCONTEXT Context
  219. );
  220. VOID
  221. BdReadVirtualMemory(
  222. IN PDBGKD_MANIPULATE_STATE64 m,
  223. IN PSTRING AdditionalData,
  224. IN PCONTEXT Context
  225. );
  226. VOID
  227. BdWriteVirtualMemory(
  228. IN PDBGKD_MANIPULATE_STATE64 m,
  229. IN PSTRING AdditionalData,
  230. IN PCONTEXT Context
  231. );
  232. VOID
  233. BdGetContext(
  234. IN PDBGKD_MANIPULATE_STATE64 m,
  235. IN PSTRING AdditionalData,
  236. IN PCONTEXT Context
  237. );
  238. VOID
  239. BdSetContext(
  240. IN PDBGKD_MANIPULATE_STATE64 m,
  241. IN PSTRING AdditionalData,
  242. IN PCONTEXT Context
  243. );
  244. //
  245. // Move memory functions (move.c)
  246. //
  247. ULONG
  248. BdMoveMemory (
  249. IN PCHAR Destination,
  250. IN PCHAR Source,
  251. IN ULONG Length
  252. );
  253. VOID
  254. BdCopyMemory (
  255. IN PCHAR Destination,
  256. IN PCHAR Source,
  257. IN ULONG Length
  258. );
  259. //
  260. // CPU specific interfaces (cpuapi.c)
  261. //
  262. VOID
  263. BdSetContextState (
  264. IN OUT PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange,
  265. IN PCONTEXT ContextRecord
  266. );
  267. VOID
  268. BdGetStateChange (
  269. IN PDBGKD_MANIPULATE_STATE64 ManipulateState,
  270. IN PCONTEXT ContextRecord
  271. );
  272. VOID
  273. BdSetStateChange (
  274. IN OUT PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange,
  275. IN PEXCEPTION_RECORD ExceptionRecord,
  276. IN PCONTEXT ContextRecord
  277. );
  278. VOID
  279. BdReadControlSpace (
  280. IN PDBGKD_MANIPULATE_STATE64 m,
  281. IN PSTRING AdditionalData,
  282. IN PCONTEXT Context
  283. );
  284. VOID
  285. BdWriteControlSpace (
  286. IN PDBGKD_MANIPULATE_STATE64 m,
  287. IN PSTRING AdditionalData,
  288. IN PCONTEXT Context
  289. );
  290. VOID
  291. BdReadIoSpace (
  292. IN PDBGKD_MANIPULATE_STATE64 m,
  293. IN PSTRING AdditionalData,
  294. IN PCONTEXT Context
  295. );
  296. VOID
  297. BdWriteIoSpace (
  298. IN PDBGKD_MANIPULATE_STATE64 m,
  299. IN PSTRING AdditionalData,
  300. IN PCONTEXT Context
  301. );
  302. VOID
  303. BdReadMachineSpecificRegister (
  304. IN PDBGKD_MANIPULATE_STATE64 m,
  305. IN PSTRING AdditionalData,
  306. IN PCONTEXT Context
  307. );
  308. VOID
  309. BdWriteMachineSpecificRegister (
  310. IN PDBGKD_MANIPULATE_STATE64 m,
  311. IN PSTRING AdditionalData,
  312. IN PCONTEXT Context
  313. );
  314. //
  315. // Print and prompt functions (dbgio.c)
  316. //
  317. VOID
  318. BdPrintf (
  319. IN PCHAR Format,
  320. ...
  321. );
  322. LOGICAL
  323. BdPrintString (
  324. IN PSTRING Output
  325. );
  326. LOGICAL
  327. BdPromptString (
  328. IN PSTRING Output,
  329. IN OUT PSTRING Input
  330. );
  331. //
  332. // Define external data.
  333. //
  334. extern BD_BREAKPOINT_TYPE BdBreakpointInstruction;
  335. extern BREAKPOINT_ENTRY BdBreakpointTable[];
  336. extern LOGICAL BdControlCPending;
  337. extern LOGICAL BdControlCPressed;
  338. extern LOGICAL BdDebuggerNotPresent;
  339. extern PBD_DEBUG_ROUTINE BdDebugRoutine;
  340. extern ULONGLONG BdMessageBuffer[];
  341. extern ULONG BdNextPacketIdToSend;
  342. extern ULONG BdNumberRetries;
  343. extern ULONG BdPacketIdExpected;
  344. extern KPRCB BdPrcb;
  345. extern ULONG BdRetryCount;
  346. extern ULONG NtBuildNumber;
  347. #endif