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.

162 lines
3.9 KiB

  1. /*++
  2. Copyright (c) 1998 Intel Corporation
  3. Module Name:
  4. dmpstore.c
  5. Abstract:
  6. Shell app "dmpstore"
  7. Revision History
  8. --*/
  9. #include "shell.h"
  10. #define DEBUG_NAME_SIZE 1050
  11. static CHAR16 *AttrType[] = {
  12. L"invalid", /* 000 */
  13. L"invalid", /* 001 */
  14. L"BS", /* 010 */
  15. L"NV+BS", /* 011 */
  16. L"RT+BS", /* 100 */
  17. L"NV+RT+BS", /* 101 */
  18. L"RT+BS", /* 110 */
  19. L"NV+RT+BS", /* 111 */
  20. };
  21. /*
  22. *
  23. */
  24. EFI_STATUS
  25. InitializeDumpStore (
  26. IN EFI_HANDLE ImageHandle,
  27. IN EFI_SYSTEM_TABLE *SystemTable
  28. );
  29. VOID
  30. DumpVariableStore (
  31. VOID
  32. );
  33. /*
  34. *
  35. */
  36. EFI_DRIVER_ENTRY_POINT(InitializeDumpStore)
  37. EFI_STATUS
  38. InitializeDumpStore (
  39. IN EFI_HANDLE ImageHandle,
  40. IN EFI_SYSTEM_TABLE *SystemTable
  41. )
  42. {
  43. /*
  44. * Check to see if the app is to install as a "internal command"
  45. * to the shell
  46. */
  47. InstallInternalShellCommand (
  48. ImageHandle, SystemTable, InitializeDumpStore,
  49. L"dmpstore", /* command */
  50. L"dmpstore", /* command syntax */
  51. L"Dumps variable store", /* 1 line descriptor */
  52. NULL /* command help page */
  53. );
  54. /*
  55. * We are no being installed as an internal command driver, initialize
  56. * as an nshell app and run
  57. */
  58. InitializeShellApplication (ImageHandle, SystemTable);
  59. /*
  60. *
  61. */
  62. DumpVariableStore ();
  63. /*
  64. * Done
  65. */
  66. return EFI_SUCCESS;
  67. }
  68. VOID
  69. DumpVariableStore (
  70. VOID
  71. )
  72. {
  73. EFI_STATUS Status;
  74. EFI_GUID Guid;
  75. UINT32 Attributes;
  76. CHAR16 Name[DEBUG_NAME_SIZE/2];
  77. UINTN NameSize;
  78. CHAR16 Data[DEBUG_NAME_SIZE/2];
  79. UINTN DataSize;
  80. UINTN ScreenCount;
  81. UINTN TempColumn;
  82. UINTN ScreenSize;
  83. UINTN ItemScreenSize;
  84. CHAR16 ReturnStr[80];
  85. ST->ConOut->QueryMode (ST->ConOut, ST->ConOut->Mode->Mode, &TempColumn, &ScreenSize);
  86. ST->ConOut->ClearScreen (ST->ConOut);
  87. ScreenCount = 1;
  88. ScreenSize -= 2;
  89. Print(L"Dump NVRAM\n");
  90. Name[0] = 0x0000;
  91. do {
  92. NameSize = DEBUG_NAME_SIZE;
  93. Status = RT->GetNextVariableName(&NameSize, Name, &Guid);
  94. if ( Status == EFI_SUCCESS) {
  95. DataSize = DEBUG_NAME_SIZE;
  96. Status = RT->GetVariable(Name, &Guid, &Attributes, &DataSize, Data);
  97. if ( Status == EFI_SUCCESS) {
  98. /*
  99. * Account for Print() and DumpHex()
  100. */
  101. ItemScreenSize = 1 + DataSize/0x10 + (((DataSize % 0x10) == 0) ? 0 : 1);
  102. ScreenCount += ItemScreenSize;
  103. if ((ScreenCount >= ScreenSize) && ScreenSize != 0) {
  104. /*
  105. * If ScreenSize == 0 we have the console redirected so don't
  106. * block updates
  107. */
  108. Print (L"Press Return to contiue :");
  109. Input (L"", ReturnStr, sizeof(ReturnStr)/sizeof(CHAR16));
  110. TempColumn = ST->ConOut->Mode->CursorColumn;
  111. if (TempColumn) {
  112. Print (L"\r%*a\r", TempColumn, "");
  113. }
  114. ScreenCount = ItemScreenSize;
  115. }
  116. /* dump for... */
  117. Print (L"Variable %hs '%hg:%hs' DataSize = %x\n",
  118. AttrType[Attributes & 7],
  119. &Guid,
  120. Name,
  121. DataSize
  122. );
  123. DumpHex (2, 0, DataSize, Data);
  124. }
  125. }
  126. } while (Status == EFI_SUCCESS);
  127. }