├── LICENSE ├── MyApps ├── Beep │ ├── Beep.c │ ├── Beep.efi │ └── Beep.inf ├── BootFWUI │ ├── BootFWUI.c │ ├── BootFWUI.efi │ ├── BootFWUI.inf │ └── ShowMSDM.c ├── Cpuid │ ├── Cpuid.c │ ├── Cpuid.efi │ └── Cpuid.inf ├── DisplayBMP │ ├── DisplayBMP.c │ ├── DisplayBMP.efi │ ├── DisplayBMP.inf │ └── Logo.bmp ├── GenTPM12RN │ ├── GenTPM12RN.c │ ├── GenTPM12RN.efi │ └── GenTPM12RN.inf ├── GraphicModes │ ├── ConsoleControl.h │ ├── GraphicModes.c │ ├── GraphicModes.efi │ └── GraphicModes.inf ├── ListACPI │ ├── ListACPI.c │ ├── ListACPI.efi │ └── ListACPI.inf ├── ListCerts │ ├── ListCerts.c │ ├── ListCerts.efi │ ├── ListCerts.inf │ ├── README │ ├── asn1.h │ ├── asn1_ber_bytecode.h │ ├── asn1_ber_decoder.c │ ├── asn1_ber_decoder.h │ ├── oid_registry.c │ ├── oid_registry.h │ ├── oid_registry_data.h │ ├── x509.c │ └── x509.h ├── MyApps.dec ├── MyApps.dsc ├── ShowBGRT │ ├── ShowBGRT.c │ ├── ShowBGRT.efi │ └── ShowBGRT.inf ├── ShowEDID │ ├── ShowEDID.c │ ├── ShowEDID.efi │ └── ShowEDID.inf ├── ShowESRT │ ├── ShowESRT.c │ ├── ShowESRT.efi │ └── ShowESRT.inf ├── ShowFACS │ ├── ShowFACS.c │ ├── ShowFACS.efi │ └── ShowFACS.inf ├── ShowHII │ ├── ShowHII.c │ ├── ShowHII.efi │ └── ShowHII.inf ├── ShowMSDM │ ├── ShowMSDM.c │ ├── ShowMSDM.efi │ └── ShowMSDM.inf ├── ShowOsIndications │ ├── ShowOsIndications.c │ ├── ShowOsIndications.efi │ └── ShowOsIndications.inf ├── ShowPCI │ ├── ShowPCI.c │ ├── ShowPCI.efi │ └── ShowPCI.inf ├── ShowPCIx │ ├── ShowPCIx.c │ ├── ShowPCIx.efi │ ├── ShowPCIx.inf │ └── pci.ids ├── ShowPCR12 │ ├── ShowPCR12.c │ ├── ShowPCR12.efi │ └── ShowPCR12.inf ├── ShowPCR20 │ ├── ShowPCR20.c │ ├── ShowPCR20.efi │ └── ShowPCR20.inf ├── ShowQVI │ ├── ShowQVI.c │ ├── ShowQVI.efi │ └── ShowQVI.inf ├── ShowSLIC │ ├── ShowSLIC.c │ ├── ShowSLIC.efi │ └── ShowSLIC.inf ├── ShowTCM20 │ ├── ShowTCM20.c │ ├── ShowTCM20.efi │ └── ShowTCM20.inf ├── ShowTPM2 │ ├── ShowTPM2.c │ ├── ShowTPM2.efi │ └── ShowTPM2.inf ├── ShowTrEE │ ├── ShowTrEE.c │ ├── ShowTrEE.efi │ └── ShowTrEE.inf ├── ShowTrEELog │ ├── ShowTrEELog.c │ ├── ShowTrEELog.efi │ └── ShowTrEELog.inf └── XBeep │ ├── XBeep.c │ ├── XBeep.efi │ └── XBeep.inf └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009-2018, Finnbarr P. Murphy 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /MyApps/Beep/Beep.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2018 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Beep 1 or more times. 5 | // 6 | // License: BSD License 7 | // 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | // Piezo Speaker Related 24 | #define EFI_SPEAKER_CONTROL_PORT 0x61 25 | #define EFI_SPEAKER_OFF_MASK 0xFC 26 | #define EFI_BEEP_ON_TIME_INTERVAL 0x50000 27 | #define EFI_BEEP_OFF_TIME_INTERVAL 0x50000 28 | 29 | #define UTILITY_VERSION L"20180225" 30 | #undef DEBUG 31 | 32 | 33 | BOOLEAN 34 | IsNumber( CHAR16* str ) 35 | { 36 | CHAR16 *s = str; 37 | 38 | // allow negative 39 | if (*s == L'-') 40 | s++; 41 | 42 | while (*s) { 43 | if (*s < L'0' || *s > L'9') 44 | return FALSE; 45 | s++; 46 | } 47 | 48 | return TRUE; 49 | } 50 | 51 | 52 | EFI_STATUS 53 | TurnOnSpeaker( VOID ) 54 | { 55 | UINT8 Data; 56 | 57 | Data = IoRead8( EFI_SPEAKER_CONTROL_PORT ); 58 | Data |= 0x03; 59 | IoWrite8( EFI_SPEAKER_CONTROL_PORT, Data) ; 60 | 61 | return EFI_SUCCESS; 62 | } 63 | 64 | 65 | EFI_STATUS 66 | TurnOffSpeaker( VOID ) 67 | { 68 | UINT8 Data; 69 | 70 | Data = IoRead8( EFI_SPEAKER_CONTROL_PORT ); 71 | Data &= EFI_SPEAKER_OFF_MASK; 72 | IoWrite8( EFI_SPEAKER_CONTROL_PORT, Data ); 73 | 74 | return EFI_SUCCESS; 75 | } 76 | 77 | 78 | EFI_STATUS 79 | GenerateBeep( UINTN NumberBeeps ) 80 | { 81 | for ( UINTN Num=0; Num < NumberBeeps; Num++ ) { 82 | TurnOnSpeaker(); 83 | gBS->Stall( EFI_BEEP_ON_TIME_INTERVAL ); 84 | TurnOffSpeaker(); 85 | gBS->Stall( EFI_BEEP_OFF_TIME_INTERVAL ); 86 | } 87 | 88 | return EFI_SUCCESS; 89 | } 90 | 91 | 92 | VOID 93 | Usage( BOOLEAN ErrorMsg ) 94 | { 95 | if ( ErrorMsg ) { 96 | Print(L"ERROR: Unknown option(s).\n"); 97 | } 98 | Print(L"Usage: Beep [NumberOfBeeps]\n"); 99 | Print(L" Beep [-V | --version]\n"); 100 | } 101 | 102 | 103 | INTN 104 | EFIAPI 105 | ShellAppMain( UINTN Argc, 106 | CHAR16 **Argv ) 107 | { 108 | EFI_STATUS Status = EFI_SUCCESS; 109 | UINTN NumberBeeps = 1; 110 | 111 | if (Argc == 2) { 112 | if (!StrCmp(Argv[1], L"--version") || 113 | !StrCmp(Argv[1], L"-V")) { 114 | Print(L"Version: %s\n", UTILITY_VERSION); 115 | return Status; 116 | } else if (!StrCmp(Argv[1], L"--help") || 117 | !StrCmp(Argv[1], L"-h")) { 118 | Usage(FALSE); 119 | return Status; 120 | } else if (IsNumber(Argv[1])) { 121 | NumberBeeps = (UINTN) StrDecimalToUint64( Argv[1] ); 122 | if (NumberBeeps < 1) { 123 | Print(L"ERROR: Invalid number of beeps\n"); 124 | Usage(FALSE); 125 | return Status; 126 | } 127 | } else { 128 | Usage(TRUE); 129 | return Status; 130 | } 131 | } 132 | if (Argc > 2) { 133 | Usage(TRUE); 134 | return Status; 135 | } 136 | 137 | Status = GenerateBeep( NumberBeeps ); 138 | 139 | return Status; 140 | } 141 | -------------------------------------------------------------------------------- /MyApps/Beep/Beep.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/Beep/Beep.efi -------------------------------------------------------------------------------- /MyApps/Beep/Beep.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = Beep 4 | FILE_GUID = 4ea87c51-7395-4dcd-0055-747010f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | Beep.c 12 | 13 | [Packages] 14 | MdePkg/MdePkg.dec 15 | ShellPkg/ShellPkg.dec 16 | 17 | [LibraryClasses] 18 | ShellCEntryLib 19 | ShellLib 20 | BaseLib 21 | BaseMemoryLib 22 | UefiLib 23 | IoLib 24 | 25 | [Protocols] 26 | 27 | [BuildOptions] 28 | 29 | [Pcd] 30 | 31 | -------------------------------------------------------------------------------- /MyApps/BootFWUI/BootFWUI.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2018 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Set OsIndications variable to reboot to UEFI firmware UI 5 | // 6 | // License: BSD License 7 | // 8 | 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | #define UTILITY_VERSION L"20180318" 26 | #undef DEBUG 27 | 28 | 29 | VOID 30 | Usage( VOID ) 31 | { 32 | Print(L"Usage: BootFWUI [-s | --set]\n"); 33 | Print(L" [-u | --unset]\n"); 34 | Print(L" [-V | --version]\n"); 35 | } 36 | 37 | 38 | INTN 39 | EFIAPI 40 | ShellAppMain( UINTN Argc, 41 | CHAR16 **Argv ) 42 | { 43 | EFI_STATUS Status = EFI_SUCCESS; 44 | BOOLEAN SupportBootFwUi, BootFwUi; 45 | BOOLEAN Unset = FALSE; 46 | BOOLEAN Set = FALSE; 47 | UINT64 OsIndicationsSupported; 48 | UINT64 OsIndications; 49 | UINTN DataSize; 50 | UINT32 Attributes; 51 | 52 | if (Argc == 2) { 53 | if (!StrCmp(Argv[1], L"--version") || 54 | !StrCmp(Argv[1], L"-V")) { 55 | Print(L"Version: %s\n", UTILITY_VERSION); 56 | return Status; 57 | } else if (!StrCmp(Argv[1], L"--set") || 58 | !StrCmp(Argv[1], L"-s")) { 59 | Set = TRUE; 60 | } else if (!StrCmp(Argv[1], L"--unset") || 61 | !StrCmp(Argv[1], L"-u")) { 62 | Unset = TRUE; 63 | } else if (!StrCmp(Argv[1], L"--help") || 64 | !StrCmp(Argv[1], L"-h")) { 65 | Usage(); 66 | return Status; 67 | } else { 68 | Usage(); 69 | return Status; 70 | } 71 | } 72 | if (Argc > 2) { 73 | Usage(); 74 | return Status; 75 | } 76 | 77 | 78 | DataSize = sizeof(UINT64); 79 | 80 | Status = gRT->GetVariable( EFI_OS_INDICATIONS_SUPPORT_VARIABLE_NAME, 81 | &gEfiGlobalVariableGuid, 82 | &Attributes, 83 | &DataSize, 84 | &OsIndicationsSupported); 85 | if (Status == EFI_NOT_FOUND) { 86 | Print(L"ERROR: OsIndicationsSupported variable not found.\n"); 87 | return Status; 88 | } 89 | 90 | #ifdef DEBUG 91 | Print(L"OSIndicationsSupported variable found: 0x%016x\n", OsIndicationSupport ); 92 | #endif 93 | 94 | Status = gRT->GetVariable( EFI_OS_INDICATIONS_VARIABLE_NAME, 95 | &gEfiGlobalVariableGuid, 96 | &Attributes, 97 | &DataSize, 98 | &OsIndications); 99 | if (Status == EFI_NOT_FOUND) { 100 | Print(L"ERROR: OsIndications variable not found.\n"); 101 | return Status; 102 | } 103 | 104 | #ifdef DEBUG 105 | Print(L"OsIndications variable: 0x%016x\n", OsIndication); 106 | #endif 107 | 108 | SupportBootFwUi = (BOOLEAN) ((OsIndicationsSupported & EFI_OS_INDICATIONS_BOOT_TO_FW_UI) != 0); 109 | BootFwUi = (BOOLEAN) ((OsIndications & EFI_OS_INDICATIONS_BOOT_TO_FW_UI) != 0); 110 | 111 | if (Set == FALSE && Unset == FALSE) { 112 | Print(L" Boot to Firmware UI: %s. Current value is %s.\n", SupportBootFwUi ? L"Supported" : L"Unsupported", 113 | BootFwUi ? L"SET" : L"UNSET"); 114 | return Status; 115 | } 116 | 117 | if ( Unset ) { 118 | OsIndications &= ~((UINT64)EFI_OS_INDICATIONS_BOOT_TO_FW_UI); 119 | } else { // set 120 | OsIndications |= EFI_OS_INDICATIONS_BOOT_TO_FW_UI; 121 | } 122 | 123 | Status = gRT->SetVariable( EFI_OS_INDICATIONS_VARIABLE_NAME, 124 | &gEfiGlobalVariableGuid, 125 | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS, 126 | sizeof (OsIndications), 127 | &OsIndications); 128 | if (Status != EFI_SUCCESS) { 129 | Print(L"ERROR: SetVariable: %d\n", Status); 130 | return Status; 131 | } 132 | 133 | // check value actually changed! 134 | Status = gRT->GetVariable( EFI_OS_INDICATIONS_VARIABLE_NAME, 135 | &gEfiGlobalVariableGuid, 136 | &Attributes, 137 | &DataSize, 138 | &OsIndications); 139 | if (Status == EFI_NOT_FOUND) { 140 | Print(L"ERROR: OsIndications variable not found.\n"); 141 | return Status; 142 | } 143 | 144 | #ifdef DEBUG 145 | Print(L"OsIndications variable: 0x%016x\n", OsIndication); 146 | #endif 147 | 148 | BootFwUi = (BOOLEAN) ((OsIndications & EFI_OS_INDICATIONS_BOOT_TO_FW_UI) != 0); 149 | 150 | Print(L" Boot to Firmware UI: %s. Current value is %s.\n", SupportBootFwUi ? L"Supported" : L"Unsupported", 151 | BootFwUi ? L"SET" : L"UNSET"); 152 | 153 | return Status; 154 | } 155 | -------------------------------------------------------------------------------- /MyApps/BootFWUI/BootFWUI.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/BootFWUI/BootFWUI.efi -------------------------------------------------------------------------------- /MyApps/BootFWUI/BootFWUI.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = BootFWUI 4 | FILE_GUID = 4ea87c51-7395-4dcd-0055-747010f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | BootFWUI.c 12 | 13 | [Packages] 14 | MdePkg/MdePkg.dec 15 | ShellPkg/ShellPkg.dec 16 | 17 | [LibraryClasses] 18 | ShellCEntryLib 19 | ShellLib 20 | BaseLib 21 | BaseMemoryLib 22 | UefiLib 23 | 24 | [Protocols] 25 | 26 | [BuildOptions] 27 | 28 | [Pcd] 29 | 30 | -------------------------------------------------------------------------------- /MyApps/BootFWUI/ShowMSDM.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2014-2018 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Display ACPI MSDM and/or Microsoft Windows License Key 5 | // 6 | // License: BSD License 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | #define UTILITY_VERSION L"20180221" 25 | #undef DEBUG 26 | 27 | 28 | #pragma pack(1) 29 | typedef struct { 30 | UINT32 Version; 31 | UINT32 Reserved; 32 | UINT32 DataType; 33 | UINT32 DataReserved; 34 | UINT32 DataLength; 35 | CHAR8 Data[30]; 36 | } SOFTWARE_LICENSING; 37 | 38 | // Microsoft Data Management table structure 39 | typedef struct { 40 | EFI_ACPI_SDT_HEADER Header; 41 | SOFTWARE_LICENSING SoftLic; 42 | } EFI_ACPI_MSDM; 43 | #pragma pack() 44 | 45 | 46 | static VOID AsciiToUnicodeSize(CHAR8 *, UINT8, CHAR16 *, BOOLEAN); 47 | 48 | 49 | static VOID 50 | AsciiToUnicodeSize( CHAR8 *String, 51 | UINT8 length, 52 | CHAR16 *UniString, 53 | BOOLEAN Quote ) 54 | { 55 | int len = length; 56 | 57 | if (Quote) 58 | *(UniString++) = L'"'; 59 | while (*String != '\0' && len > 0) { 60 | *(UniString++) = (CHAR16) *(String++); 61 | len--; 62 | } 63 | if (Quote) 64 | *(UniString++) = L'"'; 65 | *UniString = '\0'; 66 | } 67 | 68 | 69 | static VOID 70 | PrintHexTable( UINT8 *ptr, 71 | int Count ) 72 | { 73 | int i = 0; 74 | 75 | Print(L" "); 76 | for (i = 0; i < Count; i++ ) { 77 | if ( i > 0 && i%16 == 0) 78 | Print(L"\n "); 79 | Print(L"0x%02x ", 0xff & *ptr++); 80 | } 81 | Print(L"\n"); 82 | } 83 | 84 | 85 | static VOID 86 | PrintAcpiHeader( EFI_ACPI_SDT_HEADER *Ptr ) 87 | { 88 | CHAR16 Buffer[50]; 89 | 90 | Print(L"ACPI Standard Header\n"); 91 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->Signature), 4, Buffer, TRUE); 92 | Print(L" Signature : %s\n", Buffer); 93 | Print(L" Length : 0x%08x (%d)\n", Ptr->Length, Ptr->Length); 94 | Print(L" Revision : 0x%02x (%d)\n", Ptr->Revision, Ptr->Revision); 95 | Print(L" Checksum : 0x%02x (%d)\n", Ptr->Checksum, Ptr->Checksum); 96 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->OemId), 6, Buffer, TRUE); 97 | Print(L" OEM ID : %s\n", Buffer); 98 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->OemTableId), 8, Buffer, TRUE); 99 | Print(L" OEM Table ID : %s\n", Buffer); 100 | Print(L" OEM Revision : 0x%08x (%d)\n", Ptr->OemRevision, Ptr->OemRevision); 101 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->CreatorId), 4, Buffer, TRUE); 102 | Print(L" Creator ID : %s\n", Buffer); 103 | Print(L" Creator Revision : 0x%08x (%d)\n", Ptr->CreatorRevision, Ptr->CreatorRevision); 104 | Print(L"\n"); 105 | } 106 | 107 | 108 | static VOID 109 | PrintSoftwareLicensing( SOFTWARE_LICENSING *Ptr, 110 | BOOLEAN Verbose ) 111 | { 112 | CHAR16 Buffer[50]; 113 | 114 | if (Verbose) { 115 | Print(L"Software Licensing\n"); 116 | Print(L" Version : 0x%08x (%d)\n", Ptr->Version, Ptr->Version); 117 | Print(L" Reserved : 0x%08x (%d)\n", Ptr->Reserved, Ptr->Reserved); 118 | Print(L" Data Type : 0x%08x (%d)\n", Ptr->DataType, Ptr->DataType); 119 | Print(L" Data Reserved : 0x%08x (%d)\n", Ptr->DataReserved, Ptr->DataReserved); 120 | Print(L" Data Length : 0x%08x (%d)\n", Ptr->DataLength, Ptr->DataLength); 121 | AsciiToUnicodeSize((CHAR8 *)(Ptr->Data), 30, Buffer, TRUE); 122 | Print(L" Data : %s\n", Buffer); 123 | } else { 124 | AsciiToUnicodeSize((CHAR8 *)(Ptr->Data), 30, Buffer, FALSE); 125 | Print(L" %s\n", Buffer); 126 | } 127 | } 128 | 129 | 130 | static VOID 131 | PrintMSDM( EFI_ACPI_MSDM *Msdm, 132 | BOOLEAN Verbose, 133 | BOOLEAN Hexdump ) 134 | { 135 | Print(L"\n"); 136 | if (Hexdump) { 137 | PrintHexTable( (UINT8 *)Msdm, (int)(Msdm->Header.Length) ); 138 | } else { 139 | if (Verbose) { 140 | PrintAcpiHeader( (EFI_ACPI_SDT_HEADER *)&(Msdm->Header) ); 141 | } 142 | PrintSoftwareLicensing( (SOFTWARE_LICENSING *)&(Msdm->SoftLic), Verbose); 143 | } 144 | Print(L"\n"); 145 | } 146 | 147 | 148 | static int 149 | ParseRSDP( EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp, 150 | CHAR16* GuidStr, 151 | BOOLEAN Verbose, 152 | BOOLEAN Hexdump ) 153 | { 154 | EFI_ACPI_SDT_HEADER *Xsdt, *Entry; 155 | #ifdef DEBUG 156 | CHAR16 OemStr[20]; 157 | #endif 158 | UINT32 EntryCount; 159 | UINT64 *EntryPtr; 160 | 161 | #ifdef DEBUG 162 | Print(L"\n\nACPI GUID: %s\n", GuidStr); 163 | 164 | AsciiToUnicodeSize((CHAR8 *)(Rsdp->OemId), 6, OemStr, FALSE); 165 | Print(L"\nFound RSDP. Version: %d OEM ID: %s\n", (int)(Rsdp->Revision), OemStr); 166 | #endif 167 | if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) { 168 | Xsdt = (EFI_ACPI_SDT_HEADER *)(Rsdp->XsdtAddress); 169 | } else { 170 | #ifdef DEBUG 171 | Print(L"ERROR: No ACPI XSDT table found.\n"); 172 | #endif 173 | return 1; 174 | } 175 | 176 | if (Xsdt->Signature != SIGNATURE_32 ('X', 'S', 'D', 'T')) { 177 | #ifdef DEBUG 178 | Print(L"ERROR: Invalid ACPI XSDT table found.\n"); 179 | #endif 180 | return 1; 181 | } 182 | 183 | EntryCount = (Xsdt->Length - sizeof (EFI_ACPI_SDT_HEADER)) / sizeof(UINT64); 184 | #ifdef DEBUG 185 | AsciiToUnicodeSize((CHAR8 *)(Xsdt->OemId), 6, OemStr, FALSE); 186 | Print(L"Found XSDT. OEM ID: %s Entry Count: %d\n\n", OemStr, EntryCount); 187 | #endif 188 | 189 | EntryPtr = (UINT64 *)(Xsdt + 1); 190 | for (int Index = 0; Index < EntryCount; Index++, EntryPtr++) { 191 | Entry = (EFI_ACPI_SDT_HEADER *)((UINTN)(*EntryPtr)); 192 | if (Entry->Signature == SIGNATURE_32 ('M', 'S', 'D', 'M')) { 193 | PrintMSDM((EFI_ACPI_MSDM *)((UINTN)(*EntryPtr)), Verbose, Hexdump); 194 | } 195 | } 196 | 197 | return 0; 198 | } 199 | 200 | 201 | static void 202 | Usage( void ) 203 | { 204 | Print(L"Usage: ShowMSDM [-v | --verbose]\n"); 205 | Print(L" ShowMSDM [-V | --version]\n"); 206 | Print(L" ShowMSDM [-d | --dump]\n"); 207 | } 208 | 209 | 210 | INTN 211 | EFIAPI 212 | ShellAppMain( UINTN Argc, 213 | CHAR16 **Argv ) 214 | { 215 | EFI_CONFIGURATION_TABLE *ect = gST->ConfigurationTable; 216 | EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp = NULL; 217 | EFI_GUID gAcpi20TableGuid = EFI_ACPI_20_TABLE_GUID; 218 | EFI_GUID gAcpi10TableGuid = ACPI_10_TABLE_GUID; 219 | EFI_STATUS Status = EFI_SUCCESS; 220 | CHAR16 GuidStr[100]; 221 | BOOLEAN Verbose = FALSE; 222 | BOOLEAN Hexdump = FALSE; 223 | 224 | if (Argc == 2) { 225 | if (!StrCmp(Argv[1], L"--verbose") || 226 | !StrCmp(Argv[1], L"-v")) { 227 | Verbose = TRUE; 228 | } else if (!StrCmp(Argv[1], L"--dump") || 229 | !StrCmp(Argv[1], L"-d")) { 230 | Hexdump = TRUE; 231 | } else if (!StrCmp(Argv[1], L"--version") || 232 | !StrCmp(Argv[1], L"-V")) { 233 | Print(L"Version: %s\n", UTILITY_VERSION); 234 | return Status; 235 | } else if (!StrCmp(Argv[1], L"--help") || 236 | !StrCmp(Argv[1], L"-h")) { 237 | Usage(); 238 | return Status; 239 | } else { 240 | Usage(); 241 | return Status; 242 | } 243 | } 244 | if (Argc > 2) { 245 | Usage(); 246 | return Status; 247 | } 248 | 249 | // locate RSDP (Root System Description Pointer) 250 | for (int i = 0; i < gST->NumberOfTableEntries; i++) { 251 | if ((CompareGuid (&(gST->ConfigurationTable[i].VendorGuid), &gAcpi20TableGuid)) || 252 | (CompareGuid (&(gST->ConfigurationTable[i].VendorGuid), &gAcpi10TableGuid))) { 253 | if (!AsciiStrnCmp("RSD PTR ", (CHAR8 *)(ect->VendorTable), 8)) { 254 | UnicodeSPrint(GuidStr, sizeof(GuidStr), L"%g", &(gST->ConfigurationTable[i].VendorGuid)); 255 | Rsdp = (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)ect->VendorTable; 256 | ParseRSDP(Rsdp, GuidStr, Verbose, Hexdump); 257 | } 258 | } 259 | ect++; 260 | } 261 | 262 | if (Rsdp == NULL) { 263 | Print(L"ERROR: Could not find an ACPI RSDP table.\n"); 264 | Status = EFI_NOT_FOUND; 265 | } 266 | 267 | return Status; 268 | } 269 | -------------------------------------------------------------------------------- /MyApps/Cpuid/Cpuid.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/Cpuid/Cpuid.efi -------------------------------------------------------------------------------- /MyApps/Cpuid/Cpuid.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = Cpuid 4 | FILE_GUID = 4AE7E1E8-9DFE-4e3e-85B4-A5F6ABD470FB 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | Cpuid.c 12 | 13 | [Packages] 14 | MdePkg/MdePkg.dec 15 | ShellPkg/ShellPkg.dec 16 | UefiCpuPkg/UefiCpuPkg.dec 17 | 18 | [LibraryClasses] 19 | ShellCEntryLib 20 | ShellLib 21 | ShellCommandLib 22 | BaseLib 23 | BaseMemoryLib 24 | UefiLib 25 | 26 | [Protocols] 27 | 28 | [BuildOptions] 29 | 30 | [Pcd] 31 | -------------------------------------------------------------------------------- /MyApps/DisplayBMP/DisplayBMP.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015-2018 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Display an uncompressed BMP image 5 | // 6 | // License: BSD 2 clause License 7 | // 8 | 9 | 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | #define UTILITY_VERSION L"20180414" 28 | #undef DEBUG 29 | 30 | 31 | EFI_STATUS 32 | PressKey( BOOLEAN DisplayText ) 33 | { 34 | EFI_INPUT_KEY Key; 35 | EFI_STATUS Status; 36 | UINTN EventIndex; 37 | 38 | if (DisplayText) { 39 | Print(L"\nPress any key to continue...\n\n"); 40 | } 41 | 42 | gBS->WaitForEvent(1, &gST->ConIn->WaitForKey, &EventIndex); 43 | Status = gST->ConIn->ReadKeyStroke(gST->ConIn, &Key); 44 | 45 | return Status; 46 | } 47 | 48 | 49 | VOID 50 | AsciiToUnicodeSize( CHAR8 *String, 51 | UINT8 length, 52 | CHAR16 *UniString ) 53 | { 54 | int len = length; 55 | 56 | while (*String != '\0' && len > 0) { 57 | *(UniString++) = (CHAR16) *(String++); 58 | len--; 59 | } 60 | *UniString = '\0'; 61 | } 62 | 63 | 64 | EFI_STATUS 65 | DisplayImage( EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop, 66 | EFI_HANDLE *BmpBuffer ) 67 | { 68 | BMP_IMAGE_HEADER *BmpHeader = (BMP_IMAGE_HEADER *) BmpBuffer; 69 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer; 70 | EFI_STATUS Status = EFI_SUCCESS; 71 | UINT32 *Palette; 72 | UINT8 *BitmapData; 73 | UINTN Pixels; 74 | UINTN XIndex; 75 | UINTN YIndex; 76 | UINTN Pos; 77 | UINTN BltPos; 78 | 79 | BitmapData = (UINT8*)BmpBuffer + BmpHeader->ImageOffset; 80 | Palette = (UINT32*) ((UINT8*)BmpBuffer + 0x36); 81 | 82 | Pixels = BmpHeader->PixelWidth * BmpHeader->PixelHeight; 83 | BltBuffer = AllocateZeroPool( sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * Pixels); 84 | if (BltBuffer == NULL) { 85 | Print(L"ERROR: BltBuffer. No memory resources\n"); 86 | return EFI_OUT_OF_RESOURCES; 87 | } 88 | 89 | for (YIndex = BmpHeader->PixelHeight; YIndex > 0; YIndex--) { 90 | for (XIndex = 0; XIndex < BmpHeader->PixelWidth; XIndex++) { 91 | Pos = (YIndex - 1) * ((BmpHeader->PixelWidth + 3) / 4) * 4 + XIndex; 92 | BltPos = (BmpHeader->PixelHeight - YIndex) * BmpHeader->PixelWidth + XIndex; 93 | BltBuffer[BltPos].Blue = (UINT8) BitFieldRead32(Palette[BitmapData[Pos]], 0 , 7 ); 94 | BltBuffer[BltPos].Green = (UINT8) BitFieldRead32(Palette[BitmapData[Pos]], 8 , 15); 95 | BltBuffer[BltPos].Red = (UINT8) BitFieldRead32(Palette[BitmapData[Pos]], 16, 23); 96 | BltBuffer[BltPos].Reserved = (UINT8) BitFieldRead32(Palette[BitmapData[Pos]], 24, 31); 97 | } 98 | } 99 | 100 | Status = Gop->Blt( Gop, 101 | BltBuffer, 102 | EfiBltBufferToVideo, 103 | 0, 0, /* Source X, Y */ 104 | 50, 75, /* Dest X, Y */ 105 | BmpHeader->PixelWidth, BmpHeader->PixelHeight, 106 | 0 ); 107 | if (EFI_ERROR (Status)) { 108 | Print(L"ERROR: Gop->Blt [%d]\n", Status); 109 | } 110 | 111 | FreePool(BltBuffer); 112 | 113 | return Status; 114 | } 115 | 116 | 117 | // 118 | // Print the BMP header details 119 | // 120 | EFI_STATUS 121 | PrintBMP( EFI_HANDLE *BmpBuffer ) 122 | { 123 | BMP_IMAGE_HEADER *BmpHeader = (BMP_IMAGE_HEADER *)BmpBuffer; 124 | EFI_STATUS Status = EFI_SUCCESS; 125 | CHAR16 Buffer[100]; 126 | 127 | // not BMP format 128 | if (BmpHeader->CharB != 'B' || BmpHeader->CharM != 'M') { 129 | Print(L"ERROR: Unsupported image format\n"); 130 | return EFI_UNSUPPORTED; 131 | } 132 | 133 | // BITMAPINFOHEADER format unsupported 134 | if (BmpHeader->HeaderSize != sizeof (BMP_IMAGE_HEADER) \ 135 | - ((UINTN) &(((BMP_IMAGE_HEADER *)0)->HeaderSize))) { 136 | Print(L"ERROR: Unsupported BITMAPFILEHEADER\n"); 137 | return EFI_UNSUPPORTED; 138 | } 139 | 140 | // compression type not 0 141 | if (BmpHeader->CompressionType != 0) { 142 | Print(L"ERROR: Compression type not 0\n"); 143 | return EFI_UNSUPPORTED; 144 | } 145 | 146 | // unsupported bits per pixel 147 | if (BmpHeader->BitPerPixel != 4 && 148 | BmpHeader->BitPerPixel != 8 && 149 | BmpHeader->BitPerPixel != 12 && 150 | BmpHeader->BitPerPixel != 24) { 151 | Print(L"ERROR: Bits per pixel is not one of 4, 8, 12 or 24\n"); 152 | return EFI_UNSUPPORTED; 153 | } 154 | 155 | AsciiToUnicodeSize((CHAR8 *)BmpHeader, 2, Buffer); 156 | 157 | Print(L"\n"); 158 | Print(L" BMP Signature : %s\n", Buffer); 159 | Print(L" Size : %d\n", BmpHeader->Size); 160 | Print(L" Image Offset : %d\n", BmpHeader->ImageOffset); 161 | Print(L" Header Size : %d\n", BmpHeader->HeaderSize); 162 | Print(L" Image Width : %d\n", BmpHeader->PixelWidth); 163 | Print(L" Image Height : %d\n", BmpHeader->PixelHeight); 164 | Print(L" Planes : %d\n", BmpHeader->Planes); 165 | Print(L" Bit Per Pixel : %d\n", BmpHeader->BitPerPixel); 166 | Print(L" Compression Type : %d\n", BmpHeader->CompressionType); 167 | Print(L" Image Size : %d\n", BmpHeader->ImageSize); 168 | Print(L" X Pixels Per Meter : %d\n", BmpHeader->XPixelsPerMeter); 169 | Print(L" Y Pixels Per Meter : %d\n", BmpHeader->YPixelsPerMeter); 170 | Print(L" Number of Colors : %d\n", BmpHeader->NumberOfColors); 171 | Print(L" Important Colors : %d\n", BmpHeader->ImportantColors); 172 | 173 | return Status; 174 | } 175 | 176 | 177 | VOID 178 | Usage( BOOLEAN ErrorMsg ) 179 | { 180 | if ( ErrorMsg ) { 181 | Print(L"ERROR: Unknown option(s).\n"); 182 | } 183 | 184 | Print(L"Usage: DisplayBMP [-v | --verbose] BMPfilename\n"); 185 | Print(L" DisplayBMP [-V | --version]\n"); 186 | } 187 | 188 | 189 | INTN 190 | EFIAPI 191 | ShellAppMain( UINTN Argc, 192 | CHAR16 **Argv ) 193 | { 194 | EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop; 195 | EFI_DEVICE_PATH_PROTOCOL *Dpp; 196 | SHELL_FILE_HANDLE FileHandle; 197 | EFI_FILE_INFO *FileInfo = NULL; 198 | EFI_STATUS Status = EFI_SUCCESS; 199 | EFI_HANDLE *Handles = NULL; 200 | EFI_HANDLE *FileBuffer = NULL; 201 | BOOLEAN Verbose = FALSE; 202 | UINTN HandleCount = 0; 203 | UINTN FileSize; 204 | 205 | int OrgMode = 0, NewMode = 0, Pixels = 0; 206 | 207 | if (Argc == 2) { 208 | if (!StrCmp(Argv[1], L"--version") || 209 | !StrCmp(Argv[1], L"-V")) { 210 | Print(L"Version: %s\n", UTILITY_VERSION); 211 | return Status; 212 | } else if (!StrCmp(Argv[1], L"--help") || 213 | !StrCmp(Argv[1], L"-h")) { 214 | Usage(FALSE); 215 | return Status; 216 | } else if (Argv[1][0] == L'-') { 217 | Usage(TRUE); 218 | return Status; 219 | } 220 | } else if (Argc == 3) { 221 | if (!StrCmp(Argv[1], L"--verbose") || 222 | !StrCmp(Argv[1], L"-v")) { 223 | Verbose = TRUE; 224 | } else if (Argv[1][0] == L'-') { 225 | Usage(FALSE); 226 | return Status; 227 | } 228 | } else { 229 | Usage(FALSE); 230 | return Status; 231 | } 232 | 233 | // Check last argument is not an option! 234 | if (Argv[Argc-1][0] == L'-') { 235 | Usage(TRUE); 236 | return Status; 237 | } 238 | 239 | // Open the file (has to be LAST arguement on command line) 240 | Status = ShellOpenFileByName( Argv[Argc - 1], 241 | &FileHandle, 242 | EFI_FILE_MODE_READ , 0); 243 | if (EFI_ERROR (Status)) { 244 | Print(L"ERROR: Could not open specified file [%d]\n", Status); 245 | return Status; 246 | } 247 | 248 | // Allocate buffer for file contents 249 | FileInfo = ShellGetFileInfo(FileHandle); 250 | FileBuffer = AllocateZeroPool( (UINTN)FileInfo -> FileSize); 251 | if (FileBuffer == NULL) { 252 | Print(L"ERROR: File buffer. No memory resources\n"); 253 | return (SHELL_OUT_OF_RESOURCES); 254 | } 255 | 256 | // Read file contents into allocated buffer 257 | FileSize = (UINTN) FileInfo->FileSize; 258 | Status = ShellReadFile(FileHandle, &FileSize, FileBuffer); 259 | if (EFI_ERROR (Status)) { 260 | Print(L"ERROR: ShellReadFile failed [%d]\n", Status); 261 | goto cleanup; 262 | } 263 | 264 | ShellCloseFile(&FileHandle); 265 | 266 | if (Verbose) { 267 | PrintBMP(FileBuffer); 268 | PressKey(TRUE); 269 | } 270 | 271 | // Try locating GOP by handle 272 | Status = gBS->LocateHandleBuffer( ByProtocol, 273 | &gEfiGraphicsOutputProtocolGuid, 274 | NULL, 275 | &HandleCount, 276 | &Handles ); 277 | if (EFI_ERROR (Status)) { 278 | Print(L"ERROR: No GOP handles found via LocateHandleBuffer\n"); 279 | goto cleanup; 280 | } 281 | 282 | #ifdef DEBUG 283 | Print(L"Found %d GOP handles via LocateHandleBuffer\n", HandleCount); 284 | #endif 285 | 286 | // Make sure we use the correct GOP handle 287 | Gop = NULL; 288 | for (UINTN Handle = 0; Handle < HandleCount; Handle++) { 289 | Status = gBS->HandleProtocol( Handles[Handle], 290 | &gEfiDevicePathProtocolGuid, 291 | (VOID **)&Dpp ); 292 | if (!EFI_ERROR(Status)) { 293 | Status = gBS->HandleProtocol( Handles[Handle], 294 | &gEfiGraphicsOutputProtocolGuid, 295 | (VOID **)&Gop ); 296 | if (!EFI_ERROR(Status)) { 297 | break; 298 | } 299 | } 300 | } 301 | FreePool(Handles); 302 | if (Gop == NULL) { 303 | Print(L"Exiting. Graphics console not found.\n"); 304 | goto cleanup; 305 | } 306 | 307 | // Figure out maximum resolution and use it 308 | OrgMode = Gop->Mode->Mode; 309 | for (int i = 0; i < Gop->Mode->MaxMode; i++) { 310 | EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info; 311 | UINTN SizeOfInfo; 312 | 313 | Status = Gop->QueryMode( Gop, 314 | i, 315 | &SizeOfInfo, 316 | &Info ); 317 | if (EFI_ERROR(Status) && Status == EFI_NOT_STARTED) { 318 | Gop->SetMode( Gop, 319 | Gop->Mode->Mode ); 320 | Status = Gop->QueryMode( Gop, 321 | i, 322 | &SizeOfInfo, 323 | &Info ); 324 | } 325 | if (EFI_ERROR(Status)) { 326 | continue; 327 | } 328 | if (Info->PixelsPerScanLine > Pixels) { 329 | Pixels = Info->PixelsPerScanLine; 330 | NewMode = i; 331 | } 332 | } 333 | 334 | #ifdef DEBUG 335 | Print(L"OrgMode; %d NewMode: %d\n", OrgMode, NewMode); 336 | #endif 337 | 338 | // Change screen mode 339 | Status = Gop->SetMode( Gop, 340 | NewMode ); 341 | if (EFI_ERROR (Status)) { 342 | Print(L"ERROR: SetMode [%d]\n", Status); 343 | goto cleanup; 344 | } 345 | 346 | DisplayImage( Gop, FileBuffer ); 347 | 348 | // Reset screen to original mode 349 | PressKey(TRUE); 350 | Status = Gop->SetMode( Gop, 351 | OrgMode ); 352 | 353 | cleanup: 354 | FreePool(FileBuffer); 355 | return Status; 356 | } 357 | -------------------------------------------------------------------------------- /MyApps/DisplayBMP/DisplayBMP.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/DisplayBMP/DisplayBMP.efi -------------------------------------------------------------------------------- /MyApps/DisplayBMP/DisplayBMP.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = DisplayBMP 4 | FILE_GUID = 4ea87c54-7895-4dcd-0455-747010f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | DisplayBMP.c 12 | 13 | [Packages] 14 | MdePkg/MdePkg.dec 15 | ShellPkg/ShellPkg.dec 16 | 17 | [LibraryClasses] 18 | ShellCEntryLib 19 | ShellLib 20 | BaseLib 21 | BaseMemoryLib 22 | UefiLib 23 | 24 | [Protocols] 25 | 26 | [BuildOptions] 27 | 28 | [Pcd] 29 | 30 | -------------------------------------------------------------------------------- /MyApps/DisplayBMP/Logo.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/DisplayBMP/Logo.bmp -------------------------------------------------------------------------------- /MyApps/GenTPM12RN/GenTPM12RN.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2016-2018 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Generate one or more random numbers using a TPM 1.2 RNG 5 | // 6 | // License: UDK2017 license applies to code from UDK2017 sources, 7 | // BSD 2 clause license applies to all other code. 8 | // 9 | // Note: Previous versions were named "tpm_randomnumber" 10 | // 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | #define UTILITY_VERSION L"20180830" 27 | #undef DEBUG 28 | 29 | // configurable defines 30 | #define DEFAULT_NUMBER_RANDOM_BYTES 1 31 | #define MAX_RANDOM_BYTES 24 32 | 33 | #pragma pack(1) 34 | typedef struct { 35 | TPM_RQU_COMMAND_HDR Header; 36 | UINT32 BytesRequested; 37 | } TPM_COMMAND; 38 | 39 | typedef struct { 40 | TPM_RSP_COMMAND_HDR Header; 41 | UINT32 RandomBytesSize; 42 | UINT8 RandomBytes[MAX_RANDOM_BYTES]; 43 | } TPM_RESPONSE; 44 | #pragma pack() 45 | 46 | 47 | BOOLEAN 48 | IsNumber( CHAR16* str ) 49 | { 50 | CHAR16 *s = str; 51 | 52 | // allow negative 53 | if (*s == L'-') 54 | s++; 55 | 56 | while (*s) { 57 | if (*s < L'0' || *s > L'9') 58 | return FALSE; 59 | s++; 60 | } 61 | 62 | return TRUE; 63 | } 64 | 65 | 66 | BOOLEAN 67 | CheckForTpm20() 68 | { 69 | EFI_STATUS Status = EFI_SUCCESS; 70 | EFI_TCG2_PROTOCOL *Tcg2Protocol; 71 | EFI_GUID gEfiTcg2ProtocolGuid = EFI_TCG2_PROTOCOL_GUID; 72 | 73 | Status = gBS->LocateProtocol( &gEfiTcg2ProtocolGuid, 74 | NULL, 75 | (VOID **) &Tcg2Protocol ); 76 | if (EFI_ERROR (Status)) { 77 | return FALSE; 78 | } 79 | 80 | return TRUE; 81 | } 82 | 83 | 84 | VOID 85 | Usage( CHAR16 *Str, 86 | BOOLEAN ErrorMsg ) 87 | { 88 | if ( ErrorMsg ) { 89 | Print(L"ERROR: Unknown option.\n"); 90 | } 91 | Print(L"Usage: %s [-v | --verbose] [NumberOfBytes]\n", Str); 92 | Print(L" %s [-V | --version]\n", Str); 93 | } 94 | 95 | 96 | INTN 97 | EFIAPI 98 | ShellAppMain( UINTN Argc, 99 | CHAR16 **Argv ) 100 | { 101 | EFI_STATUS Status = EFI_SUCCESS; 102 | EFI_TCG_PROTOCOL *TcgProtocol; 103 | EFI_GUID gEfiTcgProtocolGuid = EFI_TCG_PROTOCOL_GUID; 104 | UINTN NumberRandomBytes = DEFAULT_NUMBER_RANDOM_BYTES; 105 | BOOLEAN Verbose = FALSE; 106 | 107 | TPM_COMMAND InBuffer; 108 | TPM_RESPONSE OutBuffer; 109 | UINT32 InBufferSize; 110 | UINT32 OutBufferSize; 111 | int RandomBytesSize = 0; 112 | 113 | if (Argc == 2) { 114 | if (!StrCmp(Argv[1], L"--version") || 115 | !StrCmp(Argv[1], L"-V")) { 116 | Print(L"Version: %s\n", UTILITY_VERSION); 117 | return Status; 118 | } else if (!StrCmp(Argv[1], L"--help") || 119 | !StrCmp(Argv[1], L"-h")) { 120 | Usage(Argv[0], FALSE); 121 | return Status; 122 | } else if (IsNumber(Argv[1])) { 123 | NumberRandomBytes = (UINTN) StrDecimalToUint64( Argv[1] ); 124 | } else { 125 | Usage(Argv[0], TRUE); 126 | return Status; 127 | } 128 | } else if (Argc == 3) { 129 | if (!StrCmp(Argv[1], L"--verbose") || 130 | !StrCmp(Argv[1], L"-v")) { 131 | Verbose = TRUE; 132 | if (IsNumber(Argv[2])) { 133 | NumberRandomBytes = (UINTN) StrDecimalToUint64( Argv[2] ); 134 | } else { 135 | Usage(Argv[0], TRUE); 136 | return Status; 137 | } 138 | } else { 139 | Usage(Argv[0], TRUE); 140 | return Status; 141 | } 142 | } else if (Argc > 3) { 143 | Usage(Argv[0], TRUE); 144 | return Status; 145 | } 146 | 147 | if (NumberRandomBytes < 1) { 148 | Print(L"ERROR: Zero or negative number entered\n"); 149 | Usage(Argv[0], FALSE); 150 | return Status; 151 | } else if (NumberRandomBytes > MAX_RANDOM_BYTES) { 152 | Print(L"Sorry - Output limited to a maximum of %d bytes\n", MAX_RANDOM_BYTES); 153 | NumberRandomBytes = MAX_RANDOM_BYTES; 154 | } 155 | 156 | Status = gBS->LocateProtocol( &gEfiTcgProtocolGuid, 157 | NULL, 158 | (VOID **) &TcgProtocol ); 159 | if (EFI_ERROR (Status)) { 160 | if (CheckForTpm20()) { 161 | Print(L"ERROR: Platform configured for TPM 2.0, not TPM 1.2\n"); 162 | } else { 163 | Print(L"ERROR: Failed to locate EFI_TCG_PROTOCOL [%d]\n", Status); 164 | } 165 | return Status; 166 | } 167 | 168 | InBufferSize = sizeof(TPM_COMMAND); 169 | OutBufferSize = sizeof(TPM_RESPONSE); 170 | 171 | InBuffer.Header.tag = SwapBytes16(TPM_TAG_RQU_COMMAND); 172 | InBuffer.Header.paramSize = SwapBytes32(InBufferSize); 173 | InBuffer.Header.ordinal = SwapBytes32(TPM_ORD_GetRandom); 174 | InBuffer.BytesRequested = SwapBytes32(NumberRandomBytes); 175 | 176 | Status = TcgProtocol->PassThroughToTpm( TcgProtocol, 177 | InBufferSize, 178 | (UINT8 *)&InBuffer, 179 | OutBufferSize, 180 | (UINT8 *)&OutBuffer ); 181 | if (EFI_ERROR (Status)) { 182 | Print(L"ERROR: PassThroughToTpm failed [%d]\n", Status); 183 | return Status; 184 | } 185 | 186 | if ((OutBuffer.Header.tag != SwapBytes16 (TPM_TAG_RSP_COMMAND)) || (OutBuffer.Header.returnCode != 0)) { 187 | Print(L"ERROR: TPM command result [%d]\n", SwapBytes32(OutBuffer.Header.returnCode)); 188 | return EFI_DEVICE_ERROR; 189 | } 190 | 191 | RandomBytesSize = SwapBytes32(OutBuffer.RandomBytesSize); 192 | 193 | if (Verbose) { 194 | Print(L"\n"); 195 | Print(L" Number of Random Bytes Requested: %d\n", SwapBytes32(InBuffer.BytesRequested)); 196 | Print(L" Number of Random Bytes Received: %d\n", RandomBytesSize); 197 | Print(L" Ramdom Bytes Received: "); 198 | for (int i = 0; i < RandomBytesSize; i++) { 199 | Print(L"%02x ", OutBuffer.RandomBytes[i]); 200 | } 201 | Print(L"\n"); 202 | } else { 203 | for (int i = 0; i < RandomBytesSize; i++) { 204 | Print(L"%02x", OutBuffer.RandomBytes[i]); 205 | } 206 | } 207 | Print(L"\n"); 208 | 209 | return Status; 210 | } 211 | -------------------------------------------------------------------------------- /MyApps/GenTPM12RN/GenTPM12RN.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/GenTPM12RN/GenTPM12RN.efi -------------------------------------------------------------------------------- /MyApps/GenTPM12RN/GenTPM12RN.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = GenTPM12RN 4 | FILE_GUID = 4ea87c51-7395-4ccd-0355-747010f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | GenTPM12RN.c 12 | 13 | [Packages] 14 | MdePkg/MdePkg.dec 15 | ShellPkg/ShellPkg.dec 16 | 17 | [LibraryClasses] 18 | ShellCEntryLib 19 | ShellLib 20 | BaseLib 21 | BaseMemoryLib 22 | UefiLib 23 | 24 | [Protocols] 25 | 26 | [BuildOptions] 27 | 28 | [Pcd] 29 | 30 | -------------------------------------------------------------------------------- /MyApps/GraphicModes/ConsoleControl.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
4 | This program and the accompanying materials 5 | are licensed and made available under the terms and conditions of the BSD License 6 | which accompanies this distribution. The full text of the license may be found at 7 | http://opensource.org/licenses/bsd-license.php 8 | 9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 11 | 12 | Module Name: 13 | 14 | ConsoleControl.h 15 | 16 | Abstract: 17 | 18 | Abstraction of a Text mode or GOP/UGA screen 19 | 20 | --*/ 21 | 22 | #ifndef __CONSOLE_CONTROL_H__ 23 | #define __CONSOLE_CONTROL_H__ 24 | 25 | #define EFI_CONSOLE_CONTROL_PROTOCOL_GUID \ 26 | { 0xf42f7782, 0x12e, 0x4c12, {0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21} } 27 | 28 | typedef struct _EFI_CONSOLE_CONTROL_PROTOCOL EFI_CONSOLE_CONTROL_PROTOCOL; 29 | 30 | 31 | typedef enum { 32 | EfiConsoleControlScreenText, 33 | EfiConsoleControlScreenGraphics, 34 | EfiConsoleControlScreenMaxValue 35 | } EFI_CONSOLE_CONTROL_SCREEN_MODE; 36 | 37 | 38 | typedef 39 | EFI_STATUS 40 | (EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_GET_MODE) ( 41 | IN EFI_CONSOLE_CONTROL_PROTOCOL *This, 42 | OUT EFI_CONSOLE_CONTROL_SCREEN_MODE *Mode, 43 | OUT BOOLEAN *GopUgaExists, OPTIONAL 44 | OUT BOOLEAN *StdInLocked OPTIONAL 45 | ) 46 | /*++ 47 | 48 | Routine Description: 49 | Return the current video mode information. Also returns info about existence 50 | of Graphics Output devices or UGA Draw devices in system, and if the Std In 51 | device is locked. All the arguments are optional and only returned if a non 52 | NULL pointer is passed in. 53 | 54 | Arguments: 55 | This - Protocol instance pointer. 56 | Mode - Are we in text of grahics mode. 57 | GopUgaExists - TRUE if Console Spliter has found a GOP or UGA device 58 | StdInLocked - TRUE if StdIn device is keyboard locked 59 | 60 | Returns: 61 | EFI_SUCCESS - Mode information returned. 62 | 63 | --*/ 64 | ; 65 | 66 | 67 | typedef 68 | EFI_STATUS 69 | (EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_SET_MODE) ( 70 | IN EFI_CONSOLE_CONTROL_PROTOCOL *This, 71 | IN EFI_CONSOLE_CONTROL_SCREEN_MODE Mode 72 | ) 73 | /*++ 74 | 75 | Routine Description: 76 | Set the current mode to either text or graphics. Graphics is 77 | for Quiet Boot. 78 | 79 | Arguments: 80 | This - Protocol instance pointer. 81 | Mode - Mode to set the 82 | 83 | Returns: 84 | EFI_SUCCESS - Mode information returned. 85 | 86 | --*/ 87 | ; 88 | 89 | 90 | typedef 91 | EFI_STATUS 92 | (EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_LOCK_STD_IN) ( 93 | IN EFI_CONSOLE_CONTROL_PROTOCOL *This, 94 | IN CHAR16 *Password 95 | ) 96 | /*++ 97 | 98 | Routine Description: 99 | Lock Std In devices until Password is typed. 100 | 101 | Arguments: 102 | This - Protocol instance pointer. 103 | Password - Password needed to unlock screen. NULL means unlock keyboard 104 | 105 | Returns: 106 | EFI_SUCCESS - Mode information returned. 107 | EFI_DEVICE_ERROR - Std In not locked 108 | 109 | --*/ 110 | ; 111 | 112 | 113 | 114 | struct _EFI_CONSOLE_CONTROL_PROTOCOL { 115 | EFI_CONSOLE_CONTROL_PROTOCOL_GET_MODE GetMode; 116 | EFI_CONSOLE_CONTROL_PROTOCOL_SET_MODE SetMode; 117 | EFI_CONSOLE_CONTROL_PROTOCOL_LOCK_STD_IN LockStdIn; 118 | }; 119 | 120 | extern EFI_GUID gEfiConsoleControlProtocolGuid; 121 | 122 | #endif 123 | -------------------------------------------------------------------------------- /MyApps/GraphicModes/GraphicModes.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/GraphicModes/GraphicModes.efi -------------------------------------------------------------------------------- /MyApps/GraphicModes/GraphicModes.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = GraphicModes 4 | FILE_GUID = 4ea87c54-7795-4dcd-0055-747010f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | GraphicModes.c 12 | 13 | [Packages] 14 | MdePkg/MdePkg.dec 15 | ShellPkg/ShellPkg.dec 16 | 17 | [LibraryClasses] 18 | ShellCEntryLib 19 | ShellLib 20 | BaseLib 21 | BaseMemoryLib 22 | UefiLib 23 | 24 | [Protocols] 25 | 26 | [BuildOptions] 27 | 28 | [Pcd] 29 | 30 | -------------------------------------------------------------------------------- /MyApps/ListACPI/ListACPI.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015-2018 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // List ACPI tables 5 | // 6 | // License: BSD License 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | #define UTILITY_VERSION L"20180306" 25 | #undef DEBUG 26 | 27 | 28 | static VOID AsciiToUnicodeSize(CHAR8 *, UINT8, CHAR16 *, BOOLEAN); 29 | 30 | static VOID 31 | AsciiToUnicodeSize( CHAR8 *String, 32 | UINT8 length, 33 | CHAR16 *UniString, 34 | BOOLEAN Quote ) 35 | { 36 | int len = length; 37 | 38 | if (Quote) 39 | *(UniString++) = L'"'; 40 | while (*String != '\0' && len > 0) { 41 | *(UniString++) = (CHAR16) *(String++); 42 | len--; 43 | } 44 | if (Quote) 45 | *(UniString++) = L'"'; 46 | *UniString = '\0'; 47 | } 48 | 49 | 50 | static VOID 51 | PrintTable( EFI_ACPI_SDT_HEADER *Ptr, 52 | BOOLEAN Verbose) 53 | { 54 | CHAR16 Buffer1[20], Buffer2[20]; 55 | 56 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->Signature), 4, Buffer1, FALSE); 57 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->CreatorId), 4, Buffer2, FALSE); 58 | if ( Verbose ) { 59 | Print(L" %s 0x%02x %s 0x%08x", Buffer1, (int)(Ptr->Revision), Buffer2, (int)(Ptr->CreatorRevision) ); 60 | if (!AsciiStrnCmp( (CHAR8 *)&(Ptr->Signature), "SSDT`", 4)) { 61 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->OemTableId), 8, Buffer1, TRUE); 62 | Print(L" %s", Buffer1); 63 | } 64 | } else { 65 | Print(L" %s", Buffer1); 66 | } 67 | if (!AsciiStrnCmp( (CHAR8 *)&(Ptr->Signature), "FACP", 4)) { 68 | Print(L" (inc. FACS, DSDT)"); 69 | } 70 | Print(L"\n"); 71 | } 72 | 73 | 74 | static int 75 | ParseRSDP( EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp, 76 | CHAR16* GuidStr, 77 | BOOLEAN Verbose ) 78 | { 79 | EFI_ACPI_SDT_HEADER *Xsdt; 80 | UINT32 EntryCount; 81 | UINT64 *EntryPtr; 82 | CHAR16 OemStr[20]; 83 | 84 | #ifdef DEBUG 85 | Print(L"\n\nACPI GUID: %s\n", GuidStr); 86 | #endif 87 | 88 | if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) { 89 | if ( Verbose ) { 90 | AsciiToUnicodeSize((CHAR8 *)(Rsdp->OemId), 6, OemStr, FALSE); 91 | Print(L"\nRSDP Revision: %d OEM ID: %s\n", (int)(Rsdp->Revision), OemStr); 92 | } 93 | Xsdt = (EFI_ACPI_SDT_HEADER *)(Rsdp->XsdtAddress); 94 | } else { 95 | #ifdef DEBUG 96 | Print(L"ERROR: RSDP table < revision ACPI 2.0 found.\n"); 97 | #endif 98 | return 1; 99 | } 100 | 101 | if (Xsdt->Signature != SIGNATURE_32 ('X', 'S', 'D', 'T')) { 102 | Print(L"ERROR: Invalid ACPI XSDT table found.\n"); 103 | return 1; 104 | } 105 | 106 | EntryCount = (Xsdt->Length - sizeof (EFI_ACPI_SDT_HEADER)) / sizeof(UINT64); 107 | if ( Verbose ) { 108 | AsciiToUnicodeSize((CHAR8 *)(Xsdt->OemId), 6, OemStr, FALSE); 109 | Print(L"XSDT Revision: %d OEM ID: %s Entry Count: %d\n\n", (int)(Xsdt->Revision), OemStr, EntryCount); 110 | 111 | Print(L" Table Revision CreatorID CreatorRev\n"); 112 | } 113 | 114 | EntryPtr = (UINT64 *)(Xsdt + 1); 115 | for (int Index = 0; Index < EntryCount; Index++, EntryPtr++) { 116 | PrintTable((EFI_ACPI_SDT_HEADER *)((UINTN)(*EntryPtr)), Verbose); 117 | } 118 | 119 | return 0; 120 | } 121 | 122 | 123 | static void 124 | Usage( void ) 125 | { 126 | Print(L"Usage: ListACPI [-v | --verbose]\n"); 127 | Print(L" ListACPI [-V | --version]\n"); 128 | } 129 | 130 | 131 | INTN 132 | EFIAPI 133 | ShellAppMain( UINTN Argc, 134 | CHAR16 **Argv ) 135 | { 136 | EFI_CONFIGURATION_TABLE *ect = gST->ConfigurationTable; 137 | EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp = NULL; 138 | EFI_GUID gAcpi20TableGuid = EFI_ACPI_20_TABLE_GUID; 139 | EFI_GUID gAcpi10TableGuid = ACPI_10_TABLE_GUID; 140 | EFI_STATUS Status = EFI_SUCCESS; 141 | CHAR16 GuidStr[100]; 142 | BOOLEAN Verbose = FALSE; 143 | 144 | if (Argc == 2) { 145 | if (!StrCmp(Argv[1], L"--verbose") || 146 | !StrCmp(Argv[1], L"-v")) { 147 | Verbose = TRUE; 148 | } else if (!StrCmp(Argv[1], L"--version") || 149 | !StrCmp(Argv[1], L"-V")) { 150 | Print(L"Version: %s\n", UTILITY_VERSION); 151 | return Status; 152 | } else if (!StrCmp(Argv[1], L"--help") || 153 | !StrCmp(Argv[1], L"-h")) { 154 | Usage(); 155 | return Status; 156 | } else { 157 | Usage(); 158 | return Status; 159 | } 160 | } 161 | if (Argc > 2) { 162 | Usage(); 163 | return Status; 164 | } 165 | 166 | 167 | // locate RSDP (Root System Description Pointer) 168 | for (int i = 0; i < gST->NumberOfTableEntries; i++) { 169 | if ((CompareGuid (&(gST->ConfigurationTable[i].VendorGuid), &gAcpi20TableGuid)) || 170 | (CompareGuid (&(gST->ConfigurationTable[i].VendorGuid), &gAcpi10TableGuid))) { 171 | if (!AsciiStrnCmp("RSD PTR ", (CHAR8 *)(ect->VendorTable), 8)) { 172 | UnicodeSPrint(GuidStr, sizeof(GuidStr), L"%g", &(gST->ConfigurationTable[i].VendorGuid)); 173 | Rsdp = (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)ect->VendorTable; 174 | ParseRSDP(Rsdp, GuidStr, Verbose); 175 | } 176 | } 177 | ect++; 178 | } 179 | 180 | if (Rsdp == NULL) { 181 | Print(L"ERROR: Could not find an ACPI RSDP table.\n"); 182 | Status = EFI_NOT_FOUND; 183 | } 184 | 185 | return Status; 186 | } 187 | -------------------------------------------------------------------------------- /MyApps/ListACPI/ListACPI.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/ListACPI/ListACPI.efi -------------------------------------------------------------------------------- /MyApps/ListACPI/ListACPI.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ListACPI 4 | FILE_GUID = 4ea87c51-7395-4dcd-0055-747010f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | ListACPI.c 12 | 13 | [Packages] 14 | MdePkg/MdePkg.dec 15 | ShellPkg/ShellPkg.dec 16 | 17 | [LibraryClasses] 18 | ShellCEntryLib 19 | ShellLib 20 | BaseLib 21 | BaseMemoryLib 22 | UefiLib 23 | 24 | [Protocols] 25 | 26 | [BuildOptions] 27 | 28 | [Pcd] 29 | 30 | -------------------------------------------------------------------------------- /MyApps/ListCerts/ListCerts.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/ListCerts/ListCerts.efi -------------------------------------------------------------------------------- /MyApps/ListCerts/ListCerts.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | # INF_VERSION = 0x00010006 3 | INF_VERSION = 1.25 4 | BASE_NAME = ListCerts 5 | FILE_GUID = 4ea87c51-6395-3dcd-0055-747010f3ce51 6 | MODULE_TYPE = UEFI_APPLICATION 7 | VERSION_STRING = 1.0 8 | ENTRY_POINT = ShellCEntryLib 9 | VALID_ARCHITECTURES = X64 10 | 11 | [Sources.common] 12 | ListCerts.c 13 | asn1_ber_decoder.c 14 | asn1_ber_decoder.h 15 | oid_registry.c 16 | oid_registry.h 17 | oid_registry_data.h 18 | x509.c 19 | x509.h 20 | 21 | [Packages] 22 | MdePkg/MdePkg.dec 23 | ShellPkg/ShellPkg.dec 24 | 25 | 26 | [LibraryClasses] 27 | ShellCEntryLib 28 | ShellLib 29 | BaseLib 30 | BaseMemoryLib 31 | UefiLib 32 | 33 | [Protocols] 34 | 35 | [BuildOptions] 36 | 37 | [Pcd] 38 | 39 | -------------------------------------------------------------------------------- /MyApps/ListCerts/README: -------------------------------------------------------------------------------- 1 | README 2 | -------- 3 | 4 | This utility is intended to be used from the UEFI shell prompt on an X86_64 5 | platform that supports UEFI 2.3.1 Secure Boot or later. Unless you sign this 6 | utility with an appropriate key, this utility will only work on a platform where 7 | UEFI Secure Boot is disabled. 8 | 9 | Run ListCerts -h to view available options. 10 | 11 | Valid options include: 12 | 13 | -pk Display information about the PK 14 | -kek Display information about KEKs 15 | -db Display information about db keys 16 | -dbx Display information about dbx keys 17 | 18 | If invoked without an option all keys are displayed. 19 | 20 | Most of the certificate parsing code came either directly or was heavily 21 | derived from work by David Howells of Red Hat for the 3.7 kernel 22 | (see .../crypo/asymmetric_keys, .../include, .../lib, etc.) I simply modified 23 | the code to work from a UEFI shell, added appropriate OIDs, etc. 24 | 25 | Note that the files x509.[hc] only contain a subset of the X509 ASN.1 schema 26 | - not all of the X509 ASN.1 schema! 27 | -------------------------------------------------------------------------------- /MyApps/ListCerts/asn1.h: -------------------------------------------------------------------------------- 1 | /* ASN.1 BER/DER/CER encoding definitions 2 | * 3 | * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved. 4 | * Written by David Howells (dhowells@redhat.com) 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public Licence 8 | * as published by the Free Software Foundation; either version 9 | * 2 of the Licence, or (at your option) any later version. 10 | */ 11 | 12 | #ifndef _ASN1_H 13 | #define _ASN1_H 14 | 15 | /* Class */ 16 | enum asn1_class { 17 | ASN1_UNIV = 0, /* Universal */ 18 | ASN1_APPL = 1, /* Application */ 19 | ASN1_CONT = 2, /* Context */ 20 | ASN1_PRIV = 3 /* Private */ 21 | }; 22 | #define ASN1_CLASS_BITS 0xc0 23 | 24 | 25 | enum asn1_method { 26 | ASN1_PRIM = 0, /* Primitive */ 27 | ASN1_CONS = 1 /* Constructed */ 28 | }; 29 | #define ASN1_CONS_BIT 0x20 30 | 31 | /* Tag */ 32 | enum asn1_tag { 33 | ASN1_EOC = 0, /* End Of Contents or N/A */ 34 | ASN1_BOOL = 1, /* Boolean */ 35 | ASN1_INT = 2, /* Integer */ 36 | ASN1_BTS = 3, /* Bit String */ 37 | ASN1_OTS = 4, /* Octet String */ 38 | ASN1_NULL = 5, /* Null */ 39 | ASN1_OID = 6, /* Object Identifier */ 40 | ASN1_ODE = 7, /* Object Description */ 41 | ASN1_EXT = 8, /* External */ 42 | ASN1_REAL = 9, /* Real float */ 43 | ASN1_ENUM = 10, /* Enumerated */ 44 | ASN1_EPDV = 11, /* Embedded PDV */ 45 | ASN1_UTF8STR = 12, /* UTF8 String */ 46 | ASN1_RELOID = 13, /* Relative OID */ 47 | /* 14 - Reserved */ 48 | /* 15 - Reserved */ 49 | ASN1_SEQ = 16, /* Sequence and Sequence of */ 50 | ASN1_SET = 17, /* Set and Set of */ 51 | ASN1_NUMSTR = 18, /* Numerical String */ 52 | ASN1_PRNSTR = 19, /* Printable String */ 53 | ASN1_TEXSTR = 20, /* T61 String / Teletext String */ 54 | ASN1_VIDSTR = 21, /* Videotex String */ 55 | ASN1_IA5STR = 22, /* IA5 String */ 56 | ASN1_UNITIM = 23, /* Universal Time */ 57 | ASN1_GENTIM = 24, /* General Time */ 58 | ASN1_GRASTR = 25, /* Graphic String */ 59 | ASN1_VISSTR = 26, /* Visible String */ 60 | ASN1_GENSTR = 27, /* General String */ 61 | ASN1_UNISTR = 28, /* Universal String */ 62 | ASN1_CHRSTR = 29, /* Character String */ 63 | ASN1_BMPSTR = 30, /* BMP String */ 64 | ASN1_LONG_TAG = 31 /* Long form tag */ 65 | }; 66 | 67 | #endif /* _ASN1_H */ 68 | 69 | -------------------------------------------------------------------------------- /MyApps/ListCerts/asn1_ber_bytecode.h: -------------------------------------------------------------------------------- 1 | 2 | /* ASN.1 BER/DER/CER parsing state machine internal definitions 3 | * 4 | * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved. 5 | * Written by David Howells (dhowells@redhat.com) 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public Licence 9 | * as published by the Free Software Foundation; either version 10 | * 2 of the Licence, or (at your option) any later version. 11 | */ 12 | 13 | #ifndef _ASN1_BER_BYTECODE_H 14 | #define _ASN1_BER_BYTECODE_H 15 | 16 | #include "asn1.h" 17 | 18 | typedef int (*asn1_action_t)(void *context, 19 | long hdrlen, /* In case of ANY type */ 20 | unsigned char tag, /* In case of ANY type */ 21 | const void *value, long vlen); 22 | 23 | struct asn1_decoder { 24 | const unsigned char *machine; 25 | long machlen; 26 | const asn1_action_t *actions; 27 | }; 28 | 29 | enum asn1_opcode { 30 | /* The tag-matching ops come first and the odd-numbered slots 31 | * are for OR_SKIP ops. 32 | */ 33 | #define ASN1_OP_MATCH__SKIP 0x01 34 | #define ASN1_OP_MATCH__ACT 0x02 35 | #define ASN1_OP_MATCH__JUMP 0x04 36 | #define ASN1_OP_MATCH__ANY 0x08 37 | #define ASN1_OP_MATCH__COND 0x10 38 | 39 | ASN1_OP_MATCH = 0x00, 40 | ASN1_OP_MATCH_OR_SKIP = 0x01, 41 | ASN1_OP_MATCH_ACT = 0x02, 42 | ASN1_OP_MATCH_ACT_OR_SKIP = 0x03, 43 | ASN1_OP_MATCH_JUMP = 0x04, 44 | ASN1_OP_MATCH_JUMP_OR_SKIP = 0x05, 45 | ASN1_OP_MATCH_ANY = 0x08, 46 | ASN1_OP_MATCH_ANY_ACT = 0x0a, 47 | /* Everything before here matches unconditionally */ 48 | 49 | ASN1_OP_COND_MATCH_OR_SKIP = 0x11, 50 | ASN1_OP_COND_MATCH_ACT_OR_SKIP = 0x13, 51 | ASN1_OP_COND_MATCH_JUMP_OR_SKIP = 0x15, 52 | ASN1_OP_COND_MATCH_ANY = 0x18, 53 | ASN1_OP_COND_MATCH_ANY_ACT = 0x1a, 54 | 55 | /* Everything before here will want a tag from the data */ 56 | #define ASN1_OP__MATCHES_TAG ASN1_OP_COND_MATCH_ANY_ACT 57 | 58 | /* These are here to help fill up space */ 59 | ASN1_OP_COND_FAIL = 0x1b, 60 | ASN1_OP_COMPLETE = 0x1c, 61 | ASN1_OP_ACT = 0x1d, 62 | ASN1_OP_RETURN = 0x1e, 63 | 64 | /* The following eight have bit 0 -> SET, 1 -> OF, 2 -> ACT */ 65 | ASN1_OP_END_SEQ = 0x20, 66 | ASN1_OP_END_SET = 0x21, 67 | ASN1_OP_END_SEQ_OF = 0x22, 68 | ASN1_OP_END_SET_OF = 0x23, 69 | ASN1_OP_END_SEQ_ACT = 0x24, 70 | ASN1_OP_END_SET_ACT = 0x25, 71 | ASN1_OP_END_SEQ_OF_ACT = 0x26, 72 | ASN1_OP_END_SET_OF_ACT = 0x27, 73 | #define ASN1_OP_END__SET 0x01 74 | #define ASN1_OP_END__OF 0x02 75 | #define ASN1_OP_END__ACT 0x04 76 | 77 | ASN1_OP__NR 78 | }; 79 | 80 | #define _tag(CLASS, CP, TAG) ((ASN1_##CLASS << 6) | (ASN1_##CP << 5) | ASN1_##TAG) 81 | #define _tagn(CLASS, CP, TAG) ((ASN1_##CLASS << 6) | (ASN1_##CP << 5) | TAG) 82 | #define _jump_target(N) (N) 83 | #define _action(N) (N) 84 | 85 | #endif /* _ASN1_BER_BYTECODE_H */ 86 | 87 | -------------------------------------------------------------------------------- /MyApps/ListCerts/asn1_ber_decoder.h: -------------------------------------------------------------------------------- 1 | /* ASN.1 decoder 2 | * 3 | * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved. 4 | * Written by David Howells (dhowells@redhat.com) 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public Licence 8 | * as published by the Free Software Foundation; either version 9 | * 2 of the Licence, or (at your option) any later version. 10 | */ 11 | 12 | /* 13 | * Copyright (c) 2018 Finnbarr P. Murphy. All rights reserved. 14 | * 15 | * Modified to work in UDK2017 environment. 16 | * 17 | */ 18 | 19 | 20 | #ifndef _ASN1_DECODER_H 21 | #define _ASN1_DECODER_H 22 | 23 | /* FPM - hack to handle any size_t issues */ 24 | typedef long size_t __attribute__((aligned (8))); 25 | #define unlikely(x) (x) 26 | 27 | 28 | #include "asn1.h" 29 | 30 | struct asn1_decoder; 31 | 32 | extern int 33 | asn1_ber_decoder( const struct asn1_decoder *decoder, 34 | void *context, 35 | const unsigned char *data, 36 | size_t datalen ); 37 | 38 | #endif /* _ASN1_DECODER_H */ 39 | -------------------------------------------------------------------------------- /MyApps/ListCerts/oid_registry.c: -------------------------------------------------------------------------------- 1 | /* ASN.1 Object identifier (OID) registry 2 | * 3 | * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved. 4 | * Written by David Howells (dhowells@redhat.com) 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public Licence 8 | * as published by the Free Software Foundation; either version 9 | * 2 of the Licence, or (at your option) any later version. 10 | */ 11 | 12 | /* 13 | * Copyright (c) 2018 Finnbarr P. Murphy. All rights reserved. 14 | * 15 | * Modified to work in UDK2017 environment. 16 | * 17 | */ 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "oid_registry.h" 32 | #include "oid_registry_data.h" 33 | 34 | /* 35 | * Find an OID registration for the specified data 36 | * @data: Binary representation of the OID 37 | * @datasize: Size of the binary representation 38 | */ 39 | enum OID 40 | Lookup_OID(const void *data, long datasize) 41 | { 42 | const unsigned char *octets = data; 43 | enum OID oid; 44 | unsigned char xhash; 45 | unsigned i, j, k, hash; 46 | long len; 47 | 48 | /* Hash the OID data */ 49 | hash = datasize - 1; 50 | for (i = 0; i < datasize; i++) 51 | hash += octets[i] * 33; 52 | hash = (hash >> 24) ^ (hash >> 16) ^ (hash >> 8) ^ hash; 53 | hash &= 0xff; 54 | 55 | /* Binary search the OID registry. OIDs are stored in ascending order 56 | * of hash value then ascending order of size and then in ascending 57 | * order of reverse value. 58 | */ 59 | i = 0; 60 | k = OID__NR; 61 | while (i < k) { 62 | j = (i + k) / 2; 63 | 64 | xhash = oid_search_table[j].hash; 65 | if (xhash > hash) { 66 | k = j; 67 | continue; 68 | } 69 | if (xhash < hash) { 70 | i = j + 1; 71 | continue; 72 | } 73 | 74 | oid = oid_search_table[j].oid; 75 | len = oid_index[oid + 1] - oid_index[oid]; 76 | if (len > datasize) { 77 | k = j; 78 | continue; 79 | } 80 | if (len < datasize) { 81 | i = j + 1; 82 | continue; 83 | } 84 | 85 | /* Variation is most likely to be at the tail end of the 86 | * OID, so do the comparison in reverse. 87 | */ 88 | while (len > 0) { 89 | unsigned char a = oid_data[oid_index[oid] + --len]; 90 | unsigned char b = octets[len]; 91 | if (a > b) { 92 | k = j; 93 | goto next; 94 | } 95 | if (a < b) { 96 | i = j + 1; 97 | goto next; 98 | } 99 | } 100 | return oid; 101 | next: 102 | ; 103 | } 104 | 105 | return OID__NR; 106 | } 107 | 108 | 109 | /* 110 | * Print an Object Identifier into a buffer 111 | * @data: The encoded OID to print 112 | * @datasize: The size of the encoded OID 113 | * @buffer: The buffer to render into 114 | * @bufsize: The size of the buffer 115 | * 116 | * The OID is rendered into the buffer in "a.b.c.d" format and the number of 117 | * bytes is returned. -EBADMSG is returned if the data could not be intepreted 118 | * and -ENOBUFS if the buffer was too small. 119 | */ 120 | int 121 | Sprint_OID(const void *data, long datasize, CHAR16 *buffer, long bufsize) 122 | { 123 | const unsigned char *v = data, *end = v + datasize; 124 | UINT64 num; 125 | UINT8 n; 126 | long ret; 127 | int count; 128 | 129 | if (v >= end) 130 | return -EBADMSG; 131 | 132 | n = (UINT8)*v++; 133 | UnicodeSPrint(buffer, (UINTN)bufsize, (CHAR16 *)L"%d.%d", n / 40, n % 40); 134 | ret = count = StrLen(buffer); 135 | buffer += count; 136 | bufsize -= count; 137 | if (bufsize == 0) 138 | return -ENOBUFS; 139 | 140 | while (v < end) { 141 | num = 0; 142 | n = (UINT8)*v++; 143 | if (!(n & 0x80)) { 144 | num = n; 145 | } else { 146 | num = n & 0x7f; 147 | do { 148 | if (v >= end) 149 | return -EBADMSG; 150 | n = (UINT8)*v++; 151 | num <<= 7; 152 | num |= n & 0x7f; 153 | } while (n & 0x80); 154 | } 155 | UnicodeSPrint(buffer, (UINTN)bufsize, (CHAR16 *)L".%ld", num); 156 | ret += count = StrLen(buffer); 157 | buffer += count; 158 | bufsize -= count; 159 | if (bufsize == 0) 160 | return -ENOBUFS; 161 | } 162 | 163 | return ret; 164 | } 165 | -------------------------------------------------------------------------------- /MyApps/ListCerts/oid_registry.h: -------------------------------------------------------------------------------- 1 | /* ASN.1 Object identifier (OID) registry 2 | * 3 | * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved. 4 | * Written by David Howells (dhowells@redhat.com) 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public Licence 8 | * as published by the Free Software Foundation; either version 9 | * 2 of the Licence, or (at your option) any later version. 10 | */ 11 | 12 | 13 | /* 14 | * Copyright (c) 2012 Finnbarr P. Murphy. All rights reserved. 15 | * 16 | * Modified to work in EFI environment. Added some Microsoft OIDs 17 | * 18 | */ 19 | 20 | 21 | #ifndef _OID_REGISTRY_H 22 | #define _OID_REGISTRY_H 23 | 24 | /* 25 | * OIDs are turned into these values if possible, or OID__NR if not held here. 26 | * 27 | * NOTE! Do not mess with the format of each line as this is read by 28 | * build_oid_registry_data.pl to generate the data for Lookup_OID. 29 | * 30 | * If you add or remove entries, you must rebuild oid_registry_data.c 31 | */ 32 | enum OID { 33 | OID_id_dsa_with_sha1, /* 1.2.840.10030.4.3 */ 34 | OID_id_dsa, /* 1.2.840.10040.4.1 */ 35 | OID_id_ecdsa_with_sha1, /* 1.2.840.10045.4.1 */ 36 | OID_id_ecPublicKey, /* 1.2.840.10045.2.1 */ 37 | 38 | /* PKCS#1 {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-1(1)} */ 39 | OID_rsaEncryption, /* 1.2.840.113549.1.1.1 */ 40 | OID_md2WithRSAEncryption, /* 1.2.840.113549.1.1.2 */ 41 | OID_md3WithRSAEncryption, /* 1.2.840.113549.1.1.3 */ 42 | OID_md4WithRSAEncryption, /* 1.2.840.113549.1.1.4 */ 43 | OID_sha1WithRSAEncryption, /* 1.2.840.113549.1.1.5 */ 44 | OID_sha256WithRSAEncryption, /* 1.2.840.113549.1.1.11 */ 45 | OID_sha384WithRSAEncryption, /* 1.2.840.113549.1.1.12 */ 46 | OID_sha512WithRSAEncryption, /* 1.2.840.113549.1.1.13 */ 47 | OID_sha224WithRSAEncryption, /* 1.2.840.113549.1.1.14 */ 48 | 49 | /* PKCS#7 {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-7(7)} */ 50 | OID_data, /* 1.2.840.113549.1.7.1 */ 51 | OID_signed_data, /* 1.2.840.113549.1.7.2 */ 52 | 53 | /* PKCS#9 {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-9(9)} */ 54 | OID_email_address, /* 1.2.840.113549.1.9.1 */ 55 | OID_content_type, /* 1.2.840.113549.1.9.3 */ 56 | OID_messageDigest, /* 1.2.840.113549.1.9.4 */ 57 | OID_signingTime, /* 1.2.840.113549.1.9.5 */ 58 | OID_smimeCapabilites, /* 1.2.840.113549.1.9.15 */ 59 | OID_smimeAuthenticatedAttrs, /* 1.2.840.113549.1.9.16.2.11 */ 60 | 61 | /* {iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2)} */ 62 | OID_md2, /* 1.2.840.113549.2.2 */ 63 | OID_md4, /* 1.2.840.113549.2.4 */ 64 | OID_md5, /* 1.2.840.113549.2.5 */ 65 | 66 | /* Microsoft OIDs */ 67 | OID_msOutlookExpress, /* 1.3.6.1.4.1.311.16.4 */ 68 | OID_msEnrollCerttypeExtension, /* 1.3.6.1.4.1.311.20.2 */ 69 | OID_msCertsrvCAVersion, /* 1.3.6.1.4.1.311.21.1 */ 70 | OID_msCertsrvPreviousCertHash, /* 1.3.6.1.4.1.311.21.2 */ 71 | 72 | OID_certAuthInfoAccess, /* 1.3.6.1.5.5.7.1.1 */ 73 | OID_sha1, /* 1.3.14.3.2.26 */ 74 | 75 | /* Distinguished Name attribute IDs [RFC 2256] */ 76 | OID_commonName, /* 2.5.4.3 */ 77 | OID_surname, /* 2.5.4.4 */ 78 | OID_countryName, /* 2.5.4.6 */ 79 | OID_locality, /* 2.5.4.7 */ 80 | OID_stateOrProvinceName, /* 2.5.4.8 */ 81 | OID_organizationName, /* 2.5.4.10 */ 82 | OID_organizationUnitName, /* 2.5.4.11 */ 83 | OID_title, /* 2.5.4.12 */ 84 | OID_description, /* 2.5.4.13 */ 85 | OID_name, /* 2.5.4.41 */ 86 | OID_givenName, /* 2.5.4.42 */ 87 | OID_initials, /* 2.5.4.43 */ 88 | OID_generationalQualifier, /* 2.5.4.44 */ 89 | 90 | /* Certificate extension IDs */ 91 | OID_subjectKeyIdentifier, /* 2.5.29.14 */ 92 | OID_keyUsage, /* 2.5.29.15 */ 93 | OID_subjectAltName, /* 2.5.29.17 */ 94 | OID_issuerAltName, /* 2.5.29.18 */ 95 | OID_basicConstraints, /* 2.5.29.19 */ 96 | OID_crlDistributionPoints, /* 2.5.29.31 */ 97 | OID_certPolicies, /* 2.5.29.32 */ 98 | OID_authorityKeyIdentifier, /* 2.5.29.35 */ 99 | OID_extKeyUsage, /* 2.5.29.37 */ 100 | 101 | OID__NR 102 | }; 103 | 104 | extern enum OID Lookup_OID(const void *data, long datasize); 105 | extern int Sprint_OID(const void *, long, CHAR16 *, long); 106 | 107 | #endif /* _OID_REGISTRY_H */ 108 | -------------------------------------------------------------------------------- /MyApps/ListCerts/oid_registry_data.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Automatically generated by build_oid_registry_data.py. Do not edit 3 | */ 4 | 5 | static const unsigned short oid_index[OID__NR + 1] = { 6 | [OID_id_dsa_with_sha1] = 0, 7 | [OID_id_dsa] = 7, 8 | [OID_id_ecdsa_with_sha1] = 14, 9 | [OID_id_ecPublicKey] = 21, 10 | [OID_rsaEncryption] = 28, 11 | [OID_md2WithRSAEncryption] = 37, 12 | [OID_md3WithRSAEncryption] = 46, 13 | [OID_md4WithRSAEncryption] = 55, 14 | [OID_sha1WithRSAEncryption] = 64, 15 | [OID_sha256WithRSAEncryption] = 73, 16 | [OID_sha384WithRSAEncryption] = 82, 17 | [OID_sha512WithRSAEncryption] = 91, 18 | [OID_sha224WithRSAEncryption] = 100, 19 | [OID_data] = 109, 20 | [OID_signed_data] = 118, 21 | [OID_email_address] = 127, 22 | [OID_content_type] = 136, 23 | [OID_messageDigest] = 145, 24 | [OID_signingTime] = 154, 25 | [OID_smimeCapabilites] = 163, 26 | [OID_smimeAuthenticatedAttrs] = 172, 27 | [OID_md2] = 183, 28 | [OID_md4] = 191, 29 | [OID_md5] = 199, 30 | [OID_msOutlookExpress] = 207, 31 | [OID_msEnrollCerttypeExtension] = 216, 32 | [OID_msCertsrvCAVersion] = 225, 33 | [OID_msCertsrvPreviousCertHash] = 234, 34 | [OID_certAuthInfoAccess] = 243, 35 | [OID_sha1] = 251, 36 | [OID_commonName] = 256, 37 | [OID_surname] = 259, 38 | [OID_countryName] = 262, 39 | [OID_locality] = 265, 40 | [OID_stateOrProvinceName] = 268, 41 | [OID_organizationName] = 271, 42 | [OID_organizationUnitName] = 274, 43 | [OID_title] = 277, 44 | [OID_description] = 280, 45 | [OID_name] = 283, 46 | [OID_givenName] = 286, 47 | [OID_initials] = 289, 48 | [OID_generationalQualifier] = 292, 49 | [OID_subjectKeyIdentifier] = 295, 50 | [OID_keyUsage] = 298, 51 | [OID_subjectAltName] = 301, 52 | [OID_issuerAltName] = 304, 53 | [OID_basicConstraints] = 307, 54 | [OID_crlDistributionPoints] = 310, 55 | [OID_certPolicies] = 313, 56 | [OID_authorityKeyIdentifier] = 316, 57 | [OID_extKeyUsage] = 319, 58 | [OID__NR] = 322 59 | }; 60 | 61 | static const unsigned char oid_data[322] = { 62 | 42, 134, 72, 206, 46, 4, 3, // id_dsa_with_sha1 63 | 42, 134, 72, 206, 56, 4, 1, // id_dsa 64 | 42, 134, 72, 206, 61, 4, 1, // id_ecdsa_with_sha1 65 | 42, 134, 72, 206, 61, 2, 1, // id_ecPublicKey 66 | 42, 134, 72, 134, 247, 13, 1, 1, 1, // rsaEncryption 67 | 42, 134, 72, 134, 247, 13, 1, 1, 2, // md2WithRSAEncryption 68 | 42, 134, 72, 134, 247, 13, 1, 1, 3, // md3WithRSAEncryption 69 | 42, 134, 72, 134, 247, 13, 1, 1, 4, // md4WithRSAEncryption 70 | 42, 134, 72, 134, 247, 13, 1, 1, 5, // sha1WithRSAEncryption 71 | 42, 134, 72, 134, 247, 13, 1, 1, 11, // sha256WithRSAEncryption 72 | 42, 134, 72, 134, 247, 13, 1, 1, 12, // sha384WithRSAEncryption 73 | 42, 134, 72, 134, 247, 13, 1, 1, 13, // sha512WithRSAEncryption 74 | 42, 134, 72, 134, 247, 13, 1, 1, 14, // sha224WithRSAEncryption 75 | 42, 134, 72, 134, 247, 13, 1, 7, 1, // data 76 | 42, 134, 72, 134, 247, 13, 1, 7, 2, // signed_data 77 | 42, 134, 72, 134, 247, 13, 1, 9, 1, // email_address 78 | 42, 134, 72, 134, 247, 13, 1, 9, 3, // content_type 79 | 42, 134, 72, 134, 247, 13, 1, 9, 4, // messageDigest 80 | 42, 134, 72, 134, 247, 13, 1, 9, 5, // signingTime 81 | 42, 134, 72, 134, 247, 13, 1, 9, 15, // smimeCapabilites 82 | 42, 134, 72, 134, 247, 13, 1, 9, 16, 2, 11, // smimeAuthenticatedAttrs 83 | 42, 134, 72, 134, 247, 13, 2, 2, // md2 84 | 42, 134, 72, 134, 247, 13, 2, 4, // md4 85 | 42, 134, 72, 134, 247, 13, 2, 5, // md5 86 | 43, 6, 1, 4, 1, 130, 55, 16, 4, // msOutlookExpress 87 | 43, 6, 1, 4, 1, 130, 55, 20, 2, // msEnrollCerttypeExtension 88 | 43, 6, 1, 4, 1, 130, 55, 21, 1, // msCertsrvCAVersion 89 | 43, 6, 1, 4, 1, 130, 55, 21, 2, // msCertsrvPreviousCertHash 90 | 43, 6, 1, 5, 5, 7, 1, 1, // certAuthInfoAccess 91 | 43, 14, 3, 2, 26, // sha1 92 | 85, 4, 3, // commonName 93 | 85, 4, 4, // surname 94 | 85, 4, 6, // countryName 95 | 85, 4, 7, // locality 96 | 85, 4, 8, // stateOrProvinceName 97 | 85, 4, 10, // organizationName 98 | 85, 4, 11, // organizationUnitName 99 | 85, 4, 12, // title 100 | 85, 4, 13, // description 101 | 85, 4, 41, // name 102 | 85, 4, 42, // givenName 103 | 85, 4, 43, // initials 104 | 85, 4, 44, // generationalQualifier 105 | 85, 29, 14, // subjectKeyIdentifier 106 | 85, 29, 15, // keyUsage 107 | 85, 29, 17, // subjectAltName 108 | 85, 29, 18, // issuerAltName 109 | 85, 29, 19, // basicConstraints 110 | 85, 29, 31, // crlDistributionPoints 111 | 85, 29, 32, // certPolicies 112 | 85, 29, 35, // authorityKeyIdentifier 113 | 85, 29, 37, // extKeyUsage 114 | }; 115 | 116 | static const struct { 117 | unsigned char hash; 118 | enum OID oid : 8; 119 | } oid_search_table[OID__NR] = { 120 | [ 0] = { 10, OID_title }, // 55040c 121 | [ 1] = { 23, OID_issuerAltName }, // 551d12 122 | [ 2] = { 23, OID_initials }, // 55042b 123 | [ 3] = { 29, OID_md2WithRSAEncryption }, // 2a864886f70d010102 124 | [ 4] = { 30, OID_md2 }, // 2a864886f70d0202 125 | [ 5] = { 32, OID_id_dsa_with_sha1 }, // 2a8648ce2e0403 126 | [ 6] = { 35, OID_content_type }, // 2a864886f70d010903 127 | [ 7] = { 35, OID_sha256WithRSAEncryption }, // 2a864886f70d01010b 128 | [ 8] = { 36, OID_authorityKeyIdentifier }, // 551d23 129 | [ 9] = { 37, OID_description }, // 55040d 130 | [ 10] = { 43, OID_id_dsa }, // 2a8648ce380401 131 | [ 11] = { 54, OID_basicConstraints }, // 551d13 132 | [ 12] = { 54, OID_generationalQualifier }, // 55042c 133 | [ 13] = { 60, OID_md3WithRSAEncryption }, // 2a864886f70d010103 134 | [ 14] = { 64, OID_signed_data }, // 2a864886f70d010702 135 | [ 15] = { 77, OID_countryName }, // 550406 136 | [ 16] = { 77, OID_id_ecdsa_with_sha1 }, // 2a8648ce3d0401 137 | [ 17] = { 85, OID_smimeCapabilites }, // 2a864886f70d01090f 138 | [ 18] = { 87, OID_sha1 }, // 2b0e03021a 139 | [ 19] = { 97, OID_email_address }, // 2a864886f70d010901 140 | [ 20] = { 106, OID_extKeyUsage }, // 551d25 141 | [ 21] = { 110, OID_locality }, // 550407 142 | [ 22] = { 126, OID_rsaEncryption }, // 2a864886f70d010101 143 | [ 23] = { 132, OID_smimeAuthenticatedAttrs }, // 2a864886f70d010910020b 144 | [ 24] = { 142, OID_id_ecPublicKey }, // 2a8648ce3d0201 145 | [ 25] = { 142, OID_sha224WithRSAEncryption }, // 2a864886f70d01010e 146 | [ 26] = { 143, OID_stateOrProvinceName }, // 550408 147 | [ 27] = { 146, OID_subjectKeyIdentifier }, // 551d0e 148 | [ 28] = { 160, OID_data }, // 2a864886f70d010701 149 | [ 29] = { 161, OID_crlDistributionPoints }, // 551d1f 150 | [ 30] = { 173, OID_msOutlookExpress }, // 2b0601040182371004 151 | [ 31] = { 179, OID_keyUsage }, // 551d0f 152 | [ 32] = { 195, OID_md4WithRSAEncryption }, // 2a864886f70d010104 153 | [ 33] = { 198, OID_certPolicies }, // 551d20 154 | [ 34] = { 201, OID_organizationName }, // 55040a 155 | [ 35] = { 204, OID_messageDigest }, // 2a864886f70d010904 156 | [ 36] = { 204, OID_sha384WithRSAEncryption }, // 2a864886f70d01010c 157 | [ 37] = { 206, OID_msCertsrvPreviousCertHash }, // 2b0601040182371502 158 | [ 38] = { 212, OID_name }, // 550429 159 | [ 39] = { 213, OID_commonName }, // 550403 160 | [ 40] = { 220, OID_md4 }, // 2a864886f70d0204 161 | [ 41] = { 226, OID_sha1WithRSAEncryption }, // 2a864886f70d010105 162 | [ 42] = { 227, OID_md5 }, // 2a864886f70d0205 163 | [ 43] = { 228, OID_certAuthInfoAccess }, // 2b06010505070101 164 | [ 44] = { 234, OID_organizationUnitName }, // 55040b 165 | [ 45] = { 237, OID_signingTime }, // 2a864886f70d010905 166 | [ 46] = { 237, OID_sha512WithRSAEncryption }, // 2a864886f70d01010d 167 | [ 47] = { 239, OID_msCertsrvCAVersion }, // 2b0601040182371501 168 | [ 48] = { 239, OID_msEnrollCerttypeExtension }, // 2b0601040182371402 169 | [ 49] = { 244, OID_surname }, // 550404 170 | [ 50] = { 245, OID_subjectAltName }, // 551d11 171 | [ 51] = { 245, OID_givenName }, // 55042a 172 | }; 173 | -------------------------------------------------------------------------------- /MyApps/ListCerts/x509.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Automatically generated by ASN1 compiler. Do not manually edit! 3 | * 4 | * ASN.1 parser for x509 5 | */ 6 | 7 | #include "asn1_ber_bytecode.h" 8 | #include "x509.h" 9 | 10 | enum x509_actions { 11 | ACT_do_algorithm = 0, 12 | ACT_do_attribute_type = 1, 13 | ACT_do_attribute_value = 2, 14 | ACT_do_extension_id = 3, 15 | ACT_do_extensions = 4, 16 | ACT_do_issuer = 5, 17 | ACT_do_serialnumber = 6, 18 | ACT_do_signature = 7, 19 | ACT_do_subject = 8, 20 | ACT_do_subject_public_key_info = 9, 21 | ACT_do_validity_not_after = 10, 22 | ACT_do_validity_not_before = 11, 23 | ACT_do_version = 12, 24 | NR__x509_actions = 13 25 | }; 26 | 27 | static const asn1_action_t x509_action_table[NR__x509_actions] = { 28 | [ 0] = do_algorithm, 29 | [ 1] = do_attribute_type, 30 | [ 2] = do_attribute_value, 31 | [ 3] = do_extension_id, 32 | [ 4] = do_extensions, 33 | [ 5] = do_issuer, 34 | [ 6] = do_serialnumber, 35 | [ 7] = do_signature, 36 | [ 8] = do_subject, 37 | [ 9] = do_subject_public_key_info, 38 | [ 10] = do_validity_not_after, 39 | [ 11] = do_validity_not_before, 40 | [ 12] = do_version, 41 | }; 42 | 43 | static const unsigned char x509_machine[] = { 44 | // Certificate 45 | [ 0] = ASN1_OP_MATCH, 46 | [ 1] = _tag(UNIV, CONS, SEQ), 47 | // TBSCertificate 48 | [ 2] = ASN1_OP_MATCH, 49 | [ 3] = _tag(UNIV, CONS, SEQ), 50 | [ 4] = ASN1_OP_MATCH_JUMP_OR_SKIP, // version 51 | [ 5] = _tagn(CONT, CONS, 0), 52 | [ 6] = _jump_target(67), 53 | // CertificateSerialNumber 54 | [ 7] = ASN1_OP_MATCH_ACT, 55 | [ 8] = _tag(UNIV, PRIM, INT), 56 | [ 9] = _action(ACT_do_serialnumber), 57 | // AlgorithmIdentifier 58 | [ 10] = ASN1_OP_MATCH_JUMP, 59 | [ 11] = _tag(UNIV, CONS, SEQ), 60 | [ 12] = _jump_target(72), // --> AlgorithmIdentifier 61 | [ 13] = ASN1_OP_ACT, 62 | [ 14] = _action(ACT_do_signature), 63 | // Name 64 | [ 15] = ASN1_OP_MATCH_JUMP, 65 | [ 16] = _tag(UNIV, CONS, SEQ), 66 | [ 17] = _jump_target(78), // --> Name 67 | [ 18] = ASN1_OP_ACT, 68 | [ 19] = _action(ACT_do_issuer), 69 | // Validity 70 | [ 20] = ASN1_OP_MATCH, 71 | [ 21] = _tag(UNIV, CONS, SEQ), 72 | // Time 73 | [ 22] = ASN1_OP_MATCH_OR_SKIP, // utcTime 74 | [ 23] = _tag(UNIV, PRIM, UNITIM), 75 | [ 24] = ASN1_OP_COND_MATCH_OR_SKIP, // generalTime 76 | [ 25] = _tag(UNIV, PRIM, GENTIM), 77 | [ 26] = ASN1_OP_COND_FAIL, 78 | [ 27] = ASN1_OP_ACT, 79 | [ 28] = _action(ACT_do_validity_not_before), 80 | // Time 81 | [ 29] = ASN1_OP_MATCH_OR_SKIP, // utcTime 82 | [ 30] = _tag(UNIV, PRIM, UNITIM), 83 | [ 31] = ASN1_OP_COND_MATCH_OR_SKIP, // generalTime 84 | [ 32] = _tag(UNIV, PRIM, GENTIM), 85 | [ 33] = ASN1_OP_COND_FAIL, 86 | [ 34] = ASN1_OP_ACT, 87 | [ 35] = _action(ACT_do_validity_not_after), 88 | [ 36] = ASN1_OP_END_SEQ, 89 | // Name 90 | [ 37] = ASN1_OP_MATCH_JUMP, 91 | [ 38] = _tag(UNIV, CONS, SEQ), 92 | [ 39] = _jump_target(78), // --> Name 93 | [ 40] = ASN1_OP_ACT, 94 | [ 41] = _action(ACT_do_subject), 95 | // SubjectPublicKeyInfo 96 | [ 42] = ASN1_OP_MATCH, 97 | [ 43] = _tag(UNIV, CONS, SEQ), 98 | // AlgorithmIdentifier 99 | [ 44] = ASN1_OP_MATCH_JUMP, 100 | [ 45] = _tag(UNIV, CONS, SEQ), 101 | [ 46] = _jump_target(72), // --> AlgorithmIdentifier 102 | [ 47] = ASN1_OP_MATCH, // subjectPublicKey 103 | [ 48] = _tag(UNIV, PRIM, BTS), 104 | [ 49] = ASN1_OP_END_SEQ, 105 | [ 50] = ASN1_OP_ACT, 106 | [ 51] = _action(ACT_do_subject_public_key_info), 107 | // UniqueIdentifier 108 | [ 52] = ASN1_OP_MATCH_OR_SKIP, 109 | [ 53] = _tagn(CONT, PRIM, 1), 110 | // UniqueIdentifier 111 | [ 54] = ASN1_OP_MATCH_OR_SKIP, 112 | [ 55] = _tagn(CONT, PRIM, 2), 113 | [ 56] = ASN1_OP_MATCH_JUMP_OR_SKIP, // extensions 114 | [ 57] = _tagn(CONT, CONS, 3), 115 | [ 58] = _jump_target(93), 116 | [ 59] = ASN1_OP_END_SEQ, 117 | // AlgorithmIdentifier 118 | [ 60] = ASN1_OP_MATCH_JUMP, 119 | [ 61] = _tag(UNIV, CONS, SEQ), 120 | [ 62] = _jump_target(72), // --> AlgorithmIdentifier 121 | [ 63] = ASN1_OP_MATCH, // signature 122 | [ 64] = _tag(UNIV, PRIM, BTS), 123 | [ 65] = ASN1_OP_END_SEQ, 124 | [ 66] = ASN1_OP_COMPLETE, 125 | 126 | // Version 127 | [ 67] = ASN1_OP_MATCH_ACT, 128 | [ 68] = _tag(UNIV, PRIM, INT), 129 | [ 69] = _action(ACT_do_version), 130 | [ 70] = ASN1_OP_END_SEQ, 131 | [ 71] = ASN1_OP_RETURN, 132 | 133 | [ 72] = ASN1_OP_MATCH_ACT, // algorithm 134 | [ 73] = _tag(UNIV, PRIM, OID), 135 | [ 74] = _action(ACT_do_algorithm), 136 | [ 75] = ASN1_OP_MATCH_ANY, // parameters 137 | [ 76] = ASN1_OP_END_SEQ, 138 | [ 77] = ASN1_OP_RETURN, 139 | 140 | // RelativeDistinguishedName 141 | [ 78] = ASN1_OP_MATCH, 142 | [ 79] = _tag(UNIV, CONS, SET), 143 | // AttributeValueAssertion 144 | [ 80] = ASN1_OP_MATCH, 145 | [ 81] = _tag(UNIV, CONS, SEQ), 146 | [ 82] = ASN1_OP_MATCH_ACT, // attributeType 147 | [ 83] = _tag(UNIV, PRIM, OID), 148 | [ 84] = _action(ACT_do_attribute_type), 149 | [ 85] = ASN1_OP_MATCH_ANY_ACT, // attributeValue 150 | [ 86] = _action(ACT_do_attribute_value), 151 | [ 87] = ASN1_OP_END_SEQ, 152 | [ 88] = ASN1_OP_END_SET_OF, 153 | [ 89] = _jump_target(80), 154 | [ 90] = ASN1_OP_END_SEQ_OF, 155 | [ 91] = _jump_target(78), 156 | [ 92] = ASN1_OP_RETURN, 157 | 158 | // Extensions 159 | [ 93] = ASN1_OP_MATCH, 160 | [ 94] = _tag(UNIV, CONS, SEQ), 161 | // Extension 162 | [ 95] = ASN1_OP_MATCH, 163 | [ 96] = _tag(UNIV, CONS, SEQ), 164 | [ 97] = ASN1_OP_MATCH_ACT, // extId 165 | [ 98] = _tag(UNIV, PRIM, OID), 166 | [ 99] = _action(ACT_do_extension_id), 167 | [ 100] = ASN1_OP_MATCH_OR_SKIP, // critical 168 | [ 101] = _tag(UNIV, PRIM, BOOL), 169 | [ 102] = ASN1_OP_MATCH, // extValue 170 | [ 103] = _tag(UNIV, PRIM, OTS), 171 | [ 104] = ASN1_OP_END_SEQ, 172 | [ 105] = ASN1_OP_END_SEQ_OF, 173 | [ 106] = _jump_target(95), 174 | [ 107] = ASN1_OP_ACT, 175 | [ 108] = _action(ACT_do_extensions), 176 | [ 109] = ASN1_OP_END_SEQ, 177 | [ 110] = ASN1_OP_RETURN, 178 | }; 179 | 180 | const struct asn1_decoder x509_decoder = { 181 | .machine = x509_machine, 182 | .machlen = sizeof(x509_machine), 183 | .actions = x509_action_table, 184 | }; 185 | -------------------------------------------------------------------------------- /MyApps/ListCerts/x509.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Automatically generated by ASN1 compiler. Do not manually edit! 3 | * 4 | * ASN.1 parser for x509 5 | */ 6 | 7 | #include "asn1_ber_bytecode.h" 8 | 9 | extern const struct asn1_decoder x509_decoder; 10 | 11 | extern int do_algorithm(void *, long, unsigned char, const void *, long); 12 | extern int do_attribute_type(void *, long, unsigned char, const void *, long); 13 | extern int do_attribute_value(void *, long, unsigned char, const void *, long); 14 | extern int do_extension_id(void *, long, unsigned char, const void *, long); 15 | extern int do_extensions(void *, long, unsigned char, const void *, long); 16 | extern int do_issuer(void *, long, unsigned char, const void *, long); 17 | extern int do_serialnumber(void *, long, unsigned char, const void *, long); 18 | extern int do_signature(void *, long, unsigned char, const void *, long); 19 | extern int do_subject(void *, long, unsigned char, const void *, long); 20 | extern int do_subject_public_key_info(void *, long, unsigned char, const void *, long); 21 | extern int do_validity_not_after(void *, long, unsigned char, const void *, long); 22 | extern int do_validity_not_before(void *, long, unsigned char, const void *, long); 23 | extern int do_version(void *, long, unsigned char, const void *, long); 24 | 25 | -------------------------------------------------------------------------------- /MyApps/MyApps.dec: -------------------------------------------------------------------------------- 1 | 2 | [Defines] 3 | DEC_SPECIFICATION = 0x00010005 4 | PACKAGE_NAME = MyApps 5 | PACKAGE_GUID = B3E3D3D5-D62B-4497-A175-264F489D127E 6 | PACKAGE_VERSION = 0.01 7 | 8 | [Guids] 9 | 10 | [PcdsFixedAtBuild] 11 | -------------------------------------------------------------------------------- /MyApps/MyApps.dsc: -------------------------------------------------------------------------------- 1 | 2 | [Defines] 3 | PLATFORM_NAME = MyApps 4 | PLATFORM_GUID = 0458dade-8b6e-4e45-b773-1b27cbda3e06 5 | PLATFORM_VERSION = 0.01 6 | DSC_SPECIFICATION = 0x00010006 7 | OUTPUT_DIRECTORY = Build/MyApps 8 | SUPPORTED_ARCHITECTURES = X64 9 | BUILD_TARGETS = DEBUG|RELEASE|NOOPT 10 | SKUID_IDENTIFIER = DEFAULT 11 | 12 | # 13 | # Debug output control 14 | # 15 | DEFINE DEBUG_ENABLE_OUTPUT = FALSE # Set to TRUE to enable debug output 16 | DEFINE DEBUG_PRINT_ERROR_LEVEL = 0x80000040 # Flags to control amount of debug output 17 | DEFINE DEBUG_PROPERTY_MASK = 0 18 | 19 | [PcdsFeatureFlag] 20 | 21 | [PcdsFixedAtBuild] 22 | gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|$(DEBUG_PROPERTY_MASK) 23 | gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|$(DEBUG_PRINT_ERROR_LEVEL) 24 | 25 | [PcdsFixedAtBuild.IPF] 26 | 27 | [LibraryClasses] 28 | # Entry Point Libraries 29 | UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf 30 | ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf 31 | UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf 32 | 33 | # Common Libraries 34 | BaseLib|MdePkg/Library/BaseLib/BaseLib.inf 35 | BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf 36 | UefiLib|MdePkg/Library/UefiLib/UefiLib.inf 37 | PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf 38 | PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf 39 | MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf 40 | UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf 41 | UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf 42 | !if $(DEBUG_ENABLE_OUTPUT) 43 | DebugLib|MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf 44 | DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf 45 | !else ## DEBUG_ENABLE_OUTPUT 46 | DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf 47 | !endif ## DEBUG_ENABLE_OUTPUT 48 | 49 | DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf 50 | PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf 51 | IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf 52 | PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf 53 | PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf 54 | SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf 55 | UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf 56 | HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf 57 | UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf 58 | PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf 59 | HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf 60 | FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf 61 | SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf 62 | ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf 63 | ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf 64 | HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf 65 | CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf 66 | 67 | [Components] 68 | 69 | #### Applications 70 | # MyApps/HelloWorld/HelloWorld.inf 71 | # MyApps/ShowMSDM/ShowMSDM.inf 72 | # MyApps/ListCerts/ListCerts.inf 73 | # MyApps/ShowSLIC/ShowSLIC.inf 74 | # MyApps/ShowFACS/ShowFACS.inf 75 | # MyApps/ListACPI/ListACPI.inf 76 | # MyApps/ShowEDID/ShowEDID.inf 77 | # MyApps/ShowBGRT/ShowBGRT.inf 78 | # MyApps/ShowESRT/ShowESRT.inf 79 | # MyApps/ShellOpt/ShellOpt.inf 80 | # MyApps/ShowOsIndications/ShowOsIndications.inf 81 | # MyApps/BootFWUI/BootFWUI.inf 82 | # MyApps/ShowQVI/ShowQVI.inf 83 | # MyApps/ShowPCI/ShowPCI.inf 84 | # MyApps/ShowERST/ShowERST.inf 85 | # MyApps/LegacySpeaker/LegacySpeaker.inf 86 | # MyApps/Beep/Beep.inf 87 | # MyApps/XBeep/XBeep.inf 88 | # MyApps/ShowPCIx/ShowPCIx.inf 89 | # MyApps/Cpuid/Cpuid.inf 90 | # MyApps/GraphicModes/GraphicModes.inf 91 | # MyApps/DisplayBMP/DisplayBMP.inf 92 | # MyApps/ShowHII/ShowHII.inf 93 | # MyApps/ShowTPM2/ShowTPM2.inf 94 | # MyApps/ShowTCM20/ShowTCM20.inf 95 | # MyApps/ShowPCR20/ShowPCR20.inf 96 | # MyApps/ShowPCR12/ShowPCR12.inf 97 | # MyApps/GenTPM12RN/GenTPM12RN.inf 98 | # MyApps/ShowTrEE/ShowTrEE.inf 99 | MyApps/ShowTrEELog/ShowTrEELog.inf 100 | -------------------------------------------------------------------------------- /MyApps/ShowBGRT/ShowBGRT.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/ShowBGRT/ShowBGRT.efi -------------------------------------------------------------------------------- /MyApps/ShowBGRT/ShowBGRT.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ShowBGRT 4 | FILE_GUID = 4ea87c57-7795-4dcd-0055-747010f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | ShowBGRT.c 12 | 13 | [Packages] 14 | MdePkg/MdePkg.dec 15 | ShellPkg/ShellPkg.dec 16 | 17 | 18 | [LibraryClasses] 19 | ShellCEntryLib 20 | ShellLib 21 | BaseLib 22 | BaseMemoryLib 23 | UefiLib 24 | 25 | [Protocols] 26 | 27 | [BuildOptions] 28 | 29 | [Pcd] 30 | 31 | -------------------------------------------------------------------------------- /MyApps/ShowEDID/ShowEDID.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/ShowEDID/ShowEDID.efi -------------------------------------------------------------------------------- /MyApps/ShowEDID/ShowEDID.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ShowEDID 4 | FILE_GUID = 4ea87c51-7395-4dcd-0055-747010f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | ShowEDID.c 12 | 13 | [Packages] 14 | MdePkg/MdePkg.dec 15 | ShellPkg/ShellPkg.dec 16 | 17 | [LibraryClasses] 18 | ShellCEntryLib 19 | ShellLib 20 | BaseLib 21 | BaseMemoryLib 22 | UefiLib 23 | 24 | [Protocols] 25 | 26 | [BuildOptions] 27 | 28 | [Pcd] 29 | 30 | -------------------------------------------------------------------------------- /MyApps/ShowESRT/ShowESRT.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015-2018 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Display ESRT (EFI System Resource Table) 5 | // 6 | // License: BSD License 7 | // 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #define UTILITY_VERSION L"20180315" 24 | #undef DEBUG 25 | 26 | // for option setting 27 | typedef enum { 28 | Verbose = 1, 29 | Hexdump, 30 | } MODE; 31 | 32 | 33 | static VOID 34 | DumpHex( UINT8 *ptr, 35 | int Count ) 36 | { 37 | int i = 0; 38 | 39 | Print(L" "); 40 | for (i = 0; i < Count; i++ ) { 41 | if ( i > 0 && i%16 == 0) 42 | Print(L"\n "); 43 | Print(L"0x%02x ", 0xff & *ptr++); 44 | } 45 | Print(L"\n"); 46 | } 47 | 48 | 49 | VOID 50 | DumpEsrt( VOID *data, 51 | MODE Mode ) 52 | { 53 | EFI_SYSTEM_RESOURCE_TABLE *Esrt = data; 54 | EFI_SYSTEM_RESOURCE_ENTRY *EsrtEntry = (EFI_SYSTEM_RESOURCE_ENTRY *)((UINT8 *)data + sizeof (*Esrt)); 55 | BOOLEAN ob; 56 | UINT16 PrivateFlags; 57 | 58 | if ( Mode == Hexdump ) { 59 | Print(L"\n"); 60 | DumpHex( (UINT8 *)Esrt, (int)(sizeof(EFI_SYSTEM_RESOURCE_TABLE) \ 61 | + ((Esrt->FwResourceCount) * sizeof(EFI_SYSTEM_RESOURCE_ENTRY))) ); 62 | Print(L"\n"); 63 | return; 64 | } 65 | 66 | if ( Mode == Verbose ) { 67 | Print(L"ESRT found at 0x%08x\n", data); 68 | Print(L"Firmware Resource Count: %d\n", Esrt->FwResourceCount); 69 | Print(L"Firmware Resource Max Count: %d\n", Esrt->FwResourceCountMax); 70 | Print(L"Firmware Resource Version: %ld\n", Esrt->FwResourceVersion); 71 | Print(L"\n"); 72 | } 73 | 74 | if (Esrt->FwResourceVersion != 1) { 75 | Print(L"ERROR: Unsupported ESRT version: %d\n", Esrt->FwResourceVersion); 76 | return; 77 | } 78 | 79 | for (int i = 0; i < Esrt->FwResourceCount; i++) { 80 | ob = FALSE; 81 | Print(L"Firmware Resource Entry: %d\n", i); 82 | Print(L"Firmware Class GUID: %g\n", &EsrtEntry->FwClass); 83 | Print(L"Firmware Type: %d ", EsrtEntry->FwType); 84 | switch (EsrtEntry->FwType) { 85 | case 0: Print(L"(Unknown)\n"); 86 | break; 87 | case 1: Print(L"(System)\n"); 88 | break; 89 | case 2: Print(L"(Device)\n"); 90 | break; 91 | case 3: Print(L"(UEFI Driver)\n"); 92 | break; 93 | default: Print(L"\n"); 94 | } 95 | Print(L"Firmware Version: 0x%08x\n", EsrtEntry->FwVersion); 96 | Print(L"Lowest Supported Firmware Version: 0x%08x\n", EsrtEntry->LowestSupportedFwVersion); 97 | 98 | Print(L"Capsule Flags: 0x%08x", EsrtEntry->CapsuleFlags); 99 | PrivateFlags = (EsrtEntry->CapsuleFlags) &= 0xffff; 100 | if ( EsrtEntry->CapsuleFlags & CAPSULE_FLAGS_PERSIST_ACROSS_RESET ) { 101 | if (!ob) { 102 | ob = TRUE; 103 | Print(L" ("); 104 | } 105 | Print(L"Persist Across Reboot"); 106 | } 107 | if ( EsrtEntry->CapsuleFlags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE ) { 108 | if (!ob) { 109 | ob = TRUE; 110 | Print(L" ("); 111 | } else 112 | Print(L", "); 113 | Print(L"Populate System Table"); 114 | } 115 | if ( EsrtEntry->CapsuleFlags & CAPSULE_FLAGS_INITIATE_RESET ) { 116 | if (!ob) { 117 | ob = TRUE; 118 | Print(L" ("); 119 | } else 120 | Print(L", "); 121 | Print(L"Initiate Reset"); 122 | } 123 | if ( PrivateFlags ) { 124 | if (!ob) { 125 | ob = TRUE; 126 | Print(L" ("); 127 | } else 128 | Print(L", "); 129 | Print(L"Private Update Flags: 0x%04x", PrivateFlags); 130 | } 131 | if (ob) 132 | Print(L")"); 133 | Print(L"\n"); 134 | Print(L"Last Attempt Version: 0x%08x\n", EsrtEntry->LastAttemptVersion); 135 | Print(L"Last Attempt Status: %d ", EsrtEntry->LastAttemptStatus); 136 | switch(EsrtEntry->LastAttemptStatus) { 137 | case 0: Print(L"(Success)\n"); 138 | break; 139 | case 1: Print(L"(Unsuccessful)\n"); 140 | break; 141 | case 2: Print(L"(Insufficient Resources)\n"); 142 | break; 143 | case 3: Print(L"(Incorrect Version)\n"); 144 | break; 145 | case 4: Print(L"(Invalid Image Format)\n"); 146 | break; 147 | case 5: Print(L"(Authentication Error)\n"); 148 | break; 149 | case 6: Print(L"(AC Power Not Connected)\n"); 150 | break; 151 | case 7: Print(L"(Insufficent Battery Power)\n"); 152 | break; 153 | default: Print(L"(Unknown)\n"); 154 | } 155 | Print(L"\n"); 156 | EsrtEntry++; 157 | } 158 | } 159 | 160 | 161 | static void 162 | Usage( void ) 163 | { 164 | Print(L"Usage: ShowESRT [-v | --verbose]\n"); 165 | Print(L" ShowESRT [-d | --dump]\n"); 166 | Print(L" ShowESRT [-V | --version]\n"); 167 | } 168 | 169 | 170 | INTN 171 | EFIAPI 172 | ShellAppMain( UINTN Argc, 173 | CHAR16 **Argv ) 174 | { 175 | EFI_CONFIGURATION_TABLE *ect = gST->ConfigurationTable; 176 | EFI_GUID EsrtGuid = EFI_SYSTEM_RESOURCE_TABLE_GUID; 177 | EFI_STATUS Status = EFI_SUCCESS; 178 | MODE Mode = 0; 179 | 180 | if (Argc == 2) { 181 | if (!StrCmp(Argv[1], L"--verbose") || 182 | !StrCmp(Argv[1], L"-v")) { 183 | Mode = Verbose; 184 | } else if (!StrCmp(Argv[1], L"--dump") || 185 | !StrCmp(Argv[1], L"-d")) { 186 | Mode = Hexdump; 187 | } else if (!StrCmp(Argv[1], L"--version") || 188 | !StrCmp(Argv[1], L"-V")) { 189 | Print(L"Version: %s\n", UTILITY_VERSION); 190 | return Status; 191 | } else if (!StrCmp(Argv[1], L"--help") || 192 | !StrCmp(Argv[1], L"-h")) { 193 | Usage(); 194 | return Status; 195 | } else { 196 | Usage(); 197 | return Status; 198 | } 199 | } 200 | if (Argc > 2) { 201 | Usage(); 202 | return Status; 203 | } 204 | 205 | for (int Index = 0; Index < gST->NumberOfTableEntries; Index++) { 206 | if (!CompareMem(&ect->VendorGuid, &EsrtGuid, sizeof(EsrtGuid))) { 207 | DumpEsrt( ect->VendorTable, Mode ); 208 | return EFI_SUCCESS; 209 | } 210 | ect++; 211 | continue; 212 | } 213 | 214 | Print(L"No ESRT found\n"); 215 | 216 | return Status; 217 | } 218 | 219 | -------------------------------------------------------------------------------- /MyApps/ShowESRT/ShowESRT.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/ShowESRT/ShowESRT.efi -------------------------------------------------------------------------------- /MyApps/ShowESRT/ShowESRT.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ShowESRT 4 | FILE_GUID = 4ea87c51-7491-4dfd-0055-747010f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | ShowESRT.c 12 | 13 | [Packages] 14 | MdePkg/MdePkg.dec 15 | ShellPkg/ShellPkg.dec 16 | 17 | 18 | [LibraryClasses] 19 | ShellCEntryLib 20 | ShellLib 21 | BaseLib 22 | BaseMemoryLib 23 | UefiLib 24 | 25 | [Protocols] 26 | 27 | [BuildOptions] 28 | 29 | [Pcd] 30 | 31 | -------------------------------------------------------------------------------- /MyApps/ShowFACS/ShowFACS.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2018 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Display ACPI FACS table 5 | // 6 | // License: BSD License 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | #define UTILITY_VERSION L"20180226" 25 | #undef DEBUG 26 | 27 | 28 | #if 0 29 | typedef struct { 30 | UINT32 Signature; 31 | UINT32 Length; 32 | UINT32 HardwareSignature; 33 | UINT32 FirmwareWakingVector; 34 | UINT32 GlobalLock; 35 | UINT32 Flags; 36 | UINT64 XFirmwareWakingVector; 37 | UINT8 Version; 38 | UINT8 Reserved[31]; 39 | } EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE; 40 | #endif 41 | 42 | 43 | static VOID AsciiToUnicodeSize(CHAR8 *, UINT8, CHAR16 *, BOOLEAN); 44 | 45 | static VOID 46 | AsciiToUnicodeSize( CHAR8 *String, 47 | UINT8 length, 48 | CHAR16 *UniString, 49 | BOOLEAN Quote ) 50 | { 51 | int len = length; 52 | 53 | if (Quote) 54 | *(UniString++) = L'"'; 55 | while (*String != '\0' && len > 0) { 56 | *(UniString++) = (CHAR16) *(String++); 57 | len--; 58 | } 59 | if (Quote) 60 | *(UniString++) = L'"'; 61 | *UniString = '\0'; 62 | } 63 | 64 | 65 | static VOID 66 | PrintHexTable( UINT8 *ptr, 67 | int Count ) 68 | { 69 | int i = 0; 70 | 71 | Print(L" "); 72 | for (i = 0; i < Count; i++ ) { 73 | if ( i > 0 && i%16 == 0) 74 | Print(L"\n "); 75 | Print(L"0x%02x ", 0xff & *ptr++); 76 | } 77 | Print(L"\n"); 78 | } 79 | 80 | 81 | static VOID 82 | PrintFACS( EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs, 83 | BOOLEAN Hexdump ) 84 | { 85 | CHAR16 Buffer[50]; 86 | 87 | Print(L"\n"); 88 | if (Hexdump) { 89 | PrintHexTable( (UINT8 *)Facs, (int)(Facs->Length) ); 90 | } else { 91 | Print(L"FACS Table Details\n"); 92 | AsciiToUnicodeSize((CHAR8 *)&(Facs->Signature), 4, Buffer, TRUE); 93 | Print(L" Signature : %s\n", Buffer); 94 | Print(L" Length : 0x%08x (%d)\n", Facs->Length, Facs->Length); 95 | Print(L" Hardware Signature : 0x%08x (%d)\n", Facs->HardwareSignature, 96 | Facs->HardwareSignature); 97 | Print(L" FirmwareWakingVector : 0x%08x (%d)\n", Facs->FirmwareWakingVector, 98 | Facs->FirmwareWakingVector); 99 | Print(L" GlobalLock : 0x%08x (%d)\n", Facs->GlobalLock, Facs->GlobalLock); 100 | Print(L" Flags : 0x%08x (%d)\n", Facs->Flags, Facs->Flags); 101 | Print(L" XFirmwareWakingVector : 0x%016x (%ld)\n", Facs->XFirmwareWakingVector, 102 | Facs->XFirmwareWakingVector); 103 | Print(L" Version : 0x%02x (%d)\n", Facs->Version, Facs->Version); 104 | Print(L" Reserved:\n"); 105 | PrintHexTable( (UINT8 *)&(Facs->Reserved), 31 ); 106 | } 107 | Print(L"\n"); 108 | } 109 | 110 | 111 | static int 112 | ParseRSDP( EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp, 113 | CHAR16* GuidStr, 114 | BOOLEAN Hexdump ) 115 | { 116 | EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt2Table; 117 | EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs2Table; 118 | EFI_ACPI_SDT_HEADER *Xsdt, *Entry; 119 | UINT32 EntryCount; 120 | UINT64 *EntryPtr; 121 | #ifdef DEBUG 122 | CHAR16 OemStr[20]; 123 | 124 | Print(L"\n\nACPI GUID: %s\n", GuidStr); 125 | 126 | AsciiToUnicodeSize((CHAR8 *)(Rsdp->OemId), 6, OemStr, FALSE); 127 | Print(L"\nFound RSDP. Version: %d OEM ID: %s\n", (int)(Rsdp->Revision), OemStr); 128 | #endif 129 | 130 | if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) { 131 | Xsdt = (EFI_ACPI_SDT_HEADER *)(Rsdp->XsdtAddress); 132 | } else { 133 | #ifdef DEBUG 134 | Print(L"ERROR: No ACPI XSDT table found.\n"); 135 | #endif 136 | return 1; 137 | } 138 | 139 | if (Xsdt->Signature != SIGNATURE_32 ('X', 'S', 'D', 'T')) { 140 | #ifdef DEBUG 141 | Print(L"ERROR: Invalid ACPI XSDT table found.\n"); 142 | #endif 143 | return 1; 144 | } 145 | 146 | EntryCount = (Xsdt->Length - sizeof (EFI_ACPI_SDT_HEADER)) / sizeof(UINT64); 147 | #ifdef DEBUG 148 | AsciiToUnicodeSize((CHAR8 *)(Xsdt->OemId), 6, OemStr, FALSE); 149 | Print(L"Found XSDT. OEM ID: %s Entry Count: %d\n\n", OemStr, EntryCount); 150 | #endif 151 | 152 | // Locate Fixed ACPI Description Table - "FACP" 153 | EntryPtr = (UINT64 *)(Xsdt + 1); 154 | for (int Index = 0; Index < EntryCount; Index++, EntryPtr++) { 155 | Entry = (EFI_ACPI_SDT_HEADER *)((UINTN)(*EntryPtr)); 156 | if (!AsciiStrnCmp( (CHAR8 *)&(Entry->Signature), "FACP", 4)) { 157 | Fadt2Table = (EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *)((UINTN)(*EntryPtr)); 158 | Facs2Table = (EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *)((UINTN)(Fadt2Table->FirmwareCtrl)); 159 | PrintFACS(Facs2Table, Hexdump); 160 | } 161 | } 162 | 163 | return 0; 164 | } 165 | 166 | 167 | static void 168 | Usage( void ) 169 | { 170 | Print(L"Usage: ShowFACS [-d | --dump]\n"); 171 | Print(L" ShowFACS [-V | --version]\n"); 172 | } 173 | 174 | 175 | INTN 176 | EFIAPI 177 | ShellAppMain( UINTN Argc, 178 | CHAR16 **Argv ) 179 | { 180 | EFI_CONFIGURATION_TABLE *ect = gST->ConfigurationTable; 181 | EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp = NULL; 182 | EFI_GUID gAcpi20TableGuid = EFI_ACPI_20_TABLE_GUID; 183 | EFI_GUID gAcpi10TableGuid = ACPI_10_TABLE_GUID; 184 | EFI_STATUS Status = EFI_SUCCESS; 185 | CHAR16 GuidStr[100]; 186 | BOOLEAN Hexdump = FALSE; 187 | 188 | if (Argc == 2) { 189 | if (!StrCmp(Argv[1], L"--dump") || 190 | !StrCmp(Argv[1], L"-d")) { 191 | Hexdump = TRUE; 192 | } else if (!StrCmp(Argv[1], L"--version") || 193 | !StrCmp(Argv[1], L"-V")) { 194 | Print(L"Version: %s\n", UTILITY_VERSION); 195 | return Status; 196 | } else if (!StrCmp(Argv[1], L"--help") || 197 | !StrCmp(Argv[1], L"-h")) { 198 | Usage(); 199 | return Status; 200 | } else { 201 | Usage(); 202 | return Status; 203 | } 204 | } 205 | if (Argc > 2) { 206 | Usage(); 207 | return Status; 208 | } 209 | 210 | // Locate Root System Description Pointer Table - "RSDP" 211 | for (int i = 0; i < gST->NumberOfTableEntries; i++) { 212 | if ((CompareGuid (&(gST->ConfigurationTable[i].VendorGuid), &gAcpi20TableGuid)) || 213 | (CompareGuid (&(gST->ConfigurationTable[i].VendorGuid), &gAcpi10TableGuid))) { 214 | if (!AsciiStrnCmp("RSD PTR ", (CHAR8 *)(ect->VendorTable), 8)) { 215 | UnicodeSPrint(GuidStr, sizeof(GuidStr), L"%g", &(gST->ConfigurationTable[i].VendorGuid)); 216 | Rsdp = (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)ect->VendorTable; 217 | ParseRSDP(Rsdp, GuidStr, Hexdump); 218 | } 219 | } 220 | ect++; 221 | } 222 | 223 | if (Rsdp == NULL) { 224 | Print(L"ERROR: Could not find an ACPI RSDP table.\n"); 225 | Status = EFI_NOT_FOUND; 226 | } 227 | 228 | return Status; 229 | } 230 | -------------------------------------------------------------------------------- /MyApps/ShowFACS/ShowFACS.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/ShowFACS/ShowFACS.efi -------------------------------------------------------------------------------- /MyApps/ShowFACS/ShowFACS.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ShowFACS 4 | FILE_GUID = 4ea87c53-7395-4dcd-0055-747010f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | ShowFACS.c 12 | 13 | [Packages] 14 | MdePkg/MdePkg.dec 15 | ShellPkg/ShellPkg.dec 16 | 17 | [LibraryClasses] 18 | ShellCEntryLib 19 | ShellLib 20 | BaseLib 21 | BaseMemoryLib 22 | UefiLib 23 | 24 | [Protocols] 25 | 26 | [BuildOptions] 27 | 28 | [Pcd] 29 | 30 | -------------------------------------------------------------------------------- /MyApps/ShowHII/ShowHII.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2017-2018 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Show basic information on HII packagesi available in UEFI shell 5 | // 6 | // License: UDK2017 license applies to code from UDK2017 sources, 7 | // BSD 2 clause license applies to all other code. 8 | // 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #define UTILITY_VERSION L"20180420" 25 | #undef DEBUG 26 | 27 | 28 | typedef struct { 29 | UINT8 PackageType; 30 | CHAR16 *PackageTypeString; 31 | } HII_PACKAGE_TYPE_STRING; 32 | 33 | HII_PACKAGE_TYPE_STRING HiiPackageTypeStringTable[] = { 34 | {EFI_HII_PACKAGE_TYPE_ALL, L"HII_PACKAGE_TYPE_ALL"}, 35 | {EFI_HII_PACKAGE_TYPE_GUID, L"HII_PACKAGE_TYPE_GUID"}, 36 | {EFI_HII_PACKAGE_FORMS, L"HII_PACKAGE_FORMS"}, 37 | {EFI_HII_PACKAGE_STRINGS, L"HII_PACKAGE_STRINGS"}, 38 | {EFI_HII_PACKAGE_FONTS, L"HII_PACKAGE_FONTS"}, 39 | {EFI_HII_PACKAGE_IMAGES, L"HII_PACKAGE_IMAGES"}, 40 | {EFI_HII_PACKAGE_SIMPLE_FONTS, L"HII_PACKAGE_SIMPLE_FONTS"}, 41 | {EFI_HII_PACKAGE_DEVICE_PATH, L"HII_PACKAGE_DEVICE_PATH"}, 42 | {EFI_HII_PACKAGE_KEYBOARD_LAYOUT, L"HII_PACKAGE_KEYBOARD_LAYOUT"}, 43 | {EFI_HII_PACKAGE_ANIMATIONS, L"HII_PACKAGE_ANIMATIONS"}, 44 | {EFI_HII_PACKAGE_END, L"HII_PACKAGE_END"}, 45 | {EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN, L"HII_PACKAGE_TYPE_SYSTEM_BEGIN"}, 46 | {EFI_HII_PACKAGE_TYPE_SYSTEM_END, L"HII_PACKAGE_TYPE_SYSTEM_END"}, 47 | }; 48 | 49 | 50 | CHAR16 * 51 | HiiPackageTypeToString( UINT8 PackageType ) 52 | { 53 | UINTN MaxIndex = ARRAY_SIZE(HiiPackageTypeStringTable); 54 | 55 | for (UINTN Index = 0; Index < MaxIndex; Index++) { 56 | if (HiiPackageTypeStringTable[Index].PackageType == PackageType) { 57 | return HiiPackageTypeStringTable[Index].PackageTypeString; 58 | } 59 | } 60 | 61 | return L"Unknown Package Type"; 62 | } 63 | 64 | 65 | VOID 66 | DumpHiiPackage( VOID *HiiPackage ) 67 | { 68 | EFI_HII_PACKAGE_HEADER *HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *) HiiPackage; 69 | 70 | Print(L" Type: 0x%02x (%s) Length: 0x%06x (%d)\n", HiiPackageHeader->Type, 71 | HiiPackageTypeToString(HiiPackageHeader->Type), 72 | HiiPackageHeader->Length, 73 | HiiPackageHeader->Length); 74 | } 75 | 76 | 77 | VOID 78 | DumpHiiDatabase( VOID *HiiDatabase, 79 | UINTN HiiDatabaseSize, 80 | BOOLEAN Terse ) 81 | { 82 | EFI_HII_PACKAGE_LIST_HEADER *HiiPackageListHeader; 83 | EFI_HII_PACKAGE_HEADER *HiiPackageHeader; 84 | CHAR16 GuidStr[100]; 85 | UINT16 HiiPackageCount = 0; 86 | 87 | if (Terse) 88 | Print(L"\n"); 89 | else 90 | Print(L"\nHII Database Size: 0x%x (%d)\n\n", HiiDatabaseSize, HiiDatabaseSize); 91 | 92 | HiiPackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER *) HiiDatabase; 93 | 94 | while ((UINTN) HiiPackageListHeader < ((UINTN) HiiDatabase + HiiDatabaseSize)) { 95 | UINTN HiiPackageSize = HiiPackageListHeader->PackageLength; 96 | if (HiiPackageSize == 0) 97 | break; 98 | HiiPackageCount++; 99 | UnicodeSPrint(GuidStr, sizeof(GuidStr), L"%g", &(HiiPackageListHeader->PackageListGuid)); 100 | Print(L"%02d GUID: %s Length: 0x%06x (%d)\n", HiiPackageCount, GuidStr, HiiPackageSize, HiiPackageSize); 101 | HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *)(HiiPackageListHeader + 1); 102 | if (!Terse) { 103 | while ((UINTN) HiiPackageHeader < (UINTN) (HiiPackageListHeader + HiiPackageListHeader->PackageLength)) { 104 | DumpHiiPackage(HiiPackageHeader); 105 | if (HiiPackageHeader->Type == EFI_HII_PACKAGE_END) 106 | break; 107 | HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *) ((UINTN) HiiPackageHeader + HiiPackageHeader->Length); 108 | } 109 | } 110 | HiiPackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER *) ((UINTN) HiiPackageListHeader + HiiPackageSize); 111 | } 112 | } 113 | 114 | 115 | VOID 116 | Usage( CHAR16 *Str, 117 | BOOLEAN ErrorMsg ) 118 | { 119 | if ( ErrorMsg ) { 120 | Print(L"ERROR: Unknown option.\n"); 121 | } 122 | Print(L"Usage: %s [-V | --version]\n", Str); 123 | Print(L" %s [-t | --terse]\n", Str); 124 | } 125 | 126 | 127 | INTN 128 | EFIAPI 129 | ShellAppMain( UINTN Argc, 130 | CHAR16 **Argv ) 131 | { 132 | EFI_STATUS Status = EFI_SUCCESS; 133 | EFI_HII_DATABASE_PROTOCOL *HiiDbProtocol; 134 | UINTN PackageListSize = 0; 135 | EFI_HII_PACKAGE_LIST_HEADER *PackageList = NULL; 136 | BOOLEAN Terse = FALSE; 137 | 138 | if (Argc == 2) { 139 | if (!StrCmp(Argv[1], L"--version") || 140 | !StrCmp(Argv[1], L"-V")) { 141 | Print(L"Version: %s\n", UTILITY_VERSION); 142 | return Status; 143 | } else if (!StrCmp(Argv[1], L"--help") || 144 | !StrCmp(Argv[1], L"-h")) { 145 | Usage(Argv[0], FALSE); 146 | return Status; 147 | } else if (!StrCmp(Argv[1], L"--terse") || 148 | !StrCmp(Argv[1], L"-t")) { 149 | Terse = TRUE; 150 | } else { 151 | Usage(Argv[0], TRUE); 152 | return Status; 153 | } 154 | } 155 | if (Argc > 2) { 156 | Usage(Argv[0], TRUE); 157 | return Status; 158 | } 159 | 160 | 161 | Status = gBS->LocateProtocol( &gEfiHiiDatabaseProtocolGuid, 162 | NULL, 163 | (VOID **) &HiiDbProtocol ); 164 | if (EFI_ERROR(Status)) { 165 | Print(L"ERROR: Could not find HII Database protocol\n"); 166 | return Status; 167 | } 168 | 169 | // Get HII packages 170 | Status = HiiDbProtocol->ExportPackageLists( HiiDbProtocol, 171 | NULL, 172 | &PackageListSize, 173 | PackageList ); 174 | if (Status != EFI_BUFFER_TOO_SMALL) { 175 | Print(L"ERROR: Could not obtain package list size\n"); 176 | return Status; 177 | } 178 | 179 | Status = gBS->AllocatePool( EfiBootServicesData, 180 | PackageListSize, 181 | (VOID **) &PackageList ); 182 | if (EFI_ERROR(Status)) { 183 | Print(L"ERROR: Could not allocate sufficient memory for package list\n"); 184 | return Status; 185 | } 186 | 187 | Status = HiiDbProtocol->ExportPackageLists( HiiDbProtocol, 188 | NULL, 189 | &PackageListSize, 190 | PackageList ); 191 | if (EFI_ERROR(Status)) { 192 | Print(L"ERROR: Could not retrieve the package list\n"); 193 | FreePool(PackageList); 194 | return Status; 195 | } 196 | 197 | DumpHiiDatabase( PackageList, PackageListSize, Terse ); 198 | 199 | FreePool(PackageList); 200 | 201 | Print(L"\n"); 202 | 203 | return Status; 204 | } 205 | 206 | 207 | -------------------------------------------------------------------------------- /MyApps/ShowHII/ShowHII.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/ShowHII/ShowHII.efi -------------------------------------------------------------------------------- /MyApps/ShowHII/ShowHII.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ShowHII 4 | FILE_GUID = 4ea87c51-7491-4dad-0055-767013f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | 11 | [Sources] 12 | ShowHII.c 13 | 14 | [Packages] 15 | MdePkg/MdePkg.dec 16 | ShellPkg/ShellPkg.dec 17 | 18 | [LibraryClasses] 19 | ShellCEntryLib 20 | ShellLib 21 | ShellCommandLib 22 | BaseLib 23 | BaseMemoryLib 24 | UefiLib 25 | 26 | [Protocols] 27 | 28 | [BuildOptions] 29 | 30 | [Pcd] 31 | 32 | -------------------------------------------------------------------------------- /MyApps/ShowMSDM/ShowMSDM.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2014-2018 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Display ACPI MSDM and/or Microsoft Windows License Key 5 | // 6 | // License: BSD License 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | #define UTILITY_VERSION L"20180221" 25 | #undef DEBUG 26 | 27 | 28 | #pragma pack(1) 29 | typedef struct { 30 | UINT32 Version; 31 | UINT32 Reserved; 32 | UINT32 DataType; 33 | UINT32 DataReserved; 34 | UINT32 DataLength; 35 | CHAR8 Data[30]; 36 | } SOFTWARE_LICENSING; 37 | 38 | // Microsoft Data Management table structure 39 | typedef struct { 40 | EFI_ACPI_SDT_HEADER Header; 41 | SOFTWARE_LICENSING SoftLic; 42 | } EFI_ACPI_MSDM; 43 | #pragma pack() 44 | 45 | 46 | static VOID AsciiToUnicodeSize(CHAR8 *, UINT8, CHAR16 *, BOOLEAN); 47 | 48 | 49 | static VOID 50 | AsciiToUnicodeSize( CHAR8 *String, 51 | UINT8 length, 52 | CHAR16 *UniString, 53 | BOOLEAN Quote ) 54 | { 55 | int len = length; 56 | 57 | if (Quote) 58 | *(UniString++) = L'"'; 59 | while (*String != '\0' && len > 0) { 60 | *(UniString++) = (CHAR16) *(String++); 61 | len--; 62 | } 63 | if (Quote) 64 | *(UniString++) = L'"'; 65 | *UniString = '\0'; 66 | } 67 | 68 | 69 | static VOID 70 | PrintHexTable( UINT8 *ptr, 71 | int Count ) 72 | { 73 | int i = 0; 74 | 75 | Print(L" "); 76 | for (i = 0; i < Count; i++ ) { 77 | if ( i > 0 && i%16 == 0) 78 | Print(L"\n "); 79 | Print(L"0x%02x ", 0xff & *ptr++); 80 | } 81 | Print(L"\n"); 82 | } 83 | 84 | 85 | static VOID 86 | PrintAcpiHeader( EFI_ACPI_SDT_HEADER *Ptr ) 87 | { 88 | CHAR16 Buffer[50]; 89 | 90 | Print(L"ACPI Standard Header\n"); 91 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->Signature), 4, Buffer, TRUE); 92 | Print(L" Signature : %s\n", Buffer); 93 | Print(L" Length : 0x%08x (%d)\n", Ptr->Length, Ptr->Length); 94 | Print(L" Revision : 0x%02x (%d)\n", Ptr->Revision, Ptr->Revision); 95 | Print(L" Checksum : 0x%02x (%d)\n", Ptr->Checksum, Ptr->Checksum); 96 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->OemId), 6, Buffer, TRUE); 97 | Print(L" OEM ID : %s\n", Buffer); 98 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->OemTableId), 8, Buffer, TRUE); 99 | Print(L" OEM Table ID : %s\n", Buffer); 100 | Print(L" OEM Revision : 0x%08x (%d)\n", Ptr->OemRevision, Ptr->OemRevision); 101 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->CreatorId), 4, Buffer, TRUE); 102 | Print(L" Creator ID : %s\n", Buffer); 103 | Print(L" Creator Revision : 0x%08x (%d)\n", Ptr->CreatorRevision, Ptr->CreatorRevision); 104 | Print(L"\n"); 105 | } 106 | 107 | 108 | static VOID 109 | PrintSoftwareLicensing( SOFTWARE_LICENSING *Ptr, 110 | BOOLEAN Verbose ) 111 | { 112 | CHAR16 Buffer[50]; 113 | 114 | if (Verbose) { 115 | Print(L"Software Licensing\n"); 116 | Print(L" Version : 0x%08x (%d)\n", Ptr->Version, Ptr->Version); 117 | Print(L" Reserved : 0x%08x (%d)\n", Ptr->Reserved, Ptr->Reserved); 118 | Print(L" Data Type : 0x%08x (%d)\n", Ptr->DataType, Ptr->DataType); 119 | Print(L" Data Reserved : 0x%08x (%d)\n", Ptr->DataReserved, Ptr->DataReserved); 120 | Print(L" Data Length : 0x%08x (%d)\n", Ptr->DataLength, Ptr->DataLength); 121 | AsciiToUnicodeSize((CHAR8 *)(Ptr->Data), 30, Buffer, TRUE); 122 | Print(L" Data : %s\n", Buffer); 123 | } else { 124 | AsciiToUnicodeSize((CHAR8 *)(Ptr->Data), 30, Buffer, FALSE); 125 | Print(L" %s\n", Buffer); 126 | } 127 | } 128 | 129 | 130 | static VOID 131 | PrintMSDM( EFI_ACPI_MSDM *Msdm, 132 | BOOLEAN Verbose, 133 | BOOLEAN Hexdump ) 134 | { 135 | Print(L"\n"); 136 | if (Hexdump) { 137 | PrintHexTable( (UINT8 *)Msdm, (int)(Msdm->Header.Length) ); 138 | } else { 139 | if (Verbose) { 140 | PrintAcpiHeader( (EFI_ACPI_SDT_HEADER *)&(Msdm->Header) ); 141 | } 142 | PrintSoftwareLicensing( (SOFTWARE_LICENSING *)&(Msdm->SoftLic), Verbose); 143 | } 144 | Print(L"\n"); 145 | } 146 | 147 | 148 | static int 149 | ParseRSDP( EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp, 150 | CHAR16* GuidStr, 151 | BOOLEAN Verbose, 152 | BOOLEAN Hexdump ) 153 | { 154 | EFI_ACPI_SDT_HEADER *Xsdt, *Entry; 155 | #ifdef DEBUG 156 | CHAR16 OemStr[20]; 157 | #endif 158 | UINT32 EntryCount; 159 | UINT64 *EntryPtr; 160 | 161 | #ifdef DEBUG 162 | Print(L"\n\nACPI GUID: %s\n", GuidStr); 163 | 164 | AsciiToUnicodeSize((CHAR8 *)(Rsdp->OemId), 6, OemStr, FALSE); 165 | Print(L"\nFound RSDP. Version: %d OEM ID: %s\n", (int)(Rsdp->Revision), OemStr); 166 | #endif 167 | if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) { 168 | Xsdt = (EFI_ACPI_SDT_HEADER *)(Rsdp->XsdtAddress); 169 | } else { 170 | #ifdef DEBUG 171 | Print(L"ERROR: No ACPI XSDT table found.\n"); 172 | #endif 173 | return 1; 174 | } 175 | 176 | if (Xsdt->Signature != SIGNATURE_32 ('X', 'S', 'D', 'T')) { 177 | #ifdef DEBUG 178 | Print(L"ERROR: Invalid ACPI XSDT table found.\n"); 179 | #endif 180 | return 1; 181 | } 182 | 183 | EntryCount = (Xsdt->Length - sizeof (EFI_ACPI_SDT_HEADER)) / sizeof(UINT64); 184 | #ifdef DEBUG 185 | AsciiToUnicodeSize((CHAR8 *)(Xsdt->OemId), 6, OemStr, FALSE); 186 | Print(L"Found XSDT. OEM ID: %s Entry Count: %d\n\n", OemStr, EntryCount); 187 | #endif 188 | 189 | EntryPtr = (UINT64 *)(Xsdt + 1); 190 | for (int Index = 0; Index < EntryCount; Index++, EntryPtr++) { 191 | Entry = (EFI_ACPI_SDT_HEADER *)((UINTN)(*EntryPtr)); 192 | if (Entry->Signature == SIGNATURE_32 ('M', 'S', 'D', 'M')) { 193 | PrintMSDM((EFI_ACPI_MSDM *)((UINTN)(*EntryPtr)), Verbose, Hexdump); 194 | } 195 | } 196 | 197 | return 0; 198 | } 199 | 200 | 201 | static void 202 | Usage( void ) 203 | { 204 | Print(L"Usage: ShowMSDM [-v | --verbose]\n"); 205 | Print(L" ShowMSDM [-V | --version]\n"); 206 | Print(L" ShowMSDM [-d | --dump]\n"); 207 | } 208 | 209 | 210 | INTN 211 | EFIAPI 212 | ShellAppMain( UINTN Argc, 213 | CHAR16 **Argv ) 214 | { 215 | EFI_CONFIGURATION_TABLE *ect = gST->ConfigurationTable; 216 | EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp = NULL; 217 | EFI_GUID gAcpi20TableGuid = EFI_ACPI_20_TABLE_GUID; 218 | EFI_GUID gAcpi10TableGuid = ACPI_10_TABLE_GUID; 219 | EFI_STATUS Status = EFI_SUCCESS; 220 | CHAR16 GuidStr[100]; 221 | BOOLEAN Verbose = FALSE; 222 | BOOLEAN Hexdump = FALSE; 223 | 224 | if (Argc == 2) { 225 | if (!StrCmp(Argv[1], L"--verbose") || 226 | !StrCmp(Argv[1], L"-v")) { 227 | Verbose = TRUE; 228 | } else if (!StrCmp(Argv[1], L"--dump") || 229 | !StrCmp(Argv[1], L"-d")) { 230 | Hexdump = TRUE; 231 | } else if (!StrCmp(Argv[1], L"--version") || 232 | !StrCmp(Argv[1], L"-V")) { 233 | Print(L"Version: %s\n", UTILITY_VERSION); 234 | return Status; 235 | } else if (!StrCmp(Argv[1], L"--help") || 236 | !StrCmp(Argv[1], L"-h")) { 237 | Usage(); 238 | return Status; 239 | } else { 240 | Usage(); 241 | return Status; 242 | } 243 | } 244 | if (Argc > 2) { 245 | Usage(); 246 | return Status; 247 | } 248 | 249 | // locate RSDP (Root System Description Pointer) 250 | for (int i = 0; i < gST->NumberOfTableEntries; i++) { 251 | if ((CompareGuid (&(gST->ConfigurationTable[i].VendorGuid), &gAcpi20TableGuid)) || 252 | (CompareGuid (&(gST->ConfigurationTable[i].VendorGuid), &gAcpi10TableGuid))) { 253 | if (!AsciiStrnCmp("RSD PTR ", (CHAR8 *)(ect->VendorTable), 8)) { 254 | UnicodeSPrint(GuidStr, sizeof(GuidStr), L"%g", &(gST->ConfigurationTable[i].VendorGuid)); 255 | Rsdp = (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)ect->VendorTable; 256 | ParseRSDP(Rsdp, GuidStr, Verbose, Hexdump); 257 | } 258 | } 259 | ect++; 260 | } 261 | 262 | if (Rsdp == NULL) { 263 | Print(L"ERROR: Could not find an ACPI RSDP table.\n"); 264 | Status = EFI_NOT_FOUND; 265 | } 266 | 267 | return Status; 268 | } 269 | -------------------------------------------------------------------------------- /MyApps/ShowMSDM/ShowMSDM.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/ShowMSDM/ShowMSDM.efi -------------------------------------------------------------------------------- /MyApps/ShowMSDM/ShowMSDM.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ShowMSDM 4 | FILE_GUID = 4ea87c51-7395-4dcd-0055-747010f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | ShowMSDM.c 12 | 13 | [Packages] 14 | MdePkg/MdePkg.dec 15 | ShellPkg/ShellPkg.dec 16 | 17 | [LibraryClasses] 18 | ShellCEntryLib 19 | ShellLib 20 | BaseLib 21 | BaseMemoryLib 22 | UefiLib 23 | 24 | [Protocols] 25 | 26 | [BuildOptions] 27 | 28 | [Pcd] 29 | 30 | -------------------------------------------------------------------------------- /MyApps/ShowOsIndications/ShowOsIndications.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2016-2018 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Display UEFI OsIndicationsSupported and OsIndications information 5 | // 6 | // License: BSD License 7 | // 8 | 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | #define UTILITY_VERSION L"20180318" 26 | #undef DEBUG 27 | 28 | 29 | VOID 30 | Usage( VOID ) 31 | { 32 | Print(L"Usage: ShowOsIndications [-v | --verbose]\n"); 33 | Print(L" [-V | --version]\n"); 34 | } 35 | 36 | 37 | INTN 38 | EFIAPI 39 | ShellAppMain( UINTN Argc, 40 | CHAR16 **Argv ) 41 | { 42 | EFI_STATUS Status = EFI_SUCCESS; 43 | BOOLEAN SupportBootFwUi, BootFwUi; 44 | BOOLEAN SupportPlatformRecovery, PlatformRecovery; 45 | BOOLEAN SupportTimeStampRevocation, TimeStampRevocation; 46 | BOOLEAN SupportFileCapsuleDelivery, FileCapsuleDelivery; 47 | BOOLEAN SupportFMPCapsuleSupported, FMPCapsuleSupported; 48 | BOOLEAN SupportCapsuleResultVariable, CapsuleResultVariable; 49 | BOOLEAN Verbose = FALSE; 50 | UINT64 OsIndicationsSupported; 51 | UINT64 OsIndications; 52 | UINTN DataSize; 53 | UINT32 Attributes; 54 | 55 | if (Argc == 2) { 56 | if (!StrCmp(Argv[1], L"--version") || 57 | !StrCmp(Argv[1], L"-V")) { 58 | Print(L"Version: %s\n", UTILITY_VERSION); 59 | return Status; 60 | } else if (!StrCmp(Argv[1], L"--verbose") || 61 | !StrCmp(Argv[1], L"-v")) { 62 | Verbose = TRUE; 63 | } else if (!StrCmp(Argv[1], L"--help") || 64 | !StrCmp(Argv[1], L"-h")) { 65 | Usage(); 66 | return Status; 67 | } else { 68 | Usage(); 69 | return Status; 70 | } 71 | } 72 | if (Argc > 2) { 73 | Usage(); 74 | return Status; 75 | } 76 | 77 | 78 | Attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS; 79 | DataSize = sizeof(UINT64); 80 | 81 | Status = gRT->GetVariable( EFI_OS_INDICATIONS_SUPPORT_VARIABLE_NAME, 82 | &gEfiGlobalVariableGuid, 83 | &Attributes, 84 | &DataSize, 85 | &OsIndicationsSupported); 86 | if (Status == EFI_NOT_FOUND) { 87 | Print(L"ERROR: OsIndicationsSupported variable not found.\n"); 88 | return Status; 89 | } 90 | 91 | #ifdef DEBUG 92 | Print(L"OSIndicationsSupported variable found: 0x%016x\n", OsIndicationSupport ); 93 | #endif 94 | 95 | Attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS; 96 | DataSize = sizeof(UINT64); 97 | 98 | Status = gRT->GetVariable( EFI_OS_INDICATIONS_VARIABLE_NAME, 99 | &gEfiGlobalVariableGuid, 100 | &Attributes, 101 | &DataSize, 102 | &OsIndications); 103 | if (Status == EFI_NOT_FOUND) { 104 | Print(L"ERROR: OSIndications variable not found.\n"); 105 | return Status; 106 | } 107 | 108 | #ifdef DEBUG 109 | Print(L"OsIndications variable found: 0x%016x\n", OsIndication); 110 | #endif 111 | 112 | SupportBootFwUi = (BOOLEAN) ((OsIndicationsSupported & EFI_OS_INDICATIONS_BOOT_TO_FW_UI) != 0); 113 | SupportTimeStampRevocation = (BOOLEAN) ((OsIndicationsSupported & EFI_OS_INDICATIONS_TIMESTAMP_REVOCATION) != 0); 114 | SupportFileCapsuleDelivery = (BOOLEAN) ((OsIndicationsSupported & EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED) != 0); 115 | SupportFMPCapsuleSupported = (BOOLEAN) ((OsIndicationsSupported & EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED) != 0); 116 | SupportCapsuleResultVariable = (BOOLEAN) ((OsIndicationsSupported & EFI_OS_INDICATIONS_CAPSULE_RESULT_VAR_SUPPORTED) != 0); 117 | SupportPlatformRecovery = (BOOLEAN) ((OsIndicationsSupported & EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY) != 0); 118 | 119 | BootFwUi = (BOOLEAN) ((OsIndications & EFI_OS_INDICATIONS_BOOT_TO_FW_UI) != 0); 120 | TimeStampRevocation = (BOOLEAN) ((OsIndications & EFI_OS_INDICATIONS_TIMESTAMP_REVOCATION) != 0); 121 | FileCapsuleDelivery = (BOOLEAN) ((OsIndications & EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED) != 0); 122 | FMPCapsuleSupported = (BOOLEAN) ((OsIndications & EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED) != 0); 123 | CapsuleResultVariable = (BOOLEAN) ((OsIndications & EFI_OS_INDICATIONS_CAPSULE_RESULT_VAR_SUPPORTED) != 0); 124 | PlatformRecovery = (BOOLEAN) ((OsIndications & EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY) != 0); 125 | 126 | Print(L"\n"); 127 | if (Verbose) { 128 | Print(L" OsIndicationsSupported Variable: 0x%016x\n", OsIndicationsSupported); 129 | Print(L" OsIndications Variable: 0x%016x\n", OsIndications); 130 | Print(L"\n"); 131 | } 132 | Print(L" Boot to Firmware UI: %s [%s]\n", SupportBootFwUi ? L"Supported " : L"Unsupported", 133 | BootFwUi ? L"Set" : L"Unset"); 134 | Print(L" Timestamp Revocation: %s [%s]\n", SupportTimeStampRevocation ? L"Supported " : L"Unsupported", 135 | TimeStampRevocation ? L"Set" : L"Unset"); 136 | Print(L" File Capsule Delivery Support: %s [%s]\n", SupportFileCapsuleDelivery ? L"Supported " : L"Unsupported", 137 | FileCapsuleDelivery ? L"Set" : L"Unset"); 138 | Print(L" FMP Capsule Support: %s [%s]\n", SupportFMPCapsuleSupported ? L"Supported " : L"Unsupported", 139 | FMPCapsuleSupported ? L"Set" : L"Unset"); 140 | Print(L" Capsule Result Variable Support: %s [%s]\n", SupportCapsuleResultVariable ? L"Supported " : L"Unsupported", 141 | CapsuleResultVariable ? L"Set" : L"Unset"); 142 | Print(L" Start Platform Recovery: %s [%s]\n", SupportPlatformRecovery ? L"Supported " : L"Unsupported", 143 | PlatformRecovery ? L"Set" : L"Unset"); 144 | Print(L"\n"); 145 | 146 | return Status; 147 | } 148 | -------------------------------------------------------------------------------- /MyApps/ShowOsIndications/ShowOsIndications.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/ShowOsIndications/ShowOsIndications.efi -------------------------------------------------------------------------------- /MyApps/ShowOsIndications/ShowOsIndications.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ShowOsIndications 4 | FILE_GUID = 4ea87c61-7491-4dfd-0055-747010f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | ShowOsIndications.c 12 | 13 | [Packages] 14 | MdePkg/MdePkg.dec 15 | ShellPkg/ShellPkg.dec 16 | 17 | [LibraryClasses] 18 | ShellCEntryLib 19 | ShellLib 20 | BaseLib 21 | BaseMemoryLib 22 | UefiLib 23 | 24 | [Protocols] 25 | 26 | [BuildOptions] 27 | 28 | [Pcd] 29 | 30 | -------------------------------------------------------------------------------- /MyApps/ShowPCI/ShowPCI.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2017-2018 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Show PCI devices 5 | // 6 | // License: UDK2015 license applies to code from UDK2015 source, 7 | // BSD 2 clause license applies to all other code. 8 | // 9 | 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | #define CALC_EFI_PCI_ADDRESS(Bus, Dev, Func, Reg) \ 29 | ((UINT64) ((((UINTN) Bus) << 24) + (((UINTN) Dev) << 16) + (((UINTN) Func) << 8) + ((UINTN) Reg))) 30 | 31 | 32 | #if 0 // See Pci22.h 33 | typedef struct { 34 | UINT16 VendorId; 35 | UINT16 DeviceId; 36 | UINT16 Command; 37 | UINT16 Status; 38 | UINT8 RevisionID; 39 | UINT8 ClassCode[3]; 40 | UINT8 CacheLineSize; 41 | UINT8 LatencyTimer; 42 | UINT8 HeaderType; 43 | UINT8 BIST; 44 | } PCI_DEVICE_INDEPENDENT_REGION; 45 | 46 | typedef struct { 47 | UINT32 Bar[6]; // Base Address Registers 48 | UINT32 CISPtr; // CardBus CIS Pointer 49 | UINT16 SubsystemVendorID; // Subsystem Vendor ID 50 | UINT16 SubsystemID; // Subsystem ID 51 | UINT32 ExpansionRomBar; // Expansion ROM Base Address 52 | UINT8 CapabilityPtr; // Capabilities Pointer 53 | UINT8 Reserved1[3]; 54 | UINT32 Reserved2; 55 | UINT8 InterruptLine; // Interrupt Line 56 | UINT8 InterruptPin; // Interrupt Pin 57 | UINT8 MinGnt; // Min_Gnt 58 | UINT8 MaxLat; // Max_Lat 59 | } PCI_DEVICE_HEADER_TYPE_REGION; 60 | 61 | typedef struct { 62 | UINT32 CardBusSocketReg; // Cardus Socket/ExCA Base Address Register 63 | UINT8 Cap_Ptr; // 14h in pci-cardbus bridge. 64 | UINT8 Reserved; 65 | UINT16 SecondaryStatus; // Secondary Status 66 | UINT8 PciBusNumber; // PCI Bus Number 67 | UINT8 CardBusBusNumber; // CardBus Bus Number 68 | UINT8 SubordinateBusNumber; // Subordinate Bus Number 69 | UINT8 CardBusLatencyTimer; // CardBus Latency Timer 70 | UINT32 MemoryBase0; // Memory Base Register 0 71 | UINT32 MemoryLimit0; // Memory Limit Register 0 72 | UINT32 MemoryBase1; 73 | UINT32 MemoryLimit1; 74 | UINT32 IoBase0; 75 | UINT32 IoLimit0; // I/O Base Register 0 76 | UINT32 IoBase1; // I/O Limit Register 0 77 | UINT32 IoLimit1; 78 | UINT8 InterruptLine; // Interrupt Line 79 | UINT8 InterruptPin; // Interrupt Pin 80 | UINT16 BridgeControl; // Bridge Control 81 | } PCI_CARDBUS_CONTROL_REGISTER; 82 | #endif 83 | 84 | 85 | #pragma pack(1) 86 | typedef union { 87 | PCI_DEVICE_HEADER_TYPE_REGION Device; 88 | PCI_CARDBUS_CONTROL_REGISTER CardBus; 89 | } NON_COMMON_UNION; 90 | 91 | typedef struct { 92 | PCI_DEVICE_INDEPENDENT_REGION Common; 93 | NON_COMMON_UNION NonCommon; 94 | UINT32 Data[48]; 95 | } PCI_CONFIG_SPACE; 96 | #pragma pack() 97 | 98 | #define UTILITY_VERSION L"20180320" 99 | #undef DEBUG 100 | 101 | 102 | // 103 | // Copyed from UDK2015 Source. UDK2015 license applies. 104 | // 105 | EFI_STATUS 106 | PciGetNextBusRange( EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors, 107 | UINT16 *MinBus, 108 | UINT16 *MaxBus, 109 | BOOLEAN *IsEnd ) 110 | { 111 | *IsEnd = FALSE; 112 | 113 | if ((*Descriptors) == NULL) { 114 | *MinBus = 0; 115 | *MaxBus = PCI_MAX_BUS; 116 | return EFI_SUCCESS; 117 | } 118 | 119 | while ((*Descriptors)->Desc != ACPI_END_TAG_DESCRIPTOR) { 120 | if ((*Descriptors)->ResType == ACPI_ADDRESS_SPACE_TYPE_BUS) { 121 | *MinBus = (UINT16) (*Descriptors)->AddrRangeMin; 122 | *MaxBus = (UINT16) (*Descriptors)->AddrRangeMax; 123 | (*Descriptors)++; 124 | return (EFI_SUCCESS); 125 | } 126 | 127 | (*Descriptors)++; 128 | } 129 | 130 | if ((*Descriptors)->Desc == ACPI_END_TAG_DESCRIPTOR) { 131 | *IsEnd = TRUE; 132 | } 133 | 134 | return EFI_SUCCESS; 135 | } 136 | 137 | 138 | // 139 | // Copyed from UDK2015 Source. UDK2015 license applies. 140 | // 141 | EFI_STATUS 142 | PciGetProtocolAndResource( EFI_HANDLE Handle, 143 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **IoDev, 144 | EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors ) 145 | { 146 | EFI_STATUS Status; 147 | 148 | // Get inferface from protocol 149 | Status = gBS->HandleProtocol( Handle, 150 | &gEfiPciRootBridgeIoProtocolGuid, 151 | (VOID**)IoDev); 152 | if (EFI_ERROR (Status)) { 153 | return Status; 154 | } 155 | 156 | Status = (*IoDev)->Configuration (*IoDev, (VOID**)Descriptors); 157 | if (Status == EFI_UNSUPPORTED) { 158 | *Descriptors = NULL; 159 | return EFI_SUCCESS; 160 | } 161 | 162 | return Status; 163 | } 164 | 165 | 166 | VOID 167 | Usage( BOOLEAN ErrorMsg ) 168 | { 169 | if ( ErrorMsg ) { 170 | Print(L"ERROR: Unknown option.\n"); 171 | } 172 | Print(L"Usage: ShowPCI [-V | --version]\n"); 173 | } 174 | 175 | 176 | INTN 177 | EFIAPI 178 | ShellAppMain( UINTN Argc, 179 | CHAR16 **Argv ) 180 | { 181 | EFI_GUID gEfiPciEnumerationCompleteProtocolGuid = EFI_PCI_ENUMERATION_COMPLETE_GUID; 182 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev; 183 | EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptors; 184 | PCI_DEVICE_INDEPENDENT_REGION PciHeader; 185 | PCI_CONFIG_SPACE ConfigSpace; 186 | PCI_DEVICE_HEADER_TYPE_REGION *DeviceHeader; 187 | EFI_STATUS Status = EFI_SUCCESS; 188 | EFI_HANDLE *HandleBuf; 189 | UINTN HandleBufSize; 190 | UINTN HandleCount; 191 | UINT64 Address; 192 | UINT16 MinBus; 193 | UINT16 MaxBus; 194 | BOOLEAN IsEnd; 195 | VOID *Interface; 196 | 197 | if (Argc == 2) { 198 | if (!StrCmp(Argv[1], L"--version") || 199 | !StrCmp(Argv[1], L"-V")) { 200 | Print(L"Version: %s\n", UTILITY_VERSION); 201 | return Status; 202 | } else if (!StrCmp(Argv[1], L"--help") || 203 | !StrCmp(Argv[1], L"-h")) { 204 | Usage(FALSE); 205 | return Status; 206 | } else { 207 | Usage(TRUE); 208 | return Status; 209 | } 210 | } 211 | if (Argc > 2) { 212 | Usage(TRUE); 213 | return Status; 214 | } 215 | 216 | 217 | Status = gBS->LocateProtocol( &gEfiPciEnumerationCompleteProtocolGuid, 218 | NULL, 219 | &Interface ); 220 | if (EFI_ERROR(Status)) { 221 | Print(L"ERROR: Could not find PCI enumeration protocol\n"); 222 | return Status; 223 | } 224 | 225 | HandleBufSize = sizeof(EFI_HANDLE); 226 | HandleBuf = (EFI_HANDLE *) AllocateZeroPool( HandleBufSize); 227 | if (HandleBuf == NULL) { 228 | Print(L"ERROR: Out of memory resources\n"); 229 | return EFI_OUT_OF_RESOURCES; 230 | } 231 | 232 | Status = gBS->LocateHandle( ByProtocol, 233 | &gEfiPciRootBridgeIoProtocolGuid, 234 | NULL, 235 | &HandleBufSize, 236 | HandleBuf ); 237 | 238 | if (Status == EFI_BUFFER_TOO_SMALL) { 239 | HandleBuf = ReallocatePool( sizeof (EFI_HANDLE), 240 | HandleBufSize, 241 | HandleBuf ); 242 | if (HandleBuf == NULL) { 243 | Print(L"ERROR: Out of memory resources\n"); 244 | Status = EFI_OUT_OF_RESOURCES; 245 | goto Done; 246 | } 247 | 248 | Status = gBS->LocateHandle( ByProtocol, 249 | &gEfiPciRootBridgeIoProtocolGuid, 250 | NULL, 251 | &HandleBufSize, 252 | HandleBuf ); 253 | } 254 | 255 | if (EFI_ERROR (Status)) { 256 | Print(L"ERROR: Failed to find any PCI handles\n"); 257 | goto Done; 258 | } 259 | 260 | HandleCount = HandleBufSize / sizeof (EFI_HANDLE); 261 | 262 | for (UINT16 Index = 0; Index < HandleCount; Index++) { 263 | Status = PciGetProtocolAndResource( HandleBuf[Index], 264 | &IoDev, 265 | &Descriptors ); 266 | if (EFI_ERROR(Status)) { 267 | Print(L"ERROR: PciGetProtocolAndResource [%d]\n, Status"); 268 | goto Done; 269 | } 270 | 271 | while(TRUE) { 272 | Status = PciGetNextBusRange( &Descriptors, 273 | &MinBus, 274 | &MaxBus, 275 | &IsEnd ); 276 | if (EFI_ERROR(Status)) { 277 | Print(L"ERROR: Retrieving PCI bus range [%d]\n", Status); 278 | goto Done; 279 | } 280 | 281 | if (IsEnd) { 282 | break; 283 | } 284 | 285 | Print(L"\n"); 286 | Print(L" Bus Vendor Device Subvendor SubvendorDevice\n"); 287 | Print(L" ----------------------------------------------------\n"); 288 | 289 | for (UINT16 Bus = MinBus; Bus <= MaxBus; Bus++) { 290 | for (UINT16 Device = 0; Device <= PCI_MAX_DEVICE; Device++) { 291 | for (UINT16 Func = 0; Func <= PCI_MAX_FUNC; Func++) { 292 | Address = CALC_EFI_PCI_ADDRESS (Bus, Device, Func, 0); 293 | 294 | Status = IoDev->Pci.Read( IoDev, 295 | EfiPciWidthUint8, 296 | Address, 297 | sizeof(ConfigSpace), 298 | &ConfigSpace ); 299 | 300 | DeviceHeader = (PCI_DEVICE_HEADER_TYPE_REGION *) &(ConfigSpace.NonCommon.Device); 301 | 302 | IoDev->Pci.Read( IoDev, 303 | EfiPciWidthUint16, 304 | Address, 305 | 1, 306 | &PciHeader.VendorId ); 307 | 308 | if (PciHeader.VendorId == 0xffff && Func == 0) { 309 | break; 310 | } 311 | 312 | if (PciHeader.VendorId != 0xffff) { 313 | IoDev->Pci.Read( IoDev, 314 | EfiPciWidthUint32, 315 | Address, 316 | sizeof (PciHeader) / sizeof (UINT32), 317 | &PciHeader ); 318 | 319 | Print(L" %02d %04x %04x %04x %04x\n", 320 | Bus, PciHeader.VendorId, PciHeader.DeviceId, 321 | DeviceHeader->SubsystemVendorID, DeviceHeader->SubsystemID); 322 | 323 | if (Func == 0 && 324 | ((PciHeader.HeaderType & HEADER_TYPE_MULTI_FUNCTION) == 0x00)) { 325 | break; 326 | } 327 | } 328 | } 329 | } 330 | } 331 | 332 | if (Descriptors == NULL) { 333 | break; 334 | } 335 | } 336 | } 337 | 338 | Print(L"\n"); 339 | 340 | Done: 341 | if (HandleBuf != NULL) { 342 | FreePool(HandleBuf); 343 | } 344 | 345 | return Status; 346 | } 347 | -------------------------------------------------------------------------------- /MyApps/ShowPCI/ShowPCI.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/ShowPCI/ShowPCI.efi -------------------------------------------------------------------------------- /MyApps/ShowPCI/ShowPCI.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ShowPCI 4 | FILE_GUID = 4ea87c51-7491-4dfd-0055-767013f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | 11 | 12 | [Sources] 13 | ShowPCI.c 14 | 15 | [Packages] 16 | MdePkg/MdePkg.dec 17 | ShellPkg/ShellPkg.dec 18 | 19 | [LibraryClasses] 20 | ShellCEntryLib 21 | ShellLib 22 | ShellCommandLib 23 | BaseLib 24 | BaseMemoryLib 25 | UefiLib 26 | 27 | [Protocols] 28 | gEfiPciRootBridgeIoProtocolGuid ## CONSUMES 29 | 30 | [BuildOptions] 31 | 32 | [Pcd] 33 | 34 | -------------------------------------------------------------------------------- /MyApps/ShowPCIx/ShowPCIx.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/ShowPCIx/ShowPCIx.efi -------------------------------------------------------------------------------- /MyApps/ShowPCIx/ShowPCIx.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ShowPCIx 4 | FILE_GUID = 4ea87c51-7491-4dfd-0055-767013f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | ShowPCIx.c 12 | 13 | [Packages] 14 | MdePkg/MdePkg.dec 15 | ShellPkg/ShellPkg.dec 16 | 17 | [LibraryClasses] 18 | ShellCEntryLib 19 | ShellLib 20 | ShellCommandLib 21 | BaseLib 22 | BaseMemoryLib 23 | UefiLib 24 | 25 | [Protocols] 26 | gEfiPciRootBridgeIoProtocolGuid ## CONSUMES 27 | 28 | [BuildOptions] 29 | 30 | [Pcd] 31 | 32 | -------------------------------------------------------------------------------- /MyApps/ShowPCR12/ShowPCR12.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2017-2018 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Retrieve and print TPMi 1.2 PCR digests 5 | // 6 | // License: UDK2017 license applies to code from UDK2017 sources, 7 | // BSD 2 clause license applies to all other code. 8 | // 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | #define UTILITY_VERSION L"20180802" 25 | #undef DEBUG 26 | 27 | 28 | VOID 29 | Print_PcrDigest( TPM_PCRINDEX PcrIndex, 30 | TPM_PCRVALUE *PcrValue ) 31 | { 32 | int size = sizeof(TPM_PCRVALUE); 33 | UINT8 *buf = (UINT8 *)PcrValue; 34 | 35 | Print(L"[%02d] ", PcrIndex); 36 | for (int i = 0; i < size; i++) { 37 | Print(L"%02x ", 0xff & buf[i]); 38 | } 39 | Print(L"\n"); 40 | } 41 | 42 | 43 | BOOLEAN 44 | CheckForTpm20() 45 | { 46 | EFI_STATUS Status = EFI_SUCCESS; 47 | EFI_TCG2_PROTOCOL *Tcg2Protocol; 48 | EFI_GUID gEfiTcg2ProtocolGuid = EFI_TCG2_PROTOCOL_GUID; 49 | 50 | Status = gBS->LocateProtocol( &gEfiTcg2ProtocolGuid, 51 | NULL, 52 | (VOID **) &Tcg2Protocol ); 53 | if (EFI_ERROR (Status)) { 54 | return FALSE; 55 | } 56 | 57 | return TRUE; 58 | } 59 | 60 | 61 | VOID 62 | Usage( CHAR16 *Str, 63 | BOOLEAN ErrorMsg ) 64 | { 65 | if ( ErrorMsg ) { 66 | Print(L"ERROR: Unknown option.\n"); 67 | } 68 | Print(L"Usage: %s [-V | --version]\n", Str); 69 | } 70 | 71 | 72 | INTN 73 | EFIAPI 74 | ShellAppMain( UINTN Argc, 75 | CHAR16 **Argv ) 76 | { 77 | EFI_GUID gEfiTcgProtocolGuid = EFI_TCG_PROTOCOL_GUID; 78 | EFI_STATUS Status = EFI_SUCCESS; 79 | EFI_TCG_PROTOCOL *TcgProtocol; 80 | TPM_RSP_COMMAND_HDR *TpmRsp; 81 | UINT32 TpmSendSize; 82 | UINT8 CmdBuf[64]; 83 | TPM_PCRINDEX PcrIndex; 84 | TPM_PCRVALUE *PcrValue; 85 | 86 | if (Argc == 2) { 87 | if ((!StrCmp(Argv[1], L"--version")) || 88 | (!StrCmp(Argv[1], L"-V"))) { 89 | Print(L"Version: %s\n", UTILITY_VERSION); 90 | return Status; 91 | } else if ((!StrCmp(Argv[1], L"--help")) || 92 | (!StrCmp(Argv[1], L"-h"))) { 93 | Usage(Argv[0], FALSE); 94 | return Status; 95 | } else { 96 | Usage(Argv[0], TRUE); 97 | return Status; 98 | } 99 | } 100 | if (Argc > 2) { 101 | Usage(Argv[0], TRUE); 102 | return Status; 103 | } 104 | 105 | Status = gBS->LocateProtocol( &gEfiTcgProtocolGuid, 106 | NULL, 107 | (VOID **) &TcgProtocol ); 108 | if (EFI_ERROR (Status)) { 109 | if (CheckForTpm20()) { 110 | Print(L"ERROR: Platform configured for TPM 2.0, not TPM 1.2\n"); 111 | } else { 112 | Print(L"ERROR: Failed to locate EFI_TCG_PROTOCOL [%d]\n", Status); 113 | } 114 | return Status; 115 | } 116 | 117 | // Loop through all the PCRs and print each digest 118 | for (PcrIndex = 1; PcrIndex <= TPM_NUM_PCR; PcrIndex++) { 119 | TpmSendSize = sizeof (TPM_RQU_COMMAND_HDR) + sizeof (UINT32); 120 | *(UINT16*)&CmdBuf[0] = SwapBytes16 (TPM_TAG_RQU_COMMAND); 121 | *(UINT32*)&CmdBuf[2] = SwapBytes32 (TpmSendSize); 122 | *(UINT32*)&CmdBuf[6] = SwapBytes32 (TPM_ORD_PcrRead); 123 | *(UINT32*)&CmdBuf[10] = SwapBytes32 (PcrIndex); 124 | 125 | Status = TcgProtocol->PassThroughToTpm( TcgProtocol, 126 | TpmSendSize, 127 | CmdBuf, 128 | sizeof (CmdBuf), 129 | CmdBuf ); 130 | if (EFI_ERROR (Status)) { 131 | if (CheckForTpm20()) { 132 | Print(L"ERROR: Platform configured for TPM 2.0, not TPM 1.2\n"); 133 | } else { 134 | Print(L"ERROR: PassThroughToTpm failed [%d]\n", Status); 135 | } 136 | return Status; 137 | } 138 | 139 | TpmRsp = (TPM_RSP_COMMAND_HDR *) &CmdBuf[0]; 140 | if ((TpmRsp->tag != SwapBytes16(TPM_TAG_RSP_COMMAND)) || (TpmRsp->returnCode != 0)) { 141 | Print(L"ERROR: TPM command result [%d]\n", SwapBytes16(TpmRsp->returnCode)); 142 | return EFI_DEVICE_ERROR; 143 | } 144 | 145 | PcrValue = (TPM_PCRVALUE *) &CmdBuf[sizeof (TPM_RSP_COMMAND_HDR)]; 146 | Print_PcrDigest(PcrIndex, PcrValue); 147 | } 148 | 149 | return Status; 150 | } 151 | -------------------------------------------------------------------------------- /MyApps/ShowPCR12/ShowPCR12.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/ShowPCR12/ShowPCR12.efi -------------------------------------------------------------------------------- /MyApps/ShowPCR12/ShowPCR12.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ShowPCR12 4 | FILE_GUID = 4ea87c51-7395-4ccd-0355-747011f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | ShowPCR12.c 12 | 13 | [Packages] 14 | MdePkg/MdePkg.dec 15 | ShellPkg/ShellPkg.dec 16 | 17 | [LibraryClasses] 18 | ShellCEntryLib 19 | ShellLib 20 | BaseLib 21 | BaseMemoryLib 22 | UefiLib 23 | 24 | [Protocols] 25 | 26 | [BuildOptions] 27 | 28 | [Pcd] 29 | 30 | -------------------------------------------------------------------------------- /MyApps/ShowPCR20/ShowPCR20.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/ShowPCR20/ShowPCR20.efi -------------------------------------------------------------------------------- /MyApps/ShowPCR20/ShowPCR20.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ShowPCR20 4 | FILE_GUID = 4ea87c51-7395-4ccd-0355-747111f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | ShowPCR20.c 12 | 13 | [Packages] 14 | MdePkg/MdePkg.dec 15 | ShellPkg/ShellPkg.dec 16 | 17 | [LibraryClasses] 18 | ShellCEntryLib 19 | ShellLib 20 | BaseLib 21 | BaseMemoryLib 22 | UefiLib 23 | 24 | [Protocols] 25 | 26 | [BuildOptions] 27 | 28 | [Pcd] 29 | 30 | -------------------------------------------------------------------------------- /MyApps/ShowQVI/ShowQVI.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2012 - 2018 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Show EFI Variable Store infomation returned by QueryVariableInformation API 5 | // 6 | // License: BSD License 7 | // 8 | 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | #define UTILITY_VERSION L"20180320" 26 | #undef DEBUG 27 | 28 | 29 | VOID 30 | Usage( VOID ) 31 | { 32 | Print(L"Usage: ShowQVI [-V | --version]\n"); 33 | } 34 | 35 | 36 | INTN 37 | EFIAPI 38 | ShellAppMain( UINTN Argc, 39 | CHAR16 **Argv ) 40 | { 41 | EFI_STATUS Status = EFI_SUCCESS; 42 | UINT32 Attributes; 43 | UINT64 MaxStoreSize = 0; 44 | UINT64 RemainStoreSize = 0; 45 | UINT64 MaxVariableSize = 0; 46 | 47 | if (Argc == 2) { 48 | if (!StrCmp(Argv[1], L"--version") || 49 | !StrCmp(Argv[1], L"-V")) { 50 | Print(L"Version: %s\n", UTILITY_VERSION); 51 | return Status; 52 | } else if (!StrCmp(Argv[1], L"--help") || 53 | !StrCmp(Argv[1], L"-h")) { 54 | Usage(); 55 | return Status; 56 | } else { 57 | Usage(); 58 | return Status; 59 | } 60 | } 61 | if (Argc > 2) { 62 | Usage(); 63 | return Status; 64 | } 65 | 66 | 67 | Attributes = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS; 68 | 69 | Status = gRT->QueryVariableInfo( Attributes, 70 | &MaxStoreSize, 71 | &RemainStoreSize, 72 | &MaxVariableSize ); 73 | if (Status != EFI_SUCCESS) { 74 | Print(L"ERROR: QueryVariableInfo: %d\n", Status); 75 | return Status; 76 | } 77 | 78 | Print(L"\n"); 79 | Print(L" Maximum Variable Storage Size: 0x%016x [%ld]\n", MaxStoreSize, MaxStoreSize); 80 | Print(L" Remaining Variable Storage Size: 0x%016x [%ld]\n", RemainStoreSize, RemainStoreSize); 81 | Print(L" Maximum Variable Size: 0x%016x [%ld]\n", MaxVariableSize, MaxVariableSize); 82 | Print(L"\n"); 83 | 84 | return Status; 85 | } 86 | -------------------------------------------------------------------------------- /MyApps/ShowQVI/ShowQVI.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/ShowQVI/ShowQVI.efi -------------------------------------------------------------------------------- /MyApps/ShowQVI/ShowQVI.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ShowQVI 4 | FILE_GUID = 4ea87c51-7395-4dcd-0055-747010f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | ShowQVI.c 12 | 13 | [Packages] 14 | MdePkg/MdePkg.dec 15 | ShellPkg/ShellPkg.dec 16 | 17 | [LibraryClasses] 18 | ShellCEntryLib 19 | ShellLib 20 | BaseLib 21 | BaseMemoryLib 22 | UefiLib 23 | 24 | [Protocols] 25 | 26 | [BuildOptions] 27 | 28 | [Pcd] 29 | 30 | -------------------------------------------------------------------------------- /MyApps/ShowSLIC/ShowSLIC.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2018 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Display ACPI SLIC table 5 | // 6 | // License: BSD License 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | #define UTILITY_VERSION L"20180227" 25 | #undef DEBUG 26 | 27 | #pragma pack(1) 28 | // OEM Public Key 29 | typedef struct { 30 | UINT32 Type; 31 | UINT32 Length; 32 | UINT8 KeyType; 33 | UINT8 Version; 34 | UINT16 Reserved; 35 | UINT32 Algorithm; 36 | CHAR8 Magic[4]; 37 | UINT32 BitLength; 38 | UINT32 Exponent; 39 | UINT8 Modulus[128]; 40 | } OEM_PUBLIC_KEY; 41 | 42 | // Windows Marker 43 | typedef struct { 44 | UINT32 Type; 45 | UINT32 Length; 46 | UINT32 Version; 47 | CHAR8 OemId[6]; 48 | CHAR8 OemTableId[8]; 49 | CHAR8 Product[8]; 50 | UINT16 MinorVersion; 51 | UINT16 MajorVersion; 52 | UINT8 Signature[144]; 53 | } WINDOWS_MARKER; 54 | 55 | // Software Licensing 56 | typedef struct { 57 | EFI_ACPI_SDT_HEADER Header; 58 | OEM_PUBLIC_KEY PubKey; 59 | WINDOWS_MARKER Marker; 60 | } EFI_ACPI_SLIC; 61 | #pragma pack() 62 | 63 | 64 | static VOID AsciiToUnicodeSize(CHAR8 *, UINT8, CHAR16 *, BOOLEAN); 65 | 66 | 67 | static VOID 68 | AsciiToUnicodeSize( CHAR8 *String, 69 | UINT8 length, 70 | CHAR16 *UniString, 71 | BOOLEAN Quote ) 72 | { 73 | int len = length; 74 | 75 | if (Quote) 76 | *(UniString++) = L'"'; 77 | while (*String != '\0' && len > 0) { 78 | *(UniString++) = (CHAR16) *(String++); 79 | len--; 80 | } 81 | if (Quote) 82 | *(UniString++) = L'"'; 83 | *UniString = '\0'; 84 | } 85 | 86 | 87 | 88 | static VOID 89 | PrintHexTable( UINT8 *ptr, 90 | int Count ) 91 | { 92 | int i = 0; 93 | 94 | Print(L" "); 95 | for (i = 0; i < Count; i++ ) { 96 | if ( i > 0 && i%16 == 0) 97 | Print(L"\n "); 98 | Print(L"0x%02x ", 0xff & *ptr++); 99 | } 100 | Print(L"\n"); 101 | } 102 | 103 | 104 | static VOID 105 | PrintAcpiHeader( EFI_ACPI_SDT_HEADER *Ptr ) 106 | { 107 | CHAR16 Buffer[50]; 108 | 109 | Print(L"ACPI Standard Header\n"); 110 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->Signature), 4, Buffer, TRUE); 111 | Print(L" Signature : %s\n", Buffer); 112 | Print(L" Length : 0x%08x (%d)\n", Ptr->Length, Ptr->Length); 113 | Print(L" Revision : 0x%02x (%d)\n", Ptr->Revision, Ptr->Revision); 114 | Print(L" Checksum : 0x%02x (%d)\n", Ptr->Checksum, Ptr->Checksum); 115 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->OemId), 6, Buffer, TRUE); 116 | Print(L" OEM ID : %s\n", Buffer); 117 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->OemTableId), 8, Buffer, TRUE); 118 | Print(L" OEM Table ID : %s\n", Buffer); 119 | Print(L" OEM Revision : 0x%08x (%d)\n", Ptr->OemRevision, 120 | Ptr->OemRevision); 121 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->CreatorId), 4, Buffer, TRUE); 122 | Print(L" Creator ID : %s\n", Buffer); 123 | Print(L" Creator Revision : 0x%08x (%d)\n", Ptr->CreatorRevision, 124 | Ptr->CreatorRevision); 125 | Print(L"\n"); 126 | } 127 | 128 | 129 | static VOID 130 | PrintOemPublicKey( OEM_PUBLIC_KEY *Ptr, 131 | int Verbose ) 132 | { 133 | CHAR16 Buffer[50]; 134 | 135 | Print(L"OEM Public Key\n"); 136 | Print(L" Type : 0x%08x (%d)\n", Ptr->Type, Ptr->Type); 137 | Print(L" Length : 0x%08x (%d)\n", Ptr->Length, Ptr->Length); 138 | Print(L" KeyType : 0x%02x (%d)\n", Ptr->KeyType, Ptr->KeyType); 139 | Print(L" Version : 0x%02x (%d)\n", Ptr->Version, Ptr->Version); 140 | Print(L" Reserved : 0x%04x (%d)\n", Ptr->Reserved, Ptr->Reserved); 141 | Print(L" Algorithm : 0x%08x (%d)\n", Ptr->Algorithm, Ptr->Algorithm); 142 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->Magic), 4, Buffer, TRUE); 143 | Print(L" Magic : %s\n", Buffer); 144 | Print(L" Bit Length : 0x%08x (%d)\n", Ptr->BitLength, Ptr->BitLength); 145 | Print(L" Exponent : 0x%08x (%d)\n", Ptr->Exponent, Ptr->Exponent); 146 | if (Verbose) { 147 | Print(L" Modulus:\n"); 148 | PrintHexTable( (UINT8 *)&(Ptr->Modulus), (int)(Ptr->BitLength)/8 ); 149 | } 150 | Print(L"\n"); 151 | } 152 | 153 | 154 | static VOID 155 | PrintWindowsMarker( WINDOWS_MARKER *Ptr, 156 | int Verbose ) 157 | { 158 | CHAR16 Buffer[50]; 159 | 160 | Print(L"Windows Marker\n"); 161 | Print(L" Type : 0x%08x (%d)\n", Ptr->Type, Ptr->Type); 162 | Print(L" Length : 0x%08x (%d)\n", Ptr->Length, Ptr->Length); 163 | Print(L" Version : 0x%02x (%d)\n", Ptr->Version, Ptr->Version); 164 | AsciiToUnicodeSize((CHAR8 *)(Ptr->OemId), 6, Buffer, TRUE); 165 | Print(L" OEM ID : %s\n", Buffer); 166 | AsciiToUnicodeSize((CHAR8 *)(Ptr->OemTableId), 8, Buffer, TRUE); 167 | Print(L" OEM Table ID : %s\n", Buffer); 168 | AsciiToUnicodeSize((CHAR8 *)(Ptr->Product), 8, Buffer, TRUE); 169 | Print(L" Windows Flag : %s\n", Buffer); 170 | Print(L" SLIC Version : 0x%04x%04x (%d.%d)\n", Ptr->MajorVersion, Ptr->MinorVersion, 171 | Ptr->MajorVersion, Ptr->MinorVersion); 172 | if (Verbose) { 173 | Print(L" Signature:\n"); 174 | PrintHexTable( (UINT8 *)&(Ptr->Signature), 144 ); // 144 - Fix up in next version 175 | } 176 | Print(L"\n"); 177 | } 178 | 179 | 180 | static VOID 181 | PrintSLIC( EFI_ACPI_SLIC *Slic, 182 | int Verbose ) 183 | { 184 | Print(L"\n"); 185 | PrintAcpiHeader( (EFI_ACPI_SDT_HEADER *)&(Slic->Header) ); 186 | PrintOemPublicKey( (OEM_PUBLIC_KEY *)&(Slic->PubKey), Verbose ); 187 | PrintWindowsMarker( (WINDOWS_MARKER *)&(Slic->Marker), Verbose ); 188 | } 189 | 190 | 191 | static int 192 | ParseRSDP( EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp, 193 | CHAR16* GuidStr, 194 | int Verbose ) 195 | { 196 | EFI_ACPI_SDT_HEADER *Xsdt, *Entry; 197 | UINT32 EntryCount; 198 | UINT64 *EntryPtr; 199 | 200 | #ifdef DEBUG 201 | CHAR16 OemStr[20]; 202 | 203 | Print(L"\n\nACPI GUID: %s\n", GuidStr); 204 | 205 | AsciiToUnicodeSize((CHAR8 *)(Rsdp->OemId), 6, OemStr, FALSE); 206 | Print(L"\nFound RSDP. Version: %d OEM ID: %s\n", (int)(Rsdp->Revision), OemStr); 207 | #endif 208 | 209 | if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) { 210 | Xsdt = (EFI_ACPI_SDT_HEADER *)(Rsdp->XsdtAddress); 211 | } else { 212 | #ifdef DEBUG 213 | Print(L"ERROR: No ACPI XSDT table found.\n"); 214 | #endif 215 | return 1; 216 | } 217 | 218 | if (Xsdt->Signature != SIGNATURE_32 ('X', 'S', 'D', 'T')) { 219 | #ifdef DEBUG 220 | Print(L"ERROR: Invalid ACPI XSDT table found.\n"); 221 | #endif 222 | return 1; 223 | } 224 | 225 | EntryCount = (Xsdt->Length - sizeof (EFI_ACPI_SDT_HEADER)) / sizeof(UINT64); 226 | #ifdef DEBUG 227 | AsciiToUnicodeSize((CHAR8 *)(Xsdt->OemId), 6, OemStr, FALSE); 228 | Print(L"Found XSDT. OEM ID: %s Entry Count: %d\n\n", OemStr, EntryCount); 229 | #endif 230 | 231 | EntryPtr = (UINT64 *)(Xsdt + 1); 232 | for (int Index = 0; Index < EntryCount; Index++, EntryPtr++) { 233 | Entry = (EFI_ACPI_SDT_HEADER *)((UINTN)(*EntryPtr)); 234 | if (Entry->Signature == SIGNATURE_32 ('S', 'L', 'I', 'C')) { 235 | PrintSLIC((EFI_ACPI_SLIC *)((UINTN)(*EntryPtr)), Verbose); 236 | } 237 | } 238 | 239 | return 0; 240 | } 241 | 242 | 243 | static void 244 | Usage( void ) 245 | { 246 | Print(L"Usage: ShowSLIC [-v | --verbose]\n"); 247 | Print(L" ShowSLIC [-V | --version]\n"); 248 | } 249 | 250 | 251 | INTN 252 | EFIAPI 253 | ShellAppMain( UINTN Argc, 254 | CHAR16 **Argv ) 255 | { 256 | EFI_CONFIGURATION_TABLE *ect = gST->ConfigurationTable; 257 | EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp = NULL; 258 | EFI_GUID gAcpi20TableGuid = EFI_ACPI_20_TABLE_GUID; 259 | EFI_GUID gAcpi10TableGuid = ACPI_10_TABLE_GUID; 260 | EFI_STATUS Status = EFI_SUCCESS; 261 | CHAR16 GuidStr[100]; 262 | int Verbose = 0; 263 | 264 | 265 | if (Argc == 2) { 266 | if (!StrCmp(Argv[1], L"--verbose") || 267 | !StrCmp(Argv[1], L"-v")) { 268 | Verbose = 1; 269 | } else if (!StrCmp(Argv[1], L"--version") || 270 | !StrCmp(Argv[1], L"-V")) { 271 | Print(L"Version: %s\n", UTILITY_VERSION); 272 | return Status; 273 | } else if (!StrCmp(Argv[1], L"--help") || 274 | !StrCmp(Argv[1], L"-h")) { 275 | Usage(); 276 | return Status; 277 | } else { 278 | Usage(); 279 | return Status; 280 | } 281 | } 282 | if (Argc > 2) { 283 | Usage(); 284 | return Status; 285 | } 286 | 287 | 288 | // locate RSDP (Root System Description Pointer) 289 | for (int i = 0; i < gST->NumberOfTableEntries; i++) { 290 | if ((CompareGuid (&(gST->ConfigurationTable[i].VendorGuid), &gAcpi20TableGuid)) || 291 | (CompareGuid (&(gST->ConfigurationTable[i].VendorGuid), &gAcpi10TableGuid))) { 292 | if (!AsciiStrnCmp("RSD PTR ", (CHAR8 *)(ect->VendorTable), 8)) { 293 | UnicodeSPrint(GuidStr, sizeof(GuidStr), L"%g", &(gST->ConfigurationTable[i].VendorGuid)); 294 | Rsdp = (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)ect->VendorTable; 295 | ParseRSDP(Rsdp, GuidStr, Verbose); 296 | } 297 | } 298 | ect++; 299 | } 300 | 301 | if (Rsdp == NULL) { 302 | Print(L"ERROR: Could not find an ACPI RSDP table.\n"); 303 | Status = EFI_NOT_FOUND; 304 | } 305 | 306 | return Status; 307 | } 308 | -------------------------------------------------------------------------------- /MyApps/ShowSLIC/ShowSLIC.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/ShowSLIC/ShowSLIC.efi -------------------------------------------------------------------------------- /MyApps/ShowSLIC/ShowSLIC.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 0x00010006 3 | BASE_NAME = ShowSLIC 4 | FILE_GUID = 4ea87c51-7395-4dcd-0055-747010f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 0.1 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | ShowSLIC.c 12 | 13 | [Packages] 14 | MdePkg/MdePkg.dec 15 | ShellPkg/ShellPkg.dec 16 | 17 | 18 | [LibraryClasses] 19 | ShellCEntryLib 20 | ShellLib 21 | BaseLib 22 | BaseMemoryLib 23 | UefiLib 24 | 25 | [Protocols] 26 | 27 | [BuildOptions] 28 | 29 | [Pcd] 30 | 31 | -------------------------------------------------------------------------------- /MyApps/ShowTCM20/ShowTCM20.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2016-2018 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Show TCM 2.0 protocol capability information and state information. 5 | // 6 | // License: UDK2017 license applies to code from UDK2017 sources, 7 | // BSD 2 clause license applies to all other code. 8 | // 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define UTILITY_VERSION L"20180822" 23 | #undef DEBUG 24 | 25 | 26 | CHAR16 * 27 | ManufacturerStr( UINT32 ManufacturerID ) 28 | { 29 | static CHAR16 Mcode[5]; 30 | 31 | Mcode[0] = (CHAR16) ((ManufacturerID & 0xff000000) >> 24); 32 | Mcode[1] = (CHAR16) ((ManufacturerID & 0x00ff0000) >> 16); 33 | Mcode[2] = (CHAR16) ((ManufacturerID & 0x0000ff00) >> 8); 34 | Mcode[3] = (CHAR16) (ManufacturerID & 0x000000ff); 35 | Mcode[4] = (CHAR16) '\0'; 36 | 37 | return Mcode; 38 | } 39 | 40 | 41 | VOID 42 | Usage( CHAR16 *Str, 43 | BOOLEAN ErrorMsg ) 44 | { 45 | if ( ErrorMsg ) { 46 | Print(L"ERROR: Unknown option.\n"); 47 | } 48 | Print(L"Usage: %s [-V | --version]\n", Str); 49 | } 50 | 51 | 52 | INTN 53 | EFIAPI 54 | ShellAppMain( UINTN Argc, 55 | CHAR16 **Argv ) 56 | { 57 | EFI_STATUS Status = EFI_SUCCESS; 58 | EFI_TCG2_PROTOCOL *Tcg2Protocol; 59 | EFI_TCG2_BOOT_SERVICE_CAPABILITY CapabilityData; 60 | EFI_GUID gEfiTcg2ProtocolGuid = EFI_TCG2_PROTOCOL_GUID; 61 | 62 | if (Argc == 2) { 63 | if (!StrCmp(Argv[1], L"--version") || 64 | !StrCmp(Argv[1], L"-V")) { 65 | Print(L"Version: %s\n", UTILITY_VERSION); 66 | return Status; 67 | } else if (!StrCmp(Argv[1], L"--help") || 68 | !StrCmp(Argv[1], L"-h")) { 69 | Usage(Argv[0], FALSE); 70 | return Status; 71 | } else { 72 | Usage(Argv[0], TRUE); 73 | return Status; 74 | } 75 | } 76 | if (Argc > 2) { 77 | Usage(Argv[0], TRUE); 78 | return Status; 79 | } 80 | 81 | Status = gBS->LocateProtocol( &gEfiTcg2ProtocolGuid, 82 | NULL, 83 | (VOID **) &Tcg2Protocol ); 84 | if (EFI_ERROR (Status)) { 85 | Print(L"ERROR: Failed to locate EFI_TCG2_PROTOCOL [%d]\n", Status); 86 | return Status; 87 | } 88 | 89 | 90 | CapabilityData.Size = (UINT8)sizeof(CapabilityData); 91 | Status = Tcg2Protocol->GetCapability( Tcg2Protocol, 92 | &CapabilityData ); 93 | if (EFI_ERROR (Status)) { 94 | Print(L"ERROR: Tcg2Protocol GetCapacity [%d]\n", Status); 95 | return Status; 96 | } 97 | 98 | Print(L"\n"); 99 | Print(L" Structure Version: %d.%d\n", CapabilityData.StructureVersion.Major, 100 | CapabilityData.StructureVersion.Minor ); 101 | Print(L" Protocol Version: %d.%d\n", CapabilityData.ProtocolVersion.Major, 102 | CapabilityData.ProtocolVersion.Minor ); 103 | Print(L" Supported Hash Algorithms: "); 104 | if ((CapabilityData.HashAlgorithmBitmap & EFI_TCG2_BOOT_HASH_ALG_SHA1) != 0) { 105 | Print(L"SHA1 "); 106 | } 107 | if ((CapabilityData.HashAlgorithmBitmap & EFI_TCG2_BOOT_HASH_ALG_SHA256) != 0) { 108 | Print(L"SHA256 "); 109 | } 110 | if ((CapabilityData.HashAlgorithmBitmap & EFI_TCG2_BOOT_HASH_ALG_SHA384) != 0) { 111 | Print(L"SHA384 "); 112 | } 113 | if ((CapabilityData.HashAlgorithmBitmap & EFI_TCG2_BOOT_HASH_ALG_SHA512) != 0) { 114 | Print(L"SHA512 "); 115 | } 116 | if ((CapabilityData.HashAlgorithmBitmap & EFI_TCG2_BOOT_HASH_ALG_SM3_256) != 0) { 117 | Print(L"SM3_256 "); 118 | } 119 | Print(L"\n"); 120 | 121 | Print(L" Supported Event Log Formats: "); 122 | if ((CapabilityData.SupportedEventLogs & EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2) != 0) { 123 | Print(L"TCG_1.2 "); 124 | } 125 | if ((CapabilityData.SupportedEventLogs & EFI_TCG2_EVENT_LOG_FORMAT_TCG_2) != 0) { 126 | Print(L"TCG_2 "); 127 | } 128 | Print(L"\n"); 129 | 130 | Print(L" TPM Present Flag: "); 131 | if (CapabilityData.TPMPresentFlag) { 132 | Print(L"True\n"); 133 | } else { 134 | Print(L"False\n"); 135 | } 136 | 137 | Print(L" Maximum Command Size: 0x%02x (%d)\n", CapabilityData.MaxCommandSize, 138 | CapabilityData.MaxCommandSize); 139 | Print(L" Maximum Response Size: 0x%02x (%d)\n", CapabilityData.MaxResponseSize, 140 | CapabilityData.MaxResponseSize); 141 | Print(L" TCG Vendor ID: %s\n", ManufacturerStr(CapabilityData.ManufacturerID)); 142 | Print(L" Number of PCR Banks: %d\n", CapabilityData.NumberOfPCRBanks); 143 | Print(L" Active PCR Banks: %d\n", (UINT32) CapabilityData.ActivePcrBanks); 144 | 145 | Print(L"\n"); 146 | 147 | return Status; 148 | } 149 | -------------------------------------------------------------------------------- /MyApps/ShowTCM20/ShowTCM20.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/ShowTCM20/ShowTCM20.efi -------------------------------------------------------------------------------- /MyApps/ShowTCM20/ShowTCM20.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ShowTCM20 4 | FILE_GUID = 4ea87c51-7395-4ccd-0355-747010f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | ShowTCM20.c 12 | 13 | [Packages] 14 | MdePkg/MdePkg.dec 15 | ShellPkg/ShellPkg.dec 16 | 17 | [LibraryClasses] 18 | ShellCEntryLib 19 | ShellLib 20 | BaseLib 21 | BaseMemoryLib 22 | UefiLib 23 | 24 | [Protocols] 25 | 26 | [BuildOptions] 27 | 28 | [Pcd] 29 | 30 | -------------------------------------------------------------------------------- /MyApps/ShowTPM2/ShowTPM2.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2016-2018 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Show TPM2 ACPI table details 5 | // 6 | // License: UDK2017 license applies to code from UDK2017 sources, 7 | // BSD 2 clause license applies to all other code. 8 | // 9 | 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | 28 | #pragma pack (1) 29 | typedef struct _MY_EFI_TPM2_ACPI_TABLE { 30 | EFI_ACPI_SDT_HEADER Header; 31 | // EFI_ACPI_DESCRIPTION_HEADER Header; 32 | UINT16 PlatformClass; 33 | UINT16 Reserved; 34 | UINT64 AddressOfControlArea; 35 | UINT32 StartMethod; 36 | // UINT8 PlatformSpecificParameters[]; 37 | } MY_EFI_TPM2_ACPI_TABLE; 38 | #pragma pack() 39 | 40 | 41 | #define EFI_ACPI_20_TABLE_GUID \ 42 | { 0x8868e871, 0xe4f1, 0x11d3, {0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 }} 43 | 44 | 45 | #define UTILITY_VERSION L"20180822" 46 | #undef DEBUG 47 | 48 | 49 | 50 | static VOID 51 | AsciiToUnicodeSize( CHAR8 *String, 52 | UINT8 length, 53 | CHAR16 *UniString) 54 | { 55 | int len = length; 56 | 57 | while (*String != '\0' && len > 0) { 58 | *(UniString++) = (CHAR16) *(String++); 59 | len--; 60 | } 61 | *UniString = '\0'; 62 | } 63 | 64 | 65 | // 66 | // Print some control area details 67 | // 68 | static VOID 69 | PrintControlArea( EFI_TPM2_ACPI_CONTROL_AREA* ControlArea ) 70 | { 71 | Print(L" CA Error Value : 0x%04x (%d)\n", ControlArea->Error, ControlArea->Error); 72 | Print(L" CA Command Buffer Size : 0x%04x (%d)\n", ControlArea->CommandSize, ControlArea->CommandSize); 73 | Print(L" CA Command Buffer Address : 0x%08x\n", (UINT64)(ControlArea->Command)); 74 | Print(L" CA Response Buffer Size : 0x%04x (%d)\n", ControlArea->ResponseSize, ControlArea->ResponseSize); 75 | Print(L" CA Response Buffer Address : 0x%08x\n", (UINT64)(ControlArea->Response)); 76 | } 77 | 78 | 79 | // 80 | // Print start method details 81 | // 82 | static VOID 83 | PrintStartMethod( UINT32 StartMethod ) 84 | { 85 | Print(L" Start Method : %d (", StartMethod); 86 | switch (StartMethod) { 87 | case 0: Print(L"Not allowed"); 88 | break; 89 | case 1: Print(L"Vendor specific legacy use"); 90 | break; 91 | case 2: Print(L"ACPI start method"); 92 | break; 93 | case 3: 94 | case 4: 95 | case 5: Print(L"Vendor specific legacy use"); 96 | break; 97 | case 6: Print(L"Memory mapped I/O"); 98 | break; 99 | case 7: Print(L"Command response buffer interface"); 100 | break; 101 | case 8: Print(L"Command response buffer interface, ACPI start method"); 102 | break; 103 | default: Print(L"Reserved for future use"); 104 | } 105 | Print(L")\n"); 106 | } 107 | 108 | 109 | // 110 | // Parse and print TCM2 table details 111 | // 112 | static VOID 113 | ParseTPM2( MY_EFI_TPM2_ACPI_TABLE *Tpm2 ) 114 | { 115 | CHAR16 Buffer[100]; 116 | UINT8 PlatformSpecificMethodsSize = Tpm2->Header.Length - 52; 117 | 118 | Print(L"\n"); 119 | AsciiToUnicodeSize((CHAR8 *)&(Tpm2->Header.Signature), 4, Buffer); 120 | Print(L" Signature : %s\n", Buffer); 121 | Print(L" Length : 0x%03x (%d)\n", Tpm2->Header.Length, Tpm2->Header.Length); 122 | Print(L" Revision : %d\n", Tpm2->Header.Revision); 123 | Print(L" Checksum : %d\n", Tpm2->Header.Checksum); 124 | AsciiToUnicodeSize((CHAR8 *)(Tpm2->Header.OemId), 6, Buffer); 125 | Print(L" Oem ID : %s\n", Buffer); 126 | AsciiToUnicodeSize((CHAR8 *)(Tpm2->Header.OemTableId), 8, Buffer); 127 | Print(L" Oem Table ID : %s\n", Buffer); 128 | Print(L" Oem Revision : %d\n", Tpm2->Header.OemRevision); 129 | AsciiToUnicodeSize((CHAR8 *)&(Tpm2->Header.CreatorId), 4, Buffer); 130 | Print(L" Creator ID : %s\n", Buffer); 131 | Print(L" Creator Revision : %d\n", Tpm2->Header.CreatorRevision); 132 | Print(L" Platform Class : %d\n", Tpm2->PlatformClass); 133 | Print(L" Control Area (CA) Address : 0x%08x\n", Tpm2->AddressOfControlArea); 134 | PrintControlArea((EFI_TPM2_ACPI_CONTROL_AREA *)(Tpm2->AddressOfControlArea)); 135 | 136 | PrintStartMethod(Tpm2->StartMethod); 137 | Print(L" Platform Specific Methods Size : %d\n", PlatformSpecificMethodsSize); 138 | if ( Tpm2->Header.Length > 0x34 ) { 139 | AsciiToUnicodeSize((CHAR8 *)(&(Tpm2) + 0x34), Tpm2->Header.Length - 0x34, Buffer); 140 | Print(L" Platform Specific Parameters : %s\n", Buffer); 141 | } 142 | Print(L"\n"); 143 | } 144 | 145 | 146 | static int 147 | ParseRSDP( EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp, 148 | CHAR16* GuidStr ) 149 | { 150 | EFI_ACPI_SDT_HEADER *Xsdt, *Entry; 151 | CHAR16 OemStr[20]; 152 | UINT32 EntryCount; 153 | UINT64 *EntryPtr; 154 | 155 | AsciiToUnicodeSize((CHAR8 *)(Rsdp->OemId), 6, OemStr); 156 | if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) { 157 | Xsdt = (EFI_ACPI_SDT_HEADER *)(Rsdp->XsdtAddress); 158 | } else { 159 | Print(L"ERROR: Invalid RSDP revision number.\n"); 160 | return 1; 161 | } 162 | 163 | if (Xsdt->Signature != SIGNATURE_32 ('X', 'S', 'D', 'T')) { 164 | Print(L"ERROR: XSDT table signature not found.\n"); 165 | return 1; 166 | } 167 | 168 | AsciiToUnicodeSize((CHAR8 *)(Xsdt->OemId), 6, OemStr); 169 | EntryCount = (Xsdt->Length - sizeof (EFI_ACPI_SDT_HEADER)) / sizeof(UINT64); 170 | 171 | EntryPtr = (UINT64 *)(Xsdt + 1); 172 | for (int Index = 0; Index < EntryCount; Index++, EntryPtr++) { 173 | Entry = (EFI_ACPI_SDT_HEADER *)((UINTN)(*EntryPtr)); 174 | if (Entry->Signature == SIGNATURE_32 ('T', 'P', 'M', '2')) { 175 | ParseTPM2((MY_EFI_TPM2_ACPI_TABLE *)((UINTN)(*EntryPtr))); 176 | } 177 | } 178 | 179 | return 0; 180 | } 181 | 182 | 183 | VOID 184 | Usage( CHAR16 *Str, 185 | BOOLEAN ErrorMsg ) 186 | { 187 | if ( ErrorMsg ) { 188 | Print(L"ERROR: Unknown option.\n"); 189 | } 190 | Print(L"Usage: %s [-V | --version]\n", Str); 191 | } 192 | 193 | 194 | INTN 195 | EFIAPI 196 | ShellAppMain( UINTN Argc, 197 | CHAR16 **Argv ) 198 | { 199 | EFI_STATUS Status = EFI_SUCCESS; 200 | EFI_CONFIGURATION_TABLE *ect = gST->ConfigurationTable; 201 | EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp = NULL; 202 | EFI_GUID Acpi20TableGuid = EFI_ACPI_20_TABLE_GUID; 203 | CHAR16 GuidStr[100]; 204 | 205 | if (Argc == 2) { 206 | if (!StrCmp(Argv[1], L"--version") || 207 | !StrCmp(Argv[1], L"-V")) { 208 | Print(L"Version: %s\n", UTILITY_VERSION); 209 | return Status; 210 | } else if (!StrCmp(Argv[1], L"--help") || 211 | !StrCmp(Argv[1], L"-h")) { 212 | Usage(Argv[0], FALSE); 213 | return Status; 214 | } else { 215 | Usage(Argv[0], TRUE); 216 | return Status; 217 | } 218 | } 219 | if (Argc > 2) { 220 | Usage(Argv[0], TRUE); 221 | return Status; 222 | } 223 | 224 | // locate RSDP (Root System Description Pointer) 225 | for (int i = 0; i < gST->NumberOfTableEntries; i++) { 226 | if (CompareGuid (&(gST->ConfigurationTable[i].VendorGuid), &Acpi20TableGuid)) { 227 | if (!AsciiStrnCmp("RSD PTR ", (CHAR8 *)(ect->VendorTable), 8)) { 228 | UnicodeSPrint(GuidStr, sizeof(GuidStr), L"%g", &(gST->ConfigurationTable[i].VendorGuid)); 229 | Rsdp = (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)ect->VendorTable; 230 | ParseRSDP(Rsdp, GuidStr); 231 | } 232 | } 233 | ect++; 234 | } 235 | 236 | if (Rsdp == NULL) { 237 | Print(L"ERROR: Could not find ACPI RSDP table.\n"); 238 | return EFI_NOT_FOUND; 239 | } 240 | 241 | return Status; 242 | } 243 | -------------------------------------------------------------------------------- /MyApps/ShowTPM2/ShowTPM2.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/ShowTPM2/ShowTPM2.efi -------------------------------------------------------------------------------- /MyApps/ShowTPM2/ShowTPM2.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ShowTPM2 4 | FILE_GUID = 4ea87c51-7491-4dfd-0055-747010f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | ShowTPM2.c 12 | 13 | [Packages] 14 | MdePkg/MdePkg.dec 15 | ShellPkg/ShellPkg.dec 16 | 17 | [LibraryClasses] 18 | ShellCEntryLib 19 | ShellLib 20 | BaseLib 21 | BaseMemoryLib 22 | UefiLib 23 | 24 | [Protocols] 25 | 26 | [BuildOptions] 27 | 28 | [Pcd] 29 | 30 | -------------------------------------------------------------------------------- /MyApps/ShowTrEE/ShowTrEE.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2016-2018 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Display TCG TPM TrEE protocol information 5 | // 6 | // License: UDK2017 license applies to code from UDK2017 sources, 7 | // BSD 2 clause license applies to all other code. 8 | // 9 | 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #define EFI_TREE_SERVICE_BINDING_PROTOCOL_GUID \ 25 | {0x4cf01d0a, 0xc48c, 0x4271, {0xa2, 0x2a, 0xad, 0x8e, 0x55, 0x97, 0x81, 0x88}} 26 | 27 | #define UTILITY_VERSION L"20180903" 28 | #undef DEBUG 29 | 30 | 31 | VOID 32 | PrintEventDetail( UINT8 *Detail, 33 | UINT32 Size ) 34 | { 35 | UINT8 *d = Detail; 36 | int Offset = 0; 37 | int Row = 1; 38 | 39 | Print(L" Event Detail: %08x: ", Offset); 40 | 41 | for (int i = 0; i < Size; i++) { 42 | Print(L"%02x", *d++); 43 | Offset++; Row++; 44 | if (Row == 17 || Row == 33) { 45 | Print(L" "); 46 | } 47 | if (Row > 48) { 48 | Row = 1; 49 | Print(L"\n %08x: ", Offset); 50 | } 51 | } 52 | 53 | Print(L"\n"); 54 | } 55 | 56 | 57 | VOID 58 | PrintEventType( UINT32 EventType, 59 | BOOLEAN Verbose ) 60 | { 61 | Print(L" Event Type: "); 62 | if (Verbose) { 63 | Print(L"%08x ", EventType); 64 | } 65 | switch (EventType) { 66 | case EV_POST_CODE: Print(L"Post Code"); 67 | break; 68 | case EV_NO_ACTION: Print(L"No Action"); 69 | break; 70 | case EV_SEPARATOR: Print(L"Separator"); 71 | break; 72 | case EV_S_CRTM_CONTENTS: Print(L"CTRM Contents"); 73 | break; 74 | case EV_S_CRTM_VERSION: Print(L"CRTM Version"); 75 | break; 76 | case EV_CPU_MICROCODE: Print(L"CPU Microcode"); 77 | break; 78 | case EV_TABLE_OF_DEVICES: Print(L"Table of Devices"); 79 | break; 80 | case EV_EFI_VARIABLE_DRIVER_CONFIG: Print(L"Variable Driver Config"); 81 | break; 82 | case EV_EFI_VARIABLE_BOOT: Print(L"Variable Boot"); 83 | break; 84 | case EV_EFI_BOOT_SERVICES_APPLICATION: Print(L"Boot Services Application"); 85 | break; 86 | case EV_EFI_BOOT_SERVICES_DRIVER: Print(L"Boot Services Driver"); 87 | break; 88 | case EV_EFI_RUNTIME_SERVICES_DRIVER: Print(L"Runtime Services Driver"); 89 | break; 90 | case EV_EFI_GPT_EVENT: Print(L"GPT Event"); 91 | break; 92 | case EV_EFI_ACTION: Print(L"Action"); 93 | break; 94 | case EV_EFI_PLATFORM_FIRMWARE_BLOB: Print(L"Platform Fireware Blob"); 95 | break; 96 | case EV_EFI_HANDOFF_TABLES: Print(L"Handoff Tables"); 97 | break; 98 | case EV_EFI_VARIABLE_AUTHORITY: Print(L"Variable Authority"); 99 | break; 100 | default: Print(L"Unknown Type"); 101 | break; 102 | } 103 | Print(L"\n"); 104 | } 105 | 106 | 107 | VOID 108 | PrintSHA1( TCG_DIGEST Digest ) 109 | { 110 | Print(L" SHA1 Digest: " ); 111 | 112 | for (int j = 0; j < SHA1_DIGEST_SIZE; j++ ) { 113 | Print(L"%02x", Digest.digest[j]); 114 | } 115 | 116 | Print(L"\n"); 117 | } 118 | 119 | 120 | CHAR16 * 121 | ManufacturerStr( UINT32 ManufacturerID ) 122 | { 123 | static CHAR16 Mcode[5]; 124 | 125 | Mcode[0] = (CHAR16) ((ManufacturerID & 0xff000000) >> 24); 126 | Mcode[1] = (CHAR16) ((ManufacturerID & 0x00ff0000) >> 16); 127 | Mcode[2] = (CHAR16) ((ManufacturerID & 0x0000ff00) >> 8); 128 | Mcode[3] = (CHAR16) (ManufacturerID & 0x000000ff); 129 | Mcode[4] = (CHAR16) '\0'; 130 | 131 | return Mcode; 132 | } 133 | 134 | 135 | VOID 136 | Usage( CHAR16 *Str, 137 | BOOLEAN ErrorMsg ) 138 | { 139 | if ( ErrorMsg ) { 140 | Print(L"ERROR: Unknown option.\n"); 141 | } 142 | Print(L"Usage: %s [-V | --version]\n", Str); 143 | Print(L" %s [-v | --verbose]\n", Str); 144 | } 145 | 146 | 147 | INTN 148 | EFIAPI 149 | ShellAppMain( UINTN Argc, 150 | CHAR16 **Argv ) 151 | { 152 | EFI_STATUS Status = EFI_SUCCESS; 153 | #if DEBUG 154 | EFI_HANDLE *HandleBuffer; 155 | UINTN HandleCount = 0; 156 | EFI_GUID gEfiGuid = EFI_TREE_SERVICE_BINDING_PROTOCOL_GUID; 157 | #endif 158 | EFI_TREE_PROTOCOL *TreeProtocol; 159 | TREE_BOOT_SERVICE_CAPABILITY CapabilityData; 160 | EFI_PHYSICAL_ADDRESS EventLogLocation; 161 | EFI_PHYSICAL_ADDRESS EventLogLastEntry; 162 | BOOLEAN EventLogTruncated; 163 | TCG_PCR_EVENT *Event = NULL; 164 | BOOLEAN Verbose = FALSE; 165 | 166 | if (Argc == 2) { 167 | if (!StrCmp(Argv[1], L"--version") || 168 | !StrCmp(Argv[1], L"-V")) { 169 | Print(L"Version: %s\n", UTILITY_VERSION); 170 | return Status; 171 | } else if (!StrCmp(Argv[1], L"--help") || 172 | !StrCmp(Argv[1], L"-h")) { 173 | Usage(Argv[0], FALSE); 174 | return Status; 175 | } else if (!StrCmp(Argv[1], L"--verbose") || 176 | !StrCmp(Argv[1], L"-v")) { 177 | Verbose = TRUE; 178 | } else { 179 | Usage(Argv[0], TRUE); 180 | return Status; 181 | } 182 | } 183 | if (Argc > 2) { 184 | Usage(Argv[0], TRUE); 185 | return Status; 186 | } 187 | 188 | #if DEBUG 189 | // Try locating EFI_TREE_SERVICE_BINDING handles 190 | Status = gBS->LocateHandleBuffer( ByProtocol, 191 | &gEfiGuid, 192 | NULL, 193 | &HandleCount, 194 | &HandleBuffer ); 195 | if (EFI_ERROR (Status)) { 196 | Print(L"No EFI_TREE_SERVICE_BINDING_PROTOCOL handles found.\n\n"); 197 | } 198 | #endif 199 | 200 | Status = gBS->LocateProtocol( &gEfiTrEEProtocolGuid, 201 | NULL, 202 | (VOID **) &TreeProtocol ); 203 | if (EFI_ERROR (Status)) { 204 | Print(L"Failed to locate EFI_TREE_PROTOCOL [%d]\n", Status); 205 | return Status; 206 | } 207 | 208 | CapabilityData.Size = (UINT8)sizeof(CapabilityData); 209 | Status = TreeProtocol->GetCapability(TreeProtocol, &CapabilityData); 210 | if (EFI_ERROR (Status)) { 211 | Print(L"ERROR: TrEEProtocol GetCapacity [%d]\n", Status); 212 | return Status; 213 | } 214 | 215 | // check TrEE Protocol present flag and exit if false 216 | if (CapabilityData.TrEEPresentFlag == FALSE) { 217 | Print(L"ERROR: TrEEProtocol TrEEPresentFlag is false.\n"); 218 | return Status; 219 | } 220 | 221 | Print(L"\n"); 222 | Print(L" Structure version: %d.%d\n", CapabilityData.StructureVersion.Major, 223 | CapabilityData.StructureVersion.Minor); 224 | Print(L" Protocol version: %d.%d\n", CapabilityData.ProtocolVersion.Major, 225 | CapabilityData.ProtocolVersion.Minor); 226 | 227 | Print(L" Supported Hash Algorithms: "); 228 | if ((CapabilityData.HashAlgorithmBitmap & EFI_TCG2_BOOT_HASH_ALG_SHA1) != 0) { 229 | Print(L"SHA1 "); 230 | } 231 | if ((CapabilityData.HashAlgorithmBitmap & EFI_TCG2_BOOT_HASH_ALG_SHA256) != 0) { 232 | Print(L"SHA256 "); 233 | } 234 | if ((CapabilityData.HashAlgorithmBitmap & EFI_TCG2_BOOT_HASH_ALG_SHA384) != 0) { 235 | Print(L"SHA384 "); 236 | } 237 | if ((CapabilityData.HashAlgorithmBitmap & EFI_TCG2_BOOT_HASH_ALG_SHA512) != 0) { 238 | Print(L"SHA512 "); 239 | } 240 | Print(L"\n"); 241 | 242 | Print(L" TrEE Present Flag: "); 243 | if (CapabilityData.TrEEPresentFlag) { 244 | Print(L"True\n"); 245 | } else { 246 | Print(L"False\n"); 247 | } 248 | 249 | Print(L" Supported Event Log Formats: "); 250 | if ((CapabilityData.SupportedEventLogs & TREE_EVENT_LOG_FORMAT_TCG_1_2) != 0) { 251 | Print(L"TCG_1.2 "); 252 | } 253 | Print(L"\n"); 254 | 255 | Print(L" Maximum Command Size: %d\n", CapabilityData.MaxCommandSize); 256 | Print(L" Maximum Response Size: %d\n", CapabilityData.MaxResponseSize); 257 | 258 | Print(L" Manufacturer ID: %s\n", ManufacturerStr(CapabilityData.ManufacturerID)); 259 | 260 | Status = TreeProtocol->GetEventLog( TreeProtocol, 261 | TREE_EVENT_LOG_FORMAT_TCG_1_2, 262 | &EventLogLocation, 263 | &EventLogLastEntry, 264 | &EventLogTruncated ); 265 | if (EFI_ERROR (Status)) { 266 | Print(L"ERROR: TreeProtocol GetEventLog [%d]\n", Status); 267 | return Status; 268 | } 269 | 270 | Event = (TCG_PCR_EVENT *) EventLogLastEntry; 271 | 272 | Print(L" Last Event PCR Index: %u\n", Event->PCRIndex); 273 | PrintEventType(Event->EventType, Verbose); 274 | PrintSHA1(Event->Digest); 275 | Print(L" Event Size: %d\n", Event->EventSize); 276 | if (Verbose) { 277 | PrintEventDetail(Event->Event, Event->EventSize); 278 | } 279 | Print(L"\n"); 280 | 281 | return Status; 282 | } 283 | -------------------------------------------------------------------------------- /MyApps/ShowTrEE/ShowTrEE.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/ShowTrEE/ShowTrEE.efi -------------------------------------------------------------------------------- /MyApps/ShowTrEE/ShowTrEE.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.50 3 | BASE_NAME = ShowTrEE 4 | FILE_GUID = 4ea87c51-7395-4ccd-0355-747010f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | ShowTrEE.c 12 | 13 | [Packages] 14 | MdePkg/MdePkg.dec 15 | ShellPkg/ShellPkg.dec 16 | 17 | [LibraryClasses] 18 | ShellCEntryLib 19 | ShellLib 20 | BaseLib 21 | BaseMemoryLib 22 | UefiLib 23 | 24 | [Protocols] 25 | gEfiTrEEProtocolGuid ## CONSUMES 26 | 27 | [BuildOptions] 28 | 29 | [Pcd] 30 | 31 | -------------------------------------------------------------------------------- /MyApps/ShowTrEELog/ShowTrEELog.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015-2018 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Display all available TCG TrEE log entries 5 | // 6 | // License: UDK2017 license applies to code from UDK2017 sources, 7 | // BSD 2 clause license applies to all other code. 8 | // 9 | 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #define UTILITY_VERSION L"20180903" 25 | #undef DEBUG 26 | 27 | 28 | VOID 29 | PrintEventDetail( UINT8 *Detail, 30 | UINT32 Size ) 31 | { 32 | UINT8 *d = Detail; 33 | int Offset = 0; 34 | int Row = 1; 35 | 36 | Print(L" Event Detail: %08x: ", Offset); 37 | 38 | for (int i = 0; i < Size; i++) { 39 | Print(L"%02x", *d++); 40 | Offset++; Row++; 41 | if (Row == 17 || Row == 33) { 42 | Print(L" "); 43 | } 44 | if (Row > 48) { 45 | Row = 1; 46 | Print(L"\n %08x: ", Offset); 47 | } 48 | } 49 | 50 | Print(L"\n"); 51 | } 52 | 53 | 54 | VOID 55 | PrintEventType( UINT32 EventType, 56 | BOOLEAN Verbose ) 57 | { 58 | Print(L" Event Type: "); 59 | if (Verbose) { 60 | Print(L"%08x ", EventType); 61 | } 62 | switch (EventType) { 63 | case EV_POST_CODE: Print(L"Post Code"); 64 | break; 65 | case EV_NO_ACTION: Print(L"No Action"); 66 | break; 67 | case EV_SEPARATOR: Print(L"Separator"); 68 | break; 69 | case EV_S_CRTM_CONTENTS: Print(L"CTRM Contents"); 70 | break; 71 | case EV_S_CRTM_VERSION: Print(L"CRTM Version"); 72 | break; 73 | case EV_CPU_MICROCODE: Print(L"CPU Microcode"); 74 | break; 75 | case EV_TABLE_OF_DEVICES: Print(L"Table of Devices"); 76 | break; 77 | case EV_EFI_VARIABLE_DRIVER_CONFIG: Print(L"Variable Driver Config"); 78 | break; 79 | case EV_EFI_VARIABLE_BOOT: Print(L"Variable Boot"); 80 | break; 81 | case EV_EFI_BOOT_SERVICES_APPLICATION: Print(L"Boot Services Application"); 82 | break; 83 | case EV_EFI_BOOT_SERVICES_DRIVER: Print(L"Boot Services Driver"); 84 | break; 85 | case EV_EFI_RUNTIME_SERVICES_DRIVER: Print(L"Runtime Services Driver"); 86 | break; 87 | case EV_EFI_GPT_EVENT: Print(L"GPT Event"); 88 | break; 89 | case EV_EFI_ACTION: Print(L"Action"); 90 | break; 91 | case EV_EFI_PLATFORM_FIRMWARE_BLOB: Print(L"Platform Fireware Blob"); 92 | break; 93 | case EV_EFI_HANDOFF_TABLES: Print(L"Handoff Tables"); 94 | break; 95 | case EV_EFI_VARIABLE_AUTHORITY: Print(L"Variable Authority"); 96 | break; 97 | default: Print(L"Unknown Type"); 98 | break; 99 | } 100 | Print(L"\n"); 101 | } 102 | 103 | 104 | VOID 105 | PrintSHA1( TCG_DIGEST Digest ) 106 | { 107 | Print(L" SHA1 Digest: " ); 108 | 109 | for (int j = 0; j < SHA1_DIGEST_SIZE; j++ ) { 110 | Print(L"%02x", Digest.digest[j]); 111 | } 112 | 113 | Print(L"\n"); 114 | } 115 | 116 | 117 | VOID 118 | PrintLog( TCG_PCR_EVENT *Event, 119 | BOOLEAN Verbose ) 120 | { 121 | Print(L" Event PCR Index: %u\n", Event->PCRIndex); 122 | PrintEventType(Event->EventType, Verbose); 123 | PrintSHA1(Event->Digest); 124 | Print(L" Event Size: %d\n", Event->EventSize); 125 | if (Verbose) { 126 | PrintEventDetail(Event->Event, Event->EventSize); 127 | } 128 | Print(L"\n"); 129 | } 130 | 131 | 132 | VOID 133 | Usage( CHAR16 *Str, 134 | BOOLEAN ErrorMsg ) 135 | { 136 | if ( ErrorMsg ) { 137 | Print(L"ERROR: Unknown option.\n"); 138 | } 139 | Print(L"Usage: %s [-V | --version]\n", Str); 140 | Print(L" %s [-v | --verbose]\n", Str); 141 | } 142 | 143 | 144 | INTN 145 | EFIAPI 146 | ShellAppMain( UINTN Argc, 147 | CHAR16 **Argv ) 148 | { 149 | EFI_STATUS Status = EFI_SUCCESS; 150 | EFI_TREE_PROTOCOL *TreeProtocol; 151 | EFI_PHYSICAL_ADDRESS LogLocation; 152 | EFI_PHYSICAL_ADDRESS LogLastEntry; 153 | EFI_PHYSICAL_ADDRESS LogAddress; 154 | TCG_PCR_EVENT *Event = NULL; 155 | BOOLEAN LogTruncated; 156 | BOOLEAN Verbose = FALSE; 157 | 158 | if (Argc == 2) { 159 | if (!StrCmp(Argv[1], L"--version") || 160 | !StrCmp(Argv[1], L"-V")) { 161 | Print(L"Version: %s\n", UTILITY_VERSION); 162 | return Status; 163 | } else if (!StrCmp(Argv[1], L"--help") || 164 | !StrCmp(Argv[1], L"-h")) { 165 | Usage(Argv[0], FALSE); 166 | return Status; 167 | } else if (!StrCmp(Argv[1], L"--verbose") || 168 | !StrCmp(Argv[1], L"-v")) { 169 | Verbose = TRUE; 170 | } else { 171 | Usage(Argv[0], TRUE); 172 | return Status; 173 | } 174 | } 175 | if (Argc > 2) { 176 | Usage(Argv[0], TRUE); 177 | return Status; 178 | } 179 | 180 | Status = gBS->LocateProtocol( &gEfiTrEEProtocolGuid, 181 | NULL, 182 | (VOID **) &TreeProtocol ); 183 | if (EFI_ERROR (Status)) { 184 | Print(L"ERROR: Failed to locate EFI_TREE_PROTOCOL [%d]\n", Status); 185 | return Status; 186 | } 187 | 188 | Status = TreeProtocol->GetEventLog( TreeProtocol, 189 | TREE_EVENT_LOG_FORMAT_TCG_1_2, 190 | &LogLocation, 191 | &LogLastEntry, 192 | &LogTruncated ); 193 | if (EFI_ERROR (Status)) { 194 | Print(L"ERROR: TreeProtocol GetEventLog [%d]\n", Status); 195 | return Status; 196 | } 197 | 198 | LogAddress = LogLocation; 199 | if (LogLocation != LogLastEntry) { 200 | do { 201 | Event = (TCG_PCR_EVENT *) LogAddress; 202 | PrintLog(Event, Verbose); 203 | LogAddress += sizeof(TCG_PCR_EVENT_HDR) + Event->EventSize; 204 | } while (LogAddress != LogLastEntry); 205 | } 206 | PrintLog((TCG_PCR_EVENT *)LogAddress, Verbose); 207 | 208 | return Status; 209 | } 210 | -------------------------------------------------------------------------------- /MyApps/ShowTrEELog/ShowTrEELog.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/ShowTrEELog/ShowTrEELog.efi -------------------------------------------------------------------------------- /MyApps/ShowTrEELog/ShowTrEELog.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ShowTrEELog 4 | FILE_GUID = 4ea87c51-7395-4ccd-0355-747010f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | ShowTrEELog.c 12 | 13 | [Packages] 14 | MdePkg/MdePkg.dec 15 | ShellPkg/ShellPkg.dec 16 | 17 | [LibraryClasses] 18 | ShellCEntryLib 19 | ShellLib 20 | BaseLib 21 | BaseMemoryLib 22 | UefiLib 23 | 24 | [Protocols] 25 | gEfiTrEEProtocolGuid ## CONSUMES 26 | 27 | [BuildOptions] 28 | 29 | [Pcd] 30 | 31 | -------------------------------------------------------------------------------- /MyApps/XBeep/XBeep.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2018/7c8cf04345ece36b7b3e7b03c4aef21547781ccc/MyApps/XBeep/XBeep.efi -------------------------------------------------------------------------------- /MyApps/XBeep/XBeep.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = XBeep 4 | FILE_GUID = 4ea87c51-7395-4dcd-0055-747010f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | XBeep.c 12 | 13 | [Packages] 14 | MdePkg/MdePkg.dec 15 | ShellPkg/ShellPkg.dec 16 | 17 | [LibraryClasses] 18 | ShellCEntryLib 19 | ShellLib 20 | BaseLib 21 | BaseMemoryLib 22 | UefiLib 23 | IoLib 24 | 25 | [Protocols] 26 | 27 | [BuildOptions] 28 | 29 | [Pcd] 30 | 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UEFI-Utilities-2018 2 | 3 | Various UEFI utilities built against UDK2017 4 | 5 | To integrate into UDK2017 source tree: 6 | 7 | Create a subdirectory immediately under UDK2017 called MyApps, populate MyApps with one or more of the 8 | utilities, fix up MyApps.dsc to build the required utility or utilities by uncommening one or more .inf 9 | lines. 10 | 11 | Note these utilities have only been built and tested on an X64 platform. 12 | 13 | I now include a 64-bit EFI binary of each utility in each utility subdirectory. 14 | 15 | See http://blog.fpmurphy.com for detailed information about the utilities. 16 | 17 | Enjoy! 18 | --------------------------------------------------------------------------------