guid.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. static struct {
  29. EFI_GUID *Guid;
  30. WCHAR *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. { &UnknownDevice, L"Unknown Device"},
  63. { &EfiPartTypeSystemPartitionGuid, L"ESP"},
  64. { &EfiPartTypeLegacyMbrGuid, L"GPT MBR"},
  65. { &ShellInterfaceProtocol, L"ShellInt"},
  66. { &SEnvId, L"SEnv"},
  67. { &SProtId, L"ShellProtId"},
  68. { &SMapId, L"ShellDevPathMap"},
  69. { &SAliasId, L"ShellAlias"},
  70. { NULL }
  71. };
  72. //
  73. //
  74. //
  75. LIST_ENTRY GuidList;
  76. VOID
  77. InitializeGuid (
  78. VOID
  79. )
  80. {
  81. }
  82. INTN
  83. CompareGuid(
  84. IN EFI_GUID *Guid1,
  85. IN EFI_GUID *Guid2
  86. )
  87. /*++
  88. Routine Description:
  89. Compares to GUIDs
  90. Arguments:
  91. Guid1 - guid to compare
  92. Guid2 - guid to compare
  93. Returns:
  94. = 0 if Guid1 == Guid2
  95. --*/
  96. {
  97. return RtCompareGuid (Guid1, Guid2);
  98. }
  99. VOID
  100. GuidToString (
  101. OUT CHAR16 *Buffer,
  102. IN EFI_GUID *Guid
  103. )
  104. {
  105. UINTN Index;
  106. //
  107. // Else, (for now) use additional internal function for mapping guids
  108. //
  109. for (Index=0; KnownGuids[Index].Guid; Index++) {
  110. if (CompareGuid(Guid, KnownGuids[Index].Guid) == 0) {
  111. SPrint (Buffer, 0, KnownGuids[Index].GuidName);
  112. return ;
  113. }
  114. }
  115. //
  116. // Else dump it
  117. //
  118. SPrint (Buffer, 0, L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
  119. Guid->Data1,
  120. Guid->Data2,
  121. Guid->Data3,
  122. Guid->Data4[0],
  123. Guid->Data4[1],
  124. Guid->Data4[2],
  125. Guid->Data4[3],
  126. Guid->Data4[4],
  127. Guid->Data4[5],
  128. Guid->Data4[6],
  129. Guid->Data4[7]
  130. );
  131. }