├── LICENSE ├── MyApps ├── Beep │ ├── Beep.c │ ├── Beep.efi │ └── Beep.inf ├── Cpuid │ ├── Cpuid.c │ ├── Cpuid.efi │ └── Cpuid.inf ├── DateTime │ ├── DateTime.c │ ├── DateTime.efi │ └── DateTime.inf ├── DisplayBMP │ ├── BootLogo.bmp │ ├── DisplayBMP.c │ ├── DisplayBMP.efi │ ├── DisplayBMP.inf │ └── Logo.bmp ├── 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 ├── ScreenShot │ ├── ScreenShot.c │ ├── ScreenShot.efi │ └── ScreenShot.inf ├── ScreenshotDriver │ ├── ScreenshotDriver.c │ ├── ScreenshotDriver.efi │ ├── ScreenshotDriver.h │ └── ScreenshotDriver.inf ├── ShowACPI │ ├── ShowACPI.c │ ├── ShowACPI.efi │ └── ShowACPI.inf ├── ShowBGRT │ ├── ShowBGRT.c │ ├── ShowBGRT.efi │ └── ShowBGRT.inf ├── ShowBoot │ ├── ShowBoot.c │ ├── ShowBoot.efi │ └── ShowBoot.inf ├── ShowEDID │ ├── ShowEDID.c │ ├── ShowEDID.efi │ └── ShowEDID.inf ├── ShowESRT │ ├── ShowESRT.c │ ├── ShowESRT.efi │ └── ShowESRT.inf ├── ShowFACS │ ├── ShowFACS.c │ ├── ShowFACS.efi │ └── ShowFACS.inf ├── ShowFreq │ ├── ShowFreq.c │ ├── ShowFreq.efi │ └── ShowFreq.inf ├── ShowHIIPkg │ ├── ShowHIIPkg.c │ ├── ShowHIIPkg.efi │ └── ShowHIIPkg.inf ├── ShowMP │ ├── ShowMP.c │ ├── ShowMP.efi │ └── ShowMP.inf ├── ShowMSDM │ ├── ShowMSDM.c │ ├── ShowMSDM.efi │ └── ShowMSDM.inf ├── ShowPCI │ ├── README │ ├── ShowPCI.c │ ├── ShowPCI.efi │ └── ShowPCI.inf ├── ShowPCIx │ ├── ShowPCIx.c │ ├── ShowPCIx.efi │ ├── ShowPCIx.inf │ └── pci.ids ├── ShowPCR │ ├── ShowPCR.c │ ├── ShowPCR.efi │ └── ShowPCR.inf ├── ShowQVI │ ├── ShowQVI.c │ ├── ShowQVI.efi │ └── ShowQVI.inf ├── ShowSLIC │ ├── ShowSLIC.c │ ├── ShowSLIC.efi │ └── ShowSLIC.inf ├── ShowUSB │ ├── ShowUSB.c │ ├── ShowUSB.efi │ └── ShowUSB.inf └── XBeep │ ├── XBeep.c │ ├── XBeep.efi │ └── XBeep.inf ├── README.md └── UEFI-Utilities-2019.tar.gz /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2019, Finnbarr P. Murphy 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /MyApps/Beep/Beep.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2018 - 2019 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Beep 1 or more times. 5 | // 6 | // License: EDKII license applies to code from EDKII 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 | 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"20190612" 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 | VOID 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 | 62 | 63 | VOID 64 | TurnOffSpeaker( VOID ) 65 | { 66 | UINT8 Data; 67 | 68 | Data = IoRead8( EFI_SPEAKER_CONTROL_PORT ); 69 | Data &= EFI_SPEAKER_OFF_MASK; 70 | IoWrite8( EFI_SPEAKER_CONTROL_PORT, Data ); 71 | } 72 | 73 | 74 | VOID 75 | GenerateBeep( UINTN NumberBeeps ) 76 | { 77 | for ( UINTN Num=0; Num < NumberBeeps; Num++ ) { 78 | TurnOnSpeaker(); 79 | gBS->Stall( EFI_BEEP_ON_TIME_INTERVAL ); 80 | TurnOffSpeaker(); 81 | gBS->Stall( EFI_BEEP_OFF_TIME_INTERVAL ); 82 | } 83 | } 84 | 85 | 86 | VOID 87 | Usage( BOOLEAN ErrorMsg ) 88 | { 89 | if ( ErrorMsg ) { 90 | Print(L"ERROR: Unknown option(s).\n"); 91 | } 92 | Print(L"Usage: Beep [NumberOfBeeps]\n"); 93 | Print(L" Beep [-V | --version]\n"); 94 | } 95 | 96 | 97 | INTN 98 | EFIAPI 99 | ShellAppMain( UINTN Argc, 100 | CHAR16 **Argv ) 101 | { 102 | EFI_STATUS Status = EFI_SUCCESS; 103 | UINTN NumberBeeps = 1; 104 | 105 | if (Argc == 2) { 106 | if (!StrCmp(Argv[1], L"--version") || 107 | !StrCmp(Argv[1], L"-V")) { 108 | Print(L"Version: %s\n", UTILITY_VERSION); 109 | return Status; 110 | } else if (!StrCmp(Argv[1], L"--help") || 111 | !StrCmp(Argv[1], L"-h")) { 112 | Usage(FALSE); 113 | return Status; 114 | } else if (IsNumber(Argv[1])) { 115 | NumberBeeps = (UINTN) StrDecimalToUint64( Argv[1] ); 116 | if (NumberBeeps < 1) { 117 | Print(L"ERROR: Invalid number of beeps\n"); 118 | Usage(FALSE); 119 | return Status; 120 | } 121 | } else { 122 | Usage(TRUE); 123 | return Status; 124 | } 125 | } 126 | if (Argc > 2) { 127 | Usage(TRUE); 128 | return Status; 129 | } 130 | 131 | GenerateBeep( NumberBeeps ); 132 | 133 | return Status; 134 | } 135 | -------------------------------------------------------------------------------- /MyApps/Beep/Beep.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/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/Cpuid/Cpuid.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2017 - 2019 Finnbarr P. Murphy. All rights reserved. 3 | // Portions Copyright (c) 2016, Intel Corporation. All rights reserved. 4 | // 5 | // Show concise CPUID information about a processsor. 6 | // 7 | // License: BSD license applies to code copyrighted by Intel Corporation. 8 | // BSD 2 clause license applies to all other code. 9 | // 10 | // 11 | 12 | 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | 22 | #define UTILITY_VERSION L"20190403" 23 | #define WIDTH 60 24 | #undef DEBUG 25 | 26 | 27 | // 28 | // Display Processor Signature 29 | // 30 | VOID 31 | ProcessorSignature( VOID ) 32 | { 33 | UINT32 Eax, Ebx, Ecx, Edx; 34 | CHAR8 Signature[13]; 35 | 36 | AsmCpuid( CPUID_SIGNATURE, &Eax, &Ebx, &Ecx, &Edx ); 37 | 38 | #ifdef DEBUG 39 | Print(L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, Ebx, Ecx, Edx); 40 | #endif 41 | 42 | *(UINT32 *)(Signature + 0) = Ebx; 43 | *(UINT32 *)(Signature + 4) = Edx; 44 | *(UINT32 *)(Signature + 8) = Ecx; 45 | Signature[12] = 0; 46 | 47 | Print(L" Signature: %a\n", Signature); 48 | } 49 | 50 | 51 | // 52 | // Display Processor Brand String 53 | // 54 | VOID 55 | ProcessorBrandString( VOID ) 56 | { 57 | CPUID_BRAND_STRING_DATA Eax, Ebx, Ecx, Edx; 58 | UINT32 BrandString[13]; 59 | 60 | AsmCpuid( CPUID_BRAND_STRING1, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32 ); 61 | #ifdef DEBUG 62 | Print(L" String1: EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32); 63 | #endif 64 | BrandString[0] = Eax.Uint32; 65 | BrandString[1] = Ebx.Uint32; 66 | BrandString[2] = Ecx.Uint32; 67 | BrandString[3] = Edx.Uint32; 68 | 69 | AsmCpuid( CPUID_BRAND_STRING2, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32 ); 70 | #ifdef DEBUG 71 | Print(L" String2: EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32); 72 | #endif 73 | BrandString[4] = Eax.Uint32; 74 | BrandString[5] = Ebx.Uint32; 75 | BrandString[6] = Ecx.Uint32; 76 | BrandString[7] = Edx.Uint32; 77 | 78 | AsmCpuid( CPUID_BRAND_STRING3, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32 ); 79 | #ifdef DEBUG 80 | Print(L" String3: EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32); 81 | #endif 82 | BrandString[8] = Eax.Uint32; 83 | BrandString[9] = Ebx.Uint32; 84 | BrandString[10] = Ecx.Uint32; 85 | BrandString[11] = Edx.Uint32; 86 | 87 | BrandString[12] = 0; 88 | 89 | Print (L" CPU String: %a\n", (CHAR8 *)BrandString); 90 | } 91 | 92 | 93 | // 94 | // Display Processor Version Information 95 | // 96 | VOID 97 | ProcessorVersionInfo( VOID ) 98 | { 99 | CPUID_VERSION_INFO_EAX Eax; 100 | CPUID_VERSION_INFO_EBX Ebx; 101 | CPUID_VERSION_INFO_ECX Ecx; 102 | CPUID_VERSION_INFO_EDX Edx; 103 | UINT32 DisplayFamily; 104 | UINT32 DisplayModel; 105 | 106 | AsmCpuid( CPUID_VERSION_INFO, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32 ); 107 | #ifdef DEBUG 108 | Print(L" VersionInfo: EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32); 109 | #endif 110 | 111 | DisplayFamily = Eax.Bits.FamilyId; 112 | if (Eax.Bits.FamilyId == 0x0F) { 113 | DisplayFamily |= (Eax.Bits.ExtendedFamilyId << 4); 114 | } 115 | 116 | DisplayModel = Eax.Bits.Model; 117 | if (Eax.Bits.FamilyId == 0x06 || Eax.Bits.FamilyId == 0x0f) { 118 | DisplayModel |= (Eax.Bits.ExtendedModelId << 4); 119 | } 120 | 121 | Print(L" Family: 0x%x\n", DisplayFamily); 122 | Print(L" Model: 0x%x\n", DisplayModel); 123 | Print(L" Stepping: 0x%x\n", Eax.Bits.SteppingId); 124 | } 125 | 126 | 127 | // 128 | // Display Available Processor Features 129 | // 130 | VOID 131 | ProcessorFeatures( VOID ) 132 | { 133 | CPUID_EXTENDED_CPU_SIG_ECX xEcx; 134 | CPUID_EXTENDED_CPU_SIG_EDX xEdx; 135 | CPUID_VERSION_INFO_EAX Eax; 136 | CPUID_VERSION_INFO_EBX Ebx; 137 | CPUID_VERSION_INFO_ECX Ecx; 138 | CPUID_VERSION_INFO_EDX Edx; 139 | BOOLEAN FirstRow = TRUE; 140 | UINT32 xEax; 141 | UINT32 Col = 0; 142 | CHAR16 Features[1000]; 143 | CHAR16 Buf[80]; 144 | UINT8 Width = WIDTH; 145 | CHAR16 *f = Features; 146 | 147 | ZeroMem( Features, 1000 ); 148 | 149 | AsmCpuid( CPUID_VERSION_INFO, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32 ); 150 | #ifdef DEBUG 151 | Print(L" Features: EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32); 152 | #endif 153 | 154 | AsmCpuid( CPUID_EXTENDED_CPU_SIG, &xEax, NULL, &xEcx.Uint32, &xEdx.Uint32 ); 155 | #ifdef DEBUG 156 | Print (L" Extended Features: EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", xEax, 0, xEcx.Uint32, xEdx.Uint32); 157 | #endif 158 | 159 | // Presorted list. No sorting routine! 160 | if (Edx.Bits.ACPI) StrCat(Features, L" ACPI"); // ACPI via MSR Support 161 | if (Ecx.Bits.AESNI) StrCat(Features, L" AESNT"); 162 | if (Edx.Bits.APIC) StrCat(Features, L" APIC"); 163 | if (Ecx.Bits.AVX) StrCat(Features, L" AVX"); // Advanced Vector Extensions 164 | if (Edx.Bits.CLFSH) StrCat(Features, L" CLFSH"); // CLFLUSH (Cache Line Flush) Instruction Support 165 | if (Edx.Bits.CMOV) StrCat(Features, L" CMOV"); // CMOV Instructions Extension 166 | if (Ecx.Bits.CMPXCHG16B) StrCat(Features, L" CMPXCHG16B"); // CMPXCHG16B Instruction Support 167 | if (Ecx.Bits.CNXT_ID) StrCat(Features, L" CNXT_ID"); // L1 Cache Adaptive Or Shared Mode Support 168 | if (Edx.Bits.CX8) StrCat(Features, L" CX8"); // CMPXCHG8 Instruction Support 169 | if (Ecx.Bits.DCA) StrCat(Features, L" DCA"); // Direct Cache Access 170 | if (Edx.Bits.DE) StrCat(Features, L" DE"); // Debugging Extensions 171 | if (Edx.Bits.DS) StrCat(Features, L" DS"); // Dubug Store Support 172 | if (Ecx.Bits.DS_CPL) StrCat(Features, L" DS_CPL"); // CPL Qual. Debug Store Support 173 | if (Ecx.Bits.DTES64) StrCat(Features, L" DTES64"); // 64-bit Debug Store Support 174 | if (Ecx.Bits.F16C) StrCat(Features, L" F16C"); // 16-bit FP Conversion Instructions Support 175 | if (Ecx.Bits.FMA) StrCat(Features, L" FMA"); // Fused Multiply-Add 176 | if (Edx.Bits.FPU) StrCat(Features, L" FPU"); // Floating Point Unit 177 | if (Edx.Bits.FXSR) StrCat(Features, L" FXSR"); // FXSAVE/FXRSTOR Support 178 | if (Edx.Bits.HTT) StrCat(Features, L" HTT"); // Max APIC IDs reserved field is Valid 179 | if (xEcx.Bits.LAHF_SAHF) StrCat(Features, L" LAHF_SAHF"); 180 | if (xEdx.Bits.LM) StrCat(Features, L" LM"); 181 | if (xEcx.Bits.LZCNT) StrCat(Features, L" LZCNT"); 182 | if (Edx.Bits.MCA) StrCat(Features, L" MCA"); // Machine Check Architecture 183 | if (Edx.Bits.MCE) StrCat(Features, L" MCE"); // Machine Check Exception 184 | if (Ecx.Bits.MONITOR) StrCat(Features, L" MONITOR"); // Monitor/Mwait Support (SSE3 supplements) 185 | if (Edx.Bits.MMX) StrCat(Features, L" MMX"); // Multimedia Extensions 186 | if (Ecx.Bits.MOVBE) StrCat(Features, L" MOVBE"); // Move Data After Swapping Bytes Instruction Support 187 | if (Edx.Bits.MSR) StrCat(Features, L" MSR"); // Model Specific Registers 188 | if (Edx.Bits.MTRR) StrCat(Features, L" MTRR"); // Memory Type Range Registers 189 | if (xEdx.Bits.NX) StrCat(Features, L" NX"); 190 | if (Ecx.Bits.OSXSAVE) StrCat(Features, L" OSXSAVE"); // OS has set bit to support CPU extended state management using XSAVE/XRSTOR 191 | if (Edx.Bits.PAE) StrCat(Features, L" PAE"); // Physical Address Extensions 192 | if (xEdx.Bits.Page1GB) StrCat(Features, L" PAGE1GB"); 193 | if (Edx.Bits.PAT) StrCat(Features, L" PAT"); // Page Attribute Table 194 | if (Edx.Bits.PBE) StrCat(Features, L" PBE"); // Pending Break Enable 195 | if (Ecx.Bits.PCID) StrCat(Features, L" PCID"); // Process Context Identifiers 196 | if (Ecx.Bits.PCLMULQDQ) StrCat(Features, L" PCLMULQDQ"); // Support Carry-Less Multiplication of Quadword instruction 197 | if (Ecx.Bits.PDCM) StrCat(Features, L" PDCM"); // Performance Capabilities 198 | if (Edx.Bits.PGE) StrCat(Features, L" PGE"); // Page Global Enable 199 | if (Ecx.Bits.POPCNT) StrCat(Features, L" POPCNT"); // Return the Count of Number of Bits Set to 1 instruction 200 | if (xEcx.Bits.PREFETCHW) StrCat(Features, L" PREFETCHW"); 201 | if (Edx.Bits.PSE) StrCat(Features, L" PSE"); // Page Size Extensions (4MB memory pages) 202 | if (Edx.Bits.PSE_36) StrCat(Features, L" PSE_36"); // 36-Bit (> 4MB) Page Size Extension 203 | if (Edx.Bits.PSN) StrCat(Features, L" PSN"); // Processor Serial Number Support 204 | if (Ecx.Bits.RDRAND) StrCat(Features, L" RDRAND"); // Read Random Number from hardware random number generator instruction Support 205 | if (xEdx.Bits.RDTSCP) StrCat(Features, L" RDTSCP"); 206 | if (Ecx.Bits.SDBG) StrCat(Features, L" SDBG"); // Silicon Debug Support 207 | if (Edx.Bits.SEP) StrCat(Features, L" SEP"); // SYSENTER/SYSEXIT Support 208 | if (Ecx.Bits.SMX) StrCat(Features, L" SMX"); 209 | if (Edx.Bits.SS) StrCat(Features, L" SS"); 210 | if (Edx.Bits.SSE) StrCat(Features, L" SSE"); 211 | if (Edx.Bits.SSE2) StrCat(Features, L" SSE2"); 212 | if (Ecx.Bits.SSE3) StrCat(Features, L" SSE3"); 213 | if (Ecx.Bits.SSE4_1) StrCat(Features, L" SSE4_1"); 214 | if (Ecx.Bits.SSE4_2) StrCat(Features, L" SSE4_2"); 215 | if (Ecx.Bits.SSSE3) StrCat(Features, L" SSSE3"); // Supplemental SSE-3 216 | if (xEdx.Bits.SYSCALL_SYSRET) StrCat(Features, L" SYSCALL_SYSRET"); 217 | if (Edx.Bits.TSC) StrCat(Features, L" TSC"); // Time Stamp Counter 218 | if (Ecx.Bits.TSC_Deadline) StrCat(Features, L" TSC_DEADLINE"); // TSC Deadline Timer 219 | if (Edx.Bits.TM) StrCat(Features, L" TM"); // Automatic Clock Control (Thermal Monitor) 220 | if (Ecx.Bits.TM2) StrCat(Features, L" TM2"); // Thermal Monitor 2 221 | if (Edx.Bits.VME) StrCat(Features, L" VME"); // Virtual 8086 Mode Enhancements 222 | if (Ecx.Bits.VMX) StrCat(Features, L" VMX"); // Hardware Virtualization Support 223 | if (Ecx.Bits.x2APIC) StrCat(Features, L" X2APIC"); // x2APIC Support 224 | if (Ecx.Bits.XSAVE) StrCat(Features, L" XSAVE"); // Save Processor Extended States 225 | if (Ecx.Bits.xTPR_Update_Control) StrCat(Features, L" XTPR_UPDATE_CONTROL"); // Change IA32_MISC_ENABLE Support 226 | 227 | Print(L" Features:"); 228 | 229 | // Not the most elegant output folding code but it works! 230 | ZeroMem( Buf, 80 ); 231 | while (*f) { 232 | Buf[Col++] = *f++; 233 | if (Col > Width) { 234 | while (Col >= 0 && Buf[Col] != L' ') { 235 | Buf[Col] = CHAR_NULL; 236 | f--; Col--; 237 | } 238 | if (FirstRow) { 239 | Print(L"%s\n", Buf); 240 | FirstRow = FALSE; 241 | } else { 242 | Print(L" %s\n", Buf); 243 | } 244 | ZeroMem(Buf,80); 245 | Col = 0; 246 | } 247 | } 248 | if (Col) { 249 | if (FirstRow) { 250 | Print(L"%s\n", Buf); 251 | } else { 252 | Print(L" %s\n", Buf); 253 | } 254 | } 255 | } 256 | 257 | 258 | VOID 259 | Usage( BOOLEAN ErrorMsg ) 260 | { 261 | if ( ErrorMsg ) { 262 | Print(L"ERROR: Unknown option(s).\n"); 263 | } 264 | 265 | Print(L"Usage: Cpuid [ -V | --version ]\n"); 266 | } 267 | 268 | 269 | INTN 270 | EFIAPI 271 | ShellAppMain( UINTN Argc, 272 | CHAR16 **Argv ) 273 | { 274 | EFI_STATUS Status = EFI_SUCCESS; 275 | 276 | if (Argc == 2) { 277 | if (!StrCmp(Argv[1], L"--version") || 278 | !StrCmp(Argv[1], L"-V")) { 279 | Print(L"Version: %s\n", UTILITY_VERSION); 280 | return Status; 281 | } else if (!StrCmp(Argv[1], L"--help") || 282 | !StrCmp(Argv[1], L"-h")) { 283 | Usage(FALSE); 284 | return Status; 285 | } else { 286 | Usage(TRUE); 287 | return Status; 288 | } 289 | } 290 | if (Argc > 2) { 291 | Usage(TRUE); 292 | return Status; 293 | } 294 | 295 | Print(L"\n"); 296 | ProcessorSignature(); 297 | ProcessorBrandString(); 298 | ProcessorVersionInfo(); 299 | ProcessorFeatures(); 300 | Print(L"\n"); 301 | 302 | return Status; 303 | } 304 | -------------------------------------------------------------------------------- /MyApps/Cpuid/Cpuid.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/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/DateTime/DateTime.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2019 - 2020 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Show date and time or GetTime debugging information 5 | // 6 | // License: EDKII license applies to code from EDKII source, 7 | // BSD 2 clause license applies to all other code. 8 | // 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | #define UTILITY_VERSION L"20200609" 25 | #undef DEBUG 26 | 27 | 28 | EFI_STATUS 29 | DebugGetTime( VOID ) 30 | { 31 | EFI_TIME_CAPABILITIES TimeCapabilities; 32 | EFI_TIME Time; 33 | EFI_STATUS Status = EFI_SUCCESS; 34 | 35 | Status = gRT->GetTime(&Time, &TimeCapabilities); 36 | if (EFI_ERROR(Status)) { 37 | Print(L"ERROR: GetTime: %d\n", Status); 38 | return Status; 39 | } 40 | 41 | Print(L"Year [%d]\n", Time.Year); 42 | Print(L"Month [%02d]\n", Time.Month); 43 | Print(L"Day [%02d]\n", Time.Day); 44 | Print(L"Hour [%02d]\n", Time.Hour); 45 | Print(L"Minute [%02d]\n", Time.Minute); 46 | Print(L"Second [%02d]\n", Time.Second); 47 | Print(L"Nanosecond [%d]\n", Time.Nanosecond); 48 | Print(L"TimeZone [%d]\n", Time.TimeZone); 49 | Print(L"Daylight [%d]\n", Time.Daylight); 50 | Print(L"\n"); 51 | Print(L"Resolution [%d]\n", TimeCapabilities.Resolution); 52 | Print(L"Accuracy [%d]\n", TimeCapabilities.Accuracy); 53 | Print(L"SetsToZero [%d]\n", TimeCapabilities.SetsToZero); 54 | Print(L"\n"); 55 | 56 | return Status; 57 | } 58 | 59 | 60 | VOID 61 | Usage( BOOLEAN ErrorMsg ) 62 | { 63 | if ( ErrorMsg ) { 64 | Print(L"ERROR: Unknown option.\n"); 65 | } 66 | Print(L"Usage: DateTime [-V | --version]\n"); 67 | Print(L" DateTime [-d | --debug]\n"); 68 | } 69 | 70 | 71 | INTN 72 | EFIAPI 73 | ShellAppMain( UINTN Argc, 74 | CHAR16 **Argv ) 75 | { 76 | EFI_STATUS Status = EFI_SUCCESS; 77 | EFI_TIME Time; 78 | 79 | if (Argc == 2) { 80 | if (!StrCmp(Argv[1], L"--version") || 81 | !StrCmp(Argv[1], L"-V")) { 82 | Print(L"Version: %s\n", UTILITY_VERSION); 83 | return Status; 84 | } else if (!StrCmp(Argv[1], L"--debug") || 85 | !StrCmp(Argv[1], L"-d")) { 86 | Status = DebugGetTime(); 87 | return Status; 88 | } else if (!StrCmp(Argv[1], L"--help") || 89 | !StrCmp(Argv[1], L"-h")) { 90 | Usage(FALSE); 91 | return Status; 92 | } else { 93 | Usage(TRUE); 94 | return Status; 95 | } 96 | } 97 | if (Argc > 2) { 98 | Usage(TRUE); 99 | return Status; 100 | } 101 | 102 | Status = gRT->GetTime(&Time, NULL); 103 | if (EFI_ERROR(Status)) { 104 | Print(L"ERROR: GetTime: %d\n", Status); 105 | return Status; 106 | } 107 | 108 | if (Time.TimeZone == EFI_UNSPECIFIED_TIMEZONE) { 109 | Print(L"%4d-%02d-%02d %02d:%02d:%02d (LOCAL)\n", 110 | Time.Year, Time.Month, Time.Day, 111 | Time.Hour, Time.Minute, Time.Second); 112 | } else { 113 | Print(L"%4d-%02d-%02d %02d:%02d:%02d (UTC%s%02d:%02d)\n", 114 | Time.Year, Time.Month, Time.Day, 115 | Time.Hour, Time.Minute, Time.Second, 116 | (Time.TimeZone > 0 ? L"-" : L"+"), 117 | ((ABS(Time.TimeZone)) / 60), 118 | ((ABS(Time.TimeZone)) % 60)); 119 | } 120 | 121 | return Status; 122 | } 123 | -------------------------------------------------------------------------------- /MyApps/DateTime/DateTime.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/MyApps/DateTime/DateTime.efi -------------------------------------------------------------------------------- /MyApps/DateTime/DateTime.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = DateTime 4 | FILE_GUID = 4ea87c51-8291-5dfd-0055-767013f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | DateTime.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 | 27 | [BuildOptions] 28 | 29 | [Pcd] 30 | 31 | -------------------------------------------------------------------------------- /MyApps/DisplayBMP/BootLogo.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/MyApps/DisplayBMP/BootLogo.bmp -------------------------------------------------------------------------------- /MyApps/DisplayBMP/DisplayBMP.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/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.1 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 | SafeIntLib 24 | 25 | [Protocols] 26 | 27 | [BuildOptions] 28 | 29 | [Pcd] 30 | 31 | -------------------------------------------------------------------------------- /MyApps/DisplayBMP/Logo.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/MyApps/DisplayBMP/Logo.bmp -------------------------------------------------------------------------------- /MyApps/ListCerts/ListCerts.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/MyApps/ListCerts/ListCerts.efi -------------------------------------------------------------------------------- /MyApps/ListCerts/ListCerts.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ListCerts 4 | FILE_GUID = 4ea87c51-6395-3dcd-0055-747010f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources.common] 11 | ListCerts.c 12 | asn1_ber_decoder.c 13 | asn1_ber_decoder.h 14 | oid_registry.c 15 | oid_registry.h 16 | oid_registry_data.h 17 | x509.c 18 | x509.h 19 | 20 | [Packages] 21 | MdePkg/MdePkg.dec 22 | ShellPkg/ShellPkg.dec 23 | 24 | [LibraryClasses] 25 | ShellCEntryLib 26 | ShellLib 27 | BaseLib 28 | BaseMemoryLib 29 | UefiLib 30 | 31 | [Protocols] 32 | 33 | [BuildOptions] 34 | 35 | [Pcd] 36 | 37 | -------------------------------------------------------------------------------- /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 | Invoke 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.c: -------------------------------------------------------------------------------- 1 | /* Decoder for ASN.1 BER/DER/CER encoded bytestream 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-2019 Finnbarr P. Murphy. All rights reserved. 15 | * 16 | * Modified to work in EDKII environment. 17 | * 18 | */ 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "asn1_ber_decoder.h" 29 | #include "asn1_ber_bytecode.h" 30 | 31 | static const unsigned char asn1_op_lengths[ASN1_OP__NR] = { 32 | /* OPC TAG JMP ACT */ 33 | [ASN1_OP_MATCH] = 1 + 1, 34 | [ASN1_OP_MATCH_OR_SKIP] = 1 + 1, 35 | [ASN1_OP_MATCH_ACT] = 1 + 1 + 1, 36 | [ASN1_OP_MATCH_ACT_OR_SKIP] = 1 + 1 + 1, 37 | [ASN1_OP_MATCH_JUMP] = 1 + 1 + 1, 38 | [ASN1_OP_MATCH_JUMP_OR_SKIP] = 1 + 1 + 1, 39 | [ASN1_OP_MATCH_ANY] = 1, 40 | [ASN1_OP_MATCH_ANY_ACT] = 1 + 1, 41 | [ASN1_OP_COND_MATCH_OR_SKIP] = 1 + 1, 42 | [ASN1_OP_COND_MATCH_ACT_OR_SKIP] = 1 + 1 + 1, 43 | [ASN1_OP_COND_MATCH_JUMP_OR_SKIP] = 1 + 1 + 1, 44 | [ASN1_OP_COND_MATCH_ANY] = 1, 45 | [ASN1_OP_COND_MATCH_ANY_ACT] = 1 + 1, 46 | [ASN1_OP_COND_FAIL] = 1, 47 | [ASN1_OP_COMPLETE] = 1, 48 | [ASN1_OP_ACT] = 1 + 1, 49 | [ASN1_OP_RETURN] = 1, 50 | [ASN1_OP_END_SEQ] = 1, 51 | [ASN1_OP_END_SEQ_OF] = 1 + 1, 52 | [ASN1_OP_END_SET] = 1, 53 | [ASN1_OP_END_SET_OF] = 1 + 1, 54 | [ASN1_OP_END_SEQ_ACT] = 1 + 1, 55 | [ASN1_OP_END_SEQ_OF_ACT] = 1 + 1 + 1, 56 | [ASN1_OP_END_SET_ACT] = 1 + 1, 57 | [ASN1_OP_END_SET_OF_ACT] = 1 + 1 + 1, 58 | }; 59 | 60 | 61 | /* 62 | * Find the length of an indefinite length object 63 | * @data: The data buffer 64 | * @datalen: The end of the innermost containing element in the buffer 65 | * @_dp: The data parse cursor (updated before returning) 66 | * @_len: Where to return the size of the element. 67 | * @_errmsg: Where to return a pointer to an error message on error 68 | */ 69 | static int asn1_find_indefinite_length(const unsigned char *data, size_t datalen, 70 | size_t *_dp, size_t *_len, 71 | const char **_errmsg) 72 | { 73 | unsigned char tag, tmp; 74 | size_t dp = *_dp, len, n; 75 | int indef_level = 1; 76 | 77 | next_tag: 78 | if (unlikely(datalen - dp < 2)) { 79 | if (datalen == dp) 80 | goto missing_eoc; 81 | goto data_overrun_error; 82 | } 83 | 84 | /* Extract a tag from the data */ 85 | tag = data[dp++]; 86 | if (tag == 0) { 87 | /* It appears to be an EOC. */ 88 | if (data[dp++] != 0) 89 | goto invalid_eoc; 90 | if (--indef_level <= 0) { 91 | *_len = dp - *_dp; 92 | *_dp = dp; 93 | return 0; 94 | } 95 | goto next_tag; 96 | } 97 | 98 | if (unlikely((tag & 0x1f) == 0x1f)) { 99 | do { 100 | if (unlikely(datalen - dp < 2)) 101 | goto data_overrun_error; 102 | tmp = data[dp++]; 103 | } while (tmp & 0x80); 104 | } 105 | 106 | /* Extract the length */ 107 | len = data[dp++]; 108 | if (len < 0x7f) { 109 | dp += len; 110 | goto next_tag; 111 | } 112 | 113 | if (unlikely(len == 0x80)) { 114 | /* Indefinite length */ 115 | if (unlikely((tag & ASN1_CONS_BIT) == ASN1_PRIM << 5)) 116 | goto indefinite_len_primitive; 117 | indef_level++; 118 | goto next_tag; 119 | } 120 | 121 | n = len - 0x80; 122 | if (unlikely(n > sizeof(size_t) - 1)) 123 | goto length_too_long; 124 | if (unlikely(n > datalen - dp)) 125 | goto data_overrun_error; 126 | for (len = 0; n > 0; n--) { 127 | len <<= 8; 128 | len |= data[dp++]; 129 | } 130 | dp += len; 131 | goto next_tag; 132 | 133 | /* 134 | * FPM - have not touched these messages. need to study code path. 135 | * if you get garbled output, these may be the culprits 136 | * 137 | */ 138 | length_too_long: 139 | *_errmsg = "Unsupported length"; 140 | goto error; 141 | indefinite_len_primitive: 142 | *_errmsg = "Indefinite len primitive not permitted"; 143 | goto error; 144 | invalid_eoc: 145 | *_errmsg = "Invalid length EOC"; 146 | goto error; 147 | data_overrun_error: 148 | *_errmsg = "Data overrun error"; 149 | goto error; 150 | missing_eoc: 151 | *_errmsg = "Missing EOC in indefinite len cons"; 152 | error: 153 | *_dp = dp; 154 | return -1; 155 | } 156 | 157 | /** 158 | * asn1_ber_decoder - Decoder BER/DER/CER ASN.1 according to pattern 159 | * @decoder: The decoder definition (produced by asn1_compiler) 160 | * @context: The caller's context (to be passed to the action functions) 161 | * @data: The encoded data 162 | * @datasize: The size of the encoded data 163 | * 164 | * Decode BER/DER/CER encoded ASN.1 data according to a bytecode pattern 165 | * produced by asn1_compiler. Action functions are called on marked tags to 166 | * allow the caller to retrieve significant data. 167 | * 168 | * LIMITATIONS: 169 | * 170 | * To keep down the amount of stack used by this function, the following limits 171 | * have been imposed: 172 | * 173 | * (1) This won't handle datalen > 65535 without increasing the size of the 174 | * cons stack elements and length_too_long checking. 175 | * 176 | * (2) The stack of constructed types is 10 deep. If the depth of non-leaf 177 | * constructed types exceeds this, the decode will fail. 178 | * 179 | * (3) The SET type (not the SET OF type) isn't really supported as tracking 180 | * what members of the set have been seen is a pain. 181 | */ 182 | int asn1_ber_decoder(const struct asn1_decoder *decoder, 183 | void *context, 184 | const unsigned char *data, 185 | size_t datalen) 186 | { 187 | const unsigned char *machine = decoder->machine; 188 | const asn1_action_t *actions = decoder->actions; 189 | size_t machlen = decoder->machlen; 190 | enum asn1_opcode op; 191 | unsigned char tag = 0, csp = 0, jsp = 0, optag = 0, hdr = 0; 192 | const char *errmsg; 193 | const CHAR16 *Errmsg = NULL; 194 | size_t pc = 0, dp = 0, tdp = 0, len = 0; 195 | int ret; 196 | 197 | unsigned char flags = 0; 198 | #define FLAG_INDEFINITE_LENGTH 0x01 199 | #define FLAG_MATCHED 0x02 200 | #define FLAG_CONS 0x20 /* Corresponds to CONS bit in the opcode tag 201 | * - ie. whether or not we are going to parse 202 | * a compound type. 203 | */ 204 | 205 | #define NR_CONS_STACK 10 206 | unsigned short cons_dp_stack[NR_CONS_STACK]; 207 | unsigned short cons_datalen_stack[NR_CONS_STACK]; 208 | unsigned char cons_hdrlen_stack[NR_CONS_STACK]; 209 | #define NR_JUMP_STACK 10 210 | unsigned char jump_stack[NR_JUMP_STACK]; 211 | 212 | if (datalen > 65535) 213 | return -EMSGSIZE; 214 | 215 | next_op: 216 | if (unlikely(pc >= machlen)) 217 | goto machine_overrun_error; 218 | op = machine[pc]; 219 | if (unlikely(pc + asn1_op_lengths[op] > machlen)) 220 | goto machine_overrun_error; 221 | 222 | /* If this command is meant to match a tag, then do that before 223 | * evaluating the command. 224 | */ 225 | if (op <= ASN1_OP__MATCHES_TAG) { 226 | unsigned char tmp; 227 | 228 | /* Skip conditional matches if possible */ 229 | if ((op & ASN1_OP_MATCH__COND && 230 | flags & FLAG_MATCHED) || 231 | dp == datalen) { 232 | pc += asn1_op_lengths[op]; 233 | goto next_op; 234 | } 235 | 236 | flags = 0; 237 | hdr = 2; 238 | 239 | /* Extract a tag from the data */ 240 | if (unlikely(dp >= datalen - 1)) 241 | goto data_overrun_error; 242 | tag = data[dp++]; 243 | if (unlikely((tag & 0x1f) == 0x1f)) 244 | goto long_tag_not_supported; 245 | 246 | if (op & ASN1_OP_MATCH__ANY) { 247 | ; 248 | } else { 249 | /* Extract the tag from the machine 250 | * - Either CONS or PRIM are permitted in the data if 251 | * CONS is not set in the op stream, otherwise CONS 252 | * is mandatory. 253 | */ 254 | optag = machine[pc + 1]; 255 | flags |= optag & FLAG_CONS; 256 | 257 | /* Determine whether the tag matched */ 258 | tmp = optag ^ tag; 259 | tmp &= ~(optag & ASN1_CONS_BIT); 260 | if (tmp != 0) { 261 | /* All odd-numbered tags are MATCH_OR_SKIP. */ 262 | if (op & ASN1_OP_MATCH__SKIP) { 263 | pc += asn1_op_lengths[op]; 264 | dp--; 265 | goto next_op; 266 | } 267 | goto tag_mismatch; 268 | } 269 | } 270 | flags |= FLAG_MATCHED; 271 | 272 | len = data[dp++]; 273 | if (len > 0x7f) { 274 | if (unlikely(len == 0x80)) { 275 | /* Indefinite length */ 276 | if (unlikely(!(tag & ASN1_CONS_BIT))) 277 | goto indefinite_len_primitive; 278 | flags |= FLAG_INDEFINITE_LENGTH; 279 | if (unlikely(2 > datalen - dp)) 280 | goto data_overrun_error; 281 | } else { 282 | int n = len - 0x80; 283 | if (unlikely(n > 2)) 284 | goto length_too_long; 285 | if (unlikely(dp >= datalen - n)) 286 | goto data_overrun_error; 287 | hdr += n; 288 | for (len = 0; n > 0; n--) { 289 | len <<= 8; 290 | len |= data[dp++]; 291 | } 292 | if (unlikely(len > datalen - dp)) 293 | goto data_overrun_error; 294 | } 295 | } 296 | 297 | if (flags & FLAG_CONS) { 298 | /* For expected compound forms, we stack the positions 299 | * of the start and end of the data. 300 | */ 301 | if (unlikely(csp >= NR_CONS_STACK)) 302 | goto cons_stack_overflow; 303 | cons_dp_stack[csp] = dp; 304 | cons_hdrlen_stack[csp] = hdr; 305 | if (!(flags & FLAG_INDEFINITE_LENGTH)) { 306 | cons_datalen_stack[csp] = datalen; 307 | datalen = dp + len; 308 | } else { 309 | cons_datalen_stack[csp] = 0; 310 | } 311 | csp++; 312 | } 313 | 314 | tdp = dp; 315 | } 316 | 317 | /* Decide how to handle the operation */ 318 | switch (op) { 319 | case ASN1_OP_MATCH_ANY_ACT: 320 | case ASN1_OP_COND_MATCH_ANY_ACT: 321 | ret = actions[machine[pc + 1]](context, hdr, tag, data + dp, len); 322 | if (ret < 0) 323 | return ret; 324 | goto skip_data; 325 | 326 | case ASN1_OP_MATCH_ACT: 327 | case ASN1_OP_MATCH_ACT_OR_SKIP: 328 | case ASN1_OP_COND_MATCH_ACT_OR_SKIP: 329 | ret = actions[machine[pc + 2]](context, hdr, tag, data + dp, len); 330 | if (ret < 0) 331 | return ret; 332 | goto skip_data; 333 | 334 | case ASN1_OP_MATCH: 335 | case ASN1_OP_MATCH_OR_SKIP: 336 | case ASN1_OP_MATCH_ANY: 337 | case ASN1_OP_COND_MATCH_OR_SKIP: 338 | case ASN1_OP_COND_MATCH_ANY: 339 | skip_data: 340 | if (!(flags & FLAG_CONS)) { 341 | if (flags & FLAG_INDEFINITE_LENGTH) { 342 | ret = asn1_find_indefinite_length( 343 | data, datalen, &dp, &len, &errmsg); 344 | if (ret < 0) 345 | goto error; 346 | } else { 347 | dp += len; 348 | } 349 | } 350 | pc += asn1_op_lengths[op]; 351 | goto next_op; 352 | 353 | case ASN1_OP_MATCH_JUMP: 354 | case ASN1_OP_MATCH_JUMP_OR_SKIP: 355 | case ASN1_OP_COND_MATCH_JUMP_OR_SKIP: 356 | if (unlikely(jsp == NR_JUMP_STACK)) 357 | goto jump_stack_overflow; 358 | jump_stack[jsp++] = pc + asn1_op_lengths[op]; 359 | pc = machine[pc + 2]; 360 | goto next_op; 361 | 362 | case ASN1_OP_COND_FAIL: 363 | if (unlikely(!(flags & FLAG_MATCHED))) 364 | goto tag_mismatch; 365 | pc += asn1_op_lengths[op]; 366 | goto next_op; 367 | 368 | case ASN1_OP_COMPLETE: 369 | if (unlikely(jsp != 0 || csp != 0)) { 370 | return -EBADMSG; 371 | } 372 | return 0; 373 | 374 | case ASN1_OP_END_SET: 375 | case ASN1_OP_END_SET_ACT: 376 | if (unlikely(!(flags & FLAG_MATCHED))) 377 | goto tag_mismatch; 378 | case ASN1_OP_END_SEQ: 379 | case ASN1_OP_END_SET_OF: 380 | case ASN1_OP_END_SEQ_OF: 381 | case ASN1_OP_END_SEQ_ACT: 382 | case ASN1_OP_END_SET_OF_ACT: 383 | case ASN1_OP_END_SEQ_OF_ACT: 384 | if (unlikely(csp <= 0)) 385 | goto cons_stack_underflow; 386 | csp--; 387 | tdp = cons_dp_stack[csp]; 388 | hdr = cons_hdrlen_stack[csp]; 389 | len = datalen; 390 | datalen = cons_datalen_stack[csp]; 391 | if (datalen == 0) { 392 | /* Indefinite length - check for the EOC. */ 393 | datalen = len; 394 | if (unlikely(datalen - dp < 2)) 395 | goto data_overrun_error; 396 | if (data[dp++] != 0) { 397 | if (op & ASN1_OP_END__OF) { 398 | dp--; 399 | csp++; 400 | pc = machine[pc + 1]; 401 | goto next_op; 402 | } 403 | goto missing_eoc; 404 | } 405 | if (data[dp++] != 0) 406 | goto invalid_eoc; 407 | len = dp - tdp - 2; 408 | } else { 409 | if (dp < len && (op & ASN1_OP_END__OF)) { 410 | datalen = len; 411 | csp++; 412 | pc = machine[pc + 1]; 413 | goto next_op; 414 | } 415 | if (dp != len) 416 | goto cons_length_error; 417 | len -= tdp; 418 | } 419 | 420 | if (op & ASN1_OP_END__ACT) { 421 | unsigned char act; 422 | if (op & ASN1_OP_END__OF) 423 | act = machine[pc + 2]; 424 | else 425 | act = machine[pc + 1]; 426 | ret = actions[act](context, hdr, 0, data + tdp, len); 427 | } 428 | pc += asn1_op_lengths[op]; 429 | goto next_op; 430 | 431 | case ASN1_OP_ACT: 432 | ret = actions[machine[pc + 1]](context, hdr, tag, data + tdp, len); 433 | pc += asn1_op_lengths[op]; 434 | goto next_op; 435 | 436 | case ASN1_OP_RETURN: 437 | if (unlikely(jsp <= 0)) 438 | goto jump_stack_underflow; 439 | pc = jump_stack[--jsp]; 440 | goto next_op; 441 | 442 | default: 443 | break; 444 | } 445 | 446 | /* Shouldn't reach here */ 447 | return -EBADMSG; 448 | 449 | data_overrun_error: 450 | Errmsg = L"Data overrun error"; 451 | goto error; 452 | machine_overrun_error: 453 | Errmsg = L"Machine overrun error"; 454 | goto error; 455 | jump_stack_underflow: 456 | Errmsg = L"Jump stack underflow"; 457 | goto error; 458 | jump_stack_overflow: 459 | Errmsg = L"Jump stack overflow"; 460 | goto error; 461 | cons_stack_underflow: 462 | Errmsg = L"Cons stack underflow"; 463 | goto error; 464 | cons_stack_overflow: 465 | Errmsg = L"Cons stack overflow"; 466 | goto error; 467 | cons_length_error: 468 | Errmsg = L"Cons length error"; 469 | goto error; 470 | missing_eoc: 471 | Errmsg = L"Missing EOC in indefinite len cons"; 472 | goto error; 473 | invalid_eoc: 474 | Errmsg = L"Invalid length EOC"; 475 | goto error; 476 | length_too_long: 477 | Errmsg = L"Unsupported length"; 478 | goto error; 479 | indefinite_len_primitive: 480 | Errmsg = L"Indefinite len primitive not permitted"; 481 | goto error; 482 | tag_mismatch: 483 | Errmsg = L"Unexpected tag"; 484 | goto error; 485 | long_tag_not_supported: 486 | Errmsg = L"Long tag not supported"; 487 | error: 488 | Print(L"ERROR: %s\n", Errmsg); 489 | return -EBADMSG; 490 | } 491 | 492 | -------------------------------------------------------------------------------- /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) 2012-2019 Finnbarr P. Murphy. All rights reserved. 14 | * 15 | * Modified to work in EDKII 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) 2012-2019 Finnbarr P. Murphy. All rights reserved. 14 | * 15 | * Modified to work in EDKII 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-2019 Finnbarr P. Murphy. All rights reserved. 15 | * 16 | * Modified to work in EDKII environment. 17 | * 18 | */ 19 | 20 | #ifndef _OID_REGISTRY_H 21 | #define _OID_REGISTRY_H 22 | 23 | /* 24 | * OIDs are turned into these values if possible, or OID__NR if not held here. 25 | * 26 | * NOTE! Do not mess with the format of each line as this is read by 27 | * build_oid_registry_data.pl to generate the data for Lookup_OID. 28 | * 29 | * If you add or remove entries, you must rebuild oid_registry_data.c 30 | */ 31 | enum OID { 32 | OID_id_dsa_with_sha1, /* 1.2.840.10030.4.3 */ 33 | OID_id_dsa, /* 1.2.840.10040.4.1 */ 34 | OID_id_ecdsa_with_sha1, /* 1.2.840.10045.4.1 */ 35 | OID_id_ecPublicKey, /* 1.2.840.10045.2.1 */ 36 | 37 | /* PKCS#1 {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-1(1)} */ 38 | OID_rsaEncryption, /* 1.2.840.113549.1.1.1 */ 39 | OID_md2WithRSAEncryption, /* 1.2.840.113549.1.1.2 */ 40 | OID_md3WithRSAEncryption, /* 1.2.840.113549.1.1.3 */ 41 | OID_md4WithRSAEncryption, /* 1.2.840.113549.1.1.4 */ 42 | OID_sha1WithRSAEncryption, /* 1.2.840.113549.1.1.5 */ 43 | OID_sha256WithRSAEncryption, /* 1.2.840.113549.1.1.11 */ 44 | OID_sha384WithRSAEncryption, /* 1.2.840.113549.1.1.12 */ 45 | OID_sha512WithRSAEncryption, /* 1.2.840.113549.1.1.13 */ 46 | OID_sha224WithRSAEncryption, /* 1.2.840.113549.1.1.14 */ 47 | 48 | /* PKCS#7 {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-7(7)} */ 49 | OID_data, /* 1.2.840.113549.1.7.1 */ 50 | OID_signed_data, /* 1.2.840.113549.1.7.2 */ 51 | 52 | /* PKCS#9 {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-9(9)} */ 53 | OID_email_address, /* 1.2.840.113549.1.9.1 */ 54 | OID_content_type, /* 1.2.840.113549.1.9.3 */ 55 | OID_messageDigest, /* 1.2.840.113549.1.9.4 */ 56 | OID_signingTime, /* 1.2.840.113549.1.9.5 */ 57 | OID_smimeCapabilites, /* 1.2.840.113549.1.9.15 */ 58 | OID_smimeAuthenticatedAttrs, /* 1.2.840.113549.1.9.16.2.11 */ 59 | 60 | /* {iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2)} */ 61 | OID_md2, /* 1.2.840.113549.2.2 */ 62 | OID_md4, /* 1.2.840.113549.2.4 */ 63 | OID_md5, /* 1.2.840.113549.2.5 */ 64 | 65 | /* Microsoft OIDs */ 66 | OID_msOutlookExpress, /* 1.3.6.1.4.1.311.16.4 */ 67 | OID_msEnrollCerttypeExtension, /* 1.3.6.1.4.1.311.20.2 */ 68 | OID_msCertsrvCAVersion, /* 1.3.6.1.4.1.311.21.1 */ 69 | OID_msCertsrvPreviousCertHash, /* 1.3.6.1.4.1.311.21.2 */ 70 | 71 | OID_certAuthInfoAccess, /* 1.3.6.1.5.5.7.1.1 */ 72 | OID_sha1, /* 1.3.14.3.2.26 */ 73 | 74 | /* Distinguished Name attribute IDs [RFC 2256] */ 75 | OID_commonName, /* 2.5.4.3 */ 76 | OID_surname, /* 2.5.4.4 */ 77 | OID_countryName, /* 2.5.4.6 */ 78 | OID_locality, /* 2.5.4.7 */ 79 | OID_stateOrProvinceName, /* 2.5.4.8 */ 80 | OID_organizationName, /* 2.5.4.10 */ 81 | OID_organizationUnitName, /* 2.5.4.11 */ 82 | OID_title, /* 2.5.4.12 */ 83 | OID_description, /* 2.5.4.13 */ 84 | OID_name, /* 2.5.4.41 */ 85 | OID_givenName, /* 2.5.4.42 */ 86 | OID_initials, /* 2.5.4.43 */ 87 | OID_generationalQualifier, /* 2.5.4.44 */ 88 | 89 | /* Certificate extension IDs */ 90 | OID_subjectKeyIdentifier, /* 2.5.29.14 */ 91 | OID_keyUsage, /* 2.5.29.15 */ 92 | OID_subjectAltName, /* 2.5.29.17 */ 93 | OID_issuerAltName, /* 2.5.29.18 */ 94 | OID_basicConstraints, /* 2.5.29.19 */ 95 | OID_crlDistributionPoints, /* 2.5.29.31 */ 96 | OID_certPolicies, /* 2.5.29.32 */ 97 | OID_authorityKeyIdentifier, /* 2.5.29.35 */ 98 | OID_extKeyUsage, /* 2.5.29.37 */ 99 | 100 | OID__NR 101 | }; 102 | 103 | extern enum OID Lookup_OID(const void *data, long datasize); 104 | extern int Sprint_OID(const void *, long, CHAR16 *, long); 105 | 106 | #endif /* _OID_REGISTRY_H */ 107 | -------------------------------------------------------------------------------- /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 = IA32|X64|EBC 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 | SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf 68 | 69 | [Components] 70 | 71 | #### Applications 72 | MyApps/DisplayBMP/DisplayBMP.inf 73 | MyApps/ShowBGRT/ShowBGRT.inf 74 | MyApps/ScreenShot/ScreenShot.inf 75 | MyApps/ScreenshotDriver/ScreenshotDriver.inf 76 | MyApps/ListCerts/ListCerts.inf 77 | MyApps/Cpuid/Cpuid.inf 78 | MyApps/ShowPCI/ShowPCI.inf 79 | MyApps/ShowPCIx/ShowPCIx.inf 80 | MyApps/ShowEDID/ShowEDID.inf 81 | MyApps/ShowUSB/ShowUSB.inf 82 | MyApps/ShowMP/ShowMP.inf 83 | MyApps/DateTime/DateTime.inf 84 | MyApps/Beep/Beep.inf 85 | MyApps/XBeep/XBeep.inf 86 | MyApps/ShowMSDM/ShowMSDM.inf 87 | MyApps/ShowACPI/ShowACPI.inf 88 | MyApps/ShowFACS/ShowFACS.inf 89 | MyApps/ShowSLIC/ShowSLIC.inf 90 | MyApps/ShowESRT/ShowESRT.inf 91 | MyApps/ShowFreq/ShowFreq.inf 92 | MyApps/ShowHIIPkg/ShowHIIPkg.inf 93 | MyApps/ShowBoot/ShowBoot.inf 94 | MyApps/ShowPCR/ShowPCR.inf 95 | -------------------------------------------------------------------------------- /MyApps/ScreenShot/ScreenShot.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2010-2019 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Take screen snapshot 5 | // 6 | // License: BSD 2 clause License 7 | // 8 | // Portions Copyright (c) 2016-2017, Microsoft Corporation 9 | // Copyright (c) 2018, Intel Corporation. All rights reserved. 10 | // See relevant code in EDK11 for exact details 11 | // 12 | 13 | 14 | #include 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL EfiGraphicsColors[16] = { 34 | // B G R reserved 35 | {0x00, 0x00, 0x00, 0x00}, // BLACK 36 | {0x98, 0x00, 0x00, 0x00}, // LIGHTBLUE 37 | {0x00, 0x98, 0x00, 0x00}, // LIGHTGREEN 38 | {0x98, 0x98, 0x00, 0x00}, // LIGHTCYAN 39 | {0x00, 0x00, 0x98, 0x00}, // LIGHTRED 40 | {0x98, 0x00, 0x98, 0x00}, // MAGENTA 41 | {0x00, 0x98, 0x98, 0x00}, // BROWN 42 | {0x98, 0x98, 0x98, 0x00}, // LIGHTGRAY 43 | {0x30, 0x30, 0x30, 0x00}, // DARKGRAY 44 | {0xff, 0x00, 0x00, 0x00}, // BLUE 45 | {0x00, 0xff, 0x00, 0x00}, // LIME 46 | {0xff, 0xff, 0x00, 0x00}, // CYAN 47 | {0x00, 0x00, 0xff, 0x00}, // RED 48 | {0xff, 0x00, 0xff, 0x00}, // FUCHSIA 49 | {0x00, 0xff, 0xff, 0x00}, // YELLOW 50 | {0xff, 0xff, 0xff, 0x00} // WHITE 51 | }; 52 | 53 | typedef enum { 54 | Black = 0, 55 | LightBlue, 56 | LightGreen, 57 | LightCyan, 58 | LightRed, 59 | Magenta, 60 | Brown, 61 | LightGray, 62 | DarkGray, 63 | Blue, 64 | Lime, 65 | Cyan, 66 | Red, 67 | Fuchsia, 68 | Yellow, 69 | White 70 | } COLOR; 71 | 72 | #define UTILITY_VERSION L"20190314" 73 | #undef DEBUG 74 | 75 | 76 | // Determines the size of status square 77 | #define STATUS_SQUARE_SIDE 10 78 | 79 | 80 | BOOLEAN 81 | IsUnicodeDecimalDigit( CHAR16 Char ) 82 | { 83 | return ((BOOLEAN)(Char >= L'0' && Char <= L'9')); 84 | } 85 | 86 | 87 | EFI_STATUS 88 | UnicodeStringToInteger( CHAR16 *String, 89 | UINTN *Value ) 90 | { 91 | UINTN Result = 0; 92 | 93 | if (String == NULL || StrSize (String) == 0 || Value == NULL) { 94 | return (EFI_INVALID_PARAMETER); 95 | } 96 | 97 | while (IsUnicodeDecimalDigit(*String)) { 98 | if (!(Result <= (DivU64x32((((UINT64) ~0) - (*String - L'0')),10)))) { 99 | return (EFI_DEVICE_ERROR); 100 | } 101 | 102 | Result = MultU64x32(Result, 10) + (*String - L'0'); 103 | String++; 104 | } 105 | 106 | *Value = Result; 107 | 108 | return (EFI_SUCCESS); 109 | } 110 | 111 | 112 | EFI_STATUS 113 | ShowStatus( EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop, 114 | UINT8 Color, 115 | UINTN StartX, 116 | UINTN StartY, 117 | UINTN Width, 118 | UINTN Height ) 119 | { 120 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL Square[STATUS_SQUARE_SIDE * STATUS_SQUARE_SIDE]; 121 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL BackupTL[STATUS_SQUARE_SIDE * STATUS_SQUARE_SIDE]; 122 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL BackupTR[STATUS_SQUARE_SIDE * STATUS_SQUARE_SIDE]; 123 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL BackupBL[STATUS_SQUARE_SIDE * STATUS_SQUARE_SIDE]; 124 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL BackupBR[STATUS_SQUARE_SIDE * STATUS_SQUARE_SIDE]; 125 | 126 | // set square color 127 | for (UINTN i = 0 ; i < STATUS_SQUARE_SIDE * STATUS_SQUARE_SIDE; i++) { 128 | Square[i].Blue = EfiGraphicsColors[Color].Blue; 129 | Square[i].Green = EfiGraphicsColors[Color].Green; 130 | Square[i].Red = EfiGraphicsColors[Color].Red; 131 | Square[i].Reserved = 0x00; 132 | } 133 | 134 | Width = Width - STATUS_SQUARE_SIDE -1; 135 | Height = Height - STATUS_SQUARE_SIDE -1; 136 | 137 | // backup current squares 138 | Gop->Blt(Gop, BackupTL, EfiBltVideoToBltBuffer, StartX, StartY, 0, 0, STATUS_SQUARE_SIDE, STATUS_SQUARE_SIDE, 0); 139 | Gop->Blt(Gop, BackupTR, EfiBltVideoToBltBuffer, StartX + Width, StartY, 0, 0, STATUS_SQUARE_SIDE, STATUS_SQUARE_SIDE, 0); 140 | Gop->Blt(Gop, BackupBL, EfiBltVideoToBltBuffer, StartX, StartY + Height, 0, 0, STATUS_SQUARE_SIDE, STATUS_SQUARE_SIDE, 0); 141 | Gop->Blt(Gop, BackupBR, EfiBltVideoToBltBuffer, StartX + Width, StartY + Height, 0, 0, STATUS_SQUARE_SIDE, STATUS_SQUARE_SIDE, 0); 142 | 143 | // draw status square 144 | Gop->Blt(Gop, Square, EfiBltBufferToVideo, 0, 0, StartX, StartY, STATUS_SQUARE_SIDE, STATUS_SQUARE_SIDE, 0); 145 | Gop->Blt(Gop, Square, EfiBltBufferToVideo, 0, 0, StartX + Width, StartY, STATUS_SQUARE_SIDE, STATUS_SQUARE_SIDE, 0); 146 | Gop->Blt(Gop, Square, EfiBltBufferToVideo, 0, 0, StartX, StartY + Height, STATUS_SQUARE_SIDE, STATUS_SQUARE_SIDE, 0); 147 | Gop->Blt(Gop, Square, EfiBltBufferToVideo, 0, 0, StartX + Width, StartY + Height, STATUS_SQUARE_SIDE, STATUS_SQUARE_SIDE, 0); 148 | 149 | // wait 500ms 150 | gBS->Stall(500*1000); 151 | 152 | // restore squares from backups 153 | Gop->Blt(Gop, BackupTL, EfiBltBufferToVideo, 0, 0, StartX, StartY, STATUS_SQUARE_SIDE, STATUS_SQUARE_SIDE, 0); 154 | Gop->Blt(Gop, BackupTR, EfiBltBufferToVideo, 0, 0, StartX + Width, StartY, STATUS_SQUARE_SIDE, STATUS_SQUARE_SIDE, 0); 155 | Gop->Blt(Gop, BackupBL, EfiBltBufferToVideo, 0, 0, StartX, StartY + Height, STATUS_SQUARE_SIDE, STATUS_SQUARE_SIDE, 0); 156 | Gop->Blt(Gop, BackupBR, EfiBltBufferToVideo, 0, 0, StartX + Width, StartY + Height, STATUS_SQUARE_SIDE, STATUS_SQUARE_SIDE, 0); 157 | 158 | return EFI_SUCCESS; 159 | } 160 | 161 | 162 | // 163 | // Save image to file 164 | // 165 | EFI_STATUS 166 | SaveImage( CHAR16 *FileName, 167 | UINT8 *FileData, 168 | UINTN FileDataLength ) 169 | { 170 | SHELL_FILE_HANDLE FileHandle = NULL; 171 | EFI_STATUS Status = EFI_SUCCESS; 172 | CONST CHAR16 *CurDir = NULL; 173 | CONST CHAR16 *PathName = NULL; 174 | CHAR16 *FullPath = NULL; 175 | UINTN Length = 0; 176 | 177 | CurDir = gEfiShellProtocol->GetCurDir(NULL); 178 | if (CurDir == NULL) { 179 | Print(L"ERROR: Cannot retrieve current directory\n"); 180 | return EFI_NOT_FOUND; 181 | } 182 | PathName = CurDir; 183 | StrnCatGrow(&FullPath, &Length, PathName, 0); 184 | StrnCatGrow(&FullPath, &Length, L"\\", 0); 185 | StrnCatGrow(&FullPath, &Length, FileName, 0); 186 | #ifdef DEBUG 187 | Print(L"FullPath: [%s]\n", FullPath); 188 | #endif 189 | 190 | Status = gEfiShellProtocol->OpenFileByName( FullPath, 191 | &FileHandle, 192 | EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE); 193 | if (EFI_ERROR(Status)) { 194 | Print(L"ERROR: OpenFileByName [%s] [%d]\n", FullPath, Status); 195 | return Status; 196 | } 197 | 198 | // BufferSize = FileDataLength; 199 | Status = gEfiShellProtocol->WriteFile( FileHandle, 200 | &FileDataLength, 201 | FileData ); 202 | gEfiShellProtocol->CloseFile( FileHandle ); 203 | 204 | if (EFI_ERROR(Status)) { 205 | Print(L"ERROR: Saving image to file: %x\n", Status); 206 | } else { 207 | Print(L"Successfully saved image to %s\n", FullPath); 208 | } 209 | 210 | return Status; 211 | } 212 | 213 | 214 | EFI_STATUS 215 | PrepareBMPFile( EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, 216 | UINT32 Width, 217 | UINT32 Height ) 218 | { 219 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Pixel; 220 | BMP_IMAGE_HEADER *BmpHeader; 221 | EFI_STATUS Status = EFI_SUCCESS; 222 | EFI_TIME Time; 223 | CHAR16 FileName[40]; 224 | UINT8 *FileData; 225 | UINTN FileDataLength; 226 | UINT8 *ImagePtr; 227 | UINT8 *ImagePtrBase; 228 | UINTN ImageLineOffset; 229 | UINTN x, y; 230 | 231 | ImageLineOffset = Width * 3; 232 | if ((ImageLineOffset % 4) != 0) { 233 | ImageLineOffset = ImageLineOffset + (4 - (ImageLineOffset % 4)); 234 | } 235 | 236 | // allocate buffer for data 237 | FileDataLength = sizeof(BMP_IMAGE_HEADER) + Height * ImageLineOffset; 238 | FileData = AllocateZeroPool( FileDataLength ); 239 | if (FileData == NULL) { 240 | FreePool( BltBuffer ); 241 | Print(L"ERROR: AllocateZeroPool. No memony resources\n"); 242 | return EFI_OUT_OF_RESOURCES; 243 | } 244 | 245 | // fill header 246 | BmpHeader = (BMP_IMAGE_HEADER *)FileData; 247 | BmpHeader->CharB = 'B'; 248 | BmpHeader->CharM = 'M'; 249 | BmpHeader->Size = (UINT32)FileDataLength; 250 | BmpHeader->ImageOffset = sizeof(BMP_IMAGE_HEADER); 251 | BmpHeader->HeaderSize = 40; 252 | BmpHeader->PixelWidth = Width; 253 | BmpHeader->PixelHeight = Height; 254 | BmpHeader->Planes = 1; 255 | BmpHeader->BitPerPixel = 24; 256 | BmpHeader->CompressionType = 0; 257 | BmpHeader->XPixelsPerMeter = 0; 258 | BmpHeader->YPixelsPerMeter = 0; 259 | 260 | // fill pixel buffer 261 | ImagePtrBase = FileData + BmpHeader->ImageOffset; 262 | for (y = 0; y < Height; y++) { 263 | ImagePtr = ImagePtrBase; 264 | ImagePtrBase += ImageLineOffset; 265 | Pixel = BltBuffer + (Height - 1 - y) * Width; 266 | 267 | for (x = 0; x < Width; x++) { 268 | *ImagePtr++ = Pixel->Blue; 269 | *ImagePtr++ = Pixel->Green; 270 | *ImagePtr++ = Pixel->Red; 271 | Pixel++; 272 | } 273 | } 274 | 275 | FreePool(BltBuffer); 276 | 277 | Status = gRT->GetTime(&Time, NULL); 278 | if (!EFI_ERROR(Status)) { 279 | UnicodeSPrint( FileName, 62, L"screenshot-%04d%02d%02d-%02d%02d%02d.bmp", 280 | Time.Year, Time.Month, Time.Day, Time.Hour, Time.Minute, Time.Second ); 281 | } else { 282 | UnicodeSPrint( FileName, 30, L"screenshot.bmp" ); 283 | } 284 | 285 | SaveImage( FileName, FileData, FileDataLength ); 286 | 287 | FreePool( FileData ); 288 | 289 | return Status; 290 | } 291 | 292 | 293 | EFI_STATUS 294 | SnapShot( EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop, 295 | UINTN StartX, 296 | UINTN StartY, 297 | UINTN Width, 298 | UINTN Height ) 299 | { 300 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer = NULL; 301 | EFI_STATUS Status = EFI_SUCCESS; 302 | UINTN ImageSize; 303 | 304 | ImageSize = Width * Height; 305 | 306 | // allocate memory for snapshot 307 | BltBuffer = AllocateZeroPool( sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * ImageSize ); 308 | if (BltBuffer == NULL) { 309 | Print(L"ERROR: BltBuffer. No memory resources\n"); 310 | return EFI_OUT_OF_RESOURCES; 311 | } 312 | 313 | // take screenshot 314 | Status = Gop->Blt( Gop, BltBuffer, EfiBltVideoToBltBuffer, StartX, StartY, 0, 0, Width, Height, 0 ); 315 | if (EFI_ERROR(Status)) { 316 | Print(L"ERROR: Gop->Blt [%d]\n", Status); 317 | FreePool( BltBuffer ); 318 | return Status; 319 | } 320 | 321 | PrepareBMPFile( BltBuffer, Width, Height ); 322 | 323 | return Status; 324 | } 325 | 326 | 327 | VOID 328 | Usage( BOOLEAN ErrorMsg ) 329 | { 330 | if ( ErrorMsg ) { 331 | Print(L"ERROR: Unknown option(s).\n"); 332 | } 333 | 334 | Print(L"Usage: ScreenShot [StartX StartY WidthX HeightY]\n"); 335 | Print(L" ScreenShot [-i | --info]\n"); 336 | Print(L" ScreenShot [-V | --version]\n"); 337 | } 338 | 339 | 340 | INTN 341 | EFIAPI 342 | ShellAppMain( UINTN Argc, 343 | CHAR16 **Argv ) 344 | { 345 | EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop = NULL; 346 | EFI_DEVICE_PATH_PROTOCOL *Dpp; 347 | EFI_STATUS Status = EFI_SUCCESS; 348 | EFI_HANDLE *Handles = NULL; 349 | BOOLEAN DisplayInfo = FALSE; 350 | UINTN HandleCount = 0; 351 | UINTN StartX = 0, StartY = 0, Width = 0, Height = 0; 352 | 353 | if (Argc == 2) { 354 | if (!StrCmp(Argv[1], L"--version") || 355 | !StrCmp(Argv[1], L"-V")) { 356 | Print(L"Version: %s\n", UTILITY_VERSION); 357 | return Status; 358 | } else if (!StrCmp(Argv[1], L"--help") || 359 | !StrCmp(Argv[1], L"-h")) { 360 | Usage(FALSE); 361 | return Status; 362 | } else if (!StrCmp(Argv[1], L"--info") || 363 | !StrCmp(Argv[1], L"-i")) { 364 | DisplayInfo = TRUE; 365 | } else if (Argv[1][0] == L'-') { 366 | Usage(TRUE); 367 | return Status; 368 | } 369 | } else if (Argc == 5) { 370 | UnicodeStringToInteger( Argv[1], &StartX ); 371 | UnicodeStringToInteger( Argv[2], &StartY ); 372 | UnicodeStringToInteger( Argv[3], &Width ); 373 | UnicodeStringToInteger( Argv[4], &Height ); 374 | } else if (Argc > 1) { 375 | Usage(FALSE); 376 | return Status; 377 | } 378 | 379 | // Try locating GOP by handle 380 | Status = gBS->LocateHandleBuffer( ByProtocol, 381 | &gEfiGraphicsOutputProtocolGuid, 382 | NULL, 383 | &HandleCount, 384 | &Handles ); 385 | if (EFI_ERROR (Status)) { 386 | Print(L"ERROR: No GOP handles found via LocateHandleBuffer\n"); 387 | return Status; 388 | } 389 | 390 | #ifdef DEBUG 391 | Print(L"Found %d GOP handles via LocateHandleBuffer\n", HandleCount); 392 | #endif 393 | 394 | // Make sure we use the correct GOP handle 395 | for (UINTN Handle = 0; Handle < HandleCount; Handle++) { 396 | Status = gBS->HandleProtocol( Handles[Handle], 397 | &gEfiDevicePathProtocolGuid, 398 | (VOID **)&Dpp ); 399 | if (!EFI_ERROR(Status)) { 400 | Status = gBS->HandleProtocol( Handles[Handle], 401 | &gEfiGraphicsOutputProtocolGuid, 402 | (VOID **)&Gop ); 403 | if (!EFI_ERROR(Status)) { 404 | break; 405 | } 406 | } 407 | } 408 | FreePool( Handles ); 409 | if (Gop == NULL) { 410 | Print(L"ERROR: No graphics console found.\n"); 411 | return Status; 412 | } 413 | 414 | if ( DisplayInfo ) { 415 | Print(L"\nScreen - Width: %d\n", Gop->Mode->Info->HorizontalResolution); 416 | Print(L" Height: %d\n\n", Gop->Mode->Info->VerticalResolution); 417 | return Status; 418 | } 419 | 420 | if ( Width == 0 ) 421 | Width = Gop->Mode->Info->HorizontalResolution; 422 | if ( Height == 0 ) 423 | Height = Gop->Mode->Info->VerticalResolution; 424 | 425 | Status = ShowStatus( Gop, Yellow, StartX, StartY, Width, Height ); 426 | gBS->Stall(500*1000); 427 | Status = SnapShot( Gop , StartX, StartY, Width, Height ); 428 | if (EFI_ERROR(Status)) { 429 | Status = ShowStatus( Gop, Red, StartX, StartY, Width, Height ); 430 | } else { 431 | Status = ShowStatus( Gop, Lime, StartX, StartY, Width, Height ); 432 | } 433 | 434 | return Status; 435 | } 436 | -------------------------------------------------------------------------------- /MyApps/ScreenShot/ScreenShot.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/MyApps/ScreenShot/ScreenShot.efi -------------------------------------------------------------------------------- /MyApps/ScreenShot/ScreenShot.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ScreenShot 4 | FILE_GUID = 4ea87c57-7795-5dcd-1055-747010f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 0.9 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | ScreenShot.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/ScreenshotDriver/ScreenshotDriver.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/MyApps/ScreenshotDriver/ScreenshotDriver.efi -------------------------------------------------------------------------------- /MyApps/ScreenshotDriver/ScreenshotDriver.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2010-2019 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Screen snapshot driver 5 | // 6 | // License: BSD 2 clause License 7 | // 8 | // Portions Copyright (c) 2018, Intel Corporation. All rights reserved. 9 | // See relevant code in EDK11 for exact details 10 | // 11 | 12 | 13 | #ifndef _SCREENSHOTDRIVER_H_ 14 | #define _SCREENSHOTDRIVER_H_ 15 | 16 | #define SCREENSHOTDRIVER_DEV_SIGNATURE SIGNATURE_32 ('s', 's', 'd', 'r') 17 | 18 | typedef struct { 19 | UINT32 Signature; 20 | EFI_HANDLE Handle; 21 | VOID *ScreenshotDriverVariable; 22 | UINT8 DeviceType; 23 | BOOLEAN FixedDevice; 24 | UINT16 Reserved; 25 | EFI_UNICODE_STRING_TABLE *ControllerNameTable; 26 | } SCREENSHOTDRIVER_DEV; 27 | 28 | #define SCREENSHOTDRIVER_DEV_FROM_THIS(a) CR (a, SCREENSHOTDRIVER_DEV, ScreenshotDriverVariable, SCREENSHOTDRIVER_DEV_SIGNATURE) 29 | 30 | // Global Variables 31 | extern EFI_DRIVER_BINDING_PROTOCOL gScreenshotDriverBinding; 32 | extern EFI_COMPONENT_NAME2_PROTOCOL gScreenshotComponentName2; 33 | extern EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gScreenshotDriverDiagnostics2; 34 | extern EFI_DRIVER_CONFIGURATION2_PROTOCOL gScreenshotDriverConfiguration2; 35 | 36 | 37 | EFI_STATUS 38 | EFIAPI 39 | ScreenshotDriverBindingSupported( IN EFI_DRIVER_BINDING_PROTOCOL *This, 40 | IN EFI_HANDLE Controller, 41 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath ); 42 | 43 | EFI_STATUS 44 | EFIAPI 45 | ScreenshotDriverBindingStart( IN EFI_DRIVER_BINDING_PROTOCOL *This, 46 | IN EFI_HANDLE Controller, 47 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath ); 48 | 49 | EFI_STATUS 50 | EFIAPI 51 | ScreenshotDriverBindingStop( IN EFI_DRIVER_BINDING_PROTOCOL *This, 52 | IN EFI_HANDLE Controller, 53 | IN UINTN NumberOfChildren, 54 | IN EFI_HANDLE *ChildHandleBuffer ); 55 | 56 | EFI_STATUS 57 | EFIAPI 58 | ScreenshotDriverComponentNameGetDriverName( IN EFI_COMPONENT_NAME2_PROTOCOL *This, 59 | IN CHAR8 *Language, 60 | OUT CHAR16 **DriverName ); 61 | 62 | EFI_STATUS 63 | EFIAPI 64 | ScreenshotDriverComponentNameGetControllerName( IN EFI_COMPONENT_NAME2_PROTOCOL *This, 65 | IN EFI_HANDLE ControllerHandle, 66 | IN EFI_HANDLE ChildHandleL, 67 | IN CHAR8 *Language, 68 | OUT CHAR16 **ControllerName ); 69 | 70 | EFI_STATUS 71 | EFIAPI 72 | ScreenshotDriverRunDiagnostics( IN EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *This, 73 | IN EFI_HANDLE ControllerHandle, 74 | IN EFI_HANDLE ChildHandle, 75 | IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType, 76 | IN CHAR8 *Language, 77 | OUT EFI_GUID **ErrorType, 78 | OUT UINTN *BufferSize, 79 | OUT CHAR16 **Buffer ); 80 | 81 | EFI_STATUS 82 | EFIAPI 83 | ScreenshotDriverConfigurationSetOptions( IN EFI_DRIVER_CONFIGURATION2_PROTOCOL *This, 84 | IN EFI_HANDLE ControllerHandle, 85 | IN EFI_HANDLE ChildHandle, 86 | IN CHAR8 *Language, 87 | OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired ); 88 | 89 | EFI_STATUS 90 | EFIAPI 91 | ScreenshotDriverConfigurationOptionsValid( IN EFI_DRIVER_CONFIGURATION2_PROTOCOL *This, 92 | IN EFI_HANDLE ControllerHandle, 93 | IN EFI_HANDLE ChildHandle ); 94 | 95 | EFI_STATUS 96 | EFIAPI 97 | ScreenshotDriverConfigurationForceDefaults( IN EFI_DRIVER_CONFIGURATION2_PROTOCOL *This, 98 | IN EFI_HANDLE ControllerHandle, 99 | IN EFI_HANDLE ChildHandle, 100 | IN UINT32 DefaultType, 101 | OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired ); 102 | 103 | #endif // _SCREENSHOTDRIVER_H_ 104 | -------------------------------------------------------------------------------- /MyApps/ScreenshotDriver/ScreenshotDriver.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ScreenshotDriver 4 | FILE_GUID = 4ea87c57-7795-5ded-1055-747010f3ce51 5 | MODULE_TYPE = UEFI_DRIVER 6 | VERSION_STRING = 0.9 7 | ENTRY_POINT = ScreenshotDriverEntryPoint 8 | UNLOAD_IMAGE = ScreenshotDriverUnload 9 | VALID_ARCHITECTURES = X64 10 | 11 | [Packages] 12 | MdePkg/MdePkg.dec 13 | MdeModulePkg/MdeModulePkg.dec 14 | 15 | [LibraryClasses] 16 | UefiBootServicesTableLib 17 | UefiRuntimeServicesTableLib 18 | UefiDriverEntryPoint 19 | DebugLib 20 | PrintLib 21 | ShellLib 22 | BaseLib 23 | BaseMemoryLib 24 | UefiLib 25 | 26 | [Sources] 27 | ScreenshotDriver.c 28 | ScreenshotDriver.h 29 | 30 | [Packages] 31 | MdePkg/MdePkg.dec 32 | ShellPkg/ShellPkg.dec 33 | 34 | [Depex] 35 | gEfiGraphicsOutputProtocolGuid AND 36 | gEfiSimpleTextInputExProtocolGuid 37 | 38 | [Pcd] 39 | 40 | -------------------------------------------------------------------------------- /MyApps/ShowACPI/ShowACPI.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2015-2019 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Show ACPI tables 5 | // 6 | // License: EDKII license applies to code from EDKII 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 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #define UTILITY_VERSION L"20190606" 26 | #undef DEBUG 27 | 28 | 29 | VOID AsciiToUnicodeSize(CHAR8 *, UINT8, CHAR16 *, BOOLEAN); 30 | 31 | VOID 32 | AsciiToUnicodeSize( CHAR8 *String, 33 | UINT8 length, 34 | CHAR16 *UniString, 35 | BOOLEAN Quote ) 36 | { 37 | int len = length; 38 | 39 | if (Quote) 40 | *(UniString++) = L'"'; 41 | while (*String != '\0' && len > 0) { 42 | *(UniString++) = (CHAR16) *(String++); 43 | len--; 44 | } 45 | if (Quote) 46 | *(UniString++) = L'"'; 47 | *UniString = '\0'; 48 | } 49 | 50 | 51 | VOID 52 | PrintListEntry( EFI_ACPI_SDT_HEADER *Ptr, int Index ) 53 | { 54 | CHAR16 Buffer1[20]; 55 | 56 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->Signature), 4, Buffer1, FALSE); 57 | Print(L" %s", Buffer1); 58 | 59 | #if 0 60 | if (!AsciiStrnCmp( (CHAR8 *)&(Ptr->Signature), "FACP", 4)) { 61 | Print(L" (inc. FACS, DSDT)"); 62 | } 63 | #endif 64 | 65 | if ((++Index)%8 == 0) { 66 | Print(L"\n"); 67 | } 68 | } 69 | 70 | 71 | VOID 72 | PrintTableEntry( EFI_ACPI_SDT_HEADER *Ptr ) 73 | { 74 | CHAR16 Buffer1[20], Buffer2[20]; 75 | 76 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->Signature), 4, Buffer1, FALSE); 77 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->CreatorId), 4, Buffer2, FALSE); 78 | 79 | Print(L" %s 0x%02x %s 0x%08x", 80 | Buffer1, (int)(Ptr->Revision), Buffer2, (int)(Ptr->CreatorRevision) ); 81 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->OemTableId), 8, Buffer1, TRUE); 82 | Print(L" %s", Buffer1); 83 | 84 | #if 0 85 | if (!AsciiStrnCmp( (CHAR8 *)&(Ptr->Signature), "FACP", 4)) { 86 | Print(L" (inc. FACS, DSDT)"); 87 | } 88 | #endif 89 | Print(L"\n"); 90 | } 91 | 92 | 93 | VOID 94 | ParseRSDP( EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp, 95 | CHAR16* GuidStr, 96 | BOOLEAN Verbose ) 97 | { 98 | EFI_ACPI_SDT_HEADER *Xsdt; 99 | UINT32 EntryCount; 100 | UINT64 *EntryPtr; 101 | CHAR16 OemStr[20]; 102 | 103 | if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) { 104 | if ( Verbose ) { 105 | AsciiToUnicodeSize((CHAR8 *)(Rsdp->OemId), 6, OemStr, FALSE); 106 | Print(L"\n RSDP Revision: %d OEM ID: %s\n", (int)(Rsdp->Revision), OemStr); 107 | } 108 | Xsdt = (EFI_ACPI_SDT_HEADER *)(Rsdp->XsdtAddress); 109 | } else { 110 | #ifdef DEBUG 111 | Print(L"ERROR: RSDP table < revision ACPI 2.0 found.\n"); 112 | #endif 113 | return; 114 | } 115 | 116 | if (Xsdt->Signature != SIGNATURE_32 ('X', 'S', 'D', 'T')) { 117 | Print(L"ERROR: Invalid ACPI XSDT table found.\n"); 118 | return; 119 | } 120 | 121 | EntryCount = (Xsdt->Length - sizeof (EFI_ACPI_SDT_HEADER)) / sizeof(UINT64); 122 | if ( Verbose ) { 123 | AsciiToUnicodeSize((CHAR8 *)(Xsdt->OemId), 6, OemStr, FALSE); 124 | Print(L" XSDT Revision: %d OEM ID: %s Entry Count: %d\n\n", (int)(Xsdt->Revision), OemStr, EntryCount); 125 | 126 | Print(L" Table Revision CreatorID CreatorRev OemTableID\n"); 127 | Print(L" -------------------------------------------------\n"); 128 | } else { 129 | Print(L"\n"); 130 | } 131 | 132 | EntryPtr = (UINT64 *)(Xsdt + 1); 133 | for (int Index = 0; Index < EntryCount; Index++, EntryPtr++) { 134 | if ( Verbose ) { 135 | PrintTableEntry((EFI_ACPI_SDT_HEADER *)((UINTN)(*EntryPtr))); 136 | } else { 137 | PrintListEntry((EFI_ACPI_SDT_HEADER *)((UINTN)(*EntryPtr)), Index); 138 | } 139 | } 140 | 141 | if ( !Verbose ) { 142 | Print(L"\n"); 143 | } 144 | Print(L"\n"); 145 | 146 | return; 147 | } 148 | 149 | 150 | VOID 151 | Usage( BOOLEAN ErrorMsg ) 152 | { 153 | if ( ErrorMsg ) { 154 | Print(L"ERROR: Unknown option.\n"); 155 | } 156 | Print(L"Usage: ShowACPI [-v | --verbose]\n"); 157 | Print(L" ShowACPI [-V | --version]\n"); 158 | } 159 | 160 | 161 | INTN 162 | EFIAPI 163 | ShellAppMain( UINTN Argc, 164 | CHAR16 **Argv ) 165 | { 166 | EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp = NULL; 167 | EFI_CONFIGURATION_TABLE *ect = gST->ConfigurationTable; 168 | EFI_STATUS Status = EFI_SUCCESS; 169 | EFI_GUID gAcpi20TableGuid = EFI_ACPI_20_TABLE_GUID; 170 | EFI_GUID gAcpi10TableGuid = ACPI_10_TABLE_GUID; 171 | BOOLEAN Verbose = FALSE; 172 | CHAR16 GuidStr[100]; 173 | 174 | if (Argc == 2) { 175 | if (!StrCmp(Argv[1], L"--verbose") || 176 | !StrCmp(Argv[1], L"-v")) { 177 | Verbose = TRUE; 178 | } else if (!StrCmp(Argv[1], L"--version") || 179 | !StrCmp(Argv[1], L"-V")) { 180 | Print(L"Version: %s\n", UTILITY_VERSION); 181 | return Status; 182 | } else if (!StrCmp(Argv[1], L"--help") || 183 | !StrCmp(Argv[1], L"-h")) { 184 | Usage(FALSE); 185 | return Status; 186 | } else { 187 | Usage(TRUE); 188 | return Status; 189 | } 190 | } 191 | if (Argc > 2) { 192 | Usage(TRUE); 193 | return Status; 194 | } 195 | 196 | 197 | // locate RSDP (Root System Description Pointer) 198 | for (int i = 0; i < gST->NumberOfTableEntries; i++) { 199 | if ((CompareGuid (&(gST->ConfigurationTable[i].VendorGuid), &gAcpi20TableGuid)) || 200 | (CompareGuid (&(gST->ConfigurationTable[i].VendorGuid), &gAcpi10TableGuid))) { 201 | if (!AsciiStrnCmp("RSD PTR ", (CHAR8 *)(ect->VendorTable), 8)) { 202 | UnicodeSPrint(GuidStr, sizeof(GuidStr), L"%g", &(gST->ConfigurationTable[i].VendorGuid)); 203 | Rsdp = (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)ect->VendorTable; 204 | ParseRSDP(Rsdp, GuidStr, Verbose); 205 | } 206 | } 207 | ect++; 208 | } 209 | 210 | if (Rsdp == NULL) { 211 | Print(L"ERROR: Could not find an ACPI RSDP table.\n"); 212 | Status = EFI_NOT_FOUND; 213 | } 214 | 215 | return Status; 216 | } 217 | -------------------------------------------------------------------------------- /MyApps/ShowACPI/ShowACPI.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/MyApps/ShowACPI/ShowACPI.efi -------------------------------------------------------------------------------- /MyApps/ShowACPI/ShowACPI.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ShowACPI 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 | ShowACPI.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/ShowBGRT/ShowBGRT.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/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/ShowBoot/ShowBoot.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2012-2020 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Show BootXXXX variables 5 | // 6 | // License: EDKII license applies to code from EDKII source, 7 | // BSD 2 clause license applies to all other code. 8 | // 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | #define UTILITY_VERSION L"20201002" 29 | #undef DEBUG 30 | 31 | // for option setting 32 | typedef enum { 33 | Default = 0, 34 | All 35 | } MODE; 36 | 37 | 38 | EFI_STATUS 39 | GetNvramVariable( CHAR16 *VariableName, 40 | EFI_GUID *VariableOwnerGuid, 41 | VOID **Buffer, 42 | UINTN *BufferSize) 43 | { 44 | EFI_STATUS Status; 45 | UINTN Size = 0; 46 | 47 | *BufferSize = 0; 48 | 49 | Status = gRT->GetVariable( VariableName, VariableOwnerGuid, NULL, &Size, NULL ); 50 | if (Status != EFI_BUFFER_TOO_SMALL) 51 | return Status; 52 | 53 | *Buffer = AllocateZeroPool( Size ); 54 | if (!Buffer) 55 | return EFI_OUT_OF_RESOURCES; 56 | 57 | Status = gRT->GetVariable( VariableName, VariableOwnerGuid, NULL, &Size, *Buffer ); 58 | if (Status != EFI_SUCCESS) { 59 | FreePool( *Buffer ); 60 | *Buffer = NULL; 61 | } else 62 | *BufferSize = Size; 63 | 64 | return Status; 65 | } 66 | 67 | 68 | EFI_STATUS 69 | OutputBootVariable( CHAR16 *VariableNane, 70 | EFI_GUID VariableOwnerGuid, 71 | MODE Mode ) 72 | { 73 | EFI_LOAD_OPTION *LoadOption; 74 | EFI_STATUS Status = EFI_SUCCESS; 75 | UINT8 *Buffer; 76 | UINTN BufferSize; 77 | CHAR16 *Description = (CHAR16 *)NULL; 78 | UINTN DescriptionSize; 79 | CHAR16 *DevPathString = (CHAR16 *)NULL; 80 | VOID *FilePathList; 81 | 82 | Status = GetNvramVariable( VariableNane, &VariableOwnerGuid, (VOID *)&Buffer, &BufferSize ); 83 | if (Status == EFI_SUCCESS) { 84 | LoadOption = (EFI_LOAD_OPTION *)Buffer; 85 | Description = (CHAR16*)(Buffer + sizeof (EFI_LOAD_OPTION)); 86 | DescriptionSize = StrSize( Description ); 87 | 88 | if (Mode == Default ) { 89 | if ((LoadOption->Attributes & LOAD_OPTION_HIDDEN) != 0) { 90 | return Status; 91 | } 92 | } 93 | if (LoadOption->FilePathListLength != 0) { 94 | FilePathList = (UINT8 *)Description + DescriptionSize; 95 | DevPathString = ConvertDevicePathToText(FilePathList, TRUE, FALSE); 96 | } 97 | 98 | Print(L"[%0x] %s: %s %s\n", LoadOption->Attributes, VariableNane, Description, DevPathString ); 99 | FreePool( Buffer ); 100 | } else if (Status == EFI_NOT_FOUND) { 101 | Print(L"Variable %s not found.\n", VariableNane); 102 | } else 103 | Print(L"ERROR: Failed to get variable %s. Status Code: %d\n", VariableNane, Status); 104 | 105 | return Status; 106 | } 107 | 108 | 109 | EFI_STATUS 110 | GetBootOrderVariable( VOID **Buffer, 111 | UINTN *BufferSize ) 112 | { 113 | EFI_STATUS Status = EFI_SUCCESS; 114 | EFI_GUID Guid = EFI_GLOBAL_VARIABLE; 115 | 116 | Status = GetNvramVariable( L"BootOrder", &Guid, Buffer, BufferSize ); 117 | 118 | return Status; 119 | } 120 | 121 | 122 | VOID 123 | Usage( BOOLEAN ErrorMsg ) 124 | { 125 | if ( ErrorMsg ) { 126 | Print(L"ERROR: Unknown option.\n"); 127 | } 128 | Print(L"Usage: ShowBoot [-a | --all]\n"); 129 | Print(L" ShowBoot [-V | --version]\n"); 130 | } 131 | 132 | 133 | INTN 134 | EFIAPI 135 | ShellAppMain( UINTN Argc, 136 | CHAR16 **Argv ) 137 | { 138 | EFI_STATUS Status = EFI_SUCCESS; 139 | EFI_GUID Guid = EFI_GLOBAL_VARIABLE; 140 | UINT16 *BootOrderList = (UINT16 *)NULL; 141 | UINT16 BootString[10]; 142 | UINTN BootOrderListSize = 0; 143 | UINTN Index; 144 | MODE Mode = Default; 145 | 146 | if (Argc == 2) { 147 | if (!StrCmp(Argv[1], L"--all") || 148 | !StrCmp(Argv[1], L"-a")) { 149 | Mode = All; 150 | } else if (!StrCmp(Argv[1], L"--version") || 151 | !StrCmp(Argv[1], L"-V")) { 152 | Print(L"Version: %s\n", UTILITY_VERSION); 153 | return Status; 154 | } else if (!StrCmp(Argv[1], L"--help") || 155 | !StrCmp(Argv[1], L"-h")) { 156 | Usage(FALSE); 157 | return Status; 158 | } else { 159 | Usage(TRUE); 160 | return Status; 161 | } 162 | } 163 | if (Argc > 2) { 164 | Usage(TRUE); 165 | return Status; 166 | } 167 | 168 | Status = GetBootOrderVariable( (VOID **) &BootOrderList, &BootOrderListSize ); 169 | if (Status != EFI_SUCCESS) { 170 | FreePool( BootOrderList ); 171 | Print(L"ERROR: Failed to find BootOrder variable [%d]\n", Status ); 172 | return Status; 173 | } 174 | 175 | for ( Index = 0; Index < BootOrderListSize / sizeof(UINT16); Index++ ) { 176 | UnicodeSPrint( BootString, sizeof (BootString), L"Boot%04x", BootOrderList[Index] ); 177 | #ifdef DEBUG 178 | Print(L"%d: %s\n", Index, BootString ); 179 | #else 180 | Status = OutputBootVariable( BootString, Guid, Mode ); 181 | #endif 182 | } 183 | 184 | FreePool( BootOrderList ); 185 | 186 | return Status; 187 | } 188 | -------------------------------------------------------------------------------- /MyApps/ShowBoot/ShowBoot.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/MyApps/ShowBoot/ShowBoot.efi -------------------------------------------------------------------------------- /MyApps/ShowBoot/ShowBoot.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ShowBoot 4 | FILE_GUID = 4ea87c51-7491-4dfd-0055-747010f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 0.8 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | ShowBoot.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-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/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-2019 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Display ESRT (EFI System Resource Table) 5 | // 6 | // License: EDKII license applies to code from EDKII source, 7 | // BSD 2 clause license applies to all other code. 8 | // 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | 21 | #include 22 | 23 | #define UTILITY_VERSION L"20190615" 24 | #undef DEBUG 25 | 26 | // for option setting 27 | typedef enum { 28 | Verbose = 1, 29 | Hexdump, 30 | } MODE; 31 | 32 | 33 | VOID 34 | PrintHexTable( UINT8 *ptr, 35 | int Count, 36 | BOOLEAN ExtraSpace ) 37 | { 38 | if (ExtraSpace) { 39 | Print(L" "); 40 | } else { 41 | Print(L" "); 42 | } 43 | 44 | for (int i = 0; i < Count; i++ ) { 45 | if ( i > 0 && i%16 == 0) { 46 | if (ExtraSpace) { 47 | Print(L"\n "); 48 | } else { 49 | Print(L"\n "); 50 | } 51 | } 52 | Print(L"0x%02x ", 0xff & *ptr++); 53 | } 54 | Print(L"\n"); 55 | } 56 | 57 | 58 | VOID 59 | DumpEsrt( VOID *data, 60 | MODE Mode ) 61 | { 62 | EFI_SYSTEM_RESOURCE_TABLE *Esrt = data; 63 | EFI_SYSTEM_RESOURCE_ENTRY *EsrtEntry = (EFI_SYSTEM_RESOURCE_ENTRY *)((UINT8 *)data + sizeof (*Esrt)); 64 | BOOLEAN ob; 65 | UINT16 PrivateFlags; 66 | 67 | Print(L"\n"); 68 | if ( Mode == Hexdump ) { 69 | PrintHexTable( (UINT8 *)Esrt, (int)(sizeof(EFI_SYSTEM_RESOURCE_TABLE) \ 70 | + ((Esrt->FwResourceCount) * sizeof(EFI_SYSTEM_RESOURCE_ENTRY))), 71 | FALSE ); 72 | Print(L"\n"); 73 | return; 74 | } 75 | 76 | if ( Mode == Verbose ) { 77 | Print(L" ESRT found at 0x%08x\n", data); 78 | Print(L" Firmware Resource Count: %d\n", Esrt->FwResourceCount); 79 | Print(L" Firmware Resource Max Count: %d\n", Esrt->FwResourceCountMax); 80 | Print(L" Firmware Resource Version: %ld\n", Esrt->FwResourceVersion); 81 | Print(L"\n"); 82 | } 83 | 84 | if (Esrt->FwResourceVersion != 1) { 85 | Print(L"ERROR: Unsupported ESRT version: %d\n", Esrt->FwResourceVersion); 86 | return; 87 | } 88 | 89 | for (int i = 0; i < Esrt->FwResourceCount; i++) { 90 | ob = FALSE; 91 | Print(L" Firmware Resource Entry: %d\n", i); 92 | Print(L" Firmware Class GUID: %g\n", &EsrtEntry->FwClass); 93 | Print(L" Firmware Type: %d ", EsrtEntry->FwType); 94 | switch (EsrtEntry->FwType) { 95 | case 0: Print(L"(Unknown)\n"); 96 | break; 97 | case 1: Print(L"(System)\n"); 98 | break; 99 | case 2: Print(L"(Device)\n"); 100 | break; 101 | case 3: Print(L"(UEFI Driver)\n"); 102 | break; 103 | default: Print(L"\n"); 104 | } 105 | Print(L" Firmware Version: 0x%08x\n", EsrtEntry->FwVersion); 106 | Print(L" Lowest Supported Firmware Version: 0x%08x\n", EsrtEntry->LowestSupportedFwVersion); 107 | 108 | Print(L" Capsule Flags: 0x%08x", EsrtEntry->CapsuleFlags); 109 | PrivateFlags = (EsrtEntry->CapsuleFlags) &= 0xffff; 110 | if ( EsrtEntry->CapsuleFlags & CAPSULE_FLAGS_PERSIST_ACROSS_RESET ) { 111 | if (!ob) { 112 | ob = TRUE; 113 | Print(L" ("); 114 | } 115 | Print(L"Persist Across Reboot"); 116 | } 117 | if ( EsrtEntry->CapsuleFlags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE ) { 118 | if (!ob) { 119 | ob = TRUE; 120 | Print(L" ("); 121 | } else 122 | Print(L", "); 123 | Print(L"Populate System Table"); 124 | } 125 | if ( EsrtEntry->CapsuleFlags & CAPSULE_FLAGS_INITIATE_RESET ) { 126 | if (!ob) { 127 | ob = TRUE; 128 | Print(L" ("); 129 | } else 130 | Print(L", "); 131 | Print(L"Initiate Reset"); 132 | } 133 | if ( PrivateFlags ) { 134 | if (!ob) { 135 | ob = TRUE; 136 | Print(L" ("); 137 | } else 138 | Print(L", "); 139 | Print(L"Private Update Flags: 0x%04x", PrivateFlags); 140 | } 141 | if (ob) 142 | Print(L")"); 143 | Print(L"\n"); 144 | Print(L" Last Attempt Version: 0x%08x\n", EsrtEntry->LastAttemptVersion); 145 | Print(L" Last Attempt Status: %d ", EsrtEntry->LastAttemptStatus); 146 | switch(EsrtEntry->LastAttemptStatus) { 147 | case 0: Print(L"(Success)\n"); 148 | break; 149 | case 1: Print(L"(Unsuccessful)\n"); 150 | break; 151 | case 2: Print(L"(Insufficient Resources)\n"); 152 | break; 153 | case 3: Print(L"(Incorrect Version)\n"); 154 | break; 155 | case 4: Print(L"(Invalid Image Format)\n"); 156 | break; 157 | case 5: Print(L"(Authentication Error)\n"); 158 | break; 159 | case 6: Print(L"(AC Power Not Connected)\n"); 160 | break; 161 | case 7: Print(L"(Insufficent Battery Power)\n"); 162 | break; 163 | default: Print(L"(Unknown)\n"); 164 | } 165 | Print(L"\n"); 166 | EsrtEntry++; 167 | } 168 | } 169 | 170 | 171 | VOID 172 | Usage( BOOLEAN ErrorMsg ) 173 | { 174 | if ( ErrorMsg ) { 175 | Print(L"ERROR: Unknown option.\n"); 176 | } 177 | Print(L"Usage: ShowESRT [-v | --verbose]\n"); 178 | Print(L" ShowESRT [-d | --dump]\n"); 179 | Print(L" ShowESRT [-V | --version]\n"); 180 | } 181 | 182 | 183 | INTN 184 | EFIAPI 185 | ShellAppMain( UINTN Argc, 186 | CHAR16 **Argv ) 187 | { 188 | EFI_CONFIGURATION_TABLE *ect = gST->ConfigurationTable; 189 | EFI_STATUS Status = EFI_SUCCESS; 190 | EFI_GUID EsrtGuid = EFI_SYSTEM_RESOURCE_TABLE_GUID; 191 | MODE Mode = 0; 192 | 193 | if (Argc == 2) { 194 | if (!StrCmp(Argv[1], L"--verbose") || 195 | !StrCmp(Argv[1], L"-v")) { 196 | Mode = Verbose; 197 | } else if (!StrCmp(Argv[1], L"--dump") || 198 | !StrCmp(Argv[1], L"-d")) { 199 | Mode = Hexdump; 200 | } else if (!StrCmp(Argv[1], L"--version") || 201 | !StrCmp(Argv[1], L"-V")) { 202 | Print(L"Version: %s\n", UTILITY_VERSION); 203 | return Status; 204 | } else if (!StrCmp(Argv[1], L"--help") || 205 | !StrCmp(Argv[1], L"-h")) { 206 | Usage(FALSE); 207 | return Status; 208 | } else { 209 | Usage(TRUE); 210 | return Status; 211 | } 212 | } 213 | if (Argc > 2) { 214 | Usage(TRUE); 215 | return Status; 216 | } 217 | 218 | for (int Index = 0; Index < gST->NumberOfTableEntries; Index++) { 219 | if (!CompareMem(&ect->VendorGuid, &EsrtGuid, sizeof(EsrtGuid))) { 220 | DumpEsrt( ect->VendorTable, Mode ); 221 | return EFI_SUCCESS; 222 | } 223 | ect++; 224 | continue; 225 | } 226 | 227 | Print(L"No ESRT found\n"); 228 | 229 | return Status; 230 | } 231 | 232 | -------------------------------------------------------------------------------- /MyApps/ShowESRT/ShowESRT.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/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-2019 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Display ACPI FACS (Firmware ACPI Control Structure) 5 | // 6 | // License: EDKII license applies to code from EDKII source, 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 | 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | #define UTILITY_VERSION L"20190612" 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 | VOID AsciiToUnicodeSize(CHAR8 *, UINT8, CHAR16 *, BOOLEAN); 44 | 45 | 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 | VOID 66 | PrintHexTable( UINT8 *ptr, 67 | int Count, 68 | BOOLEAN ExtraSpace ) 69 | { 70 | if (ExtraSpace) { 71 | Print(L" "); 72 | } else { 73 | Print(L" "); 74 | } 75 | 76 | for (int i = 0; i < Count; i++ ) { 77 | if ( i > 0 && i%16 == 0) { 78 | if (ExtraSpace) { 79 | Print(L"\n "); 80 | } else { 81 | Print(L"\n "); 82 | } 83 | } 84 | Print(L"0x%02x ", 0xff & *ptr++); 85 | } 86 | Print(L"\n"); 87 | } 88 | 89 | 90 | VOID 91 | PrintFACS( EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs, 92 | BOOLEAN Hexdump ) 93 | { 94 | CHAR16 Buffer[50]; 95 | 96 | Print(L"\n"); 97 | if (Hexdump) { 98 | PrintHexTable( (UINT8 *)Facs, (int)(Facs->Length), FALSE ); 99 | } else { 100 | Print(L" FACS Table Details\n"); 101 | AsciiToUnicodeSize((CHAR8 *)&(Facs->Signature), 4, Buffer, TRUE); 102 | Print(L" Signature : %s\n", Buffer); 103 | Print(L" Length : 0x%08x (%d)\n", Facs->Length, Facs->Length); 104 | Print(L" Hardware Signature : 0x%08x (%d)\n", Facs->HardwareSignature, 105 | Facs->HardwareSignature); 106 | Print(L" FirmwareWakingVector : 0x%08x (%d)\n", Facs->FirmwareWakingVector, 107 | Facs->FirmwareWakingVector); 108 | Print(L" GlobalLock : 0x%08x (%d)\n", Facs->GlobalLock, Facs->GlobalLock); 109 | Print(L" Flags : 0x%08x (%d)\n", Facs->Flags, Facs->Flags); 110 | Print(L" XFirmwareWakingVector : 0x%016x (%ld)\n", Facs->XFirmwareWakingVector, 111 | Facs->XFirmwareWakingVector); 112 | Print(L" Version : 0x%02x (%d)\n", Facs->Version, Facs->Version); 113 | Print(L" Reserved:\n"); 114 | PrintHexTable( (UINT8 *)&(Facs->Reserved), 31, TRUE ); 115 | } 116 | Print(L"\n"); 117 | } 118 | 119 | 120 | VOID 121 | ParseRSDP( EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp, 122 | CHAR16* GuidStr, 123 | BOOLEAN Hexdump ) 124 | { 125 | EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt2Table; 126 | EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs2Table; 127 | EFI_ACPI_SDT_HEADER *Xsdt, *Entry; 128 | UINT32 EntryCount; 129 | UINT64 *EntryPtr; 130 | #ifdef DEBUG 131 | CHAR16 OemStr[20]; 132 | 133 | Print(L"\n\nACPI GUID: %s\n", GuidStr); 134 | 135 | AsciiToUnicodeSize((CHAR8 *)(Rsdp->OemId), 6, OemStr, FALSE); 136 | Print(L"\nFound RSDP. Version: %d OEM ID: %s\n", (int)(Rsdp->Revision), OemStr); 137 | #endif 138 | 139 | if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) { 140 | Xsdt = (EFI_ACPI_SDT_HEADER *)(Rsdp->XsdtAddress); 141 | } else { 142 | #ifdef DEBUG 143 | Print(L"ERROR: No ACPI XSDT table found.\n"); 144 | #endif 145 | return; 146 | } 147 | 148 | if (Xsdt->Signature != SIGNATURE_32 ('X', 'S', 'D', 'T')) { 149 | #ifdef DEBUG 150 | Print(L"ERROR: Invalid ACPI XSDT table found.\n"); 151 | #endif 152 | return; 153 | } 154 | 155 | EntryCount = (Xsdt->Length - sizeof (EFI_ACPI_SDT_HEADER)) / sizeof(UINT64); 156 | #ifdef DEBUG 157 | AsciiToUnicodeSize((CHAR8 *)(Xsdt->OemId), 6, OemStr, FALSE); 158 | Print(L"Found XSDT. OEM ID: %s Entry Count: %d\n\n", OemStr, EntryCount); 159 | #endif 160 | 161 | // Locate Fixed ACPI Description Table - "FACP" 162 | EntryPtr = (UINT64 *)(Xsdt + 1); 163 | for (int Index = 0; Index < EntryCount; Index++, EntryPtr++) { 164 | Entry = (EFI_ACPI_SDT_HEADER *)((UINTN)(*EntryPtr)); 165 | if (!AsciiStrnCmp( (CHAR8 *)&(Entry->Signature), "FACP", 4)) { 166 | Fadt2Table = (EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *)((UINTN)(*EntryPtr)); 167 | Facs2Table = (EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *)((UINTN)(Fadt2Table->FirmwareCtrl)); 168 | PrintFACS(Facs2Table, Hexdump); 169 | } 170 | } 171 | 172 | return; 173 | } 174 | 175 | 176 | VOID 177 | Usage( BOOLEAN ErrorMsg ) 178 | { 179 | if ( ErrorMsg ) { 180 | Print(L"ERROR: Unknown option.\n"); 181 | } 182 | Print(L"Usage: ShowFACS [-d | --dump]\n"); 183 | Print(L" ShowFACS [-V | --version]\n"); 184 | } 185 | 186 | 187 | INTN 188 | EFIAPI 189 | ShellAppMain( UINTN Argc, 190 | CHAR16 **Argv ) 191 | { 192 | EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp = NULL; 193 | EFI_CONFIGURATION_TABLE *ect = gST->ConfigurationTable; 194 | EFI_STATUS Status = EFI_SUCCESS; 195 | EFI_GUID gAcpi20TableGuid = EFI_ACPI_20_TABLE_GUID; 196 | EFI_GUID gAcpi10TableGuid = ACPI_10_TABLE_GUID; 197 | BOOLEAN Hexdump = FALSE; 198 | CHAR16 GuidStr[100]; 199 | 200 | if (Argc == 2) { 201 | if (!StrCmp(Argv[1], L"--dump") || 202 | !StrCmp(Argv[1], L"-d")) { 203 | Hexdump = TRUE; 204 | } else if (!StrCmp(Argv[1], L"--version") || 205 | !StrCmp(Argv[1], L"-V")) { 206 | Print(L"Version: %s\n", UTILITY_VERSION); 207 | return Status; 208 | } else if (!StrCmp(Argv[1], L"--help") || 209 | !StrCmp(Argv[1], L"-h")) { 210 | Usage(FALSE); 211 | return Status; 212 | } else { 213 | Usage(TRUE); 214 | return Status; 215 | } 216 | } 217 | if (Argc > 2) { 218 | Usage(TRUE); 219 | return Status; 220 | } 221 | 222 | // Locate Root System Description Pointer Table - "RSDP" 223 | for (int i = 0; i < gST->NumberOfTableEntries; i++) { 224 | if ((CompareGuid (&(gST->ConfigurationTable[i].VendorGuid), &gAcpi20TableGuid)) || 225 | (CompareGuid (&(gST->ConfigurationTable[i].VendorGuid), &gAcpi10TableGuid))) { 226 | if (!AsciiStrnCmp("RSD PTR ", (CHAR8 *)(ect->VendorTable), 8)) { 227 | UnicodeSPrint(GuidStr, sizeof(GuidStr), L"%g", &(gST->ConfigurationTable[i].VendorGuid)); 228 | Rsdp = (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)ect->VendorTable; 229 | ParseRSDP(Rsdp, GuidStr, Hexdump); 230 | } 231 | } 232 | ect++; 233 | } 234 | 235 | if (Rsdp == NULL) { 236 | Print(L"ERROR: Could not find an ACPI RSDP table.\n"); 237 | Status = EFI_NOT_FOUND; 238 | } 239 | 240 | return Status; 241 | } 242 | -------------------------------------------------------------------------------- /MyApps/ShowFACS/ShowFACS.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/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/ShowFreq/ShowFreq.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2018-2020 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Show CPU frequency via Intel RDTSC instruction 5 | // 6 | // License: BSD 2 clause License 7 | // 8 | // Portions Copyright (c) 2018, Intel Corporation. All rights reserved. 9 | // See relevant code in EDK11 for exact details 10 | // 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | #define UTILITY_VERSION L"20200627" 29 | #undef DEBUG 30 | 31 | 32 | // 33 | // Based on code found at http://code.google.com/p/my-itoa/ 34 | // 35 | int 36 | Integer2AsciiString( int val, 37 | char* buf ) 38 | { 39 | const unsigned int radix = 10; 40 | 41 | char* p = buf; 42 | unsigned int a; 43 | int len; 44 | char* b; 45 | char temp; 46 | unsigned int u; 47 | 48 | if (val < 0) { 49 | *p++ = '-'; 50 | val = 0 - val; 51 | } 52 | u = (unsigned int)val; 53 | b = p; 54 | 55 | do { 56 | a = u % radix; 57 | u /= radix; 58 | *p++ = a + '0'; 59 | } while (u > 0); 60 | 61 | len = (int)(p - buf); 62 | *p-- = 0; 63 | 64 | // swap 65 | do { 66 | temp = *p; *p = *b; *b = temp; 67 | --p; ++b; 68 | } while (b < p); 69 | 70 | return len; 71 | } 72 | 73 | 74 | // 75 | // Based on code found on the Internet (author unknown) 76 | // Search for ftoa implementations 77 | // 78 | int 79 | Float2AsciiString( float f, 80 | char *buffer, 81 | int numdecimals ) 82 | { 83 | int status = 0; 84 | char *s = buffer; 85 | long mantissa, int_part, frac_part; 86 | short exp2; 87 | char m; 88 | 89 | typedef union { 90 | long L; 91 | float F; 92 | } LF_t; 93 | LF_t x; 94 | 95 | if (f == 0.0) { // return 0.00 96 | *s++ = '0'; *s++ = '.'; *s++ = '0'; *s++ = '0'; 97 | *s = 0; 98 | return status; 99 | } 100 | 101 | x.F = f; 102 | 103 | exp2 = (unsigned char)(x.L >> 23) - 127; 104 | mantissa = (x.L & 0xFFFFFF) | 0x800000; 105 | frac_part = 0; 106 | int_part = 0; 107 | 108 | if (exp2 >= 31 || exp2 < -23) { 109 | *s = 0; 110 | return 1; 111 | } 112 | 113 | if (exp2 >= 0) { 114 | int_part = mantissa >> (23 - exp2); 115 | frac_part = (mantissa << (exp2 + 1)) & 0xFFFFFF; 116 | } else { 117 | frac_part = (mantissa & 0xFFFFFF) >> -(exp2 + 1); 118 | } 119 | 120 | if (int_part == 0) 121 | *s++ = '0'; 122 | else { 123 | Integer2AsciiString(int_part, s); 124 | while (*s) s++; 125 | } 126 | *s++ = '.'; 127 | 128 | if (frac_part == 0) 129 | *s++ = '0'; 130 | else { 131 | for (m = 0; m < numdecimals; m++) { // print BCD 132 | frac_part = (frac_part << 3) + (frac_part << 1); // frac_part *= 10 133 | *s++ = (frac_part >> 24) + '0'; 134 | frac_part &= 0xFFFFFF; 135 | } 136 | } 137 | *s = 0; 138 | 139 | return status; 140 | } 141 | 142 | 143 | VOID 144 | Ascii2UnicodeString( CHAR8 *String, 145 | CHAR16 *UniString ) 146 | { 147 | while (*String != '\0') { 148 | *(UniString++) = (CHAR16) *(String++); 149 | } 150 | *UniString = '\0'; 151 | } 152 | 153 | 154 | CHAR16 * 155 | FreqString( UINT64 Val ) 156 | { 157 | char Str[8]; 158 | static CHAR16 Wstr[8]; 159 | 160 | float g1 = (float) Val/1000000000; 161 | 162 | Float2AsciiString(g1, Str, 2); 163 | Ascii2UnicodeString(Str, Wstr); 164 | 165 | return Wstr; 166 | } 167 | 168 | 169 | UINT64 170 | Rdtsc(VOID) 171 | { 172 | UINT32 Hi = 0, Lo = 0; 173 | 174 | #if defined(__clang__) 175 | __asm__ __volatile__ ("rdtsc" : "=a"(Lo), "=d"(Hi)); 176 | #elif defined(__GNUC__) 177 | __asm__ __volatile__ ("rdtsc" : "=a"(Lo), "=d"(Hi)); 178 | #else 179 | #error No inline assembly code found. 180 | #endif 181 | 182 | return( ((UINT64)Lo) | (((UINT64)Hi)<<32) ); 183 | } 184 | 185 | 186 | VOID 187 | Usage( BOOLEAN ErrorMsg ) 188 | { 189 | if ( ErrorMsg ) { 190 | Print(L"ERROR: Unknown option.\n"); 191 | } 192 | Print(L"ShowFreq [-V | --version]\n"); 193 | } 194 | 195 | 196 | INTN 197 | EFIAPI 198 | ShellAppMain( UINTN Argc, 199 | CHAR16 **Argv ) 200 | { 201 | EFI_STATUS Status = EFI_SUCCESS; 202 | UINT64 Second = 0; 203 | UINT64 First = 0; 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(FALSE); 213 | return Status; 214 | } else { 215 | Usage(TRUE); 216 | return Status; 217 | } 218 | } 219 | if (Argc > 2) { 220 | Usage(TRUE); 221 | return Status; 222 | } 223 | 224 | First = Rdtsc(); 225 | gBS->Stall(1000000); 226 | Second = Rdtsc(); 227 | 228 | #if DEBUG 229 | Print(L"CPU Frequency: %ld Hz\n", (Second - First)); 230 | #else 231 | Print(L"CPU Frequency: %s GHz\n", FreqString( (Second - First))); 232 | #endif 233 | 234 | return Status; 235 | } 236 | -------------------------------------------------------------------------------- /MyApps/ShowFreq/ShowFreq.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/MyApps/ShowFreq/ShowFreq.efi -------------------------------------------------------------------------------- /MyApps/ShowFreq/ShowFreq.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ShowFreq 4 | FILE_GUID = 4ea87c51-7493-4dfe-0055-749414f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | ShowFreq.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/ShowHIIPkg/ShowHIIPkg.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2017-2020 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // ShowHIIPkg - Show basic information on available HII packages 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 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | #define UTILITY_VERSION L"20200620" 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_HII_PACKAGE_LIST_HEADER *PackageList = NULL; 133 | EFI_HII_DATABASE_PROTOCOL *HiiDbProtocol; 134 | EFI_STATUS Status = EFI_SUCCESS; 135 | BOOLEAN Terse = FALSE; 136 | UINTN PackageListSize = 0; 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/ShowHIIPkg/ShowHIIPkg.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/MyApps/ShowHIIPkg/ShowHIIPkg.efi -------------------------------------------------------------------------------- /MyApps/ShowHIIPkg/ShowHIIPkg.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ShowHIIPkg 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 | ShowHIIPkg.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/ShowMP/ShowMP.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2019 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Show UEFI multi-processor status 5 | // 6 | // License: EDKII license applies to code from EDKII 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 | 23 | #include 24 | #include 25 | 26 | #define UTILITY_VERSION L"20190608" 27 | #undef DEBUG 28 | 29 | 30 | 31 | VOID 32 | Usage( BOOLEAN ErrorMsg ) 33 | { 34 | if ( ErrorMsg ) { 35 | Print(L"ERROR: Unknown option.\n"); 36 | } 37 | Print(L"Usage: ShowMP [-V | --version]\n"); 38 | } 39 | 40 | 41 | INTN 42 | EFIAPI 43 | ShellAppMain( UINTN Argc, 44 | CHAR16 **Argv ) 45 | { 46 | EFI_MP_SERVICES_PROTOCOL *MpServiceProtocol = NULL; 47 | EFI_PROCESSOR_INFORMATION ProcessorInfo; 48 | EFI_STATUS Status = EFI_SUCCESS; 49 | EFI_GUID gEfiMpServiceProtocolGuid = EFI_MP_SERVICES_PROTOCOL_GUID; 50 | UINTN Proc; 51 | UINTN NumProc; 52 | UINTN NumEnabledProc; 53 | 54 | if (Argc == 2) { 55 | if (!StrCmp(Argv[1], L"--version") || 56 | !StrCmp(Argv[1], L"-V")) { 57 | Print(L"Version: %s\n", UTILITY_VERSION); 58 | return Status; 59 | } else if (!StrCmp(Argv[1], L"--help") || 60 | !StrCmp(Argv[1], L"-h")) { 61 | Usage(FALSE); 62 | return Status; 63 | } else { 64 | Usage(TRUE); 65 | return Status; 66 | } 67 | } 68 | if (Argc > 2) { 69 | Usage(TRUE); 70 | return Status; 71 | } 72 | 73 | // Get MP services protocol 74 | Status = gBS->LocateProtocol( &gEfiMpServiceProtocolGuid, 75 | NULL, 76 | (VOID **)&MpServiceProtocol ); 77 | if (EFI_ERROR(Status)) { 78 | Print(L"ERROR: Cannot locate MpService procotol: %d\n", Status); 79 | return Status; 80 | } 81 | 82 | // Processor counts 83 | Status = MpServiceProtocol->GetNumberOfProcessors( MpServiceProtocol, 84 | &NumProc, 85 | &NumEnabledProc ); 86 | if (EFI_ERROR(Status)) { 87 | Print(L"ERROR: Cannot get processor count: %d\n", Status); 88 | return Status; 89 | } 90 | 91 | Print(L"\n"); 92 | Print(L" Number of processors: %d\n", NumProc); 93 | Print(L" Number of enabled processors: %d\n", NumEnabledProc); 94 | Print(L"\n"); 95 | Print(L" ProcID Enabled Type Healthy Pkg Core Thread\n"); 96 | Print(L" -----------------------------------------------------\n"); 97 | 98 | for (Proc=0; Proc < NumProc; Proc++) { 99 | Status = MpServiceProtocol->GetProcessorInfo( MpServiceProtocol, 100 | Proc, 101 | &ProcessorInfo ); 102 | if (EFI_ERROR(Status)) { 103 | Print(L"ERROR: Cannot get information for processor: %d [%d]\n", Proc, Status); 104 | return Status; 105 | } 106 | 107 | Print(L" %04x %s %3s %s %4d %2d %d\n", 108 | ProcessorInfo.ProcessorId, 109 | (ProcessorInfo.StatusFlag & PROCESSOR_ENABLED_BIT) ? L"Y" : L"N", 110 | (ProcessorInfo.StatusFlag & PROCESSOR_AS_BSP_BIT) ? L"BSP" : L" AP", 111 | (ProcessorInfo.StatusFlag & PROCESSOR_HEALTH_STATUS_BIT) ? L"Y" : L"N", 112 | ProcessorInfo.Location.Package, 113 | ProcessorInfo.Location.Core, 114 | ProcessorInfo.Location.Thread ); 115 | } 116 | Print(L"\n"); 117 | 118 | return Status; 119 | } 120 | -------------------------------------------------------------------------------- /MyApps/ShowMP/ShowMP.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/MyApps/ShowMP/ShowMP.efi -------------------------------------------------------------------------------- /MyApps/ShowMP/ShowMP.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ShowMP 4 | FILE_GUID = 4ea87c51-7291-5dfd-0055-767013f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | ShowMP.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 | 27 | [BuildOptions] 28 | 29 | [Pcd] 30 | 31 | -------------------------------------------------------------------------------- /MyApps/ShowMSDM/ShowMSDM.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2014-2019 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Display ACPI MSDM and/or Microsoft Windows License Key 5 | // 6 | // License: EDKII license applies to code from EDKII 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 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #define UTILITY_VERSION L"20190611" 26 | #undef DEBUG 27 | 28 | 29 | #pragma pack(1) 30 | typedef struct { 31 | UINT32 Version; 32 | UINT32 Reserved; 33 | UINT32 DataType; 34 | UINT32 DataReserved; 35 | UINT32 DataLength; 36 | CHAR8 Data[30]; 37 | } SOFTWARE_LICENSING; 38 | 39 | // Microsoft Data Management table structure 40 | typedef struct { 41 | EFI_ACPI_SDT_HEADER Header; 42 | SOFTWARE_LICENSING SoftLic; 43 | } EFI_ACPI_MSDM; 44 | #pragma pack() 45 | 46 | 47 | VOID AsciiToUnicodeSize(CHAR8 *, UINT8, CHAR16 *, BOOLEAN); 48 | 49 | 50 | VOID 51 | AsciiToUnicodeSize( CHAR8 *String, 52 | UINT8 length, 53 | CHAR16 *UniString, 54 | BOOLEAN Quote ) 55 | { 56 | int len = length; 57 | 58 | if (Quote) 59 | *(UniString++) = L'"'; 60 | while (*String != '\0' && len > 0) { 61 | *(UniString++) = (CHAR16) *(String++); 62 | len--; 63 | } 64 | if (Quote) 65 | *(UniString++) = L'"'; 66 | *UniString = '\0'; 67 | } 68 | 69 | 70 | VOID 71 | PrintHexTable( UINT8 *ptr, 72 | int Count ) 73 | { 74 | int i = 0; 75 | 76 | Print(L" "); 77 | for (i = 0; i < Count; i++ ) { 78 | if ( i > 0 && i%16 == 0) 79 | Print(L"\n "); 80 | Print(L"0x%02x ", 0xff & *ptr++); 81 | } 82 | Print(L"\n"); 83 | } 84 | 85 | 86 | VOID 87 | PrintAcpiHeader( EFI_ACPI_SDT_HEADER *Ptr ) 88 | { 89 | CHAR16 Buffer[50]; 90 | 91 | Print(L" ACPI Standard Header\n"); 92 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->Signature), 4, Buffer, TRUE); 93 | Print(L" Signature : %s\n", Buffer); 94 | Print(L" Length : 0x%08x (%d)\n", Ptr->Length, Ptr->Length); 95 | Print(L" Revision : 0x%02x (%d)\n", Ptr->Revision, Ptr->Revision); 96 | Print(L" Checksum : 0x%02x (%d)\n", Ptr->Checksum, Ptr->Checksum); 97 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->OemId), 6, Buffer, TRUE); 98 | Print(L" OEM ID : %s\n", Buffer); 99 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->OemTableId), 8, Buffer, TRUE); 100 | Print(L" OEM Table ID : %s\n", Buffer); 101 | Print(L" OEM Revision : 0x%08x (%d)\n", Ptr->OemRevision, Ptr->OemRevision); 102 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->CreatorId), 4, Buffer, TRUE); 103 | Print(L" Creator ID : %s\n", Buffer); 104 | Print(L" Creator Revision : 0x%08x (%d)\n", Ptr->CreatorRevision, Ptr->CreatorRevision); 105 | Print(L"\n"); 106 | } 107 | 108 | 109 | VOID 110 | PrintSoftwareLicensing( SOFTWARE_LICENSING *Ptr, 111 | BOOLEAN Verbose ) 112 | { 113 | CHAR16 Buffer[50]; 114 | 115 | if (Verbose) { 116 | Print(L" Software Licensing\n"); 117 | Print(L" Version : 0x%08x (%d)\n", Ptr->Version, Ptr->Version); 118 | Print(L" Reserved : 0x%08x (%d)\n", Ptr->Reserved, Ptr->Reserved); 119 | Print(L" Data Type : 0x%08x (%d)\n", Ptr->DataType, Ptr->DataType); 120 | Print(L" Data Reserved : 0x%08x (%d)\n", Ptr->DataReserved, Ptr->DataReserved); 121 | Print(L" Data Length : 0x%08x (%d)\n", Ptr->DataLength, Ptr->DataLength); 122 | AsciiToUnicodeSize((CHAR8 *)(Ptr->Data), 30, Buffer, TRUE); 123 | Print(L" Data : %s\n", Buffer); 124 | } else { 125 | AsciiToUnicodeSize((CHAR8 *)(Ptr->Data), 30, Buffer, FALSE); 126 | Print(L" %s\n", Buffer); 127 | } 128 | } 129 | 130 | 131 | VOID 132 | PrintMSDM( EFI_ACPI_MSDM *Msdm, 133 | BOOLEAN Verbose, 134 | BOOLEAN Hexdump ) 135 | { 136 | Print(L"\n"); 137 | if (Hexdump) { 138 | PrintHexTable( (UINT8 *)Msdm, (int)(Msdm->Header.Length) ); 139 | } else { 140 | if (Verbose) { 141 | PrintAcpiHeader( (EFI_ACPI_SDT_HEADER *)&(Msdm->Header) ); 142 | } 143 | PrintSoftwareLicensing( (SOFTWARE_LICENSING *)&(Msdm->SoftLic), Verbose); 144 | } 145 | Print(L"\n"); 146 | } 147 | 148 | 149 | int 150 | ParseRSDP( EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp, 151 | CHAR16* GuidStr, 152 | BOOLEAN Verbose, 153 | BOOLEAN Hexdump ) 154 | { 155 | EFI_ACPI_SDT_HEADER *Xsdt, *Entry; 156 | #ifdef DEBUG 157 | CHAR16 OemStr[20]; 158 | #endif 159 | UINT32 EntryCount; 160 | UINT64 *EntryPtr; 161 | 162 | #ifdef DEBUG 163 | Print(L"\n\nACPI GUID: %s\n", GuidStr); 164 | 165 | AsciiToUnicodeSize((CHAR8 *)(Rsdp->OemId), 6, OemStr, FALSE); 166 | Print(L"\nFound RSDP. Version: %d OEM ID: %s\n", (int)(Rsdp->Revision), OemStr); 167 | #endif 168 | if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) { 169 | Xsdt = (EFI_ACPI_SDT_HEADER *)(Rsdp->XsdtAddress); 170 | } else { 171 | #ifdef DEBUG 172 | Print(L"ERROR: No ACPI XSDT table found.\n"); 173 | #endif 174 | return 1; 175 | } 176 | 177 | if (Xsdt->Signature != SIGNATURE_32 ('X', 'S', 'D', 'T')) { 178 | #ifdef DEBUG 179 | Print(L"ERROR: Invalid ACPI XSDT table found.\n"); 180 | #endif 181 | return 1; 182 | } 183 | 184 | EntryCount = (Xsdt->Length - sizeof (EFI_ACPI_SDT_HEADER)) / sizeof(UINT64); 185 | #ifdef DEBUG 186 | AsciiToUnicodeSize((CHAR8 *)(Xsdt->OemId), 6, OemStr, FALSE); 187 | Print(L"Found XSDT. OEM ID: %s Entry Count: %d\n\n", OemStr, EntryCount); 188 | #endif 189 | 190 | EntryPtr = (UINT64 *)(Xsdt + 1); 191 | for (int Index = 0; Index < EntryCount; Index++, EntryPtr++) { 192 | Entry = (EFI_ACPI_SDT_HEADER *)((UINTN)(*EntryPtr)); 193 | if (Entry->Signature == SIGNATURE_32 ('M', 'S', 'D', 'M')) { 194 | PrintMSDM((EFI_ACPI_MSDM *)((UINTN)(*EntryPtr)), Verbose, Hexdump); 195 | } 196 | } 197 | 198 | return 0; 199 | } 200 | 201 | 202 | VOID 203 | Usage( BOOLEAN ErrorMsg ) 204 | { 205 | if ( ErrorMsg ) { 206 | Print(L"ERROR: Unknown option.\n"); 207 | } 208 | 209 | Print(L"Usage: ShowMSDM [-v | --verbose]\n"); 210 | Print(L" ShowMSDM [-V | --version]\n"); 211 | Print(L" ShowMSDM [-d | --dump]\n"); 212 | } 213 | 214 | 215 | INTN 216 | EFIAPI 217 | ShellAppMain( UINTN Argc, 218 | CHAR16 **Argv ) 219 | { 220 | EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp = NULL; 221 | EFI_CONFIGURATION_TABLE *ect = gST->ConfigurationTable; 222 | EFI_STATUS Status = EFI_SUCCESS; 223 | EFI_GUID gAcpi20TableGuid = EFI_ACPI_20_TABLE_GUID; 224 | EFI_GUID gAcpi10TableGuid = ACPI_10_TABLE_GUID; 225 | BOOLEAN Verbose = FALSE; 226 | BOOLEAN Hexdump = FALSE; 227 | CHAR16 GuidStr[100]; 228 | 229 | if (Argc == 2) { 230 | if (!StrCmp(Argv[1], L"--verbose") || 231 | !StrCmp(Argv[1], L"-v")) { 232 | Verbose = TRUE; 233 | } else if (!StrCmp(Argv[1], L"--dump") || 234 | !StrCmp(Argv[1], L"-d")) { 235 | Hexdump = TRUE; 236 | } else if (!StrCmp(Argv[1], L"--version") || 237 | !StrCmp(Argv[1], L"-V")) { 238 | Print(L"Version: %s\n", UTILITY_VERSION); 239 | return Status; 240 | } else if (!StrCmp(Argv[1], L"--help") || 241 | !StrCmp(Argv[1], L"-h")) { 242 | Usage(FALSE); 243 | return Status; 244 | } else { 245 | Usage(TRUE); 246 | return Status; 247 | } 248 | } 249 | if (Argc > 2) { 250 | Usage(TRUE); 251 | return Status; 252 | } 253 | 254 | // locate RSDP (Root System Description Pointer) 255 | for (int i = 0; i < gST->NumberOfTableEntries; i++) { 256 | if ((CompareGuid (&(gST->ConfigurationTable[i].VendorGuid), &gAcpi20TableGuid)) || 257 | (CompareGuid (&(gST->ConfigurationTable[i].VendorGuid), &gAcpi10TableGuid))) { 258 | if (!AsciiStrnCmp("RSD PTR ", (CHAR8 *)(ect->VendorTable), 8)) { 259 | UnicodeSPrint(GuidStr, sizeof(GuidStr), L"%g", &(gST->ConfigurationTable[i].VendorGuid)); 260 | Rsdp = (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)ect->VendorTable; 261 | ParseRSDP(Rsdp, GuidStr, Verbose, Hexdump); 262 | } 263 | } 264 | ect++; 265 | } 266 | 267 | if (Rsdp == NULL) { 268 | Print(L"ERROR: Could not find an ACPI RSDP table.\n"); 269 | Status = EFI_NOT_FOUND; 270 | } 271 | 272 | return Status; 273 | } 274 | -------------------------------------------------------------------------------- /MyApps/ShowMSDM/ShowMSDM.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/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/ShowPCI/README: -------------------------------------------------------------------------------- 1 | This utility is deprecated in this release of UEFI-UtiLities 2 | and will be removed in a future release. 3 | -------------------------------------------------------------------------------- /MyApps/ShowPCI/ShowPCI.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2017-2019 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 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | #define CALC_EFI_PCI_ADDRESS(Bus, Dev, Func, Reg) \ 27 | ((UINT64) ((((UINTN) Bus) << 24) + (((UINTN) Dev) << 16) + (((UINTN) Func) << 8) + ((UINTN) Reg))) 28 | 29 | 30 | #pragma pack(1) 31 | typedef union { 32 | PCI_DEVICE_HEADER_TYPE_REGION Device; 33 | PCI_CARDBUS_CONTROL_REGISTER CardBus; 34 | } NON_COMMON_UNION; 35 | 36 | typedef struct { 37 | PCI_DEVICE_INDEPENDENT_REGION Common; 38 | NON_COMMON_UNION NonCommon; 39 | UINT32 Data[48]; 40 | } PCI_CONFIG_SPACE; 41 | #pragma pack() 42 | 43 | #define UTILITY_VERSION L"20190329" 44 | #undef DEBUG 45 | 46 | 47 | // 48 | // Copyed from UDK2015 Source. UDK2015 license applies. 49 | // 50 | EFI_STATUS 51 | PciGetNextBusRange( EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors, 52 | UINT16 *MinBus, 53 | UINT16 *MaxBus, 54 | BOOLEAN *IsEnd ) 55 | { 56 | *IsEnd = FALSE; 57 | 58 | if ((*Descriptors) == NULL) { 59 | *MinBus = 0; 60 | *MaxBus = PCI_MAX_BUS; 61 | return EFI_SUCCESS; 62 | } 63 | 64 | while ((*Descriptors)->Desc != ACPI_END_TAG_DESCRIPTOR) { 65 | if ((*Descriptors)->ResType == ACPI_ADDRESS_SPACE_TYPE_BUS) { 66 | *MinBus = (UINT16) (*Descriptors)->AddrRangeMin; 67 | *MaxBus = (UINT16) (*Descriptors)->AddrRangeMax; 68 | (*Descriptors)++; 69 | return (EFI_SUCCESS); 70 | } 71 | 72 | (*Descriptors)++; 73 | } 74 | 75 | if ((*Descriptors)->Desc == ACPI_END_TAG_DESCRIPTOR) { 76 | *IsEnd = TRUE; 77 | } 78 | 79 | return EFI_SUCCESS; 80 | } 81 | 82 | 83 | // 84 | // Copyed from UDK2015 Source. UDK2015 license applies. 85 | // 86 | EFI_STATUS 87 | PciGetProtocolAndResource( EFI_HANDLE Handle, 88 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL **IoDev, 89 | EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptors ) 90 | { 91 | EFI_STATUS Status; 92 | 93 | // Get inferface from protocol 94 | Status = gBS->HandleProtocol( Handle, 95 | &gEfiPciRootBridgeIoProtocolGuid, 96 | (VOID**)IoDev ); 97 | if (EFI_ERROR (Status)) { 98 | return Status; 99 | } 100 | 101 | Status = (*IoDev)->Configuration( *IoDev, (VOID**)Descriptors ); 102 | if (Status == EFI_UNSUPPORTED) { 103 | *Descriptors = NULL; 104 | return EFI_SUCCESS; 105 | } 106 | 107 | return Status; 108 | } 109 | 110 | 111 | VOID 112 | Usage( CHAR16 *Str, 113 | BOOLEAN ErrorMsg ) 114 | { 115 | if ( ErrorMsg ) { 116 | Print(L"ERROR: Unknown option.\n"); 117 | } 118 | Print(L"Usage: %s [-V | --version]\n", Str); 119 | } 120 | 121 | 122 | INTN 123 | EFIAPI 124 | ShellAppMain( UINTN Argc, 125 | CHAR16 **Argv ) 126 | { 127 | EFI_GUID gEfiPciEnumerationCompleteProtocolGuid = EFI_PCI_ENUMERATION_COMPLETE_GUID; 128 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev; 129 | EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptors; 130 | PCI_DEVICE_INDEPENDENT_REGION PciHeader; 131 | PCI_CONFIG_SPACE ConfigSpace; 132 | PCI_DEVICE_HEADER_TYPE_REGION *DeviceHeader; 133 | EFI_STATUS Status = EFI_SUCCESS; 134 | EFI_HANDLE *HandleBuf; 135 | UINTN HandleBufSize; 136 | UINTN HandleCount; 137 | UINT64 Address; 138 | UINT16 MinBus; 139 | UINT16 MaxBus; 140 | BOOLEAN IsEnd; 141 | VOID *Interface; 142 | 143 | if (Argc == 2) { 144 | if (!StrCmp(Argv[1], L"--version") || 145 | !StrCmp(Argv[1], L"-V")) { 146 | Print(L"Version: %s\n", UTILITY_VERSION); 147 | return Status; 148 | } else if (!StrCmp(Argv[1], L"--help") || 149 | !StrCmp(Argv[1], L"-h")) { 150 | Usage(Argv[0], FALSE); 151 | return Status; 152 | } else { 153 | Usage(Argv[0], TRUE); 154 | return Status; 155 | } 156 | } 157 | if (Argc > 2) { 158 | Usage(Argv[0], TRUE); 159 | return Status; 160 | } 161 | 162 | 163 | Status = gBS->LocateProtocol( &gEfiPciEnumerationCompleteProtocolGuid, 164 | NULL, 165 | &Interface ); 166 | if (EFI_ERROR(Status)) { 167 | Print(L"ERROR: Could not find PCI enumeration protocol\n"); 168 | return Status; 169 | } 170 | 171 | HandleBufSize = sizeof(EFI_HANDLE); 172 | HandleBuf = (EFI_HANDLE *) AllocateZeroPool( HandleBufSize); 173 | if (HandleBuf == NULL) { 174 | Print(L"ERROR: Out of memory resources\n"); 175 | return EFI_OUT_OF_RESOURCES; 176 | } 177 | 178 | Status = gBS->LocateHandle( ByProtocol, 179 | &gEfiPciRootBridgeIoProtocolGuid, 180 | NULL, 181 | &HandleBufSize, 182 | HandleBuf); 183 | 184 | if (Status == EFI_BUFFER_TOO_SMALL) { 185 | HandleBuf = ReallocatePool (sizeof (EFI_HANDLE), HandleBufSize, HandleBuf); 186 | if (HandleBuf == NULL) { 187 | Print(L"ERROR: Out of memory resources\n"); 188 | Status = EFI_OUT_OF_RESOURCES; 189 | goto Done; 190 | } 191 | 192 | Status = gBS->LocateHandle( ByProtocol, 193 | &gEfiPciRootBridgeIoProtocolGuid, 194 | NULL, 195 | &HandleBufSize, 196 | HandleBuf); 197 | } 198 | 199 | if (EFI_ERROR (Status)) { 200 | Print(L"ERROR: Failed to find any PCI handles\n"); 201 | goto Done; 202 | } 203 | 204 | HandleCount = HandleBufSize / sizeof (EFI_HANDLE); 205 | 206 | for (UINT16 Index = 0; Index < HandleCount; Index++) { 207 | Status = PciGetProtocolAndResource( HandleBuf[Index], 208 | &IoDev, 209 | &Descriptors); 210 | if (EFI_ERROR(Status)) { 211 | Print(L"ERROR: PciGetProtocolAndResource [%d]\n, Status"); 212 | goto Done; 213 | } 214 | 215 | while(TRUE) { 216 | Status = PciGetNextBusRange( &Descriptors, &MinBus, &MaxBus, &IsEnd); 217 | if (EFI_ERROR(Status)) { 218 | Print(L"ERROR: Retrieving PCI bus range [%d]\n", Status); 219 | goto Done; 220 | } 221 | 222 | if (IsEnd) { 223 | break; 224 | } 225 | 226 | Print(L"\n"); 227 | Print(L" Bus Vendor Device Subvendor SubvendorDevice\n"); 228 | Print(L" ----------------------------------------------------\n"); 229 | 230 | for (UINT16 Bus = MinBus; Bus <= MaxBus; Bus++) { 231 | for (UINT16 Device = 0; Device <= PCI_MAX_DEVICE; Device++) { 232 | for (UINT16 Func = 0; Func <= PCI_MAX_FUNC; Func++) { 233 | Address = CALC_EFI_PCI_ADDRESS (Bus, Device, Func, 0); 234 | 235 | Status = IoDev->Pci.Read( IoDev, 236 | EfiPciWidthUint8, 237 | Address, 238 | sizeof(ConfigSpace), 239 | &ConfigSpace); 240 | 241 | DeviceHeader = (PCI_DEVICE_HEADER_TYPE_REGION *) &(ConfigSpace.NonCommon.Device); 242 | 243 | IoDev->Pci.Read( IoDev, 244 | EfiPciWidthUint16, 245 | Address, 246 | 1, 247 | &PciHeader.VendorId ); 248 | 249 | if (PciHeader.VendorId == 0xffff && Func == 0) { 250 | break; 251 | } 252 | 253 | if (PciHeader.VendorId != 0xffff) { 254 | IoDev->Pci.Read( IoDev, 255 | EfiPciWidthUint32, 256 | Address, 257 | sizeof (PciHeader) / sizeof (UINT32), 258 | &PciHeader ); 259 | 260 | Print(L" %02d %04x %04x %04x %04x\n", 261 | Bus, PciHeader.VendorId, PciHeader.DeviceId, 262 | DeviceHeader->SubsystemVendorID, DeviceHeader->SubsystemID); 263 | 264 | if (Func == 0 && 265 | ((PciHeader.HeaderType & HEADER_TYPE_MULTI_FUNCTION) == 0x00)) { 266 | break; 267 | } 268 | } 269 | } 270 | } 271 | } 272 | 273 | if (Descriptors == NULL) { 274 | break; 275 | } 276 | } 277 | } 278 | 279 | Print(L"\n"); 280 | 281 | Done: 282 | if (HandleBuf != NULL) { 283 | FreePool( HandleBuf ); 284 | } 285 | 286 | return Status; 287 | } 288 | -------------------------------------------------------------------------------- /MyApps/ShowPCI/ShowPCI.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/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 | [Sources] 11 | ShowPCI.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/ShowPCIx/ShowPCIx.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/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/ShowPCR/ShowPCR.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/MyApps/ShowPCR/ShowPCR.efi -------------------------------------------------------------------------------- /MyApps/ShowPCR/ShowPCR.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ShowPCR 4 | FILE_GUID = 4ea87c51-7395-4ccd-0355-747111f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.1 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | ShowPCR.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 - 2020 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Show EFI Variable Store infomation returned by QueryVariableInformation API 5 | // 6 | // License: EDKII license applies to code from EDKII source, 7 | // BSD 2 clause license applies to all other code. 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 | 24 | #define UTILITY_VERSION L"20201103" 25 | #undef DEBUG 26 | 27 | 28 | VOID 29 | Usage( BOOLEAN ErrorMsg ) 30 | { 31 | if ( ErrorMsg ) { 32 | Print(L"ERROR: Unknown option.\n"); 33 | } 34 | Print(L"Usage: ShowQVI [-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 | UINT32 Attributes; 45 | UINT64 MaxStoreSize = 0; 46 | UINT64 RemainStoreSize = 0; 47 | UINT64 MaxVariableSize = 0; 48 | 49 | if (Argc == 2) { 50 | if (!StrCmp(Argv[1], L"--version") || 51 | !StrCmp(Argv[1], L"-V")) { 52 | Print(L"Version: %s\n", UTILITY_VERSION); 53 | return Status; 54 | } else if (!StrCmp(Argv[1], L"--help") || 55 | !StrCmp(Argv[1], L"-h")) { 56 | Usage(FALSE); 57 | return Status; 58 | } else { 59 | Usage(TRUE); 60 | return Status; 61 | } 62 | } 63 | if (Argc > 2) { 64 | Usage(TRUE); 65 | return Status; 66 | } 67 | 68 | 69 | Attributes = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS; 70 | 71 | Status = gRT->QueryVariableInfo( Attributes, 72 | &MaxStoreSize, 73 | &RemainStoreSize, 74 | &MaxVariableSize ); 75 | if (Status != EFI_SUCCESS) { 76 | Print(L"ERROR: QueryVariableInfo: %d\n", Status); 77 | return Status; 78 | } 79 | 80 | Print(L"\n"); 81 | Print(L" Maximum Variable Storage Size: 0x%08x [%ld]\n", MaxStoreSize, MaxStoreSize); 82 | Print(L" Remaining Variable Storage Size: 0x%08x [%ld]\n", RemainStoreSize, RemainStoreSize); 83 | Print(L" Maximum Variable Size: 0x%08x [%ld]\n", MaxVariableSize, MaxVariableSize); 84 | Print(L"\n"); 85 | 86 | return Status; 87 | } 88 | -------------------------------------------------------------------------------- /MyApps/ShowQVI/ShowQVI.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/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.1 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-2019 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Display ACPI SLIC (System Licensed Internal Code) table 5 | // 6 | // License: EDKII license applies to code from EDKII source, 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 | 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | #define UTILITY_VERSION L"20190615" 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 | VOID AsciiToUnicodeSize(CHAR8 *, UINT8, CHAR16 *, BOOLEAN); 65 | 66 | VOID 67 | AsciiToUnicodeSize( CHAR8 *String, 68 | UINT8 length, 69 | CHAR16 *UniString, 70 | BOOLEAN Quote ) 71 | { 72 | int len = length; 73 | 74 | if (Quote) 75 | *(UniString++) = L'"'; 76 | while (*String != '\0' && len > 0) { 77 | *(UniString++) = (CHAR16) *(String++); 78 | len--; 79 | } 80 | if (Quote) 81 | *(UniString++) = L'"'; 82 | *UniString = '\0'; 83 | } 84 | 85 | 86 | VOID 87 | PrintHexTable( UINT8 *ptr, 88 | int Count, 89 | BOOLEAN ExtraSpace ) 90 | { 91 | if (ExtraSpace) { 92 | Print(L" "); 93 | } else { 94 | Print(L" "); 95 | } 96 | 97 | for (int i = 0; i < Count; i++ ) { 98 | if ( i > 0 && i%16 == 0) { 99 | if (ExtraSpace) { 100 | Print(L"\n "); 101 | } else { 102 | Print(L"\n "); 103 | } 104 | } 105 | Print(L"0x%02x ", 0xff & *ptr++); 106 | } 107 | Print(L"\n"); 108 | } 109 | 110 | 111 | 112 | VOID 113 | PrintAcpiHeader( EFI_ACPI_SDT_HEADER *Ptr ) 114 | { 115 | CHAR16 Buffer[50]; 116 | 117 | Print(L" ACPI Standard Header\n"); 118 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->Signature), 4, Buffer, TRUE); 119 | Print(L" Signature : %s\n", Buffer); 120 | Print(L" Length : 0x%08x (%d)\n", Ptr->Length, Ptr->Length); 121 | Print(L" Revision : 0x%02x (%d)\n", Ptr->Revision, Ptr->Revision); 122 | Print(L" Checksum : 0x%02x (%d)\n", Ptr->Checksum, Ptr->Checksum); 123 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->OemId), 6, Buffer, TRUE); 124 | Print(L" OEM ID : %s\n", Buffer); 125 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->OemTableId), 8, Buffer, TRUE); 126 | Print(L" OEM Table ID : %s\n", Buffer); 127 | Print(L" OEM Revision : 0x%08x (%d)\n", Ptr->OemRevision, 128 | Ptr->OemRevision); 129 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->CreatorId), 4, Buffer, TRUE); 130 | Print(L" Creator ID : %s\n", Buffer); 131 | Print(L" Creator Revision : 0x%08x (%d)\n", Ptr->CreatorRevision, 132 | Ptr->CreatorRevision); 133 | Print(L"\n"); 134 | } 135 | 136 | 137 | VOID 138 | PrintOemPublicKey( OEM_PUBLIC_KEY *Ptr, 139 | BOOLEAN Verbose ) 140 | { 141 | CHAR16 Buffer[50]; 142 | 143 | Print(L" OEM Public Key\n"); 144 | Print(L" Type : 0x%08x (%d)\n", Ptr->Type, Ptr->Type); 145 | Print(L" Length : 0x%08x (%d)\n", Ptr->Length, Ptr->Length); 146 | Print(L" KeyType : 0x%02x (%d)\n", Ptr->KeyType, Ptr->KeyType); 147 | Print(L" Version : 0x%02x (%d)\n", Ptr->Version, Ptr->Version); 148 | Print(L" Reserved : 0x%04x (%d)\n", Ptr->Reserved, Ptr->Reserved); 149 | Print(L" Algorithm : 0x%08x (%d)\n", Ptr->Algorithm, Ptr->Algorithm); 150 | AsciiToUnicodeSize((CHAR8 *)&(Ptr->Magic), 4, Buffer, TRUE); 151 | Print(L" Magic : %s\n", Buffer); 152 | Print(L" Bit Length : 0x%08x (%d)\n", Ptr->BitLength, Ptr->BitLength); 153 | Print(L" Exponent : 0x%08x (%d)\n", Ptr->Exponent, Ptr->Exponent); 154 | if (Verbose) { 155 | Print(L" Modulus:\n"); 156 | PrintHexTable( (UINT8 *)&(Ptr->Modulus), (int)(Ptr->BitLength)/8, TRUE ); 157 | } 158 | Print(L"\n"); 159 | } 160 | 161 | 162 | VOID 163 | PrintWindowsMarker( WINDOWS_MARKER *Ptr, 164 | BOOLEAN Verbose ) 165 | { 166 | CHAR16 Buffer[50]; 167 | 168 | Print(L" Windows Marker\n"); 169 | Print(L" Type : 0x%08x (%d)\n", Ptr->Type, Ptr->Type); 170 | Print(L" Length : 0x%08x (%d)\n", Ptr->Length, Ptr->Length); 171 | Print(L" Version : 0x%02x (%d)\n", Ptr->Version, Ptr->Version); 172 | AsciiToUnicodeSize((CHAR8 *)(Ptr->OemId), 6, Buffer, TRUE); 173 | Print(L" OEM ID : %s\n", Buffer); 174 | AsciiToUnicodeSize((CHAR8 *)(Ptr->OemTableId), 8, Buffer, TRUE); 175 | Print(L" OEM Table ID : %s\n", Buffer); 176 | AsciiToUnicodeSize((CHAR8 *)(Ptr->Product), 8, Buffer, TRUE); 177 | Print(L" Windows Flag : %s\n", Buffer); 178 | Print(L" SLIC Version : 0x%04x%04x (%d.%d)\n", Ptr->MajorVersion, Ptr->MinorVersion, 179 | Ptr->MajorVersion, Ptr->MinorVersion); 180 | if (Verbose) { 181 | Print(L" Signature:\n"); 182 | PrintHexTable( (UINT8 *)&(Ptr->Signature), 144, TRUE ); 183 | } 184 | Print(L"\n"); 185 | } 186 | 187 | 188 | VOID 189 | PrintSLIC( EFI_ACPI_SLIC *Slic, 190 | BOOLEAN Verbose, 191 | BOOLEAN Hexdump ) 192 | { 193 | Print(L"\n"); 194 | if (Hexdump) { 195 | PrintHexTable( (UINT8 *)Slic, sizeof(EFI_ACPI_SLIC), FALSE ); 196 | Print(L"\n"); 197 | } else { 198 | PrintAcpiHeader( (EFI_ACPI_SDT_HEADER *)&(Slic->Header) ); 199 | PrintOemPublicKey( (OEM_PUBLIC_KEY *)&(Slic->PubKey), Verbose ); 200 | PrintWindowsMarker( (WINDOWS_MARKER *)&(Slic->Marker), Verbose ); 201 | } 202 | } 203 | 204 | 205 | VOID 206 | ParseRSDP( EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp, 207 | CHAR16* GuidStr, 208 | BOOLEAN Verbose, 209 | BOOLEAN Hexdump ) 210 | { 211 | EFI_ACPI_SDT_HEADER *Xsdt, *Entry; 212 | UINT32 EntryCount; 213 | UINT64 *EntryPtr; 214 | 215 | #ifdef DEBUG 216 | CHAR16 OemStr[20]; 217 | 218 | Print(L"\n\nACPI GUID: %s\n", GuidStr); 219 | 220 | AsciiToUnicodeSize((CHAR8 *)(Rsdp->OemId), 6, OemStr, FALSE); 221 | Print(L"\nFound RSDP. Version: %d OEM ID: %s\n", (int)(Rsdp->Revision), OemStr); 222 | #endif 223 | 224 | if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) { 225 | Xsdt = (EFI_ACPI_SDT_HEADER *)(Rsdp->XsdtAddress); 226 | } else { 227 | #ifdef DEBUG 228 | Print(L"ERROR: No ACPI XSDT table found.\n"); 229 | #endif 230 | return; 231 | } 232 | 233 | if (Xsdt->Signature != SIGNATURE_32 ('X', 'S', 'D', 'T')) { 234 | #ifdef DEBUG 235 | Print(L"ERROR: Invalid ACPI XSDT table found.\n"); 236 | #endif 237 | return; 238 | } 239 | 240 | EntryCount = (Xsdt->Length - sizeof (EFI_ACPI_SDT_HEADER)) / sizeof(UINT64); 241 | #ifdef DEBUG 242 | AsciiToUnicodeSize((CHAR8 *)(Xsdt->OemId), 6, OemStr, FALSE); 243 | Print(L"Found XSDT. OEM ID: %s Entry Count: %d\n\n", OemStr, EntryCount); 244 | #endif 245 | 246 | EntryPtr = (UINT64 *)(Xsdt + 1); 247 | for (int Index = 0; Index < EntryCount; Index++, EntryPtr++) { 248 | Entry = (EFI_ACPI_SDT_HEADER *)((UINTN)(*EntryPtr)); 249 | if (Entry->Signature == SIGNATURE_32 ('S', 'L', 'I', 'C')) { 250 | PrintSLIC((EFI_ACPI_SLIC *)((UINTN)(*EntryPtr)), Verbose, Hexdump); 251 | } 252 | } 253 | 254 | return; 255 | } 256 | 257 | 258 | VOID 259 | Usage( BOOLEAN ErrorMsg ) 260 | { 261 | if ( ErrorMsg ) { 262 | Print(L"ERROR: Unknown option.\n"); 263 | } 264 | Print(L"Usage: ShowSLIC [-v | --verbose]\n"); 265 | Print(L" ShowSLIC [-d | --dump]\n"); 266 | Print(L" ShowSLIC [-V | --version]\n"); 267 | } 268 | 269 | 270 | INTN 271 | EFIAPI 272 | ShellAppMain( UINTN Argc, 273 | CHAR16 **Argv ) 274 | { 275 | EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp = NULL; 276 | EFI_CONFIGURATION_TABLE *ect = gST->ConfigurationTable; 277 | EFI_STATUS Status = EFI_SUCCESS; 278 | EFI_GUID gAcpi20TableGuid = EFI_ACPI_20_TABLE_GUID; 279 | EFI_GUID gAcpi10TableGuid = ACPI_10_TABLE_GUID; 280 | BOOLEAN Verbose = FALSE; 281 | BOOLEAN Hexdump = FALSE; 282 | CHAR16 GuidStr[100]; 283 | 284 | if (Argc == 2) { 285 | if (!StrCmp(Argv[1], L"--dump") || 286 | !StrCmp(Argv[1], L"-d")) { 287 | Hexdump = TRUE; 288 | } else if (!StrCmp(Argv[1], L"--verbose") || 289 | !StrCmp(Argv[1], L"-v")) { 290 | Verbose = TRUE; 291 | } else if (!StrCmp(Argv[1], L"--version") || 292 | !StrCmp(Argv[1], L"-V")) { 293 | Print(L"Version: %s\n", UTILITY_VERSION); 294 | return Status; 295 | } else if (!StrCmp(Argv[1], L"--help") || 296 | !StrCmp(Argv[1], L"-h")) { 297 | Usage(FALSE); 298 | return Status; 299 | } else { 300 | Usage(TRUE); 301 | return Status; 302 | } 303 | } 304 | if (Argc > 2) { 305 | Usage(TRUE); 306 | return Status; 307 | } 308 | 309 | 310 | // locate RSDP (Root System Description Pointer) 311 | for (int i = 0; i < gST->NumberOfTableEntries; i++) { 312 | if ((CompareGuid (&(gST->ConfigurationTable[i].VendorGuid), &gAcpi20TableGuid)) || 313 | (CompareGuid (&(gST->ConfigurationTable[i].VendorGuid), &gAcpi10TableGuid))) { 314 | if (!AsciiStrnCmp("RSD PTR ", (CHAR8 *)(ect->VendorTable), 8)) { 315 | UnicodeSPrint(GuidStr, sizeof(GuidStr), L"%g", &(gST->ConfigurationTable[i].VendorGuid)); 316 | Rsdp = (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)ect->VendorTable; 317 | ParseRSDP(Rsdp, GuidStr, Verbose, Hexdump); 318 | } 319 | } 320 | ect++; 321 | } 322 | 323 | if (Rsdp == NULL) { 324 | Print(L"ERROR: Could not find an ACPI RSDP table.\n"); 325 | Status = EFI_NOT_FOUND; 326 | } 327 | 328 | return Status; 329 | } 330 | -------------------------------------------------------------------------------- /MyApps/ShowSLIC/ShowSLIC.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/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/ShowUSB/ShowUSB.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2019 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Show USB devices 5 | // 6 | // License: EDKII license applies to code from EDKII 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 | 24 | #define UTILITY_VERSION L"20190408" 25 | #undef DEBUG 26 | 27 | 28 | VOID 29 | Usage( BOOLEAN ErrorMsg ) 30 | { 31 | if ( ErrorMsg ) { 32 | Print(L"ERROR: Unknown option.\n"); 33 | } 34 | Print(L"Usage: ShowUSB [-V | --version]\n"); 35 | } 36 | 37 | 38 | INTN 39 | EFIAPI 40 | ShellAppMain( UINTN Argc, 41 | CHAR16 **Argv ) 42 | { 43 | EFI_USB_DEVICE_DESCRIPTOR DevDesc; 44 | EFI_USB_INTERFACE_DESCRIPTOR IfDesc; 45 | EFI_USB_IO_PROTOCOL *UsbIo; 46 | EFI_STATUS Status = EFI_SUCCESS; 47 | EFI_HANDLE *HandleBuffer = NULL; 48 | BOOLEAN LangFound; 49 | CHAR16 *Manufacturer; 50 | CHAR16 *Product; 51 | CHAR16 *SerialNumber; 52 | UINT16 *LangIdTable; 53 | UINT16 TableSize; 54 | UINTN HandleCount; 55 | 56 | if (Argc == 2) { 57 | if (!StrCmp(Argv[1], L"--version") || 58 | !StrCmp(Argv[1], L"-V")) { 59 | Print(L"Version: %s\n", UTILITY_VERSION); 60 | return Status; 61 | } else if (!StrCmp(Argv[1], L"--help") || 62 | !StrCmp(Argv[1], L"-h")) { 63 | Usage(FALSE); 64 | return Status; 65 | } else { 66 | Usage(TRUE); 67 | return Status; 68 | } 69 | } 70 | if (Argc > 2) { 71 | Usage(TRUE); 72 | return Status; 73 | } 74 | 75 | Status = gBS->LocateHandleBuffer( ByProtocol, 76 | &gEfiUsbIoProtocolGuid, 77 | NULL, 78 | &HandleCount, 79 | &HandleBuffer ); 80 | if (EFI_ERROR(Status)) { 81 | Print(L"ERROR: LocateHandleBuffer.\n"); 82 | return Status; 83 | } 84 | 85 | Print(L"\n"); 86 | Print(L" VendorID ProductID Manufacturer/Product/SerialNumbaer\n"); 87 | Print(L" -------------------------------------------------------\n"); 88 | Print(L"\n"); 89 | 90 | for ( UINT8 Index = 0; Index < HandleCount; Index++) { 91 | Status = gBS->HandleProtocol( HandleBuffer[Index], 92 | &gEfiUsbIoProtocolGuid, 93 | (VOID**)&UsbIo ); 94 | if (EFI_ERROR(Status)) { 95 | Print(L"ERROR: Open UsbIo.\n"); 96 | FreePool( HandleBuffer ); 97 | return Status; 98 | } 99 | 100 | Status = UsbIo->UsbGetDeviceDescriptor( UsbIo, &DevDesc ); 101 | if (EFI_ERROR(Status)) { 102 | Print(L"ERROR: UsbGetDeviceDescriptor.\n"); 103 | FreePool( HandleBuffer ); 104 | return Status; 105 | } 106 | 107 | Status = UsbIo->UsbGetInterfaceDescriptor( UsbIo, &IfDesc ); 108 | if (EFI_ERROR (Status)) { 109 | Print(L"ERROR: UsbGetInterfaceDescriptor.\n"); 110 | FreePool( HandleBuffer ); 111 | return Status; 112 | } 113 | 114 | TableSize = 0; 115 | LangIdTable = NULL; 116 | LangFound = TRUE; 117 | Status = UsbIo->UsbGetSupportedLanguages (UsbIo, &LangIdTable, &TableSize); 118 | #if 0 119 | if (EFI_ERROR (Status) || (TableSize == 0) || (LangIdTable == NULL)) { 120 | Print(L"ERROR: UsbGetSupportedLanguages\n"); 121 | LangFound = FALSE; 122 | FreePool( HandleBuffer ); 123 | return Status; 124 | } 125 | #endif 126 | FreePool( LangIdTable ); 127 | 128 | Status = UsbIo->UsbGetStringDescriptor( UsbIo, 129 | 0x0409, // English 130 | DevDesc.StrManufacturer, 131 | &Manufacturer ); 132 | if (EFI_ERROR (Status)) { 133 | Manufacturer = L"Unknown"; 134 | } 135 | 136 | Status = UsbIo->UsbGetStringDescriptor( UsbIo, 137 | 0x0409, 138 | DevDesc.StrProduct, 139 | &Product ); 140 | if (EFI_ERROR (Status)) { 141 | Product = L"Unknown"; 142 | } 143 | 144 | Status = UsbIo->UsbGetStringDescriptor( UsbIo, 145 | 0x0409, 146 | DevDesc.StrSerialNumber, 147 | &SerialNumber ); 148 | if (EFI_ERROR (Status)) { 149 | SerialNumber = L"Unknown"; 150 | } 151 | 152 | Print(L" %04X %04X %s, %s, %s\n", 153 | DevDesc.IdVendor, 154 | DevDesc.IdProduct, 155 | Manufacturer, 156 | Product, 157 | SerialNumber ); 158 | } 159 | Print(L"\n"); 160 | 161 | FreePool( HandleBuffer ); 162 | 163 | return Status; 164 | } 165 | -------------------------------------------------------------------------------- /MyApps/ShowUSB/ShowUSB.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/MyApps/ShowUSB/ShowUSB.efi -------------------------------------------------------------------------------- /MyApps/ShowUSB/ShowUSB.inf: -------------------------------------------------------------------------------- 1 | [Defines] 2 | INF_VERSION = 1.25 3 | BASE_NAME = ShowUSB 4 | FILE_GUID = 4ea87c51-7491-5dfd-0055-767013f3ce51 5 | MODULE_TYPE = UEFI_APPLICATION 6 | VERSION_STRING = 1.0 7 | ENTRY_POINT = ShellCEntryLib 8 | VALID_ARCHITECTURES = X64 9 | 10 | [Sources] 11 | ShowUSB.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 | 27 | [BuildOptions] 28 | 29 | [Pcd] 30 | 31 | -------------------------------------------------------------------------------- /MyApps/XBeep/XBeep.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2018 - 2019 Finnbarr P. Murphy. All rights reserved. 3 | // 4 | // Beep 1 or more times. Options to vary frequency, duration, interval, and more. 5 | // 6 | // License: EDKII license applies to code from EDKII source, 7 | // BSD 2 clause license applies to all other code. 8 | // 9 | 10 | 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | // Piezo speaker or PIT related 25 | #define EFI_SPEAKER_CONTROL_PORT 0x61 26 | #define EFI_SPEAKER_OFF_MASK 0xFC 27 | #define EFI_TIMER_CONTROL_PORT 0x43 28 | #define EFI_TIMER_CONTROL2_PORT 0x42 29 | 30 | #define EFI_DEFAULT_BEEP_NUMBER 1 31 | #define EFI_DEFAULT_BEEP_ON_TIME 0x50000 32 | #define EFI_DEFAULT_BEEP_OFF_TIME 0x50000 33 | #define EFI_DEFAULT_BEEP_FREQUENCY 0x500 34 | #define EFI_DEFAULT_BEEP_ALTFREQUENCY 0x1500 35 | 36 | #define I8254_CTRL_SEL_CTR(x) ((x) << 6) 37 | #define I8254_CTRL_RW(x) (((x) & 0x3) << 4) 38 | #define I8254_CTRL_LATCH I8254_CTRL_RW(0) 39 | #define I8254_CTRL_REG 0x03 40 | #define I8254_CTRL_LSB_MSB I8254_CTRL_RW(3) 41 | 42 | #define UTILITY_VERSION L"20190612" 43 | #undef DEBUG 44 | 45 | // global 46 | UINT16 CountdownValue; 47 | 48 | 49 | BOOLEAN 50 | IsHexNumber( CHAR16* str ) 51 | { 52 | CHAR16 *s = str; 53 | 54 | // allow negative 55 | if (*s == L'-') 56 | s++; 57 | 58 | if (*s && (*s == L'0')) { 59 | s++; 60 | if (*s && (*s == L'x' || *s == L'X')) { 61 | s++; 62 | } else { 63 | return FALSE; 64 | } 65 | } else { 66 | return FALSE; 67 | } 68 | 69 | while (*s) { 70 | if (! ((*s >= L'0') && (*s <= L'9')) || 71 | ((*s >= L'A') && (*s <= L'F')) || 72 | ((*s >= L'a') && (*s <= L'f'))) { 73 | return FALSE; 74 | } 75 | s++; 76 | } 77 | 78 | return TRUE; 79 | } 80 | 81 | 82 | BOOLEAN 83 | IsDecNumber( CHAR16* str ) 84 | { 85 | CHAR16 *s = str; 86 | 87 | // allow negative 88 | if (*s == L'-') 89 | s++; 90 | 91 | if (*s == CHAR_NULL) { 92 | return FALSE; 93 | } 94 | 95 | while (*s) { 96 | if (*s < L'0' || *s > L'9') 97 | return FALSE; 98 | s++; 99 | } 100 | 101 | return TRUE; 102 | } 103 | 104 | 105 | VOID 106 | TurnOnSpeaker( VOID ) 107 | { 108 | UINT8 Data; 109 | 110 | Data = IoRead8( EFI_SPEAKER_CONTROL_PORT ); 111 | Data |= 0x03; 112 | IoWrite8( EFI_SPEAKER_CONTROL_PORT, Data) ; 113 | } 114 | 115 | 116 | VOID 117 | TurnOffSpeaker( VOID ) 118 | { 119 | UINT8 Data; 120 | 121 | Data = IoRead8( EFI_SPEAKER_CONTROL_PORT ); 122 | Data &= EFI_SPEAKER_OFF_MASK; 123 | IoWrite8( EFI_SPEAKER_CONTROL_PORT, Data ); 124 | } 125 | 126 | 127 | #ifdef DEBUG 128 | // FPM - WARNING: Probably wrong. Inconsident values returned. Not sure why yet! 129 | UINT16 130 | ReadCounter(UINT32 Counter) 131 | { 132 | UINT16 Val = 0; 133 | UINT8 Data; 134 | 135 | if (Counter > 2) 136 | return 0; 137 | 138 | Data = I8254_CTRL_SEL_CTR(Counter) | I8254_CTRL_LATCH; 139 | IoWrite8(EFI_TIMER_CONTROL_PORT, Data); // 43 140 | 141 | Data = I8254_CTRL_SEL_CTR(Counter) | I8254_CTRL_RW(Counter) | I8254_CTRL_LSB_MSB ; 142 | // Data = I8254_CTRL_SEL_CTR(Counter) | I8254_CTRL_READBACK_STATUS ; 143 | IoWrite8(EFI_TIMER_CONTROL_PORT, Data); // 43 144 | 145 | Val = IoRead8( EFI_TIMER_CONTROL2_PORT ); // 42 LSB 146 | // Val |= (IoRead8( EFI_TIMER_CONTROL2_PORT ) << 8); // 42 MSB 147 | Val += (IoRead8( EFI_TIMER_CONTROL2_PORT ) << 8); // 42 MSB 148 | 149 | return Val; 150 | } 151 | #endif 152 | 153 | 154 | EFI_STATUS 155 | ChangeFrequency( UINT16 Frequency ) 156 | { 157 | UINT8 Data; 158 | 159 | Data = 0xB6; 160 | IoWrite8(EFI_TIMER_CONTROL_PORT, Data); 161 | 162 | Data = (UINT8)(Frequency & 0x00FF); 163 | IoWrite8( EFI_TIMER_CONTROL2_PORT, Data ); 164 | Data = (UINT8)((Frequency & 0xFF00) >> 8); 165 | IoWrite8( EFI_TIMER_CONTROL2_PORT, Data ); 166 | 167 | return EFI_SUCCESS; 168 | } 169 | 170 | 171 | EFI_STATUS 172 | ResetFrequency( VOID ) 173 | { 174 | EFI_STATUS Status; 175 | 176 | Status = ChangeFrequency( EFI_DEFAULT_BEEP_FREQUENCY ); 177 | 178 | return Status; 179 | } 180 | 181 | 182 | VOID 183 | SimpleBeep( BOOLEAN TwoTone ) 184 | { 185 | TurnOnSpeaker(); 186 | gBS->Stall( EFI_DEFAULT_BEEP_ON_TIME ); 187 | TurnOffSpeaker(); 188 | gBS->Stall( EFI_DEFAULT_BEEP_OFF_TIME ); 189 | if (TwoTone) { 190 | // CountdownValue = ReadCounter(2); 191 | ChangeFrequency( EFI_DEFAULT_BEEP_ALTFREQUENCY ); 192 | TurnOnSpeaker(); 193 | gBS->Stall( EFI_DEFAULT_BEEP_ON_TIME ); 194 | TurnOffSpeaker(); 195 | // gBS->Stall( EFI_DEFAULT_BEEP_OFF_TIME ); 196 | ResetFrequency(); 197 | } 198 | } 199 | 200 | 201 | EFI_STATUS 202 | ComplexBeep( UINTN NumBeeps, 203 | UINTN Interval, 204 | UINTN Duration, 205 | UINTN Frequency, 206 | UINTN AltFreq, 207 | BOOLEAN TwoTone ) 208 | { 209 | #ifdef DEBUG 210 | CountdownValue = ReadCounter(2); 211 | #endif 212 | 213 | ChangeFrequency( Frequency ); 214 | for ( UINTN Num = 0; Num < NumBeeps; Num++ ) { 215 | TurnOnSpeaker(); 216 | gBS->Stall( Duration ); 217 | TurnOffSpeaker(); 218 | gBS->Stall( Interval ); 219 | if (TwoTone) { 220 | ChangeFrequency( AltFreq ); 221 | TurnOnSpeaker(); 222 | gBS->Stall( Duration ); 223 | TurnOffSpeaker(); 224 | if (Num < NumBeeps) { 225 | gBS->Stall( Interval ); 226 | ChangeFrequency( Frequency ); 227 | } 228 | } 229 | } 230 | ResetFrequency(); 231 | 232 | return EFI_SUCCESS; 233 | } 234 | 235 | 236 | VOID 237 | PrintDefaults( VOID ) 238 | { 239 | Print(L"\n"); 240 | Print(L" Default beep count: %d\n", EFI_DEFAULT_BEEP_NUMBER ); 241 | Print(L" Default beep enabled time: 0x%x\n", EFI_DEFAULT_BEEP_ON_TIME ); 242 | Print(L" Default beep disabled time: 0x%x\n", EFI_DEFAULT_BEEP_OFF_TIME ); 243 | Print(L" Default beep frequency: 0x%x\n", EFI_DEFAULT_BEEP_FREQUENCY ); 244 | Print(L" Default beep alternative frequency: 0x%x\n", EFI_DEFAULT_BEEP_ALTFREQUENCY ); 245 | Print(L"\n"); 246 | } 247 | 248 | 249 | VOID 250 | Usage( BOOLEAN ErrorMsg ) 251 | { 252 | if ( ErrorMsg ) { 253 | Print(L"ERROR: Unknown option(s).\n"); 254 | } 255 | Print(L"Usage: XBeep [-T] [-n number ] [-d hexduration] [-i hexinteravl] [-f hexfrequency] [-a hexaltfreq]\n"); 256 | Print(L" XBeep -D | --defaults\n"); 257 | Print(L" XBeep -T | --twotone\n"); 258 | Print(L" XBeep -V | --version\n"); 259 | } 260 | 261 | 262 | INTN 263 | EFIAPI 264 | ShellAppMain( UINTN Argc, 265 | CHAR16 **Argv ) 266 | { 267 | EFI_STATUS Status = EFI_SUCCESS; 268 | UINTN NumBeeps = EFI_DEFAULT_BEEP_NUMBER; 269 | UINTN Duration = EFI_DEFAULT_BEEP_ON_TIME; 270 | UINTN Interval = EFI_DEFAULT_BEEP_OFF_TIME; 271 | UINTN Frequency = EFI_DEFAULT_BEEP_FREQUENCY; 272 | UINTN AltFreq = EFI_DEFAULT_BEEP_ALTFREQUENCY; 273 | BOOLEAN TwoTone = FALSE; 274 | #ifdef DEBUG 275 | UINT32 Val = 0; 276 | #endif 277 | 278 | if (Argc == 1) { 279 | SimpleBeep(FALSE); 280 | return Status; 281 | } else if (Argc == 2) { 282 | if (!StrCmp(Argv[1], L"--version") || 283 | !StrCmp(Argv[1], L"-V")) { 284 | Print(L"Version: %s\n", UTILITY_VERSION); 285 | } else if (!StrCmp(Argv[1], L"--help") || 286 | !StrCmp(Argv[1], L"-h")) { 287 | Usage(FALSE); 288 | } else if (!StrCmp(Argv[1], L"--defaults") || 289 | !StrCmp(Argv[1], L"-D")) { 290 | PrintDefaults(); 291 | return Status; 292 | } else if (!StrCmp(Argv[1], L"--twotone") || 293 | !StrCmp(Argv[1], L"-T")) { 294 | SimpleBeep(TRUE); 295 | return Status; 296 | #ifdef DEBUG 297 | } else if (!StrCmp(Argv[1], L"-R")) { // undocumented experimental option 298 | Val = ReadCounter(2); 299 | Print(L"Timer 3 count value: %d %x\n", Val, Val); 300 | return Status; 301 | #endif 302 | } else { 303 | Usage(TRUE); 304 | } 305 | return Status; 306 | } 307 | 308 | for (int i = 1; i < Argc; i++) { 309 | if (!StrCmp(Argv[i], L"-n")) { 310 | if (i < Argc && IsDecNumber(Argv[i+1])) { 311 | i++; 312 | NumBeeps = (UINTN) StrDecimalToUint64( Argv[i] ); 313 | if (NumBeeps < 1) { 314 | Print(L"ERROR: Invalid number of beeps entered.\n"); 315 | Usage(FALSE); 316 | return Status; 317 | } 318 | } else { 319 | Print(L"ERROR: Invalid or missing argument to option.\n"); 320 | Usage(FALSE); 321 | return Status; 322 | } 323 | } else if (!StrCmp(Argv[i], L"-d")) { 324 | if (i < Argc && IsHexNumber(Argv[i+1])) { 325 | i++; 326 | Duration = (UINTN) StrHexToUint64( Argv[i] ); 327 | if (Duration < 1) { 328 | Print(L"ERROR: Invalid duration entered.\n"); 329 | Usage(FALSE); 330 | return Status; 331 | } 332 | } else { 333 | Print(L"ERROR: Invalid or missing argument to option.\n"); 334 | Usage(FALSE); 335 | return Status; 336 | } 337 | } else if (!StrCmp(Argv[i], L"-i")) { 338 | if (i < Argc && IsHexNumber(Argv[i+1])) { 339 | i++; 340 | Interval = (UINTN) StrHexToUint64( Argv[i] ); 341 | if (Interval < 1) { 342 | Print(L"ERROR: Invalid interval entered.\n"); 343 | Usage(FALSE); 344 | return Status; 345 | } 346 | } else { 347 | Print(L"ERROR: Invalid or missing argument to option.\n"); 348 | Usage(FALSE); 349 | return Status; 350 | } 351 | } else if (!StrCmp(Argv[i], L"-f")) { 352 | if (i < Argc && IsHexNumber(Argv[i+1])) { 353 | i++; 354 | Frequency = (UINTN) StrHexToUint64( Argv[i] ); 355 | if (Frequency < 1) { 356 | Print(L"ERROR: Invalid frequency entered.\n"); 357 | Usage(FALSE); 358 | return Status; 359 | } 360 | } else { 361 | Print(L"ERROR: Invalid or missing argument to option.\n"); 362 | Usage(FALSE); 363 | return Status; 364 | } 365 | } else if (!StrCmp(Argv[i], L"-a")) { 366 | if (i < Argc && IsHexNumber(Argv[i+1])) { 367 | i++; 368 | AltFreq = (UINTN) StrHexToUint64( Argv[i] ); 369 | if (AltFreq < 1) { 370 | Print(L"ERROR: Invalid alternative frequency entered.\n"); 371 | Usage(FALSE); 372 | return Status; 373 | } 374 | } else { 375 | Print(L"ERROR: Invalid or missing argument to option.\n"); 376 | Usage(FALSE); 377 | return Status; 378 | } 379 | } else if (!StrCmp(Argv[i], L"-T")) { 380 | TwoTone = TRUE; 381 | } else { 382 | Usage(TRUE); 383 | return Status; 384 | } 385 | } 386 | 387 | 388 | Status = ComplexBeep( NumBeeps, Interval, Duration, Frequency, AltFreq, TwoTone ); 389 | 390 | return Status; 391 | } 392 | -------------------------------------------------------------------------------- /MyApps/XBeep/XBeep.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/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-2019 2 | 3 | Various UEFI utilities built against UDK2018 using Clang. 4 | 5 | To integrate into UDK2018 source tree: 6 | 7 | Create a subdirectory immediately under UDK2018 called MyApps, populate MyApps with one or more of the utilities, fix up MyApps.dsc to build the required utility or utilities by uncommenting one or more .inf lines. 8 | 9 | Note these utilities have only been built and tested on an Lenovo T480 X64 platform. 10 | 11 | I now include a 64-bit EFI binary of each utility in each utility subdirectory. 12 | 13 | See http://blog.fpmurphy.com for detailed information about the utilities. 14 | 15 | See also https://blog.fpmurphy.com/2019/01/installing-and-configuring-udk2018-clang-7-0-on-fedora-29.html 16 | 17 | Enjoy! 18 | -------------------------------------------------------------------------------- /UEFI-Utilities-2019.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fpmurphy/UEFI-Utilities-2019/d3a08f4cb6c83ad083566e1487e3b3346797da62/UEFI-Utilities-2019.tar.gz --------------------------------------------------------------------------------