Source code of Windows XP (NT5)
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.

248 lines
4.0 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. USB.c
  5. Abstract:
  6. WinDbg Extension Api
  7. Author:
  8. Kenneth D. Ray (kenray) June 1997
  9. Environment:
  10. User Mode.
  11. Revision History:
  12. --*/
  13. #include "precomp.h"
  14. typedef union _USB_FLAGS {
  15. struct {
  16. ULONG FullListing : 1;
  17. ULONG Reserved : 31;
  18. };
  19. ULONG Flags;
  20. } USB_FLAGS;
  21. #define PRINT_FLAGS(value, flag) \
  22. if ((value) & (flag)) { \
  23. dprintf (#flag " "); \
  24. }
  25. #define DESC_MAXTOKENS 3
  26. #define DESC_MAXBUFFER 80
  27. #define DESC_USAGE() { UsbStrucUsage(); return E_INVALIDARG; }
  28. extern
  29. ULONG
  30. TokenizeString(
  31. PUCHAR Input,
  32. PUCHAR *Output,
  33. ULONG Max
  34. );
  35. extern
  36. VOID
  37. OhciHcdTd (
  38. ULONG64 MemLoc
  39. );
  40. extern
  41. VOID
  42. OhciHcdEd (
  43. ULONG64 MemLoc
  44. );
  45. extern
  46. VOID
  47. OhciEndpoint (
  48. ULONG64 MemLoc
  49. );
  50. extern
  51. VOID
  52. OhciHCRegisters(
  53. ULONG64 MemLoc
  54. );
  55. extern
  56. VOID
  57. OhciHCCA(
  58. ULONG64 MemLoc
  59. );
  60. extern
  61. VOID
  62. OhciHcEd(
  63. ULONG64 MemLoc
  64. );
  65. extern
  66. VOID
  67. OhciHcTd(
  68. ULONG64 MemLoc
  69. );
  70. VOID
  71. UHCD_HCRegisters(
  72. ULONG64 MemLoc
  73. );
  74. extern
  75. VOID
  76. USBD_DeviceHandle(
  77. ULONG64 MemLoc
  78. );
  79. VOID
  80. UsbStrucUsage ()
  81. {
  82. dprintf("!UsbStruc <address> <type>\n");
  83. dprintf(" <address> - address of a structure to be dumped\n");
  84. dprintf(" <type> - {OHCIReg | HCCA | OHCIHcdED | OHCIHcdTD |\n"
  85. " OHCIEndpoint | DevData | UHCDReg }\n");
  86. dprintf("\n");
  87. }
  88. DECLARE_API ( usbstruc )
  89. {
  90. ULONG64 Desc = 0;
  91. PUCHAR Tokens[DESC_MAXTOKENS];
  92. UCHAR Buffer[DESC_MAXBUFFER];
  93. PUCHAR s;
  94. UCHAR c;
  95. ULONG count;
  96. //
  97. // Validate parameters. Tokenize the incoming string, the first
  98. // argument should be a (kernel mode) address, the second a string.
  99. //
  100. //
  101. // args is const, we need to modify the buffer, copy it.
  102. //
  103. for (count = 0; count < DESC_MAXBUFFER; count++) {
  104. if ((Buffer[count] = args[count]) == '\0') {
  105. break;
  106. }
  107. }
  108. if (count == DESC_MAXBUFFER) {
  109. dprintf("Buffer to small to contain input arguments\n");
  110. DESC_USAGE();
  111. }
  112. if (TokenizeString(Buffer, Tokens, DESC_MAXTOKENS) !=
  113. (DESC_MAXTOKENS - 1)) {
  114. DESC_USAGE();
  115. }
  116. if ((Desc = GetExpression(Tokens[0])) == 0) {
  117. DESC_USAGE();
  118. }
  119. //
  120. // The second argument should be a string telling us what kind of
  121. // device extension to dump. Convert it to upper case to make life
  122. // easier.
  123. //
  124. s = Tokens[1];
  125. while ((c = *s) != '\0') {
  126. *s++ = (UCHAR)toupper(c);
  127. }
  128. s = Tokens[1];
  129. if (!strcmp(s, "OHCIHCDED")) {
  130. //
  131. // It's an OpenHCI Hcd Endpoint Descriptor
  132. //
  133. OhciHcdEd (Desc);
  134. } else if (!strcmp(s, "OHCIHCDTD")) {
  135. //
  136. // It's an OpenHCI Hcd Transfer Descriptor
  137. //
  138. OhciHcdTd (Desc);
  139. } else if (!strcmp(s, "OHCIENDPOINT")) {
  140. //
  141. // It's an OpenHCI Hcd Endpoint Descriptor
  142. //
  143. OhciEndpoint(Desc);
  144. } else if (!strcmp(s, "OHCIREG")) {
  145. //
  146. // It's the OpenHCI Registers
  147. //
  148. OhciHCRegisters(Desc);
  149. } else if (!strcmp(s, "HCCA")) {
  150. //
  151. // It's the OpenHCI HCCA
  152. //
  153. OhciHCCA(Desc);
  154. } else if (!strcmp(s, "OHCIHCED")) {
  155. //
  156. // It's the OpenHCI HcED
  157. //
  158. OhciHcEd(Desc);
  159. } else if (!strcmp(s, "OHCIHCTD")) {
  160. //
  161. // It's the OpenHCI HcTD
  162. //
  163. OhciHcTd(Desc);
  164. } else if (!strcmp(s, "DEVDATA")) {
  165. //
  166. // It's the USBD_DEVICE_DATA
  167. //
  168. USBD_DeviceHandle(Desc);
  169. } else if (!strcmp(s, "UHCDREG")) {
  170. //
  171. // It's the UHCD_Registers
  172. //
  173. // UHCD_HCRegisters(Desc);
  174. #if 0
  175. } else if (!strcmp(s, "SOME_OTHER_DESCRIPTOR_TYPE")) {
  176. //
  177. // It's some other extension type.
  178. //
  179. UsbStruc (Extension);
  180. #endif
  181. } else {
  182. dprintf("Structure type '%s' is not handled by !usbStruc.\n", s);
  183. }
  184. return S_OK;
  185. }