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.

173 lines
4.1 KiB

  1. /*++
  2. Copyright (c) 1998 Intel Corporation
  3. Module Name:
  4. misc.c
  5. Abstract:
  6. Misc EFI support functions
  7. Revision History
  8. --*/
  9. #include "lib.h"
  10. /*
  11. * Additional Known guids
  12. */
  13. #define SHELL_INTERFACE_PROTOCOL \
  14. { 0x47c7b223, 0xc42a, 0x11d2, 0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b }
  15. #define ENVIRONMENT_VARIABLE_ID \
  16. { 0x47c7b224, 0xc42a, 0x11d2, 0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b }
  17. #define DEVICE_PATH_MAPPING_ID \
  18. { 0x47c7b225, 0xc42a, 0x11d2, 0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b }
  19. #define PROTOCOL_ID_ID \
  20. { 0x47c7b226, 0xc42a, 0x11d2, 0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b }
  21. #define ALIAS_ID \
  22. { 0x47c7b227, 0xc42a, 0x11d2, 0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b }
  23. static EFI_GUID ShellInterfaceProtocol = SHELL_INTERFACE_PROTOCOL;
  24. static EFI_GUID SEnvId = ENVIRONMENT_VARIABLE_ID;
  25. static EFI_GUID SMapId = DEVICE_PATH_MAPPING_ID;
  26. static EFI_GUID SProtId = PROTOCOL_ID_ID;
  27. static EFI_GUID SAliasId = ALIAS_ID;
  28. struct {
  29. EFI_GUID *Guid;
  30. CHAR16 *GuidName;
  31. } KnownGuids[] = {
  32. &NullGuid, L"G0",
  33. &EfiGlobalVariable, L"Efi",
  34. &VariableStoreProtocol, L"varstore",
  35. &DevicePathProtocol, L"dpath",
  36. &LoadedImageProtocol, L"image",
  37. &TextInProtocol, L"txtin",
  38. &TextOutProtocol, L"txtout",
  39. &BlockIoProtocol, L"blkio",
  40. &DiskIoProtocol, L"diskio",
  41. &FileSystemProtocol, L"fs",
  42. &LoadFileProtocol, L"load",
  43. &DeviceIoProtocol, L"DevIo",
  44. &GenericFileInfo, L"GenFileInfo",
  45. &FileSystemInfo, L"FileSysInfo",
  46. &UnicodeCollationProtocol, L"unicode",
  47. &LegacyBootProtocol, L"LegacyBoot",
  48. &SerialIoProtocol, L"serialio",
  49. &VgaClassProtocol, L"vgaclass",
  50. &SimpleNetworkProtocol, L"net",
  51. &NetworkInterfaceIdentifierProtocol, L"nii",
  52. &PxeBaseCodeProtocol, L"pxebc",
  53. &PxeCallbackProtocol, L"pxecb",
  54. &VariableStoreProtocol, L"varstore",
  55. &LegacyBootProtocol, L"LegacyBoot",
  56. &VgaClassProtocol, L"VgaClass",
  57. &TextOutSpliterProtocol, L"TxtOutSplit",
  58. &ErrorOutSpliterProtocol, L"ErrOutSplit",
  59. &TextInSpliterProtocol, L"TxtInSplit",
  60. &PcAnsiProtocol, L"PcAnsi",
  61. &Vt100Protocol, L"Vt100",
  62. &InternalLoadProtocol, L"InternalLoad",
  63. &UnknownDevice, L"Unknown Device",
  64. &ShellInterfaceProtocol, L"ShellInt",
  65. &SEnvId, L"SEnv",
  66. &SProtId, L"ShellProtId",
  67. &SMapId, L"ShellDevPathMap",
  68. &SAliasId, L"ShellAlias",
  69. NULL
  70. };
  71. /*
  72. *
  73. */
  74. LIST_ENTRY GuidList;
  75. VOID
  76. InitializeGuid (
  77. VOID
  78. )
  79. {
  80. }
  81. INTN
  82. CompareGuid(
  83. IN EFI_GUID *Guid1,
  84. IN EFI_GUID *Guid2
  85. )
  86. /*++
  87. Routine Description:
  88. Compares to GUIDs
  89. Arguments:
  90. Guid1 - guid to compare
  91. Guid2 - guid to compare
  92. Returns:
  93. = 0 if Guid1 == Guid2
  94. --*/
  95. {
  96. return RtCompareGuid (Guid1, Guid2);
  97. }
  98. VOID
  99. GuidToString (
  100. OUT CHAR16 *Buffer,
  101. IN EFI_GUID *Guid
  102. )
  103. {
  104. UINTN Index;
  105. /*
  106. * Else, (for now) use additional internal function for mapping guids
  107. */
  108. for (Index=0; KnownGuids[Index].Guid; Index++) {
  109. if (CompareGuid(Guid, KnownGuids[Index].Guid) == 0) {
  110. SPrint (Buffer, 0, KnownGuids[Index].GuidName);
  111. return ;
  112. }
  113. }
  114. /*
  115. * Else dump it
  116. */
  117. SPrint (Buffer, 0, L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
  118. Guid->Data1,
  119. Guid->Data2,
  120. Guid->Data3,
  121. Guid->Data4[0],
  122. Guid->Data4[1],
  123. Guid->Data4[2],
  124. Guid->Data4[3],
  125. Guid->Data4[4],
  126. Guid->Data4[5],
  127. Guid->Data4[6],
  128. Guid->Data4[7]
  129. );
  130. }