Home | History | Annotate | Line # | Download | only in lib
guid.c revision 1.1.1.1.36.1
      1  1.1.1.1.36.1  christos /*	$NetBSD: guid.c,v 1.1.1.1.36.1 2019/06/10 22:08:36 christos Exp $	*/
      2           1.1  jakllsch 
      3           1.1  jakllsch /*++
      4           1.1  jakllsch 
      5           1.1  jakllsch Copyright (c) 1998  Intel Corporation
      6           1.1  jakllsch 
      7           1.1  jakllsch Module Name:
      8           1.1  jakllsch 
      9           1.1  jakllsch     misc.c
     10           1.1  jakllsch 
     11           1.1  jakllsch Abstract:
     12           1.1  jakllsch 
     13           1.1  jakllsch     Misc EFI support functions
     14           1.1  jakllsch 
     15           1.1  jakllsch 
     16           1.1  jakllsch 
     17           1.1  jakllsch Revision History
     18           1.1  jakllsch 
     19           1.1  jakllsch --*/
     20           1.1  jakllsch 
     21           1.1  jakllsch #include "lib.h"
     22           1.1  jakllsch 
     23           1.1  jakllsch 
     24           1.1  jakllsch //
     25           1.1  jakllsch // Additional Known guids
     26           1.1  jakllsch //
     27           1.1  jakllsch 
     28           1.1  jakllsch #define SHELL_INTERFACE_PROTOCOL \
     29           1.1  jakllsch     { 0x47c7b223, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
     30           1.1  jakllsch 
     31           1.1  jakllsch #define ENVIRONMENT_VARIABLE_ID  \
     32           1.1  jakllsch     { 0x47c7b224, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
     33           1.1  jakllsch 
     34           1.1  jakllsch #define DEVICE_PATH_MAPPING_ID  \
     35           1.1  jakllsch     { 0x47c7b225, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
     36           1.1  jakllsch 
     37           1.1  jakllsch #define PROTOCOL_ID_ID  \
     38           1.1  jakllsch     { 0x47c7b226, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
     39           1.1  jakllsch 
     40           1.1  jakllsch #define ALIAS_ID  \
     41           1.1  jakllsch     { 0x47c7b227, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
     42           1.1  jakllsch 
     43           1.1  jakllsch static EFI_GUID ShellInterfaceProtocol = SHELL_INTERFACE_PROTOCOL;
     44           1.1  jakllsch static EFI_GUID SEnvId                 = ENVIRONMENT_VARIABLE_ID;
     45           1.1  jakllsch static EFI_GUID SMapId                 = DEVICE_PATH_MAPPING_ID;
     46           1.1  jakllsch static EFI_GUID SProtId                = PROTOCOL_ID_ID;
     47           1.1  jakllsch static EFI_GUID SAliasId               = ALIAS_ID;
     48           1.1  jakllsch 
     49           1.1  jakllsch static struct {
     50           1.1  jakllsch     EFI_GUID        *Guid;
     51           1.1  jakllsch     WCHAR           *GuidName;
     52           1.1  jakllsch } KnownGuids[] = {
     53  1.1.1.1.36.1  christos 	{  &NullGuid,                                       L"G0" },
     54  1.1.1.1.36.1  christos 	{  &gEfiGlobalVariableGuid,                         L"EfiVar" },
     55           1.1  jakllsch 
     56  1.1.1.1.36.1  christos 	{  &VariableStoreProtocol,                          L"VarStore" },
     57  1.1.1.1.36.1  christos 	{  &gEfiDevicePathProtocolGuid,                     L"DevPath" },
     58  1.1.1.1.36.1  christos 	{  &gEfiLoadedImageProtocolGuid,                    L"LdImg" },
     59  1.1.1.1.36.1  christos 	{  &gEfiSimpleTextInProtocolGuid,                   L"TxtIn" },
     60  1.1.1.1.36.1  christos 	{  &gEfiSimpleTextOutProtocolGuid,                  L"TxtOut" },
     61  1.1.1.1.36.1  christos 	{  &gEfiBlockIoProtocolGuid,                        L"BlkIo" },
     62  1.1.1.1.36.1  christos 	{  &gEfiBlockIo2ProtocolGuid,                       L"BlkIo2" },
     63  1.1.1.1.36.1  christos 	{  &gEfiDiskIoProtocolGuid,                         L"DskIo" },
     64  1.1.1.1.36.1  christos 	{  &gEfiDiskIo2ProtocolGuid,                        L"DskIo2" },
     65  1.1.1.1.36.1  christos 	{  &gEfiSimpleFileSystemProtocolGuid,               L"Fs" },
     66  1.1.1.1.36.1  christos 	{  &gEfiLoadFileProtocolGuid,                       L"LdFile" },
     67  1.1.1.1.36.1  christos 	{  &gEfiDeviceIoProtocolGuid,                       L"DevIo" },
     68  1.1.1.1.36.1  christos 	{  &gEfiComponentNameProtocolGuid,                  L"CName" },
     69  1.1.1.1.36.1  christos 	{  &gEfiComponentName2ProtocolGuid,                 L"CName2" },
     70  1.1.1.1.36.1  christos 
     71  1.1.1.1.36.1  christos 	{  &gEfiFileInfoGuid,                               L"FileInfo" },
     72  1.1.1.1.36.1  christos 	{  &gEfiFileSystemInfoGuid,                         L"FsInfo" },
     73  1.1.1.1.36.1  christos 	{  &gEfiFileSystemVolumeLabelInfoIdGuid,            L"FsVolInfo" },
     74  1.1.1.1.36.1  christos 
     75  1.1.1.1.36.1  christos 	{  &gEfiUnicodeCollationProtocolGuid,               L"Unicode" },
     76  1.1.1.1.36.1  christos 	{  &LegacyBootProtocol,                             L"LegacyBoot" },
     77  1.1.1.1.36.1  christos 	{  &gEfiSerialIoProtocolGuid,                       L"SerIo" },
     78  1.1.1.1.36.1  christos 	{  &VgaClassProtocol,                               L"VgaClass"},
     79  1.1.1.1.36.1  christos 	{  &gEfiSimpleNetworkProtocolGuid,                  L"Net" },
     80  1.1.1.1.36.1  christos 	{  &gEfiNetworkInterfaceIdentifierProtocolGuid,     L"Nii" },
     81  1.1.1.1.36.1  christos 	{  &gEfiPxeBaseCodeProtocolGuid,                    L"Pxe" },
     82  1.1.1.1.36.1  christos 	{  &gEfiPxeBaseCodeCallbackProtocolGuid,            L"PxeCb" },
     83  1.1.1.1.36.1  christos 
     84  1.1.1.1.36.1  christos 	{  &TextOutSpliterProtocol,                         L"TxtOutSplit" },
     85  1.1.1.1.36.1  christos 	{  &ErrorOutSpliterProtocol,                        L"ErrOutSplit" },
     86  1.1.1.1.36.1  christos 	{  &TextInSpliterProtocol,                          L"TxtInSplit" },
     87  1.1.1.1.36.1  christos 	{  &gEfiPcAnsiGuid,                                 L"PcAnsi" },
     88  1.1.1.1.36.1  christos 	{  &gEfiVT100Guid,                                  L"Vt100" },
     89  1.1.1.1.36.1  christos 	{  &gEfiVT100PlusGuid,                              L"Vt100Plus" },
     90  1.1.1.1.36.1  christos 	{  &gEfiVTUTF8Guid,                                 L"VtUtf8" },
     91  1.1.1.1.36.1  christos 	{  &UnknownDevice,                                  L"UnknownDev" },
     92  1.1.1.1.36.1  christos 
     93  1.1.1.1.36.1  christos 	{  &EfiPartTypeSystemPartitionGuid,                 L"ESP" },
     94  1.1.1.1.36.1  christos 	{  &EfiPartTypeLegacyMbrGuid,                       L"GPT MBR" },
     95  1.1.1.1.36.1  christos 
     96  1.1.1.1.36.1  christos 	{  &ShellInterfaceProtocol,                         L"ShellInt" },
     97  1.1.1.1.36.1  christos 	{  &SEnvId,                                         L"SEnv" },
     98  1.1.1.1.36.1  christos 	{  &SProtId,                                        L"ShellProtId" },
     99  1.1.1.1.36.1  christos 	{  &SMapId,                                         L"ShellDevPathMap" },
    100  1.1.1.1.36.1  christos 	{  &SAliasId,                                       L"ShellAlias" },
    101           1.1  jakllsch 
    102  1.1.1.1.36.1  christos 	{  NULL, L"" }
    103           1.1  jakllsch };
    104           1.1  jakllsch 
    105           1.1  jakllsch //
    106           1.1  jakllsch //
    107           1.1  jakllsch //
    108           1.1  jakllsch 
    109           1.1  jakllsch LIST_ENTRY          GuidList;
    110           1.1  jakllsch 
    111           1.1  jakllsch 
    112           1.1  jakllsch VOID
    113           1.1  jakllsch InitializeGuid (
    114           1.1  jakllsch     VOID
    115           1.1  jakllsch     )
    116           1.1  jakllsch {
    117           1.1  jakllsch }
    118           1.1  jakllsch 
    119           1.1  jakllsch INTN
    120           1.1  jakllsch CompareGuid(
    121           1.1  jakllsch     IN EFI_GUID     *Guid1,
    122           1.1  jakllsch     IN EFI_GUID     *Guid2
    123           1.1  jakllsch     )
    124           1.1  jakllsch /*++
    125           1.1  jakllsch 
    126           1.1  jakllsch Routine Description:
    127           1.1  jakllsch 
    128           1.1  jakllsch     Compares to GUIDs
    129           1.1  jakllsch 
    130           1.1  jakllsch Arguments:
    131           1.1  jakllsch 
    132           1.1  jakllsch     Guid1       - guid to compare
    133           1.1  jakllsch     Guid2       - guid to compare
    134           1.1  jakllsch 
    135           1.1  jakllsch Returns:
    136           1.1  jakllsch     = 0     if Guid1 == Guid2
    137           1.1  jakllsch 
    138           1.1  jakllsch --*/
    139           1.1  jakllsch {
    140           1.1  jakllsch     return RtCompareGuid (Guid1, Guid2);
    141           1.1  jakllsch }
    142           1.1  jakllsch 
    143           1.1  jakllsch 
    144           1.1  jakllsch VOID
    145           1.1  jakllsch GuidToString (
    146           1.1  jakllsch     OUT CHAR16      *Buffer,
    147           1.1  jakllsch     IN EFI_GUID     *Guid
    148           1.1  jakllsch     )
    149           1.1  jakllsch {
    150           1.1  jakllsch 
    151           1.1  jakllsch     UINTN           Index;
    152           1.1  jakllsch 
    153           1.1  jakllsch     //
    154           1.1  jakllsch     // Else, (for now) use additional internal function for mapping guids
    155           1.1  jakllsch     //
    156           1.1  jakllsch 
    157           1.1  jakllsch     for (Index=0; KnownGuids[Index].Guid; Index++) {
    158           1.1  jakllsch         if (CompareGuid(Guid, KnownGuids[Index].Guid) == 0) {
    159           1.1  jakllsch             SPrint (Buffer, 0, KnownGuids[Index].GuidName);
    160           1.1  jakllsch             return ;
    161           1.1  jakllsch         }
    162           1.1  jakllsch     }
    163           1.1  jakllsch 
    164           1.1  jakllsch     //
    165           1.1  jakllsch     // Else dump it
    166           1.1  jakllsch     //
    167           1.1  jakllsch 
    168           1.1  jakllsch     SPrint (Buffer, 0, L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
    169  1.1.1.1.36.1  christos         Guid->Data1,
    170           1.1  jakllsch         Guid->Data2,
    171           1.1  jakllsch         Guid->Data3,
    172           1.1  jakllsch         Guid->Data4[0],
    173           1.1  jakllsch         Guid->Data4[1],
    174           1.1  jakllsch         Guid->Data4[2],
    175           1.1  jakllsch         Guid->Data4[3],
    176           1.1  jakllsch         Guid->Data4[4],
    177           1.1  jakllsch         Guid->Data4[5],
    178           1.1  jakllsch         Guid->Data4[6],
    179           1.1  jakllsch         Guid->Data4[7]
    180           1.1  jakllsch         );
    181           1.1  jakllsch }
    182