kexts.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*++
  2. Copyright (c) 2012 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. kexts.c
  5. Abstract:
  6. This module implements kernel debugger extensions.
  7. Author:
  8. Evan Green 10-Sep-2012
  9. Environment:
  10. Debug Client
  11. --*/
  12. //
  13. // ------------------------------------------------------------------- Includes
  14. //
  15. #include <minoca/lib/types.h>
  16. #include <minoca/lib/status.h>
  17. #include <minoca/lib/rtl.h>
  18. #include <minoca/debug/dbgext.h>
  19. #include "memory.h"
  20. #include "objects.h"
  21. #include "threads.h"
  22. #include "acpiext.h"
  23. #include "reslist.h"
  24. #include <assert.h>
  25. #include <errno.h>
  26. #include <stdio.h>
  27. //
  28. // ---------------------------------------------------------------- Definitions
  29. //
  30. //
  31. // ------------------------------------------------------ Data Type Definitions
  32. //
  33. //
  34. // ----------------------------------------------- Internal Function Prototypes
  35. //
  36. //
  37. // -------------------------------------------------------------------- Globals
  38. //
  39. //
  40. // ------------------------------------------------------------------ Functions
  41. //
  42. INT
  43. ExtensionMain (
  44. PDEBUGGER_CONTEXT Context,
  45. ULONG ExtensionApiVersion,
  46. PVOID Token
  47. )
  48. /*++
  49. Routine Description:
  50. This routine defines the extension's main routine. This routine will get
  51. called when the extension is loaded. It is responsible for registering the
  52. debugger extensions it supports.
  53. Arguments:
  54. Context - Supplies the application instance context. This must be passed
  55. into the registration routines.
  56. ExtensionApiVersion - Supplies the revision of the debugger extension API.
  57. Token - Supplies a token that uniquely idenfies the extension. This is used
  58. when registering extensions.
  59. Return Value:
  60. 0 on success.
  61. Returns an error code on failure. The extension will be unloaded if it
  62. returns non-zero.
  63. --*/
  64. {
  65. PSTR Extension;
  66. PSTR OneLineDescription;
  67. INT Status;
  68. INT TotalStatus;
  69. TotalStatus = 0;
  70. Extension = "mdl";
  71. OneLineDescription = "Print the contents of a Memory Descriptor List.";
  72. Status = DbgRegisterExtension(Context,
  73. Token,
  74. Extension,
  75. OneLineDescription,
  76. ExtMdl);
  77. if (Status != 0) {
  78. DbgOut("Error: Unable to register %s.\n", Extension);
  79. TotalStatus = Status;
  80. }
  81. Extension = "object";
  82. OneLineDescription = "Print the contents of a kernel Object.";
  83. Status = DbgRegisterExtension(Context,
  84. Token,
  85. Extension,
  86. OneLineDescription,
  87. ExtObject);
  88. if (Status != 0) {
  89. DbgOut("Error: Unable to register %s.\n", Extension);
  90. TotalStatus = Status;
  91. }
  92. Extension = "thread";
  93. OneLineDescription = "Prints the contents of a thread object.";
  94. Status = DbgRegisterExtension(Context,
  95. Token,
  96. Extension,
  97. OneLineDescription,
  98. ExtThread);
  99. if (Status != 0) {
  100. DbgOut("Error: Unable to register %s.\n", Extension);
  101. TotalStatus = Status;
  102. }
  103. Extension = "acpi";
  104. OneLineDescription = "Provides help debugging ACPI issues.";
  105. Status = DbgRegisterExtension(Context,
  106. Token,
  107. Extension,
  108. OneLineDescription,
  109. ExtAcpi);
  110. if (Status != 0) {
  111. DbgOut("Error: Unable to register %s.\n", Extension);
  112. TotalStatus = Status;
  113. }
  114. Extension = "res";
  115. OneLineDescription = "Prints resource allocations, requirements, and "
  116. "lists.";
  117. Status = DbgRegisterExtension(Context,
  118. Token,
  119. Extension,
  120. OneLineDescription,
  121. ExtResource);
  122. if (Status != 0) {
  123. DbgOut("Error: Unable to register %s.\n", Extension);
  124. TotalStatus = Status;
  125. }
  126. return TotalStatus;
  127. }
  128. //
  129. // --------------------------------------------------------- Internal Functions
  130. //