├── .gitattributes ├── .gitignore ├── BootAppToEfi ├── BootAppToEfi.sln ├── BootAppToEfi.vcxproj ├── BootAppToEfi.vcxproj.filters ├── ba2efi.c ├── ba2efi.h ├── bootapp.h ├── efi_inc │ ├── Makefile │ ├── aarch64 │ │ ├── efibind.h │ │ ├── efilibplat.h │ │ └── efisetjmp_arch.h │ ├── efi.h │ ├── efi_nii.h │ ├── efi_pxe.h │ ├── efiapi.h │ ├── eficompiler.h │ ├── eficon.h │ ├── eficonex.h │ ├── efidebug.h │ ├── efidef.h │ ├── efidevp.h │ ├── efierr.h │ ├── efifs.h │ ├── efigpt.h │ ├── efiip.h │ ├── efilib.h │ ├── efilink.h │ ├── efinet.h │ ├── efipart.h │ ├── efipciio.h │ ├── efipoint.h │ ├── efiprot.h │ ├── efipxebc.h │ ├── efirtlib.h │ ├── efiser.h │ ├── efisetjmp.h │ ├── efishell.h │ ├── efishellintf.h │ ├── efistdarg.h │ ├── efitcp.h │ ├── efiudp.h │ ├── efiui.h │ ├── ia32 │ │ ├── efibind.h │ │ ├── efilibplat.h │ │ ├── efisetjmp_arch.h │ │ └── pe.h │ ├── ia64 │ │ ├── efibind.h │ │ ├── efilibplat.h │ │ ├── efisetjmp_arch.h │ │ ├── pe.h │ │ └── salproc.h │ ├── inc.mak │ ├── lib.h │ ├── libsmbios.h │ ├── make.inf │ ├── makefile.hdr │ ├── mips64el │ │ ├── efibind.h │ │ ├── efilibplat.h │ │ └── efisetjmp_arch.h │ ├── pci22.h │ ├── protocol │ │ ├── adapterdebug.h │ │ ├── eficonsplit.h │ │ ├── efidbg.h │ │ ├── efivar.h │ │ ├── ia64 │ │ │ └── eficontext.h │ │ ├── intload.h │ │ ├── legacyboot.h │ │ ├── make.inf │ │ ├── makefile.hdr │ │ ├── piflash64.h │ │ ├── readme.txt │ │ └── vgaclass.h │ ├── riscv64 │ │ ├── efibind.h │ │ ├── efilibplat.h │ │ └── efisetjmp_arch.h │ ├── romload.h │ └── x86_64 │ │ ├── efibind.h │ │ ├── efilibplat.h │ │ ├── efisetjmp_arch.h │ │ └── pe.h ├── efientry.c └── efientry.h ├── EfiInstallPolicy ├── EfiInstallPolicy.sln ├── EfiInstallPolicy.vcxproj ├── EfiInstallPolicy.vcxproj.filters ├── SecureBootPolicy.h ├── efi_inc │ ├── Makefile │ ├── aarch64 │ │ ├── efibind.h │ │ ├── efilibplat.h │ │ └── efisetjmp_arch.h │ ├── efi.h │ ├── efi_nii.h │ ├── efi_pxe.h │ ├── efiapi.h │ ├── eficompiler.h │ ├── eficon.h │ ├── eficonex.h │ ├── efidebug.h │ ├── efidef.h │ ├── efidevp.h │ ├── efierr.h │ ├── efifs.h │ ├── efigpt.h │ ├── efiip.h │ ├── efilib.h │ ├── efilink.h │ ├── efinet.h │ ├── efipart.h │ ├── efipciio.h │ ├── efipoint.h │ ├── efiprot.h │ ├── efipxebc.h │ ├── efirtlib.h │ ├── efiser.h │ ├── efisetjmp.h │ ├── efishell.h │ ├── efishellintf.h │ ├── efistdarg.h │ ├── efitcp.h │ ├── efiudp.h │ ├── efiui.h │ ├── ia32 │ │ ├── efibind.h │ │ ├── efilibplat.h │ │ ├── efisetjmp_arch.h │ │ └── pe.h │ ├── ia64 │ │ ├── efibind.h │ │ ├── efilibplat.h │ │ ├── efisetjmp_arch.h │ │ ├── pe.h │ │ └── salproc.h │ ├── inc.mak │ ├── lib.h │ ├── libsmbios.h │ ├── make.inf │ ├── makefile.hdr │ ├── mips64el │ │ ├── efibind.h │ │ ├── efilibplat.h │ │ └── efisetjmp_arch.h │ ├── pci22.h │ ├── protocol │ │ ├── adapterdebug.h │ │ ├── eficonsplit.h │ │ ├── efidbg.h │ │ ├── efivar.h │ │ ├── ia64 │ │ │ └── eficontext.h │ │ ├── intload.h │ │ ├── legacyboot.h │ │ ├── make.inf │ │ ├── makefile.hdr │ │ ├── piflash64.h │ │ ├── readme.txt │ │ └── vgaclass.h │ ├── riscv64 │ │ ├── efibind.h │ │ ├── efilibplat.h │ │ └── efisetjmp_arch.h │ ├── romload.h │ └── x86_64 │ │ ├── efibind.h │ │ ├── efilibplat.h │ │ ├── efisetjmp_arch.h │ │ └── pe.h ├── efientry.c └── efientry.h ├── LICENSE.txt ├── SecureBootPolicy ├── SecureBootPolicy.sln ├── SecureBootPolicy │ ├── Binary.cs │ ├── Constants.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ └── Resources.resx │ ├── SBPolicy.cs │ ├── SBPolicy.xsd │ ├── SecureBootPolicy.csproj │ ├── SpanExtensions.cs │ ├── StreamExtensions.cs │ ├── XmlPolicy.cs │ └── packages.config ├── SecureBootPolicyCompiler │ ├── App.config │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── SecureBootPolicyCompiler.csproj ├── SecureBootPolicyDefault.xml ├── SecureBootPolicyDefaultWithSigners.xml ├── SecureBootPolicyExample.xml └── readme.md └── readme.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /BootAppToEfi/BootAppToEfi.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.31919.166 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BootAppToEfi", "BootAppToEfi.vcxproj", "{A9F6BFD0-80E3-4BC4-808C-9F4A3A425285}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {A9F6BFD0-80E3-4BC4-808C-9F4A3A425285}.Debug|x64.ActiveCfg = Debug|x64 17 | {A9F6BFD0-80E3-4BC4-808C-9F4A3A425285}.Debug|x64.Build.0 = Debug|x64 18 | {A9F6BFD0-80E3-4BC4-808C-9F4A3A425285}.Debug|x86.ActiveCfg = Debug|Win32 19 | {A9F6BFD0-80E3-4BC4-808C-9F4A3A425285}.Debug|x86.Build.0 = Debug|Win32 20 | {A9F6BFD0-80E3-4BC4-808C-9F4A3A425285}.Release|x64.ActiveCfg = Release|x64 21 | {A9F6BFD0-80E3-4BC4-808C-9F4A3A425285}.Release|x64.Build.0 = Release|x64 22 | {A9F6BFD0-80E3-4BC4-808C-9F4A3A425285}.Release|x86.ActiveCfg = Release|Win32 23 | {A9F6BFD0-80E3-4BC4-808C-9F4A3A425285}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {232B3675-40E7-44EC-8116-121BED242AAF} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /BootAppToEfi/BootAppToEfi.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | -------------------------------------------------------------------------------- /BootAppToEfi/ba2efi.c: -------------------------------------------------------------------------------- 1 | #include "ba2efi.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | typedef void (*fptrArchSetDescriptorTableContext)(void* DescriptorTable); 9 | 10 | #define SHELLCODE_VARIABLE(name) __declspec(allocate(".text")) const uint8_t name ## [] 11 | 12 | #ifdef _M_X64 13 | #pragma section(".text") 14 | // for one-file purpose... 15 | SHELLCODE_VARIABLE(bArchSetDescriptorTableContext) = { 16 | 0x0F, 0x01, 0x11, // lgdt [rcx] 17 | 0x0F, 0x01, 0x59, 0x0A, // lidt [rcx+0Ah] 18 | 0x0F, 0x00, 0x51, 0x14, // lldt [rcx+14h] 19 | 20 | // the original uses a full 64-bit mov here, 21 | // lea should do just fine, and make this position independant 22 | 0x48, 0x8D, 0x15, 0x09, 0x00, 0x00, 0x00, // lea rdx, SecondHalf 23 | 24 | 0x48, 0x0F, 0xB7, 0x41, 0x16, // movzx rax, word [rcx+16h] 25 | 0x50, // push rax 26 | 0x52, // push rdx 27 | 0x48, 0xCB, // retfq 28 | // SecondHalf: 29 | // original restores gs before fs, 30 | // i decided to do the restores in structure-offset order for aesthetics. 31 | 0x8E, 0x59, 0x18, // mov ds, word [rcx+18h] 32 | 0x8E, 0x41, 0x1A, // mov es, word [rcx+1Ah] 33 | 0x8E, 0x61, 0x1C, // mov fs, word [rcx+1Ch] 34 | 0x8E, 0x69, 0x1E, // mov gs, word [rcx+1Eh] 35 | 0x8E, 0x51, 0x20, // mov ss, word [rcx+20h] 36 | 0xC3 // retn 37 | }; 38 | #define ArchSetDescriptorTableContext(x) \ 39 | ((fptrArchSetDescriptorTableContext)bArchSetDescriptorTableContext) \ 40 | (x) 41 | #endif 42 | 43 | void SwitchToFirmwareContext(void* FirmwareData) { 44 | // Reinterpret the firmware data as pointer to bytes. 45 | uint8_t* FwData8 = (uint8_t*)FirmwareData; 46 | #ifdef _M_X64 47 | // x64 stores additional state in the firmware data at specific offsets. 48 | // Set page table base from the firmware data. 49 | uint64_t cr3 = *(uint64_t*)&FwData8[0x1C]; 50 | __writecr3(cr3); 51 | // Set GDT/IDT/LDT and segment registers from the firmware data. 52 | ArchSetDescriptorTableContext(&FwData8[0x24]); 53 | // Enable interrupts. 54 | _enable(); 55 | #elif _M_IX86 56 | // Disable paging. 57 | __writecr0(__readcr0() & ~0x80000000); 58 | // Disable PAE. 59 | __writecr4(__readcr4() & ~0x20); 60 | // Enable interrupts. 61 | _enable(); 62 | #elif _M_ARM 63 | #error "Not implemented" // there's a chainloader already for ARMv7, TODO: port that? 64 | #elif _M_ARM64 65 | #error "Not implemented (yet)" // original code here literally uses a switch instead of shifting right, lol. TODO: reimplement 66 | #else 67 | #error "Unsupported architecture" 68 | #endif 69 | } 70 | 71 | static inline __forceinline void WaitForInterrupt() { 72 | #if defined(_M_X64) || defined(_M_IX86) 73 | __halt(); 74 | #elif defined(_M_ARM) || defined(_M_ARM64) 75 | __wfi(); 76 | #else 77 | #error "Unsupported architecture" 78 | #endif 79 | } 80 | 81 | NTSTATUS BootApplicationEntryPoint(__inout PBOOT_APPLICATION_PARAMETERS Parameters) { 82 | // Get the offset to the firmware data. 83 | uint32_t FirmwareDataOffset = *((uint32_t*)((size_t)Parameters + FIRMWARE_DATA_OFFSET)); 84 | // Get a pointer to the firmware data. 85 | size_t* FirmwareData = (size_t*)((size_t)Parameters + FirmwareDataOffset); 86 | 87 | // Get the EFI system table and EFI image handle. 88 | // Please note: 89 | // The start of the FIRMWARE_DATA structure is architecture independent: uint32_t Version; EFI_HANDLE ImageHandle; EFI_SYSTEM_TABLE* SystemTable 90 | // On 64-bit architectures there is padding between the first two elements; so interpreting as an array of size_t will work fine. 91 | EFI_HANDLE ImageHandle = (EFI_HANDLE)FirmwareData[1]; 92 | EFI_SYSTEM_TABLE* SystemTable = (EFI_SYSTEM_TABLE*)FirmwareData[2]; 93 | 94 | // Switch to the firmware context. 95 | SwitchToFirmwareContext(FirmwareData); 96 | 97 | // In the firmware context: call the EFI entry point. 98 | EfiMain(ImageHandle, SystemTable); 99 | 100 | // We don't want to return to the caller. 101 | while (1) WaitForInterrupt(); 102 | } -------------------------------------------------------------------------------- /BootAppToEfi/ba2efi.h: -------------------------------------------------------------------------------- 1 | // Boot Application and EFI headers. 2 | 3 | #pragma once 4 | #include "bootapp.h" 5 | #include "efientry.h" -------------------------------------------------------------------------------- /BootAppToEfi/bootapp.h: -------------------------------------------------------------------------------- 1 | // Boot Application Headers 2 | 3 | #pragma once 4 | 5 | // Source Code Annotation Language. 6 | #include 7 | 8 | // NTSTATUS definitions. 9 | typedef _Return_type_success_(return >= 0) long NTSTATUS; 10 | #define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0) 11 | 12 | #include 13 | 14 | // Boot application parameters. 15 | #define FIRMWARE_DATA_OFFSET 0x30 // Same offset for all architectures. 16 | typedef struct _BOOT_APPLICATION_PARAMETERS* PBOOT_APPLICATION_PARAMETERS; 17 | 18 | /// Entry point for a Windows Boot Application executable. 19 | /// Parameters passed to the boot application. 20 | /// NT status code. 21 | NTSTATUS BootApplicationEntryPoint(__inout PBOOT_APPLICATION_PARAMETERS Parameters); -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/Makefile: -------------------------------------------------------------------------------- 1 | SRCDIR = . 2 | 3 | VPATH = $(SRCDIR) 4 | 5 | include $(SRCDIR)/../Make.defaults 6 | 7 | TOPDIR = $(SRCDIR)/.. 8 | 9 | CDIR=$(TOPDIR)/.. 10 | 11 | all: 12 | 13 | clean: 14 | 15 | install: 16 | mkdir -p $(INSTALLROOT)$(PREFIX)/include/efi 17 | mkdir -p $(INSTALLROOT)$(PREFIX)/include/efi/protocol 18 | mkdir -p $(INSTALLROOT)$(PREFIX)/include/efi/$(ARCH) 19 | $(INSTALL) -m 644 $(SRCDIR)/*.h $(INSTALLROOT)$(PREFIX)/include/efi 20 | $(INSTALL) -m 644 $(SRCDIR)/protocol/*.h $(INSTALLROOT)$(PREFIX)/include/efi/protocol 21 | $(INSTALL) -m 644 $(SRCDIR)/$(ARCH)/*.h $(INSTALLROOT)$(PREFIX)/include/efi/$(ARCH) 22 | ifeq ($(ARCH),ia64) 23 | mkdir -p $(INSTALLROOT)$(PREFIX)/include/efi/protocol/ia64 24 | $(INSTALL) -m 644 $(SRCDIR)/protocol/ia64/*.h $(INSTALLROOT)$(PREFIX)/include/efi/protocol/ia64 25 | endif 26 | 27 | include $(SRCDIR)/../Make.rules 28 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/aarch64/efilibplat.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 1998 Intel Corporation 4 | 5 | Module Name: 6 | 7 | efilibplat.h 8 | 9 | Abstract: 10 | 11 | EFI to compile bindings 12 | 13 | 14 | 15 | 16 | Revision History 17 | 18 | --*/ 19 | 20 | VOID 21 | InitializeLibPlatform ( 22 | IN EFI_HANDLE ImageHandle, 23 | IN EFI_SYSTEM_TABLE *SystemTable 24 | ); 25 | 26 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/aarch64/efisetjmp_arch.h: -------------------------------------------------------------------------------- 1 | #ifndef GNU_EFI_AARCH64_SETJMP_H 2 | #define GNU_EFI_AARCH64_SETJMP_H 3 | 4 | #define JMPBUF_ALIGN 8 5 | 6 | typedef struct { 7 | /* GP regs */ 8 | UINT64 X19; 9 | UINT64 X20; 10 | UINT64 X21; 11 | UINT64 X22; 12 | UINT64 X23; 13 | UINT64 X24; 14 | UINT64 X25; 15 | UINT64 X26; 16 | UINT64 X27; 17 | UINT64 X28; 18 | UINT64 FP; 19 | UINT64 LR; 20 | UINT64 IP0; 21 | 22 | /* FP regs */ 23 | UINT64 D8; 24 | UINT64 D9; 25 | UINT64 D10; 26 | UINT64 D11; 27 | UINT64 D12; 28 | UINT64 D13; 29 | UINT64 D14; 30 | UINT64 D15; 31 | } ALIGN(JMPBUF_ALIGN) jmp_buf[1]; 32 | 33 | #endif /* GNU_EFI_AARCH64_SETJMP_H */ 34 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/efi.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 1998 Intel Corporation 4 | 5 | Module Name: 6 | 7 | efi.h 8 | 9 | Abstract: 10 | 11 | Public EFI header files 12 | 13 | 14 | 15 | Revision History 16 | 17 | --*/ 18 | 19 | 20 | // Add a predefined macro to detect usage of the library 21 | #ifndef _GNU_EFI 22 | #define _GNU_EFI 23 | #endif 24 | 25 | // 26 | // Build flags on input 27 | // EFI32 28 | // EFI_DEBUG - Enable debugging code 29 | // EFI_NT_EMULATOR - Building for running under NT 30 | // 31 | 32 | 33 | #ifndef _EFI_INCLUDE_ 34 | #define _EFI_INCLUDE_ 35 | 36 | #define EFI_FIRMWARE_VENDOR L"INTEL" 37 | #define EFI_FIRMWARE_MAJOR_REVISION 12 38 | #define EFI_FIRMWARE_MINOR_REVISION 33 39 | #define EFI_FIRMWARE_REVISION ((EFI_FIRMWARE_MAJOR_REVISION <<16) | (EFI_FIRMWARE_MINOR_REVISION)) 40 | 41 | #if defined(_M_X64) || defined(__x86_64__) || defined(__amd64__) 42 | #include "x86_64/efibind.h" 43 | #elif defined(_M_IX86) || defined(__i386__) 44 | #include "ia32/efibind.h" 45 | #elif defined(_M_IA64) || defined(__ia64__) 46 | #include "ia64/efibind.h" 47 | #elif defined (_M_ARM64) || defined(__aarch64__) 48 | #include "aarch64/efibind.h" 49 | #elif defined (_M_ARM) || defined(__arm__) 50 | #include "arm/efibind.h" 51 | #elif defined (_M_MIPS64) || defined(__mips64__) 52 | #include "mips64el/efibind.h" 53 | #elif defined (__riscv) && __riscv_xlen == 64 54 | #include "riscv64/efibind.h" 55 | #else 56 | #error Usupported architecture 57 | #endif 58 | 59 | #include "eficompiler.h" 60 | #include "efidef.h" 61 | #include "efidevp.h" 62 | #include "efipciio.h" 63 | #include "efiprot.h" 64 | #include "eficon.h" 65 | #include "eficonex.h" 66 | #include "efiser.h" 67 | #include "efi_nii.h" 68 | #include "efipxebc.h" 69 | #include "efinet.h" 70 | #include "efiapi.h" 71 | #include "efifs.h" 72 | #include "efierr.h" 73 | #include "efiui.h" 74 | #include "efiip.h" 75 | #include "efiudp.h" 76 | #include "efitcp.h" 77 | #include "efipoint.h" 78 | #include "efishell.h" 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/efi_nii.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_NII_H 2 | #define _EFI_NII_H 3 | 4 | /*++ 5 | Copyright (c) 2000 Intel Corporation 6 | 7 | Module name: 8 | efi_nii.h 9 | 10 | Abstract: 11 | 12 | Revision history: 13 | 2000-Feb-18 M(f)J GUID updated. 14 | Structure order changed for machine word alignment. 15 | Added StringId[4] to structure. 16 | 17 | 2000-Feb-14 M(f)J Genesis. 18 | --*/ 19 | 20 | #define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID \ 21 | { 0xE18541CD, 0xF755, 0x4f73, {0x92, 0x8D, 0x64, 0x3C, 0x8A, 0x79, 0xB2, 0x29} } 22 | 23 | #define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION 0x00010000 24 | #define EFI_NETWORK_INTERFACE_IDENTIFIER_INTERFACE_REVISION EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION 25 | 26 | typedef enum { 27 | EfiNetworkInterfaceUndi = 1 28 | } EFI_NETWORK_INTERFACE_TYPE; 29 | 30 | typedef struct _EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL { 31 | 32 | UINT64 Revision; 33 | // Revision of the network interface identifier protocol interface. 34 | 35 | UINT64 ID; 36 | // Address of the first byte of the identifying structure for this 37 | // network interface. This is set to zero if there is no structure. 38 | // 39 | // For PXE/UNDI this is the first byte of the !PXE structure. 40 | 41 | UINT64 ImageAddr; 42 | // Address of the UNrelocated driver/ROM image. This is set 43 | // to zero if there is no driver/ROM image. 44 | // 45 | // For 16-bit UNDI, this is the first byte of the option ROM in 46 | // upper memory. 47 | // 48 | // For 32/64-bit S/W UNDI, this is the first byte of the EFI ROM 49 | // image. 50 | // 51 | // For H/W UNDI, this is set to zero. 52 | 53 | UINT32 ImageSize; 54 | // Size of the UNrelocated driver/ROM image of this network interface. 55 | // This is set to zero if there is no driver/ROM image. 56 | 57 | CHAR8 StringId[4]; 58 | // 4 char ASCII string to go in class identifier (option 60) in DHCP 59 | // and Boot Server discover packets. 60 | // For EfiNetworkInterfaceUndi this field is "UNDI". 61 | // For EfiNetworkInterfaceSnp this field is "SNPN". 62 | 63 | UINT8 Type; 64 | UINT8 MajorVer; 65 | UINT8 MinorVer; 66 | // Information to be placed into the PXE DHCP and Discover packets. 67 | // This is the network interface type and version number that will 68 | // be placed into DHCP option 94 (client network interface identifier). 69 | BOOLEAN Ipv6Supported; 70 | UINT8 IfNum; // interface number to be used with pxeid structure 71 | } EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL, EFI_NETWORK_INTERFACE_IDENTIFIER_INTERFACE; 72 | 73 | // Note: Because it conflicted with the EDK2 struct name, the 74 | // 'EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL' GUID definition, 75 | // from older versions of gnu-efi, is now obsoleted. 76 | // Use 'EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID' instead. 77 | 78 | #endif // _EFI_NII_H 79 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/eficompiler.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Pete Batard 4 | 5 | Module Name: 6 | 7 | eficompiler.h 8 | 9 | Abstract: 10 | 11 | Compiler specific adjustments 12 | 13 | --*/ 14 | 15 | #ifdef _MSC_EXTENSIONS 16 | #define EFI_UNUSED 17 | #else 18 | #define EFI_UNUSED __attribute__((__unused__)) 19 | #endif 20 | 21 | #ifdef _MSC_EXTENSIONS 22 | #define ALIGN(x) __declspec(align(x)) 23 | #else 24 | #define ALIGN(x) __attribute__((__aligned__(x))) 25 | #endif 26 | 27 | /* Also add a catch-all on __attribute__() for MS compilers */ 28 | #ifdef _MSC_EXTENSIONS 29 | #define __attribute__(x) 30 | #endif 31 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/eficonex.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_CONEX_H 2 | #define _EFI_CONEX_H 3 | 4 | /*++ 5 | 6 | Copyright (c) 2020 Kagurazaka Kotori 7 | 8 | Module Name: 9 | 10 | eficonex.h 11 | 12 | Abstract: 13 | 14 | EFI console extension protocols 15 | 16 | --*/ 17 | 18 | // 19 | // Simple Text Input Ex Protocol 20 | // 21 | 22 | #define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \ 23 | { 0xdd9e7534, 0x7762, 0x4698, {0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa} } 24 | 25 | INTERFACE_DECL(_EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL); 26 | 27 | typedef UINT8 EFI_KEY_TOGGLE_STATE; 28 | 29 | typedef struct EFI_KEY_STATE { 30 | UINT32 KeyShiftState; 31 | EFI_KEY_TOGGLE_STATE KeyToggleState; 32 | } EFI_KEY_STATE; 33 | 34 | typedef struct { 35 | EFI_INPUT_KEY Key; 36 | EFI_KEY_STATE KeyState; 37 | } EFI_KEY_DATA; 38 | 39 | // Shift states 40 | #define EFI_SHIFT_STATE_VALID 0x80000000 41 | #define EFI_RIGHT_SHIFT_PRESSED 0x00000001 42 | #define EFI_LEFT_SHIFT_PRESSED 0x00000002 43 | #define EFI_RIGHT_CONTROL_PRESSED 0x00000004 44 | #define EFI_LEFT_CONTROL_PRESSED 0x00000008 45 | #define EFI_RIGHT_ALT_PRESSED 0x00000010 46 | #define EFI_LEFT_ALT_PRESSED 0x00000020 47 | #define EFI_RIGHT_LOGO_PRESSED 0x00000040 48 | #define EFI_LEFT_LOGO_PRESSED 0x00000080 49 | #define EFI_MENU_KEY_PRESSED 0x00000100 50 | #define EFI_SYS_REQ_PRESSED 0x00000200 51 | 52 | // Toggle states 53 | #define EFI_TOGGLE_STATE_VALID 0x80 54 | #define EFI_KEY_STATE_EXPOSED 0x40 55 | #define EFI_SCROLL_LOCK_ACTIVE 0x01 56 | #define EFI_NUM_LOCK_ACTIVE 0x02 57 | #define EFI_CAPS_LOCK_ACTIVE 0x04 58 | 59 | typedef 60 | EFI_STATUS 61 | (EFIAPI *EFI_INPUT_RESET_EX) ( 62 | IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, 63 | IN BOOLEAN ExtendedVerification 64 | ); 65 | 66 | typedef 67 | EFI_STATUS 68 | (EFIAPI *EFI_INPUT_READ_KEY_EX) ( 69 | IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, 70 | OUT EFI_KEY_DATA *KeyData 71 | ); 72 | 73 | typedef 74 | EFI_STATUS 75 | (EFIAPI *EFI_SET_STATE) ( 76 | IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, 77 | IN EFI_KEY_TOGGLE_STATE *KeyToggleState 78 | ); 79 | 80 | typedef 81 | EFI_STATUS 82 | (EFIAPI *EFI_KEY_NOTIFY_FUNCTION) ( 83 | IN EFI_KEY_DATA *KeyData 84 | ); 85 | 86 | typedef 87 | EFI_STATUS 88 | (EFIAPI *EFI_REGISTER_KEYSTROKE_NOTIFY) ( 89 | IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, 90 | IN EFI_KEY_DATA *KeyData, 91 | IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction, 92 | OUT VOID **NotifyHandle 93 | ); 94 | 95 | typedef 96 | EFI_STATUS 97 | (EFIAPI *EFI_UNREGISTER_KEYSTROKE_NOTIFY) ( 98 | IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, 99 | IN VOID *NotificationHandle 100 | ); 101 | 102 | typedef struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL{ 103 | EFI_INPUT_RESET_EX Reset; 104 | EFI_INPUT_READ_KEY_EX ReadKeyStrokeEx; 105 | EFI_EVENT WaitForKeyEx; 106 | EFI_SET_STATE SetState; 107 | EFI_REGISTER_KEYSTROKE_NOTIFY RegisterKeyNotify; 108 | EFI_UNREGISTER_KEYSTROKE_NOTIFY UnregisterKeyNotify; 109 | } EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL; 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/efierr.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_ERR_H 2 | #define _EFI_ERR_H 3 | 4 | /*++ 5 | 6 | Copyright (c) 1998 Intel Corporation 7 | 8 | Module Name: 9 | 10 | efierr.h 11 | 12 | Abstract: 13 | 14 | EFI error codes 15 | 16 | 17 | 18 | 19 | Revision History 20 | 21 | --*/ 22 | 23 | 24 | #define EFIWARN(a) (a) 25 | #define EFI_ERROR(a) (((INTN) a) < 0) 26 | 27 | 28 | #define EFI_SUCCESS 0 29 | #define EFI_LOAD_ERROR EFIERR(1) 30 | #define EFI_INVALID_PARAMETER EFIERR(2) 31 | #define EFI_UNSUPPORTED EFIERR(3) 32 | #define EFI_BAD_BUFFER_SIZE EFIERR(4) 33 | #define EFI_BUFFER_TOO_SMALL EFIERR(5) 34 | #define EFI_NOT_READY EFIERR(6) 35 | #define EFI_DEVICE_ERROR EFIERR(7) 36 | #define EFI_WRITE_PROTECTED EFIERR(8) 37 | #define EFI_OUT_OF_RESOURCES EFIERR(9) 38 | #define EFI_VOLUME_CORRUPTED EFIERR(10) 39 | #define EFI_VOLUME_FULL EFIERR(11) 40 | #define EFI_NO_MEDIA EFIERR(12) 41 | #define EFI_MEDIA_CHANGED EFIERR(13) 42 | #define EFI_NOT_FOUND EFIERR(14) 43 | #define EFI_ACCESS_DENIED EFIERR(15) 44 | #define EFI_NO_RESPONSE EFIERR(16) 45 | #define EFI_NO_MAPPING EFIERR(17) 46 | #define EFI_TIMEOUT EFIERR(18) 47 | #define EFI_NOT_STARTED EFIERR(19) 48 | #define EFI_ALREADY_STARTED EFIERR(20) 49 | #define EFI_ABORTED EFIERR(21) 50 | #define EFI_ICMP_ERROR EFIERR(22) 51 | #define EFI_TFTP_ERROR EFIERR(23) 52 | #define EFI_PROTOCOL_ERROR EFIERR(24) 53 | #define EFI_INCOMPATIBLE_VERSION EFIERR(25) 54 | #define EFI_SECURITY_VIOLATION EFIERR(26) 55 | #define EFI_CRC_ERROR EFIERR(27) 56 | #define EFI_END_OF_MEDIA EFIERR(28) 57 | #define EFI_END_OF_FILE EFIERR(31) 58 | #define EFI_INVALID_LANGUAGE EFIERR(32) 59 | #define EFI_COMPROMISED_DATA EFIERR(33) 60 | 61 | #define EFI_WARN_UNKOWN_GLYPH EFIWARN(1) 62 | #define EFI_WARN_UNKNOWN_GLYPH EFIWARN(1) 63 | #define EFI_WARN_DELETE_FAILURE EFIWARN(2) 64 | #define EFI_WARN_WRITE_FAILURE EFIWARN(3) 65 | #define EFI_WARN_BUFFER_TOO_SMALL EFIWARN(4) 66 | 67 | #endif 68 | 69 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/efifs.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_FS_H 2 | #define _EFI_FS_H 3 | 4 | /*++ 5 | 6 | Copyright (c) 1998 Intel Corporation 7 | 8 | Module Name: 9 | 10 | efifs.h 11 | 12 | Abstract: 13 | 14 | EFI File System structures 15 | 16 | 17 | 18 | Revision History 19 | 20 | --*/ 21 | 22 | 23 | // 24 | // EFI Partition header (normaly starts in LBA 1) 25 | // 26 | 27 | #define EFI_PARTITION_SIGNATURE 0x5053595320494249 28 | #define EFI_PARTITION_REVISION 0x00010001 29 | #define MIN_EFI_PARTITION_BLOCK_SIZE 512 30 | #define EFI_PARTITION_LBA 1 31 | 32 | typedef struct _EFI_PARTITION_HEADER { 33 | EFI_TABLE_HEADER Hdr; 34 | UINT32 DirectoryAllocationNumber; 35 | UINT32 BlockSize; 36 | EFI_LBA FirstUsableLba; 37 | EFI_LBA LastUsableLba; 38 | EFI_LBA UnusableSpace; 39 | EFI_LBA FreeSpace; 40 | EFI_LBA RootFile; 41 | EFI_LBA SecutiryFile; 42 | } EFI_PARTITION_HEADER; 43 | 44 | 45 | // 46 | // File header 47 | // 48 | 49 | #define EFI_FILE_HEADER_SIGNATURE 0x454c494620494249 50 | #define EFI_FILE_HEADER_REVISION 0x00010000 51 | #define EFI_FILE_STRING_SIZE 260 52 | 53 | typedef struct _EFI_FILE_HEADER { 54 | EFI_TABLE_HEADER Hdr; 55 | UINT32 Class; 56 | UINT32 LBALOffset; 57 | EFI_LBA Parent; 58 | UINT64 FileSize; 59 | UINT64 FileAttributes; 60 | EFI_TIME FileCreateTime; 61 | EFI_TIME FileModificationTime; 62 | EFI_GUID VendorGuid; 63 | CHAR16 FileString[EFI_FILE_STRING_SIZE]; 64 | } EFI_FILE_HEADER; 65 | 66 | 67 | // 68 | // Return the file's first LBAL which is in the same 69 | // logical block as the file header 70 | // 71 | 72 | #define EFI_FILE_LBAL(a) ((EFI_LBAL *) (((CHAR8 *) (a)) + (a)->LBALOffset)) 73 | 74 | #define EFI_FILE_CLASS_FREE_SPACE 1 75 | #define EFI_FILE_CLASS_EMPTY 2 76 | #define EFI_FILE_CLASS_NORMAL 3 77 | 78 | 79 | // 80 | // Logical Block Address List - the fundemental block 81 | // description structure 82 | // 83 | 84 | #define EFI_LBAL_SIGNATURE 0x4c41424c20494249 85 | #define EFI_LBAL_REVISION 0x00010000 86 | 87 | typedef struct _EFI_LBAL { 88 | EFI_TABLE_HEADER Hdr; 89 | UINT32 Class; 90 | EFI_LBA Parent; 91 | EFI_LBA Next; 92 | UINT32 ArraySize; 93 | UINT32 ArrayCount; 94 | } EFI_LBAL; 95 | 96 | // Array size 97 | #define EFI_LBAL_ARRAY_SIZE(lbal,offs,blks) \ 98 | (((blks) - (offs) - (lbal)->Hdr.HeaderSize) / sizeof(EFI_RL)) 99 | 100 | // 101 | // Logical Block run-length 102 | // 103 | 104 | typedef struct { 105 | EFI_LBA Start; 106 | UINT64 Length; 107 | } EFI_RL; 108 | 109 | // 110 | // Return the run-length structure from an LBAL header 111 | // 112 | 113 | #define EFI_LBAL_RL(a) ((EFI_RL*) (((CHAR8 *) (a)) + (a)->Hdr.HeaderSize)) 114 | 115 | #endif 116 | 117 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/efigpt.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_GPT_H 2 | #define _EFI_GPT_H 3 | /*++ 4 | 5 | Copyright (c) 1998 Intel Corporation 6 | 7 | Module Name: 8 | 9 | EfiGpt.h 10 | 11 | Abstract: 12 | Include file for EFI partitioning scheme 13 | 14 | 15 | 16 | Revision History 17 | 18 | --*/ 19 | 20 | #define PRIMARY_PART_HEADER_LBA 1 21 | 22 | typedef struct { 23 | EFI_TABLE_HEADER Header; 24 | EFI_LBA MyLBA; 25 | EFI_LBA AlternateLBA; 26 | EFI_LBA FirstUsableLBA; 27 | EFI_LBA LastUsableLBA; 28 | EFI_GUID DiskGUID; 29 | EFI_LBA PartitionEntryLBA; 30 | UINT32 NumberOfPartitionEntries; 31 | UINT32 SizeOfPartitionEntry; 32 | UINT32 PartitionEntryArrayCRC32; 33 | } EFI_PARTITION_TABLE_HEADER; 34 | 35 | #define EFI_PTAB_HEADER_ID "EFI PART" 36 | 37 | typedef struct { 38 | EFI_GUID PartitionTypeGUID; 39 | EFI_GUID UniquePartitionGUID; 40 | EFI_LBA StartingLBA; 41 | EFI_LBA EndingLBA; 42 | UINT64 Attributes; 43 | CHAR16 PartitionName[36]; 44 | } EFI_PARTITION_ENTRY; 45 | 46 | // 47 | // EFI Partition Attributes 48 | // 49 | #define EFI_PART_USED_BY_EFI 0x0000000000000001 50 | #define EFI_PART_REQUIRED_TO_FUNCTION 0x0000000000000002 51 | #define EFI_PART_USED_BY_OS 0x0000000000000004 52 | #define EFI_PART_REQUIRED_BY_OS 0x0000000000000008 53 | #define EFI_PART_BACKUP_REQUIRED 0x0000000000000010 54 | #define EFI_PART_USER_DATA 0x0000000000000020 55 | #define EFI_PART_CRITICAL_USER_DATA 0x0000000000000040 56 | #define EFI_PART_REDUNDANT_PARTITION 0x0000000000000080 57 | 58 | #define EFI_PART_TYPE_UNUSED_GUID \ 59 | { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} } 60 | 61 | #define EFI_PART_TYPE_EFI_SYSTEM_PART_GUID \ 62 | { 0xc12a7328, 0xf81f, 0x11d2, {0xba, 0x4b, 0x00, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b} } 63 | 64 | #define EFI_PART_TYPE_LEGACY_MBR_GUID \ 65 | { 0x024dee41, 0x33e7, 0x11d3, {0x9d, 0x69, 0x00, 0x08, 0xc7, 0x81, 0xf3, 0x9f} } 66 | 67 | #endif 68 | 69 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/efilink.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_LINK_H 2 | #define _EFI_LINK_H 3 | 4 | /*++ 5 | 6 | Copyright (c) 1998 Intel Corporation 7 | 8 | Module Name: 9 | 10 | link.h (renamed efilink.h to avoid conflicts) 11 | 12 | Abstract: 13 | 14 | EFI link list macro's 15 | 16 | 17 | 18 | Revision History 19 | 20 | --*/ 21 | 22 | #ifndef EFI_NT_EMUL 23 | 24 | // 25 | // List entry - doubly linked list 26 | // 27 | 28 | typedef struct _LIST_ENTRY { 29 | struct _LIST_ENTRY *Flink; 30 | struct _LIST_ENTRY *Blink; 31 | } LIST_ENTRY, EFI_LIST_ENTRY; 32 | 33 | #endif 34 | 35 | 36 | // 37 | // VOID 38 | // InitializeListHead( 39 | // LIST_ENTRY *ListHead 40 | // ); 41 | // 42 | 43 | #define InitializeListHead(ListHead) \ 44 | (ListHead)->Flink = ListHead; \ 45 | (ListHead)->Blink = ListHead; 46 | 47 | // 48 | // BOOLEAN 49 | // IsListEmpty( 50 | // PLIST_ENTRY ListHead 51 | // ); 52 | // 53 | 54 | #define IsListEmpty(ListHead) \ 55 | ((ListHead)->Flink == (ListHead)) 56 | 57 | // 58 | // VOID 59 | // RemoveEntryList( 60 | // PLIST_ENTRY Entry 61 | // ); 62 | // 63 | 64 | #define _RemoveEntryList(Entry) { \ 65 | LIST_ENTRY *_Blink, *_Flink; \ 66 | _Flink = (Entry)->Flink; \ 67 | _Blink = (Entry)->Blink; \ 68 | _Blink->Flink = _Flink; \ 69 | _Flink->Blink = _Blink; \ 70 | } 71 | 72 | #if EFI_DEBUG 73 | #define RemoveEntryList(Entry) \ 74 | _RemoveEntryList(Entry); \ 75 | (Entry)->Flink = (LIST_ENTRY *) BAD_POINTER; \ 76 | (Entry)->Blink = (LIST_ENTRY *) BAD_POINTER; 77 | #else 78 | #define RemoveEntryList(Entry) \ 79 | _RemoveEntryList(Entry); 80 | #endif 81 | 82 | // 83 | // VOID 84 | // InsertTailList( 85 | // PLIST_ENTRY ListHead, 86 | // PLIST_ENTRY Entry 87 | // ); 88 | // 89 | 90 | #define InsertTailList(ListHead,Entry) {\ 91 | LIST_ENTRY *_ListHead, *_Blink; \ 92 | _ListHead = (ListHead); \ 93 | _Blink = _ListHead->Blink; \ 94 | (Entry)->Flink = _ListHead; \ 95 | (Entry)->Blink = _Blink; \ 96 | _Blink->Flink = (Entry); \ 97 | _ListHead->Blink = (Entry); \ 98 | } 99 | 100 | // 101 | // VOID 102 | // InsertHeadList( 103 | // PLIST_ENTRY ListHead, 104 | // PLIST_ENTRY Entry 105 | // ); 106 | // 107 | 108 | #define InsertHeadList(ListHead,Entry) {\ 109 | LIST_ENTRY *_ListHead, *_Flink; \ 110 | _ListHead = (ListHead); \ 111 | _Flink = _ListHead->Flink; \ 112 | (Entry)->Flink = _Flink; \ 113 | (Entry)->Blink = _ListHead; \ 114 | _Flink->Blink = (Entry); \ 115 | _ListHead->Flink = (Entry); \ 116 | } 117 | 118 | // VOID 119 | // SwapListEntries( 120 | // PLIST_ENTRY Entry1, 121 | // PLIST_ENTRY Entry2 122 | // ); 123 | // 124 | // Put Entry2 before Entry1 125 | // 126 | #define SwapListEntries(Entry1,Entry2) {\ 127 | LIST_ENTRY *Entry1Flink, *Entry1Blink; \ 128 | LIST_ENTRY *Entry2Flink, *Entry2Blink; \ 129 | Entry2Flink = (Entry2)->Flink; \ 130 | Entry2Blink = (Entry2)->Blink; \ 131 | Entry1Flink = (Entry1)->Flink; \ 132 | Entry1Blink = (Entry1)->Blink; \ 133 | Entry2Blink->Flink = Entry2Flink; \ 134 | Entry2Flink->Blink = Entry2Blink; \ 135 | (Entry2)->Flink = Entry1; \ 136 | (Entry2)->Blink = Entry1Blink; \ 137 | Entry1Blink->Flink = (Entry2); \ 138 | (Entry1)->Blink = (Entry2); \ 139 | } 140 | 141 | // 142 | // EFI_FIELD_OFFSET - returns the byte offset to a field within a structure 143 | // 144 | 145 | #define EFI_FIELD_OFFSET(TYPE,Field) ((UINTN)(intptr_t)(&(((TYPE *) 0)->Field))) 146 | 147 | // 148 | // CONTAINING_RECORD - returns a pointer to the structure 149 | // from one of it's elements. 150 | // 151 | 152 | #define _CR(Record, TYPE, Field) \ 153 | ((TYPE *) ( (CHAR8 *)(Record) - (CHAR8 *) &(((TYPE *) 0)->Field))) 154 | 155 | // 156 | // EDK2 uses BASE_CR for the above 157 | // 158 | #define BASE_CR _CR 159 | 160 | #if EFI_DEBUG 161 | #define CR(Record, TYPE, Field, Sig) \ 162 | _CR(Record, TYPE, Field)->Signature != Sig ? \ 163 | (TYPE *) ASSERT_STRUCT(_CR(Record, TYPE, Field), Record) : \ 164 | _CR(Record, TYPE, Field) 165 | #else 166 | #define CR(Record, TYPE, Field, Signature) \ 167 | _CR(Record, TYPE, Field) 168 | #endif 169 | 170 | 171 | // 172 | // A lock structure 173 | // 174 | 175 | typedef struct _FLOCK { 176 | EFI_TPL Tpl; 177 | EFI_TPL OwnerTpl; 178 | UINTN Lock; 179 | } FLOCK; 180 | 181 | #endif 182 | 183 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/efipart.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_PART_H 2 | #define _EFI_PART_H 3 | 4 | /*++ 5 | 6 | Copyright (c) 1998 Intel Corporation 7 | 8 | Module Name: 9 | 10 | efipart.h 11 | 12 | Abstract: 13 | Info about disk partitions and Master Boot Records 14 | 15 | 16 | 17 | 18 | Revision History 19 | 20 | --*/ 21 | 22 | // 23 | // 24 | // 25 | 26 | #define EFI_PARTITION 0xef 27 | #define MBR_SIZE 512 28 | 29 | #pragma pack(1) 30 | 31 | typedef struct { 32 | UINT8 BootIndicator; 33 | UINT8 StartHead; 34 | UINT8 StartSector; 35 | UINT8 StartTrack; 36 | UINT8 OSIndicator; 37 | UINT8 EndHead; 38 | UINT8 EndSector; 39 | UINT8 EndTrack; 40 | UINT8 StartingLBA[4]; 41 | UINT8 SizeInLBA[4]; 42 | } MBR_PARTITION_RECORD; 43 | 44 | #define EXTRACT_UINT32(D) (UINT32)(D[0] | (D[1] << 8) | (D[2] << 16) | (D[3] << 24)) 45 | 46 | #define MBR_SIGNATURE 0xaa55 47 | #define MIN_MBR_DEVICE_SIZE 0x80000 48 | #define MBR_ERRATA_PAD 0x40000 // 128 MB 49 | 50 | #define MAX_MBR_PARTITIONS 4 51 | typedef struct { 52 | UINT8 BootStrapCode[440]; 53 | UINT8 UniqueMbrSignature[4]; 54 | UINT8 Unknown[2]; 55 | MBR_PARTITION_RECORD Partition[MAX_MBR_PARTITIONS]; 56 | UINT16 Signature; 57 | } MASTER_BOOT_RECORD; 58 | #pragma pack() 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/efipoint.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 by John Cronin 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | * THE SOFTWARE. 20 | */ 21 | 22 | #ifndef _EFI_POINT_H 23 | #define _EFI_POINT_H 24 | 25 | #define EFI_SIMPLE_POINTER_PROTOCOL_GUID \ 26 | { 0x31878c87, 0xb75, 0x11d5, { 0x9a, 0x4f, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } } 27 | 28 | INTERFACE_DECL(_EFI_SIMPLE_POINTER); 29 | 30 | typedef struct { 31 | INT32 RelativeMovementX; 32 | INT32 RelativeMovementY; 33 | INT32 RelativeMovementZ; 34 | BOOLEAN LeftButton; 35 | BOOLEAN RightButton; 36 | } EFI_SIMPLE_POINTER_STATE; 37 | 38 | typedef struct { 39 | UINT64 ResolutionX; 40 | UINT64 ResolutionY; 41 | UINT64 ResolutionZ; 42 | BOOLEAN LeftButton; 43 | BOOLEAN RightButton; 44 | } EFI_SIMPLE_POINTER_MODE; 45 | 46 | typedef 47 | EFI_STATUS 48 | (EFIAPI *EFI_SIMPLE_POINTER_RESET) ( 49 | IN struct _EFI_SIMPLE_POINTER *This, 50 | IN BOOLEAN ExtendedVerification 51 | ); 52 | 53 | typedef 54 | EFI_STATUS 55 | (EFIAPI *EFI_SIMPLE_POINTER_GET_STATE) ( 56 | IN struct _EFI_SIMPLE_POINTER *This, 57 | IN OUT EFI_SIMPLE_POINTER_STATE *State 58 | ); 59 | 60 | typedef struct _EFI_SIMPLE_POINTER { 61 | EFI_SIMPLE_POINTER_RESET Reset; 62 | EFI_SIMPLE_POINTER_GET_STATE GetState; 63 | EFI_EVENT WaitForInput; 64 | EFI_SIMPLE_POINTER_MODE *Mode; 65 | } EFI_SIMPLE_POINTER_PROTOCOL; 66 | 67 | #define EFI_ABSOLUTE_POINTER_PROTOCOL_GUID \ 68 | { 0x8D59D32B, 0xC655, 0x4AE9, { 0x9B, 0x15, 0xF2, 0x59, 0x04, 0x99, 0x2A, 0x43 } } 69 | 70 | INTERFACE_DECL(_EFI_ABSOLUTE_POINTER_PROTOCOL); 71 | 72 | typedef struct { 73 | UINT64 AbsoluteMinX; 74 | UINT64 AbsoluteMinY; 75 | UINT64 AbsoluteMinZ; 76 | UINT64 AbsoluteMaxX; 77 | UINT64 AbsoluteMaxY; 78 | UINT64 AbsoluteMaxZ; 79 | UINT32 Attributes; 80 | } EFI_ABSOLUTE_POINTER_MODE; 81 | 82 | typedef struct { 83 | UINT64 CurrentX; 84 | UINT64 CurrentY; 85 | UINT64 CurrentZ; 86 | UINT32 ActiveButtons; 87 | } EFI_ABSOLUTE_POINTER_STATE; 88 | 89 | #define EFI_ABSP_SupportsAltActive 0x00000001 90 | #define EFI_ABSP_SupportsPressureAsZ 0x00000002 91 | #define EFI_ABSP_TouchActive 0x00000001 92 | #define EFI_ABS_AltActive 0x00000002 93 | 94 | typedef 95 | EFI_STATUS 96 | (EFIAPI *EFI_ABSOLUTE_POINTER_RESET) ( 97 | IN struct _EFI_ABSOLUTE_POINTER_PROTOCOL *This, 98 | IN BOOLEAN ExtendedVerification 99 | ); 100 | 101 | typedef 102 | EFI_STATUS 103 | (EFIAPI *EFI_ABSOLUTE_POINTER_GET_STATE) ( 104 | IN struct _EFI_ABSOLUTE_POINTER_PROTOCOL *This, 105 | IN OUT EFI_ABSOLUTE_POINTER_STATE *State 106 | ); 107 | 108 | typedef struct _EFI_ABSOLUTE_POINTER_PROTOCOL { 109 | EFI_ABSOLUTE_POINTER_RESET Reset; 110 | EFI_ABSOLUTE_POINTER_GET_STATE GetState; 111 | EFI_EVENT WaitForInput; 112 | EFI_ABSOLUTE_POINTER_MODE *Mode; 113 | } EFI_ABSOLUTE_POINTER_PROTOCOL; 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/efirtlib.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_RT_LIB_INCLUDE_ 2 | #define _EFI_RT_LIB_INCLUDE_ 3 | /*++ 4 | 5 | Copyright (c) 1998 Intel Corporation 6 | 7 | Module Name: 8 | 9 | efilib.h 10 | 11 | Abstract: 12 | 13 | EFI Runtime library functions 14 | 15 | 16 | 17 | Revision History 18 | 19 | --*/ 20 | 21 | #include "efidebug.h" 22 | #include "efipart.h" 23 | #if defined(_M_X64) || defined(__x86_64__) || defined(__amd64__) 24 | #include "x86_64/efilibplat.h" 25 | #elif defined(_M_IX86) || defined(__i386__) 26 | #include "ia32/efilibplat.h" 27 | #elif defined(_M_IA64) || defined(__ia64__) 28 | #include "ia64/efilibplat.h" 29 | #elif defined (_M_ARM64) || defined(__aarch64__) 30 | #include "aarch64/efilibplat.h" 31 | #elif defined (_M_ARM) || defined(__arm__) 32 | #include "arm/efilibplat.h" 33 | #elif defined (_M_MIPS64) || defined(__mips64__) 34 | #include "mips64el/efilibplat.h" 35 | #elif defined (__riscv) && __riscv_xlen == 64 36 | #include "riscv64/efilibplat.h" 37 | #endif 38 | 39 | 40 | VOID 41 | RUNTIMEFUNCTION 42 | RtZeroMem ( 43 | IN VOID *Buffer, 44 | IN UINTN Size 45 | ); 46 | 47 | VOID 48 | RUNTIMEFUNCTION 49 | RtSetMem ( 50 | IN VOID *Buffer, 51 | IN UINTN Size, 52 | IN UINT8 Value 53 | ); 54 | 55 | VOID 56 | RUNTIMEFUNCTION 57 | RtCopyMem ( 58 | IN VOID *Dest, 59 | IN CONST VOID *Src, 60 | IN UINTN len 61 | ); 62 | 63 | INTN 64 | RUNTIMEFUNCTION 65 | RtCompareMem ( 66 | IN CONST VOID *Dest, 67 | IN CONST VOID *Src, 68 | IN UINTN len 69 | ); 70 | 71 | INTN 72 | RUNTIMEFUNCTION 73 | RtStrCmp ( 74 | IN CONST CHAR16 *s1, 75 | IN CONST CHAR16 *s2 76 | ); 77 | 78 | 79 | VOID 80 | RUNTIMEFUNCTION 81 | RtStrCpy ( 82 | IN CHAR16 *Dest, 83 | IN CONST CHAR16 *Src 84 | ); 85 | 86 | VOID 87 | RUNTIMEFUNCTION 88 | RtStrnCpy ( 89 | IN CHAR16 *Dest, 90 | IN CONST CHAR16 *Src, 91 | IN UINTN Len 92 | ); 93 | 94 | CHAR16 * 95 | RUNTIMEFUNCTION 96 | RtStpCpy ( 97 | IN CHAR16 *Dest, 98 | IN CONST CHAR16 *Src 99 | ); 100 | 101 | CHAR16 * 102 | RUNTIMEFUNCTION 103 | RtStpnCpy ( 104 | IN CHAR16 *Dest, 105 | IN CONST CHAR16 *Src, 106 | IN UINTN Len 107 | ); 108 | 109 | VOID 110 | RUNTIMEFUNCTION 111 | RtStrCat ( 112 | IN CHAR16 *Dest, 113 | IN CONST CHAR16 *Src 114 | ); 115 | 116 | VOID 117 | RUNTIMEFUNCTION 118 | RtStrnCat ( 119 | IN CHAR16 *Dest, 120 | IN CONST CHAR16 *Src, 121 | IN UINTN Len 122 | ); 123 | 124 | UINTN 125 | RUNTIMEFUNCTION 126 | RtStrLen ( 127 | IN CONST CHAR16 *s1 128 | ); 129 | 130 | UINTN 131 | RUNTIMEFUNCTION 132 | RtStrnLen ( 133 | IN CONST CHAR16 *s1, 134 | IN UINTN Len 135 | ); 136 | 137 | UINTN 138 | RUNTIMEFUNCTION 139 | RtStrSize ( 140 | IN CONST CHAR16 *s1 141 | ); 142 | 143 | INTN 144 | RUNTIMEFUNCTION 145 | RtCompareGuid ( 146 | IN EFI_GUID *Guid1, 147 | IN EFI_GUID *Guid2 148 | ); 149 | 150 | UINT8 151 | RUNTIMEFUNCTION 152 | RtDecimaltoBCD( 153 | IN UINT8 BcdValue 154 | ); 155 | 156 | UINT8 157 | RUNTIMEFUNCTION 158 | RtBCDtoDecimal( 159 | IN UINT8 BcdValue 160 | ); 161 | 162 | // 163 | // Virtual mapping transition support. (Only used during 164 | // the virtual address change transisition) 165 | // 166 | 167 | VOID 168 | RUNTIMEFUNCTION 169 | RtLibEnableVirtualMappings ( 170 | VOID 171 | ); 172 | 173 | VOID 174 | RUNTIMEFUNCTION 175 | RtConvertList ( 176 | IN UINTN DebugDisposition, 177 | IN OUT LIST_ENTRY *ListHead 178 | ); 179 | 180 | VOID 181 | RUNTIMEFUNCTION 182 | RtAcquireLock ( 183 | IN FLOCK *Lock 184 | ); 185 | 186 | VOID 187 | RUNTIMEFUNCTION 188 | RtReleaseLock ( 189 | IN FLOCK *Lock 190 | ); 191 | 192 | 193 | #endif 194 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/efiser.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_SER_H 2 | #define _EFI_SER_H 3 | 4 | /*++ 5 | 6 | Copyright (c) 1998 Intel Corporation 7 | 8 | Module Name: 9 | 10 | efiser.h 11 | 12 | Abstract: 13 | 14 | EFI serial protocol 15 | 16 | Revision History 17 | 18 | --*/ 19 | 20 | // 21 | // Serial protocol 22 | // 23 | 24 | #define EFI_SERIAL_IO_PROTOCOL_GUID \ 25 | { 0xBB25CF6F, 0xF1D4, 0x11D2, {0x9A, 0x0C, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0xFD} } 26 | #define SERIAL_IO_PROTOCOL EFI_SERIAL_IO_PROTOCOL_GUID 27 | 28 | INTERFACE_DECL(_EFI_SERIAL_IO_PROTOCOL); 29 | 30 | typedef enum { 31 | DefaultParity, 32 | NoParity, 33 | EvenParity, 34 | OddParity, 35 | MarkParity, 36 | SpaceParity 37 | } EFI_PARITY_TYPE; 38 | 39 | typedef enum { 40 | DefaultStopBits, 41 | OneStopBit, // 1 stop bit 42 | OneFiveStopBits, // 1.5 stop bits 43 | TwoStopBits // 2 stop bits 44 | } EFI_STOP_BITS_TYPE; 45 | 46 | #define EFI_SERIAL_CLEAR_TO_SEND 0x0010 // RO 47 | #define EFI_SERIAL_DATA_SET_READY 0x0020 // RO 48 | #define EFI_SERIAL_RING_INDICATE 0x0040 // RO 49 | #define EFI_SERIAL_CARRIER_DETECT 0x0080 // RO 50 | #define EFI_SERIAL_REQUEST_TO_SEND 0x0002 // WO 51 | #define EFI_SERIAL_DATA_TERMINAL_READY 0x0001 // WO 52 | #define EFI_SERIAL_INPUT_BUFFER_EMPTY 0x0100 // RO 53 | #define EFI_SERIAL_OUTPUT_BUFFER_EMPTY 0x0200 // RO 54 | #define EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE 0x1000 // RW 55 | #define EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE 0x2000 // RW 56 | #define EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE 0x4000 // RW 57 | 58 | typedef 59 | EFI_STATUS 60 | (EFIAPI *EFI_SERIAL_RESET) ( 61 | IN struct _EFI_SERIAL_IO_PROTOCOL *This 62 | ); 63 | 64 | typedef 65 | EFI_STATUS 66 | (EFIAPI *EFI_SERIAL_SET_ATTRIBUTES) ( 67 | IN struct _EFI_SERIAL_IO_PROTOCOL *This, 68 | IN UINT64 BaudRate, 69 | IN UINT32 ReceiveFifoDepth, 70 | IN UINT32 Timeout, 71 | IN EFI_PARITY_TYPE Parity, 72 | IN UINT8 DataBits, 73 | IN EFI_STOP_BITS_TYPE StopBits 74 | ); 75 | 76 | typedef 77 | EFI_STATUS 78 | (EFIAPI *EFI_SERIAL_SET_CONTROL_BITS) ( 79 | IN struct _EFI_SERIAL_IO_PROTOCOL *This, 80 | IN UINT32 Control 81 | ); 82 | 83 | typedef 84 | EFI_STATUS 85 | (EFIAPI *EFI_SERIAL_GET_CONTROL_BITS) ( 86 | IN struct _EFI_SERIAL_IO_PROTOCOL *This, 87 | OUT UINT32 *Control 88 | ); 89 | 90 | typedef 91 | EFI_STATUS 92 | (EFIAPI *EFI_SERIAL_WRITE) ( 93 | IN struct _EFI_SERIAL_IO_PROTOCOL *This, 94 | IN OUT UINTN *BufferSize, 95 | IN VOID *Buffer 96 | ); 97 | 98 | typedef 99 | EFI_STATUS 100 | (EFIAPI *EFI_SERIAL_READ) ( 101 | IN struct _EFI_SERIAL_IO_PROTOCOL *This, 102 | IN OUT UINTN *BufferSize, 103 | OUT VOID *Buffer 104 | ); 105 | 106 | typedef struct { 107 | UINT32 ControlMask; 108 | 109 | // current Attributes 110 | UINT32 Timeout; 111 | UINT64 BaudRate; 112 | UINT32 ReceiveFifoDepth; 113 | UINT32 DataBits; 114 | UINT32 Parity; 115 | UINT32 StopBits; 116 | } SERIAL_IO_MODE; 117 | 118 | #define SERIAL_IO_INTERFACE_REVISION 0x00010000 119 | 120 | typedef struct _EFI_SERIAL_IO_PROTOCOL { 121 | UINT32 Revision; 122 | EFI_SERIAL_RESET Reset; 123 | EFI_SERIAL_SET_ATTRIBUTES SetAttributes; 124 | EFI_SERIAL_SET_CONTROL_BITS SetControl; 125 | EFI_SERIAL_GET_CONTROL_BITS GetControl; 126 | EFI_SERIAL_WRITE Write; 127 | EFI_SERIAL_READ Read; 128 | 129 | SERIAL_IO_MODE *Mode; 130 | } EFI_SERIAL_IO_PROTOCOL; 131 | 132 | typedef struct _EFI_SERIAL_IO_PROTOCOL _SERIAL_IO_INTERFACE; 133 | typedef EFI_SERIAL_IO_PROTOCOL SERIAL_IO_INTERFACE; 134 | 135 | #endif 136 | 137 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/efisetjmp.h: -------------------------------------------------------------------------------- 1 | #ifndef GNU_EFI_SETJMP_H 2 | #define GNU_EFI_SETJMP_H 3 | 4 | #include "eficompiler.h" 5 | #include "efisetjmp_arch.h" 6 | 7 | extern UINTN setjmp(jmp_buf env) __attribute__((returns_twice)); 8 | extern VOID longjmp(jmp_buf env, UINTN value) __attribute__((noreturn)); 9 | 10 | #endif /* GNU_EFI_SETJMP_H */ 11 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/efishellintf.h: -------------------------------------------------------------------------------- 1 | /** @file 2 | SHELL_INTERFACE_PROTOCOL from EDK shell (no spec). 3 | 4 | Shell Interface - additional information (over image_info) provided 5 | to an application started by the shell. 6 | 7 | ConIo provides a file-style interface to the console. 8 | 9 | The shell interface's and data (including ConIo) are only valid during 10 | the applications Entry Point. Once the application returns from it's 11 | entry point the data is freed by the invoking shell. 12 | 13 | Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
14 | This program and the accompanying materials 15 | are licensed and made available under the terms and conditions of the BSD License 16 | which accompanies this distribution. The full text of the license may be found at 17 | http://opensource.org/licenses/bsd-license.php 18 | 19 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 20 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 21 | 22 | **/ 23 | /* 24 | * This is based on ShellPkg/Include/Protocol/EfiShellInterface.h from EDK II. 25 | */ 26 | 27 | #ifndef _SHELLINTERFACE_H_ 28 | #define _SHELLINTERFACE_H_ 29 | 30 | 31 | #define SHELL_INTERFACE_PROTOCOL_GUID \ 32 | { \ 33 | 0x47c7b223, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} \ 34 | } 35 | 36 | /// 37 | /// Bit definitions for EFI_SHELL_ARG_INFO 38 | /// 39 | typedef enum { 40 | ARG_NO_ATTRIB = 0x0, 41 | ARG_IS_QUOTED = 1<<0, 42 | ARG_PARTIALLY_QUOTED = 1<<1, 43 | ARG_FIRST_HALF_QUOTED = 1<<2, 44 | ARG_FIRST_CHAR_IS_ESC = 1<<3 45 | } EFI_SHELL_ARG_INFO_TYPES; 46 | 47 | /// 48 | /// Attributes for an argument. 49 | /// 50 | typedef struct _EFI_SHELL_ARG_INFO { 51 | UINT32 Attributes; 52 | } EFI_SHELL_ARG_INFO; 53 | 54 | /// 55 | /// This protocol provides access to additional information about a shell application. 56 | /// 57 | typedef struct { 58 | /// 59 | /// Handle back to original image handle & image information. 60 | /// 61 | EFI_HANDLE ImageHandle; 62 | EFI_LOADED_IMAGE *Info; 63 | 64 | /// 65 | /// Parsed arg list converted more C-like format. 66 | /// 67 | CHAR16 **Argv; 68 | UINTN Argc; 69 | 70 | /// 71 | /// Storage for file redirection args after parsing. 72 | /// 73 | CHAR16 **RedirArgv; 74 | UINTN RedirArgc; 75 | 76 | /// 77 | /// A file style handle for console io. 78 | /// 79 | EFI_FILE *StdIn; 80 | EFI_FILE *StdOut; 81 | EFI_FILE *StdErr; 82 | 83 | /// 84 | /// List of attributes for each argument. 85 | /// 86 | EFI_SHELL_ARG_INFO *ArgInfo; 87 | 88 | /// 89 | /// Whether we are echoing. 90 | /// 91 | BOOLEAN EchoOn; 92 | } EFI_SHELL_INTERFACE; 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/efistdarg.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFISTDARG_H_ 2 | #define _EFISTDARG_H_ 3 | 4 | /*++ 5 | 6 | Copyright (c) 1998 Intel Corporation 7 | 8 | Module Name: 9 | 10 | devpath.h 11 | 12 | Abstract: 13 | 14 | Defines for parsing the EFI Device Path structures 15 | 16 | 17 | 18 | Revision History 19 | 20 | --*/ 21 | 22 | #if !defined(GNU_EFI_USE_EXTERNAL_STDARG) && !defined(_MSC_VER) 23 | typedef __builtin_va_list va_list; 24 | 25 | # define va_start(v,l) __builtin_va_start(v,l) 26 | # define va_end(v) __builtin_va_end(v) 27 | # define va_arg(v,l) __builtin_va_arg(v,l) 28 | # define va_copy(d,s) __builtin_va_copy(d,s) 29 | #else 30 | # include 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/efiui.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_UI_H 2 | #define _EFI_UI_H 3 | 4 | /*++ 5 | 6 | Copyright (c) 200 Intel Corporation 7 | 8 | Module Name: 9 | 10 | EfiUi.h 11 | 12 | Abstract: 13 | Protocol used to build User Interface (UI) stuff. 14 | 15 | This protocol is just data. It is a multi dimentional array. 16 | For each string there is an array of UI_STRING_ENTRY. Each string 17 | is for a different language translation of the same string. The list 18 | is terminated by a NULL UiString. There can be any number of 19 | UI_STRING_ENTRY arrays. A NULL array terminates the list. A NULL array 20 | entry contains all zeros. 21 | 22 | Thus the shortest possible EFI_UI_PROTOCOL has three UI_STRING_ENTRY. 23 | The String, it's NULL terminator, and the NULL terminator for the entire 24 | thing. 25 | 26 | 27 | Revision History 28 | 29 | --*/ 30 | 31 | #define EFI_UI_INTERFACE_PROTOCOL_GUID \ 32 | { 0x32dd7981, 0x2d27, 0x11d4, {0xbc, 0x8b, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} } 33 | #define EFI_UI_PROTOCOL EFI_UI_INTERFACE_PROTOCOL_GUID 34 | 35 | 36 | typedef enum { 37 | UiDeviceString, 38 | UiVendorString, 39 | UiMaxString 40 | } UI_STRING_TYPE; 41 | 42 | typedef struct { 43 | ISO_639_2 *LangCode; 44 | CHAR16 *UiString; 45 | } UI_STRING_ENTRY; 46 | 47 | #define EFI_UI_INTERFACE_PROTOCOL_VERSION 0x00010000 48 | #define EFI_UI_VERSION EFI_UI_INTERFACE_PROTOCOL_VERSION 49 | 50 | typedef struct _EFI_UI_INTERFACE_PROTOCOL { 51 | UINT32 Version; 52 | UI_STRING_ENTRY *Entry; 53 | } EFI_UI_INTERFACE_PROTOCOL; 54 | 55 | typedef struct _EFI_UI_INTERFACE_PROTOCOL _UI_INTERFACE; 56 | typedef EFI_UI_INTERFACE_PROTOCOL UI_INTERFACE; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/ia32/efilibplat.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 1998 Intel Corporation 4 | 5 | Module Name: 6 | 7 | efilibplat.h 8 | 9 | Abstract: 10 | 11 | EFI to compile bindings 12 | 13 | 14 | 15 | 16 | Revision History 17 | 18 | --*/ 19 | 20 | VOID 21 | InitializeLibPlatform ( 22 | IN EFI_HANDLE ImageHandle, 23 | IN EFI_SYSTEM_TABLE *SystemTable 24 | ); 25 | 26 | 27 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/ia32/efisetjmp_arch.h: -------------------------------------------------------------------------------- 1 | #ifndef GNU_EFI_IA32_SETJMP_H 2 | #define GNU_EFI_IA32_SETJMP_H 3 | 4 | #define JMPBUF_ALIGN 4 5 | 6 | typedef struct { 7 | UINT32 Ebx; 8 | UINT32 Esi; 9 | UINT32 Edi; 10 | UINT32 Ebp; 11 | UINT32 Esp; 12 | UINT32 Eip; 13 | } ALIGN(JMPBUF_ALIGN) jmp_buf[1]; 14 | 15 | #endif /* GNU_EFI_IA32_SETJMP_H */ 16 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/ia64/efilibplat.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_LIB_PLAT_H 2 | #define _EFI_LIB_PLAT_H 3 | /*++ 4 | 5 | Copyright (c) 1998 Intel Corporation 6 | 7 | Module Name: 8 | 9 | efilibplat.h 10 | 11 | Abstract: 12 | 13 | EFI to compile bindings 14 | 15 | 16 | 17 | Revision History 18 | 19 | --*/ 20 | 21 | #include "salproc.h" 22 | 23 | 24 | VOID 25 | InitializeLibPlatform ( 26 | IN EFI_HANDLE ImageHandle, 27 | IN EFI_SYSTEM_TABLE *SystemTable 28 | ); 29 | 30 | VOID 31 | LibInitSalAndPalProc( 32 | OUT PLABEL *SalPlabel, 33 | OUT UINT64 *PalEntry 34 | ); 35 | 36 | EFI_STATUS 37 | LibGetSalIoPortMapping ( 38 | OUT UINT64 *IoPortMapping 39 | ); 40 | 41 | EFI_STATUS 42 | LibGetSalIpiBlock ( 43 | OUT UINT64 *IpiBlock 44 | ); 45 | 46 | EFI_STATUS 47 | LibGetSalWakeupVector ( 48 | OUT UINT64 *WakeVector 49 | ); 50 | 51 | VOID * 52 | LibSearchSalSystemTable ( 53 | IN UINT8 EntryType 54 | ); 55 | 56 | 57 | VOID 58 | LibSalProc ( 59 | IN UINT64 Arg1, 60 | IN UINT64 Arg2, 61 | IN UINT64 Arg3, 62 | IN UINT64 Arg4, 63 | IN UINT64 Arg5, 64 | IN UINT64 Arg6, 65 | IN UINT64 Arg7, 66 | IN UINT64 Arg8, 67 | OUT rArg *Results OPTIONAL 68 | ); 69 | 70 | VOID 71 | LibPalProc ( 72 | IN UINT64 Arg1, 73 | IN UINT64 Arg2, 74 | IN UINT64 Arg3, 75 | IN UINT64 Arg4, 76 | OUT rArg *Results OPTIONAL 77 | ); 78 | 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/ia64/efisetjmp_arch.h: -------------------------------------------------------------------------------- 1 | #ifndef GNU_EFI_IA64_SETJMP_H 2 | #define GNU_EFI_IA64_SETJMP_H 3 | 4 | #define JMPBUF_ALIGN 0x10 5 | 6 | typedef struct { 7 | UINT64 F2[2]; 8 | UINT64 F3[2]; 9 | UINT64 F4[2]; 10 | UINT64 F5[2]; 11 | UINT64 F16[2]; 12 | UINT64 F17[2]; 13 | UINT64 F18[2]; 14 | UINT64 F19[2]; 15 | UINT64 F20[2]; 16 | UINT64 F21[2]; 17 | UINT64 F22[2]; 18 | UINT64 F23[2]; 19 | UINT64 F24[2]; 20 | UINT64 F25[2]; 21 | UINT64 F26[2]; 22 | UINT64 F27[2]; 23 | UINT64 F28[2]; 24 | UINT64 F29[2]; 25 | UINT64 F30[2]; 26 | UINT64 F31[2]; 27 | UINT64 R4; 28 | UINT64 R5; 29 | UINT64 R6; 30 | UINT64 R7; 31 | UINT64 SP; 32 | UINT64 BR0; 33 | UINT64 BR1; 34 | UINT64 BR2; 35 | UINT64 BR3; 36 | UINT64 BR4; 37 | UINT64 BR5; 38 | UINT64 InitialUNAT; 39 | UINT64 AfterSpillUNAT; 40 | UINT64 PFS; 41 | UINT64 BSP; 42 | UINT64 Predicates; 43 | UINT64 LoopCount; 44 | UINT64 FPSR; 45 | } ALIGN(JMPBUF_ALIGN) jmp_buf[1]; 46 | 47 | #endif /* GNU_EFI_IA64_SETJMP_H */ 48 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/inc.mak: -------------------------------------------------------------------------------- 1 | 2 | 3 | INC_DEPS = $(INC_DEPS) \ 4 | efi.h \ 5 | efiapi.h \ 6 | efibind.h \ 7 | eficon.h \ 8 | efidebug.h \ 9 | efidef.h \ 10 | efidevp.h \ 11 | efierr.h \ 12 | efifs.h \ 13 | efilib.h \ 14 | efipart.h \ 15 | efipciio.h \ 16 | efiprot.h \ 17 | efipxe.h \ 18 | efivar.h \ 19 | pe.h \ 20 | efiip.h \ 21 | efiudp.h \ 22 | efitcp.h \ 23 | stdarg.h 24 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/lib.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 1998 Intel Corporation 4 | 5 | Module Name: 6 | 7 | lib.h 8 | 9 | Abstract: 10 | 11 | EFI library header files 12 | 13 | 14 | 15 | Revision History 16 | 17 | --*/ 18 | 19 | #ifdef __GNUC__ 20 | #pragma GCC visibility push(hidden) 21 | #endif 22 | 23 | #include "efi.h" 24 | #include "efilib.h" 25 | #include "efirtlib.h" 26 | 27 | // 28 | // Include non architectural protocols 29 | // 30 | #include "protocol/efivar.h" 31 | #include "protocol/legacyboot.h" 32 | #include "protocol/intload.h" 33 | #include "protocol/vgaclass.h" 34 | #include "protocol/eficonsplit.h" 35 | #include "protocol/adapterdebug.h" 36 | #include "protocol/intload.h" 37 | 38 | #include "efigpt.h" 39 | #include "libsmbios.h" 40 | 41 | // 42 | // Prototypes 43 | // 44 | 45 | VOID 46 | InitializeGuid ( 47 | VOID 48 | ); 49 | 50 | INTN EFIAPI 51 | LibStubStriCmp ( 52 | IN EFI_UNICODE_COLLATION_INTERFACE *This, 53 | IN CHAR16 *S1, 54 | IN CHAR16 *S2 55 | ); 56 | 57 | BOOLEAN EFIAPI 58 | LibStubMetaiMatch ( 59 | IN EFI_UNICODE_COLLATION_INTERFACE *This, 60 | IN CHAR16 *String, 61 | IN CHAR16 *Pattern 62 | ); 63 | 64 | VOID EFIAPI 65 | LibStubStrLwrUpr ( 66 | IN EFI_UNICODE_COLLATION_INTERFACE *This, 67 | IN CHAR16 *Str 68 | ); 69 | 70 | BOOLEAN 71 | LibMatchDevicePaths ( 72 | IN EFI_DEVICE_PATH *Multi, 73 | IN EFI_DEVICE_PATH *Single 74 | ); 75 | 76 | EFI_DEVICE_PATH * 77 | LibDuplicateDevicePathInstance ( 78 | IN EFI_DEVICE_PATH *DevPath 79 | ); 80 | 81 | 82 | // 83 | // Globals 84 | // 85 | extern BOOLEAN LibInitialized; 86 | extern BOOLEAN LibFwInstance; 87 | extern EFI_HANDLE LibImageHandle; 88 | extern SIMPLE_TEXT_OUTPUT_INTERFACE *LibRuntimeDebugOut; 89 | extern EFI_UNICODE_COLLATION_INTERFACE *UnicodeInterface; 90 | extern EFI_UNICODE_COLLATION_INTERFACE LibStubUnicodeInterface; 91 | extern EFI_RAISE_TPL LibRuntimeRaiseTPL; 92 | extern EFI_RESTORE_TPL LibRuntimeRestoreTPL; 93 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/libsmbios.h: -------------------------------------------------------------------------------- 1 | #ifndef _LIB_SMBIOS_H 2 | #define _LIB_SMBIOS_H 3 | /*++ 4 | 5 | Copyright (c) 2000 Intel Corporation 6 | 7 | Module Name: 8 | 9 | LibSmbios.h 10 | 11 | Abstract: 12 | 13 | Lib include for SMBIOS services. Used to get system serial number and GUID 14 | 15 | Revision History 16 | 17 | --*/ 18 | 19 | // 20 | // Define SMBIOS tables. 21 | // 22 | #pragma pack(1) 23 | typedef struct { 24 | UINT8 AnchorString[4]; 25 | UINT8 EntryPointStructureChecksum; 26 | UINT8 EntryPointLength; 27 | UINT8 MajorVersion; 28 | UINT8 MinorVersion; 29 | UINT16 MaxStructureSize; 30 | UINT8 EntryPointRevision; 31 | UINT8 FormattedArea[5]; 32 | UINT8 IntermediateAnchorString[5]; 33 | UINT8 IntermediateChecksum; 34 | UINT16 TableLength; 35 | UINT32 TableAddress; 36 | UINT16 NumberOfSmbiosStructures; 37 | UINT8 SmbiosBcdRevision; 38 | } SMBIOS_STRUCTURE_TABLE; 39 | 40 | typedef struct { 41 | UINT8 AnchorString[5]; 42 | UINT8 EntryPointStructureChecksum; 43 | UINT8 EntryPointLength; 44 | UINT8 MajorVersion; 45 | UINT8 MinorVersion; 46 | UINT8 DocRev; 47 | UINT8 EntryPointRevision; 48 | UINT8 Reserved; 49 | UINT32 TableMaximumSize; 50 | UINT64 TableAddress; 51 | } SMBIOS3_STRUCTURE_TABLE; 52 | 53 | // 54 | // Please note that SMBIOS structures can be odd byte aligned since the 55 | // unformated section of each record is a set of arbitrary size strings. 56 | // 57 | 58 | typedef struct { 59 | UINT8 Type; 60 | UINT8 Length; 61 | UINT8 Handle[2]; 62 | } SMBIOS_HEADER; 63 | 64 | typedef UINT8 SMBIOS_STRING; 65 | 66 | typedef struct { 67 | SMBIOS_HEADER Hdr; 68 | SMBIOS_STRING Vendor; 69 | SMBIOS_STRING BiosVersion; 70 | UINT8 BiosSegment[2]; 71 | SMBIOS_STRING BiosReleaseDate; 72 | UINT8 BiosSize; 73 | UINT8 BiosCharacteristics[8]; 74 | } SMBIOS_TYPE0; 75 | 76 | typedef struct { 77 | SMBIOS_HEADER Hdr; 78 | SMBIOS_STRING Manufacturer; 79 | SMBIOS_STRING ProductName; 80 | SMBIOS_STRING Version; 81 | SMBIOS_STRING SerialNumber; 82 | 83 | // 84 | // always byte copy this data to prevent alignment faults! 85 | // 86 | EFI_GUID Uuid; 87 | 88 | UINT8 WakeUpType; 89 | } SMBIOS_TYPE1; 90 | 91 | typedef struct { 92 | SMBIOS_HEADER Hdr; 93 | SMBIOS_STRING Manufacturer; 94 | SMBIOS_STRING ProductName; 95 | SMBIOS_STRING Version; 96 | SMBIOS_STRING SerialNumber; 97 | } SMBIOS_TYPE2; 98 | 99 | typedef struct { 100 | SMBIOS_HEADER Hdr; 101 | SMBIOS_STRING Manufacturer; 102 | UINT8 Type; 103 | SMBIOS_STRING Version; 104 | SMBIOS_STRING SerialNumber; 105 | SMBIOS_STRING AssetTag; 106 | UINT8 BootupState; 107 | UINT8 PowerSupplyState; 108 | UINT8 ThermalState; 109 | UINT8 SecurityStatus; 110 | UINT8 OemDefined[4]; 111 | } SMBIOS_TYPE3; 112 | 113 | typedef struct { 114 | SMBIOS_HEADER Hdr; 115 | UINT8 Socket; 116 | UINT8 ProcessorType; 117 | UINT8 ProcessorFamily; 118 | SMBIOS_STRING ProcessorManufacture; 119 | UINT8 ProcessorId[8]; 120 | SMBIOS_STRING ProcessorVersion; 121 | UINT8 Voltage; 122 | UINT8 ExternalClock[2]; 123 | UINT8 MaxSpeed[2]; 124 | UINT8 CurrentSpeed[2]; 125 | UINT8 Status; 126 | UINT8 ProcessorUpgrade; 127 | UINT8 L1CacheHandle[2]; 128 | UINT8 L2CacheHandle[2]; 129 | UINT8 L3CacheHandle[2]; 130 | } SMBIOS_TYPE4; 131 | 132 | typedef union { 133 | SMBIOS_HEADER *Hdr; 134 | SMBIOS_TYPE0 *Type0; 135 | SMBIOS_TYPE1 *Type1; 136 | SMBIOS_TYPE2 *Type2; 137 | SMBIOS_TYPE3 *Type3; 138 | SMBIOS_TYPE4 *Type4; 139 | UINT8 *Raw; 140 | } SMBIOS_STRUCTURE_POINTER; 141 | #pragma pack() 142 | 143 | #endif 144 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/make.inf: -------------------------------------------------------------------------------- 1 | # 2 | # 3 | # 4 | 5 | [sources] 6 | efi.h 7 | efiapi.h 8 | eficon.h 9 | efidebug.h 10 | efidef.h 11 | efidevp.h 12 | efierr.h 13 | efifs.h 14 | efilib.h 15 | efipart.h 16 | efipciio.h 17 | efiprot.h 18 | efipxebc.h 19 | efistdarg.h 20 | efinet.h 21 | efiip.h 22 | efiudp.h 23 | efitcp.h 24 | 25 | [ia32sources] 26 | efibind.h 27 | pe.h 28 | efilibplat.h 29 | 30 | [ia64sources] 31 | efibind.h 32 | pe.h 33 | efilibplat.h 34 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/makefile.hdr: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # This is a machine generated file - DO NOT EDIT 4 | # Generated by genmake.exe 5 | # Generated from make.inf 6 | # Copyright (c) 1998 Intel Corporation 7 | # 8 | 9 | INC_DEPS = $(INC_DEPS) \ 10 | $(SDK_INSTALL_DIR)\include\efi\efi.h \ 11 | $(SDK_INSTALL_DIR)\include\efi\efiapi.h \ 12 | $(SDK_INSTALL_DIR)\include\efi\eficon.h \ 13 | $(SDK_INSTALL_DIR)\include\efi\efidebug.h \ 14 | $(SDK_INSTALL_DIR)\include\efi\efidef.h \ 15 | $(SDK_INSTALL_DIR)\include\efi\efidevp.h \ 16 | $(SDK_INSTALL_DIR)\include\efi\efierr.h \ 17 | $(SDK_INSTALL_DIR)\include\efi\efifs.h \ 18 | $(SDK_INSTALL_DIR)\include\efi\efilib.h \ 19 | $(SDK_INSTALL_DIR)\include\efi\efipart.h \ 20 | $(SDK_INSTALL_DIR)\include\efi\efipciio.h \ 21 | $(SDK_INSTALL_DIR)\include\efi\efiprot.h \ 22 | $(SDK_INSTALL_DIR)\include\efi\efipxebc.h \ 23 | $(SDK_INSTALL_DIR)\include\efi\efistdarg.h \ 24 | $(SDK_INSTALL_DIR)\include\efi\efinet.h \ 25 | $(SDK_INSTALL_DIR)\include\efi\efiip.h \ 26 | $(SDK_INSTALL_DIR)\include\efi\efiudp.h \ 27 | $(SDK_INSTALL_DIR)\include\efi\efitcp.h \ 28 | 29 | 30 | !IF "$(PROCESSOR)" == "Ia32" 31 | INC_DEPS = $(INC_DEPS) \ 32 | $(SDK_INSTALL_DIR)\include\efi\Ia32\efibind.h \ 33 | $(SDK_INSTALL_DIR)\include\efi\Ia32\pe.h \ 34 | $(SDK_INSTALL_DIR)\include\efi\Ia32\efilibplat.h \ 35 | 36 | 37 | !ENDIF 38 | 39 | 40 | !IF "$(PROCESSOR)" == "Ia64" 41 | INC_DEPS = $(INC_DEPS) \ 42 | $(SDK_INSTALL_DIR)\include\efi\Ia64\efibind.h \ 43 | $(SDK_INSTALL_DIR)\include\efi\Ia64\pe.h \ 44 | $(SDK_INSTALL_DIR)\include\efi\Ia64\efilibplat.h \ 45 | 46 | 47 | !ENDIF 48 | 49 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/mips64el/efilibplat.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 1998 Intel Corporation 4 | 5 | Module Name: 6 | 7 | efilibplat.h 8 | 9 | Abstract: 10 | 11 | EFI to compile bindings 12 | 13 | 14 | 15 | 16 | Revision History 17 | 18 | --*/ 19 | 20 | VOID 21 | InitializeLibPlatform ( 22 | IN EFI_HANDLE ImageHandle, 23 | IN EFI_SYSTEM_TABLE *SystemTable 24 | ); 25 | 26 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/mips64el/efisetjmp_arch.h: -------------------------------------------------------------------------------- 1 | #ifndef GNU_EFI_MIPS64EL_SETJMP_H 2 | #define GNU_EFI_MIPS64EL_SETJMP_H 3 | 4 | #define JMPBUF_ALIGN 8 5 | 6 | typedef struct { 7 | /* GP regs */ 8 | UINT64 RA; 9 | UINT64 SP; 10 | UINT64 FP; 11 | UINT64 GP; 12 | UINT64 S0; 13 | UINT64 S1; 14 | UINT64 S2; 15 | UINT64 S3; 16 | UINT64 S4; 17 | UINT64 S5; 18 | UINT64 S6; 19 | UINT64 S7; 20 | 21 | #ifdef __mips_hard_float 22 | /* FP regs */ 23 | UINT64 F24; 24 | UINT64 F25; 25 | UINT64 F26; 26 | UINT64 F27; 27 | UINT64 F28; 28 | UINT64 F29; 29 | UINT64 F30; 30 | UINT64 F31; 31 | #endif 32 | } ALIGN(JMPBUF_ALIGN) jmp_buf[1]; 33 | 34 | #endif /* GNU_EFI_MIPS64EL_SETJMP_H */ 35 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/pci22.h: -------------------------------------------------------------------------------- 1 | #ifndef _PCI22_H 2 | #define _PCI22_H 3 | 4 | /*++ 5 | 6 | Copyright (c) 1999 Intel Corporation 7 | 8 | Module Name: 9 | 10 | pci22.h 11 | 12 | Abstract: 13 | Support for PCI 2.2 standard. 14 | 15 | 16 | 17 | 18 | Revision History 19 | 20 | --*/ 21 | 22 | #ifdef SOFT_SDV 23 | #define PCI_MAX_BUS 1 24 | #else 25 | #define PCI_MAX_BUS 255 26 | #endif 27 | 28 | #define PCI_MAX_DEVICE 31 29 | #define PCI_MAX_FUNC 7 30 | 31 | // 32 | // Command 33 | // 34 | #define PCI_VGA_PALETTE_SNOOP_DISABLED 0x20 35 | 36 | #pragma pack(1) 37 | typedef struct { 38 | UINT16 VendorId; 39 | UINT16 DeviceId; 40 | UINT16 Command; 41 | UINT16 Status; 42 | UINT8 RevisionID; 43 | UINT8 ClassCode[3]; 44 | UINT8 CacheLineSize; 45 | UINT8 LaytencyTimer; 46 | UINT8 HeaderType; 47 | UINT8 BIST; 48 | } PCI_DEVICE_INDEPENDENT_REGION; 49 | 50 | typedef struct { 51 | UINT32 Bar[6]; 52 | UINT32 CISPtr; 53 | UINT16 SubsystemVendorID; 54 | UINT16 SubsystemID; 55 | UINT32 ExpansionRomBar; 56 | UINT32 Reserved[2]; 57 | UINT8 InterruptLine; 58 | UINT8 InterruptPin; 59 | UINT8 MinGnt; 60 | UINT8 MaxLat; 61 | } PCI_DEVICE_HEADER_TYPE_REGION; 62 | 63 | typedef struct { 64 | PCI_DEVICE_INDEPENDENT_REGION Hdr; 65 | PCI_DEVICE_HEADER_TYPE_REGION Device; 66 | } PCI_TYPE00; 67 | 68 | typedef struct { 69 | UINT32 Bar[2]; 70 | UINT8 PrimaryBus; 71 | UINT8 SecondaryBus; 72 | UINT8 SubordinateBus; 73 | UINT8 SecondaryLatencyTimer; 74 | UINT8 IoBase; 75 | UINT8 IoLimit; 76 | UINT16 SecondaryStatus; 77 | UINT16 MemoryBase; 78 | UINT16 MemoryLimit; 79 | UINT16 PrefetchableMemoryBase; 80 | UINT16 PrefetchableMemoryLimit; 81 | UINT32 PrefetchableBaseUpper32; 82 | UINT32 PrefetchableLimitUpper32; 83 | UINT16 IoBaseUpper16; 84 | UINT16 IoLimitUpper16; 85 | UINT32 Reserved; 86 | UINT32 ExpansionRomBAR; 87 | UINT8 InterruptLine; 88 | UINT8 InterruptPin; 89 | UINT16 BridgeControl; 90 | } PCI_BRIDGE_CONTROL_REGISTER; 91 | 92 | #define PCI_CLASS_DISPLAY_CTRL 0x03 93 | #define PCI_CLASS_VGA 0x00 94 | 95 | #define PCI_CLASS_BRIDGE 0x06 96 | #define PCI_CLASS_ISA 0x01 97 | #define PCI_CLASS_ISA_POSITIVE_DECODE 0x80 98 | 99 | #define PCI_CLASS_NETWORK 0x02 100 | #define PCI_CLASS_ETHERNET 0x00 101 | 102 | #define HEADER_TYPE_DEVICE 0x00 103 | #define HEADER_TYPE_PCI_TO_PCI_BRIDGE 0x01 104 | #define HEADER_TYPE_MULTI_FUNCTION 0x80 105 | #define HEADER_LAYOUT_CODE 0x7f 106 | 107 | #define IS_PCI_BRIDGE(_p) ((((_p)->Hdr.HeaderType) & HEADER_LAYOUT_CODE) == HEADER_TYPE_PCI_TO_PCI_BRIDGE) 108 | #define IS_PCI_MULTI_FUNC(_p) (((_p)->Hdr.HeaderType) & HEADER_TYPE_MULTI_FUNCTION) 109 | 110 | typedef struct { 111 | PCI_DEVICE_INDEPENDENT_REGION Hdr; 112 | PCI_BRIDGE_CONTROL_REGISTER Bridge; 113 | } PCI_TYPE01; 114 | 115 | typedef struct { 116 | UINT8 Register; 117 | UINT8 Function; 118 | UINT8 Device; 119 | UINT8 Bus; 120 | UINT8 Reserved[4]; 121 | } DEFIO_PCI_ADDR; 122 | 123 | typedef struct { 124 | UINT32 Reg : 8; 125 | UINT32 Func : 3; 126 | UINT32 Dev : 5; 127 | UINT32 Bus : 8; 128 | UINT32 Reserved: 7; 129 | UINT32 Enable : 1; 130 | } PCI_CONFIG_ACCESS_CF8; 131 | 132 | #pragma pack() 133 | 134 | #define EFI_ROOT_BRIDGE_LIST 'eprb' 135 | typedef struct { 136 | UINTN Signature; 137 | 138 | UINT16 BridgeNumber; 139 | UINT16 PrimaryBus; 140 | UINT16 SubordinateBus; 141 | 142 | EFI_DEVICE_PATH *DevicePath; 143 | 144 | LIST_ENTRY Link; 145 | } PCI_ROOT_BRIDGE_ENTRY; 146 | 147 | 148 | #define PCI_EXPANSION_ROM_HEADER_SIGNATURE 0xaa55 149 | #define EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE 0x0EF1 150 | #define PCI_DATA_STRUCTURE_SIGNATURE EFI_SIGNATURE_32('P','C','I','R') 151 | 152 | #pragma pack(1) 153 | typedef struct { 154 | UINT16 Signature; // 0xaa55 155 | UINT8 Reserved[0x16]; 156 | UINT16 PcirOffset; 157 | } PCI_EXPANSION_ROM_HEADER; 158 | 159 | 160 | typedef struct { 161 | UINT16 Signature; // 0xaa55 162 | UINT16 InitializationSize; 163 | UINT16 EfiSignature; // 0x0EF1 164 | UINT16 EfiSubsystem; 165 | UINT16 EfiMachineType; 166 | UINT8 Reserved[0x0A]; 167 | UINT16 EfiImageHeaderOffset; 168 | UINT16 PcirOffset; 169 | } EFI_PCI_EXPANSION_ROM_HEADER; 170 | 171 | typedef struct { 172 | UINT32 Signature; // "PCIR" 173 | UINT16 VendorId; 174 | UINT16 DeviceId; 175 | UINT16 Reserved0; 176 | UINT16 Length; 177 | UINT8 Revision; 178 | UINT8 ClassCode[3]; 179 | UINT16 ImageLength; 180 | UINT16 CodeRevision; 181 | UINT8 CodeType; 182 | UINT8 Indicator; 183 | UINT16 Reserved1; 184 | } PCI_DATA_STRUCTURE; 185 | #pragma pack() 186 | 187 | #endif 188 | 189 | 190 | 191 | 192 | 193 | 194 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/protocol/adapterdebug.h: -------------------------------------------------------------------------------- 1 | #ifndef _ADAPTER_DEBUG_H 2 | #define _ADAPTER_DEBUG_H 3 | 4 | /*++ 5 | 6 | Copyright (c) 1999 Intel Corporation 7 | 8 | Module Name: 9 | 10 | AdapterDebug.h 11 | 12 | Abstract: 13 | 14 | Protocol to debug the EDD 3.0 enablement of BIOS option ROMs 15 | 16 | 17 | 18 | Revision History 19 | 20 | --*/ 21 | 22 | // {82F86881-282B-11d4-BC7D-0080C73C8881} 23 | #define ADAPTER_DEBUG_PROTOCOL \ 24 | { 0x82f86881, 0x282b, 0x11d4, {0xbc, 0x7d, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} } 25 | 26 | // 27 | // This protocol points to the BIOS_LEGACY_DRIVE data structure 28 | // see edd.h for more details 29 | // 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/protocol/eficonsplit.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_CONFORK_H 2 | #define _EFI_CONFORK_H 3 | /*++ 4 | 5 | Copyright (c) 1999 Intel Corporation 6 | 7 | Module Name: 8 | 9 | Abstract: 10 | 11 | 12 | 13 | Revision History 14 | 15 | --*/ 16 | 17 | 18 | 19 | // 20 | // ConOut Forker Protocol 21 | // 22 | 23 | #define TEXT_OUT_SPLITER_PROTOCOL \ 24 | { 0x56d830a0, 0x7e7a, 0x11d3, {0xbb, 0xa0, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } 25 | 26 | #define ERROR_OUT_SPLITER_PROTOCOL \ 27 | { 0xf0ba9039, 0x68f1, 0x425e, {0xaa, 0x7f, 0xd9, 0xaa, 0xf9, 0x1b, 0x82, 0xa1}} 28 | 29 | #define TEXT_IN_SPLITER_PROTOCOL \ 30 | { 0xf9a3c550, 0x7fb5, 0x11d3, {0xbb, 0xa0, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/protocol/efivar.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 1998 Intel Corporation 4 | 5 | Module Name: 6 | 7 | Abstract: 8 | 9 | 10 | 11 | Revision History 12 | 13 | --*/ 14 | 15 | 16 | 17 | // 18 | // The variable store protocol interface is specific to the reference 19 | // implementation. The initialization code adds variable store devices 20 | // to the system, and the FW connects to the devices to provide the 21 | // variable store interfaces through these devices. 22 | // 23 | 24 | // 25 | // Variable Store Device protocol 26 | // 27 | 28 | #define VARIABLE_STORE_PROTOCOL \ 29 | { 0xf088cd91, 0xa046, 0x11d2, {0x8e, 0x42, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } 30 | 31 | INTERFACE_DECL(_EFI_VARIABLE_STORE); 32 | 33 | typedef 34 | EFI_STATUS 35 | (EFIAPI *EFI_STORE_CLEAR) ( 36 | IN struct _EFI_VARIABLE_STORE *This, 37 | IN UINTN BankNo, 38 | IN OUT VOID *Scratch 39 | ); 40 | 41 | 42 | typedef 43 | EFI_STATUS 44 | (EFIAPI *EFI_STORE_READ) ( 45 | IN struct _EFI_VARIABLE_STORE *This, 46 | IN UINTN BankNo, 47 | IN UINTN Offset, 48 | IN UINTN BufferSize, 49 | OUT VOID *Buffer 50 | ); 51 | 52 | typedef 53 | EFI_STATUS 54 | (EFIAPI *EFI_STORE_UPDATE) ( 55 | IN struct _EFI_VARIABLE_STORE *This, 56 | IN UINTN BankNo, 57 | IN UINTN Offset, 58 | IN UINTN BufferSize, 59 | IN VOID *Buffer 60 | ); 61 | 62 | typedef 63 | EFI_STATUS 64 | (EFIAPI *EFI_STORE_SIZE) ( 65 | IN struct _EFI_VARIABLE_STORE *This, 66 | IN UINTN NoBanks 67 | ); 68 | 69 | typedef 70 | EFI_STATUS 71 | (EFIAPI *EFI_TRANSACTION_UPDATE) ( 72 | IN struct _EFI_VARIABLE_STORE *This, 73 | IN UINTN BankNo, 74 | IN VOID *NewContents 75 | ); 76 | 77 | typedef struct _EFI_VARIABLE_STORE { 78 | 79 | // 80 | // Number of banks and bank size 81 | // 82 | 83 | UINT32 Attributes; 84 | UINT32 BankSize; 85 | UINT32 NoBanks; 86 | 87 | // 88 | // Functions to access the storage banks 89 | // 90 | 91 | EFI_STORE_CLEAR ClearStore; 92 | EFI_STORE_READ ReadStore; 93 | EFI_STORE_UPDATE UpdateStore; 94 | EFI_STORE_SIZE SizeStore OPTIONAL; 95 | EFI_TRANSACTION_UPDATE TransactionUpdate OPTIONAL; 96 | 97 | } EFI_VARIABLE_STORE; 98 | 99 | 100 | // 101 | // 102 | // ClearStore() - A function to clear the requested storage bank. A cleared 103 | // bank contains all "on" bits. 104 | // 105 | // ReadStore() - Read data from the requested store. 106 | // 107 | // UpdateStore() - Updates data on the requested store. The FW will only 108 | // ever issue updates to clear bits in the store. Updates must be 109 | // performed in LSb to MSb order of the update buffer. 110 | // 111 | // SizeStore() - An optional function for non-runtime stores that can be 112 | // dynamically sized. The FW will only ever increase or decrease the store 113 | // by 1 banksize at a time, and it is always adding or removing a bank from 114 | // the end of the store. 115 | // 116 | // By default the FW will update variables and storage banks in an 117 | // "atomic" manner by keeping 1 old copy of the data during an update, 118 | // and recovering appropiately if the power is lost during the middle 119 | // of an operation. To do this the FW needs to have multiple banks 120 | // of storage dedicated to its use. If that's not possible, the driver 121 | // can implement an atomic bank update function and the FW will allow 122 | // 1 bank in this case. (It will allow any number of banks, 123 | // but it won't require an "extra" bank to provide its bank transaction 124 | // function). 125 | // 126 | // TransactionUpdate() - An optional function that can clear & update an 127 | // entire bank in an "atomic" fashion. If the operation fails in the 128 | // middle the driver is responsible for having either the previous copy 129 | // of the bank's data or the new copy. A copy that's partially written 130 | // is not valid as internal data settings may get lost. Supply this 131 | // function only when needed. 132 | // 133 | 134 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/protocol/intload.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 1999 Intel Corporation 4 | 5 | Module Name: 6 | 7 | intload 8 | 9 | Abstract: 10 | 11 | EFI support for loading internally linked in apps 12 | 13 | 14 | 15 | Revision History 16 | 17 | --*/ 18 | 19 | #ifndef _INTERNAL_LOAD_INCLUDE_ 20 | #define _INTERNAL_LOAD_INCLUDE_ 21 | 22 | // {D65A6B8C-71E5-4df0-A909-F0D2992B5AA9} 23 | #define INTERNAL_SHELL_GUID \ 24 | { 0xd65a6b8c, 0x71e5, 0x4df0, {0xa9, 0x09, 0xf0, 0xd2, 0x99, 0x2b, 0x5a, 0xa9} } 25 | 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/protocol/legacyboot.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 1999 Intel Corporation 4 | 5 | Module Name: 6 | 7 | legacyboot 8 | 9 | Abstract: 10 | 11 | EFI support for legacy boot 12 | 13 | 14 | 15 | Revision History 16 | 17 | --*/ 18 | 19 | #ifndef _LEGACY_BOOT_INCLUDE_ 20 | #define _LEGACY_BOOT_INCLUDE_ 21 | 22 | #define LEGACY_BOOT_PROTOCOL \ 23 | { 0x376e5eb2, 0x30e4, 0x11d3, { 0xba, 0xe5, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } } 24 | 25 | #pragma pack(1) 26 | 27 | // 28 | // BBS 1.01 (See Appendix A) IPL and BCV Table Entry Data structure. 29 | // Seg:Off pointers have been converted to EFI pointers in this data structure 30 | // This is the structure that also maps to the EFI device path for the boot selection 31 | // 32 | typedef struct { 33 | UINT16 DeviceType; 34 | UINT16 StatusFlag; 35 | UINT32 Reserved; 36 | VOID *BootHandler; // Not an EFI entry point 37 | CHAR8 *DescString; 38 | } BBS_TABLE_ENTRY; 39 | #pragma pack() 40 | 41 | typedef 42 | EFI_STATUS 43 | (EFIAPI *LEGACY_BOOT_CALL) ( 44 | IN EFI_DEVICE_PATH *DevicePath 45 | ); 46 | 47 | 48 | // 49 | // BBS support functions 50 | // PnP Call numbers and BiosSelector hidden in implementation 51 | // 52 | 53 | typedef enum { 54 | IplRelative, 55 | BcvRelative 56 | } BBS_TYPE; 57 | 58 | INTERFACE_DECL(_LEGACY_BOOT_INTERFACE); 59 | 60 | // 61 | // == PnP Function 0x60 then BbsVersion == 0x0101 if this call fails then BbsVersion == 0x0000 62 | // 63 | 64 | // 65 | // == PnP Function 0x61 66 | // 67 | typedef 68 | EFI_STATUS 69 | (EFIAPI *GET_DEVICE_COUNT) ( 70 | IN struct _LEGACY_BOOT_INTERFACE *This, 71 | IN BBS_TYPE *TableType, 72 | OUT UINTN *DeviceCount, 73 | OUT UINTN *MaxCount 74 | ); 75 | 76 | // 77 | // == PnP Function 0x62 78 | // 79 | typedef 80 | EFI_STATUS 81 | (EFIAPI *GET_PRIORITY_AND_TABLE) ( 82 | IN struct _LEGACY_BOOT_INTERFACE *This, 83 | IN BBS_TYPE *TableType, 84 | IN OUT UINTN *PrioritySize, // MaxCount * sizeof(UINT8) 85 | OUT UINTN *Priority, 86 | IN OUT UINTN *TableSize, // MaxCount * sizeof(BBS_TABLE_ENTRY) 87 | OUT BBS_TABLE_ENTRY *TableEntrySize 88 | ); 89 | 90 | // 91 | // == PnP Function 0x63 92 | // 93 | typedef 94 | EFI_STATUS 95 | (EFIAPI *SET_PRIORITY) ( 96 | IN struct _LEGACY_BOOT_INTERFACE *This, 97 | IN BBS_TYPE *TableType, 98 | IN OUT UINTN *PrioritySize, 99 | OUT UINTN *Priority 100 | ); 101 | 102 | typedef struct _LEGACY_BOOT_INTERFACE { 103 | LEGACY_BOOT_CALL BootIt; 104 | 105 | // 106 | // New functions to allow BBS booting to be configured from EFI 107 | // 108 | UINTN BbsVersion; // Currently 0x0101 109 | GET_DEVICE_COUNT GetDeviceCount; 110 | GET_PRIORITY_AND_TABLE GetPriorityAndTable; 111 | SET_PRIORITY SetPriority; 112 | } LEGACY_BOOT_INTERFACE; 113 | 114 | EFI_STATUS 115 | PlInitializeLegacyBoot ( 116 | VOID 117 | ); 118 | 119 | #endif 120 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/protocol/make.inf: -------------------------------------------------------------------------------- 1 | # 2 | # 3 | # 4 | 5 | [sources] 6 | efivar.h 7 | legacyboot.h 8 | VgaClass.h 9 | intload.h 10 | 11 | [ia32sources] 12 | 13 | [ia64sources] 14 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/protocol/makefile.hdr: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # This is a machine generated file - DO NOT EDIT 4 | # Generated by genmake.exe 5 | # Generated from make.inf 6 | # Copyright (c) 1998 Intel Corporation 7 | # 8 | 9 | INC_DEPS = $(INC_DEPS) \ 10 | $(SDK_INSTALL_DIR)\include\efi\protocol\efivar.h \ 11 | $(SDK_INSTALL_DIR)\include\efi\protocol\legacyboot.h \ 12 | $(SDK_INSTALL_DIR)\include\efi\protocol\vgaclass.h \ 13 | $(SDK_INSTALL_DIR)\include\efi\protocol\efidbg.h \ 14 | 15 | 16 | !IF "$(PROCESSOR)" == "Ia32" 17 | INC_DEPS = $(INC_DEPS) \ 18 | 19 | 20 | !ENDIF 21 | 22 | 23 | !IF "$(PROCESSOR)" == "Ia64" 24 | INC_DEPS = $(INC_DEPS) \ 25 | $(SDK_INSTALL_DIR)\include\efi\protocol\$(PROCESSOR)\eficontext.h \ 26 | 27 | 28 | !ENDIF 29 | 30 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/protocol/piflash64.h: -------------------------------------------------------------------------------- 1 | #ifndef _PIFLASH64_H 2 | #define _PIFLASH64_H 3 | 4 | /*++ 5 | 6 | Copyright (c) 1999 Intel Corporation 7 | 8 | Module Name: 9 | 10 | PIflash64.h 11 | 12 | Abstract: 13 | 14 | Iflash64.efi protocol to abstract iflash from 15 | the system. 16 | 17 | Revision History 18 | 19 | --*/ 20 | 21 | // 22 | // Guid that identifies the IFLASH protocol 23 | // 24 | #define IFLASH64_PROTOCOL_PROTOCOL \ 25 | { 0x65cba110, 0x74ab, 0x11d3, 0xbb, 0x89, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 }; 26 | 27 | // 28 | // Unlock FLASH from StartAddress to EndAddress and return a LockKey 29 | // 30 | typedef 31 | EFI_STATUS 32 | (EFIAPI *UNLOCK_FLASH_API)( 33 | IN struct _IFLASH64_PROTOCOL_INTERFACE *This 34 | ); 35 | 36 | // 37 | // Lock the flash represented by the LockKey 38 | // 39 | typedef 40 | EFI_STATUS 41 | (EFIAPI *LOCK_FLASH_API)( 42 | IN struct _IFLASH64_PROTOCOL_INTERFACE *This 43 | ); 44 | 45 | // 46 | // Status callback for a utility like IFLASH64 47 | // 48 | // Token would map to a list like Ted proposed. The utility has no idea what 49 | // happens on the other side. 50 | // ErrorStatus - Level of Error or success. Independent of Token. If you 51 | // don't know the token you will at least know pass or fail. 52 | // String - Optional extra information about the error. Could be used for 53 | // debug or future expansion 54 | // 55 | // Attributes - Options screen attributes for String. Could allow the string to be different colors. 56 | // 57 | typedef 58 | EFI_STATUS 59 | (EFIAPI *UTILITY_PROGRESS_API)( 60 | IN struct _IFLASH64_PROTOCOL_INTERFACE *This, 61 | IN UINTN Token, 62 | IN EFI_STATUS ErrorStatus, 63 | IN CHAR16 *String, OPTIONAL 64 | IN UINTN *Attributes OPTIONAL 65 | ); 66 | 67 | // 68 | // Token Values 69 | // 70 | // IFlash64 Token Codes 71 | #define IFLASH_TOKEN_IFLASHSTART 0xB0 // IFlash64 has started 72 | #define IFLASH_TOKEN_READINGFILE 0xB1 // Reading File 73 | #define IFLASH_TOKEN_INITVPP 0xB2 // Initializing Vpp 74 | #define IFLASH_TOKEN_DISABLEVPP 0x10 // Disable Vpp 75 | #define IFLASH_TOKEN_FLASHUNLOCK 0xB3 // Unlocking FLASH Devices 76 | #define IFLASH_TOKEN_FLASHERASE 0xB4 // Erasing FLASH Devices 77 | #define IFLASH_TOKEN_FLASHPROGRAM 0xB5 // Programming FLASH 78 | #define IFLASH_TOKEN_FLASHVERIFY 0xB6 // Verifying FLASH 79 | #define IFLASH_TOKEN_UPDATESUCCES 0xB7 // FLASH Updage Success! 80 | 81 | #define IFLASH_TOKEN_PROGRESS_READINGFILE 0x11 // % Reading File 82 | #define IFLASH_TOKEN_PROGRESS_FLASHUNLOCK 0x13 // % Unlocking FLASH Devices 83 | #define IFLASH_TOKEN_PROGRESS_FLASHERASE 0x14 // % Erasing FLASH Devices 84 | #define IFLASH_TOKEN_PROGRESS_FLASHPROGRAM 0x15 // % Programming FLASH 85 | #define IFLASH_TOKEN_PROGRESS_FLASHVERIFY 0x16 // % Verifying FLASH 86 | 87 | #define IFLASH_TOKEN_READINGFILE_ER 0xB8 // File Read Error 88 | #define IFLASH_TOKEN_INITVPP_ER 0xB9 // Initialization of IFB Error 89 | #define IFLASH_TOKEN_FLASHUNLOCK_ER 0xBA // FLASH Unlock Error 90 | #define IFLASH_TOKEN_FLASHERASE_ER 0xBB // FLASH Erase Error 91 | #define IFLASH_TOKEN_FLASHVERIFY_ER 0xBC // FLASH Verify Error 92 | #define IFLASH_TOKEN_FLASHPROG_ER 0xBD // FLASH Program Error 93 | 94 | #define IFLASH_TABLE_END 0x00 95 | 96 | // 97 | // If this number changes one of the existing API's has changes 98 | // 99 | #define IFLASH_PI_MAJOR_VERSION 0x01 100 | 101 | // 102 | // This number changes when new APIs or data variables get added to the end 103 | // of the data structure 104 | // 105 | #define IFLASH_PI_MINOR_VERSION 0x01 106 | 107 | typedef struct _IFLASH64_PROTOCOL_INTERFACE { 108 | UINT32 MajorVersion; 109 | UINT32 MinorVersion; 110 | UNLOCK_FLASH_API UnlockFlash; 111 | LOCK_FLASH_API LockFlash; 112 | UTILITY_PROGRESS_API Progress; 113 | 114 | // 115 | // Future expansion goes here 116 | // 117 | 118 | } IFLASH64_PROTOCOL_INTERFACE; 119 | 120 | 121 | #endif 122 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/protocol/readme.txt: -------------------------------------------------------------------------------- 1 | The protocol directory contains non Architectural 2 | Protocols that span the FW, Platform, or application 3 | space. -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/protocol/vgaclass.h: -------------------------------------------------------------------------------- 1 | #ifndef _VGA_CLASS_H 2 | #define _VGA_CLASS_H 3 | 4 | /*++ 5 | 6 | Copyright (c) 1999 Intel Corporation 7 | 8 | Module Name: 9 | 10 | VgaClass.h 11 | 12 | Abstract: 13 | 14 | Vga Mini port binding to Vga Class protocol 15 | 16 | 17 | 18 | Revision History 19 | 20 | --*/ 21 | 22 | // 23 | // VGA Device Structure 24 | // 25 | 26 | // {0E3D6310-6FE4-11d3-BB81-0080C73C8881} 27 | #define VGA_CLASS_DRIVER_PROTOCOL \ 28 | { 0xe3d6310, 0x6fe4, 0x11d3, {0xbb, 0x81, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} } 29 | 30 | typedef 31 | EFI_STATUS 32 | (* INIT_VGA_CARD) ( 33 | IN UINTN VgaMode, 34 | IN VOID *Context 35 | ); 36 | 37 | typedef struct { 38 | UINTN MaxColumns; 39 | UINTN MaxRows; 40 | } MAX_CONSOLE_GEOMETRY; 41 | 42 | #define VGA_CON_OUT_DEV_SIGNATURE EFI_SIGNATURE_32('c','v','g','a') 43 | typedef struct { 44 | UINTN Signature; 45 | 46 | EFI_HANDLE Handle; 47 | SIMPLE_TEXT_OUTPUT_INTERFACE ConOut; 48 | SIMPLE_TEXT_OUTPUT_MODE ConOutMode; 49 | EFI_DEVICE_PATH *DevicePath; 50 | 51 | UINT8 *Buffer; 52 | EFI_DEVICE_IO_INTERFACE *DeviceIo; 53 | 54 | // 55 | // Video Card Context 56 | // 57 | INIT_VGA_CARD InitVgaCard; 58 | VOID *VgaCardContext; 59 | MAX_CONSOLE_GEOMETRY *Geometry; 60 | // 61 | // Video buffer normally 0xb8000 62 | // 63 | UINT64 VideoBuffer; 64 | 65 | // 66 | // Clear Screen & Default Attribute 67 | // 68 | UINT32 Attribute; 69 | 70 | // 71 | // -1 means search for active VGA device 72 | // 73 | EFI_PCI_ADDRESS_UNION Pci; 74 | } VGA_CON_OUT_DEV; 75 | 76 | #define VGA_CON_OUT_DEV_FROM_THIS(a) CR(a, VGA_CON_OUT_DEV, ConOut, VGA_CON_OUT_DEV_SIGNATURE) 77 | 78 | // 79 | // Vga Class Driver Protocol. 80 | // GUID defined in EFI Lib 81 | // 82 | 83 | typedef 84 | EFI_STATUS 85 | (EFIAPI *INSTALL_VGA_DRIVER) ( 86 | IN VGA_CON_OUT_DEV *ConOutDev 87 | ); 88 | 89 | typedef struct { 90 | UINT32 Version; 91 | INSTALL_VGA_DRIVER InstallGenericVgaDriver; 92 | } INSTALL_VGA_DRIVER_INTERFACE; 93 | 94 | #endif 95 | 96 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/riscv64/efibind.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copright (C) 2014 - 2015 Linaro Ltd. 3 | * Author: Ard Biesheuvel 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice and this list of conditions, without modification. 10 | * 2. The name of the author may not be used to endorse or promote products 11 | * derived from this software without specific prior written permission. 12 | * 13 | * Alternatively, this software may be distributed under the terms of the 14 | * GNU General Public License as published by the Free Software Foundation; 15 | * either version 2 of the License, or (at your option) any later version. 16 | */ 17 | 18 | #include 19 | 20 | // 21 | // Basic EFI types of various widths 22 | // 23 | 24 | 25 | 26 | typedef uint64_t UINT64; 27 | typedef int64_t INT64; 28 | typedef uint32_t UINT32; 29 | typedef int32_t INT32; 30 | typedef uint16_t UINT16; 31 | typedef int16_t INT16; 32 | typedef uint8_t UINT8; 33 | typedef int8_t INT8; 34 | #ifndef __WCHAR_TYPE__ 35 | #define __WCHAR_TYPE__ short 36 | #endif 37 | typedef __WCHAR_TYPE__ WCHAR; 38 | #ifndef BOOLEAN 39 | typedef uint8_t BOOLEAN; 40 | #endif 41 | #undef VOID 42 | #define VOID void 43 | typedef int64_t INTN; 44 | typedef uint64_t UINTN; 45 | 46 | #define EFI_ERROR_MASK 0x8000000000000000 47 | #define EFIERR(a) (EFI_ERROR_MASK | a) 48 | #define EFIERR_OEM(a) (0xc000000000000000 | a) 49 | 50 | #define BAD_POINTER 0xFBFBFBFBFBFBFBFB 51 | #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFF 52 | 53 | #define BREAKPOINT() while(1); 54 | 55 | // 56 | // Pointers must be aligned to these address to function 57 | // 58 | #define MIN_ALIGNMENT_SIZE 8 59 | 60 | #define ALIGN_VARIABLE(Value, Adjustment) \ 61 | (UINTN)Adjustment = 0; \ 62 | if((UINTN)Value % MIN_ALIGNMENT_SIZE) \ 63 | (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \ 64 | Value = (UINTN)Value + (UINTN)Adjustment 65 | 66 | // 67 | // Define macros to build data structure signatures from characters. 68 | // 69 | #define EFI_SIGNATURE_16(A,B) ((A) | (B<<8)) 70 | #define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16(A,B) | (EFI_SIGNATURE_16(C,D) << 16)) 71 | #define EFI_SIGNATURE_64(A,B,C,D,E,F,G,H) (EFI_SIGNATURE_32(A,B,C,D) | ((UINT64)(EFI_SIGNATURE_32(E,F,G,H)) << 32)) 72 | 73 | // 74 | // EFIAPI - prototype calling convention for EFI function pointers 75 | // BOOTSERVICE - prototype for implementation of a boot service interface 76 | // RUNTIMESERVICE - prototype for implementation of a runtime service interface 77 | // RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service 78 | // RUNTIME_CODE - pragma macro for declaring runtime code 79 | // 80 | #ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options 81 | #define EFIAPI // Substitute expresion to force C calling convention 82 | #endif 83 | #define BOOTSERVICE 84 | #define RUNTIMESERVICE 85 | #define RUNTIMEFUNCTION 86 | #define RUNTIME_CODE(a) alloc_text("rtcode", a) 87 | #define BEGIN_RUNTIME_DATA() data_seg("rtdata") 88 | #define END_RUNTIME_DATA() data_seg("") 89 | 90 | #define VOLATILE volatile 91 | #define MEMORY_FENCE __sync_synchronize 92 | 93 | // 94 | // When build similiar to FW, then link everything together as 95 | // one big module. For the MSVC toolchain, we simply tell the 96 | // linker what our driver init function is using /ENTRY. 97 | // 98 | #if defined(_MSC_EXTENSIONS) 99 | #define EFI_DRIVER_ENTRY_POINT(InitFunction) \ 100 | __pragma(comment(linker, "/ENTRY:" # InitFunction)) 101 | #else 102 | #define EFI_DRIVER_ENTRY_POINT(InitFunction) \ 103 | UINTN \ 104 | InitializeDriver ( \ 105 | VOID *ImageHandle, \ 106 | VOID *SystemTable \ 107 | ) \ 108 | { \ 109 | return InitFunction(ImageHandle, \ 110 | SystemTable); \ 111 | } \ 112 | \ 113 | EFI_STATUS efi_main( \ 114 | EFI_HANDLE image, \ 115 | EFI_SYSTEM_TABLE *systab \ 116 | ) __attribute__((weak, \ 117 | alias ("InitializeDriver"))); 118 | #endif 119 | 120 | #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \ 121 | (_if)->LoadInternal(type, name, entry) 122 | 123 | // 124 | // Some compilers don't support the forward reference construct: 125 | // typedef struct XXXXX 126 | // 127 | // The following macro provide a workaround for such cases. 128 | #define INTERFACE_DECL(x) struct x 129 | 130 | #define uefi_call_wrapper(func, va_num, ...) func(__VA_ARGS__) 131 | #define EFI_FUNCTION 132 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/riscv64/efilibplat.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0+ */ 2 | 3 | VOID 4 | InitializeLibPlatform ( 5 | IN EFI_HANDLE ImageHandle, 6 | IN EFI_SYSTEM_TABLE *SystemTable 7 | ); 8 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/riscv64/efisetjmp_arch.h: -------------------------------------------------------------------------------- 1 | #ifndef GNU_EFI_RISCV64_SETJMP_H 2 | #define GNU_EFI_RISCV64_SETJMP_H 3 | 4 | #define JMPBUF_ALIGN 8 5 | 6 | typedef struct { 7 | /* GP regs */ 8 | UINT64 s0; 9 | UINT64 s1; 10 | UINT64 s2; 11 | UINT64 s3; 12 | UINT64 s4; 13 | UINT64 s5; 14 | UINT64 s6; 15 | UINT64 s7; 16 | UINT64 s8; 17 | UINT64 s9; 18 | UINT64 s10; 19 | UINT64 s11; 20 | UINT64 sp; 21 | UINT64 ra; 22 | 23 | /* FP regs */ 24 | UINT64 fs0; 25 | UINT64 fs1; 26 | UINT64 fs2; 27 | UINT64 fs3; 28 | UINT64 fs4; 29 | UINT64 fs5; 30 | UINT64 fs6; 31 | UINT64 fs7; 32 | UINT64 fs8; 33 | UINT64 fs9; 34 | UINT64 fs10; 35 | UINT64 fs11; 36 | } ALIGN(JMPBUF_ALIGN) jmp_buf[1]; 37 | 38 | #endif /* GNU_EFI_RISCV64_SETJMP_H */ 39 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/romload.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_ROMLOAD_H 2 | #define _EFI_ROMLOAD_H 3 | 4 | #define ROM_SIGNATURE 0xaa55 5 | #define PCIDS_SIGNATURE "PCIR" 6 | #pragma pack(push) 7 | #pragma pack(1) 8 | typedef struct 9 | { 10 | UINT8 Pcids_Sig[4]; 11 | UINT16 VendId; 12 | UINT16 DevId; 13 | UINT16 Vpd_Off; 14 | UINT16 Size; 15 | UINT8 Rev; 16 | UINT8 Class_Code[3]; 17 | UINT16 Image_Len; 18 | UINT16 Rev_Lvl; 19 | UINT8 Code_Type; 20 | UINT8 Indi; 21 | UINT16 Rsvd; 22 | }PciDataStructure; 23 | typedef struct 24 | { 25 | UINT16 Size; 26 | UINT32 Header_Sig; 27 | UINT16 SubSystem; 28 | UINT16 MachineType; 29 | UINT8 Resvd[10]; 30 | UINT16 EfiOffset; 31 | }ArchData; 32 | typedef struct 33 | { 34 | UINT16 Rom_Sig; 35 | ArchData Arch_Data; 36 | UINT16 Pcids_Off; 37 | UINT8 resvd[38]; 38 | }RomHeader; 39 | #pragma pack(pop) 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/x86_64/efilibplat.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 1998 Intel Corporation 4 | 5 | Module Name: 6 | 7 | efilibplat.h 8 | 9 | Abstract: 10 | 11 | EFI to compile bindings 12 | 13 | 14 | 15 | 16 | Revision History 17 | 18 | --*/ 19 | 20 | VOID 21 | InitializeLibPlatform ( 22 | IN EFI_HANDLE ImageHandle, 23 | IN EFI_SYSTEM_TABLE *SystemTable 24 | ); 25 | 26 | 27 | -------------------------------------------------------------------------------- /BootAppToEfi/efi_inc/x86_64/efisetjmp_arch.h: -------------------------------------------------------------------------------- 1 | #ifndef GNU_EFI_X86_64_SETJMP_H 2 | #define GNU_EFI_X86_64_SETJMP_H 3 | 4 | #define JMPBUF_ALIGN 8 5 | 6 | typedef struct { 7 | UINT64 Rbx; 8 | UINT64 Rsp; 9 | UINT64 Rbp; 10 | 11 | UINT64 Rdi; 12 | UINT64 Rsi; 13 | UINT64 R12; 14 | UINT64 R13; 15 | UINT64 R14; 16 | UINT64 R15; 17 | UINT64 Rip; 18 | UINT64 MxCsr; 19 | UINT8 XmmBuffer[160]; // XMM6 - XMM15 20 | } ALIGN(JMPBUF_ALIGN) jmp_buf[1]; 21 | 22 | #endif /* GNU_EFI_X86_64_SETJMP_H */ 23 | -------------------------------------------------------------------------------- /BootAppToEfi/efientry.c: -------------------------------------------------------------------------------- 1 | #include "efientry.h" 2 | 3 | EFI_STATUS EfiMain(__in EFI_HANDLE ImageHandle, __in EFI_SYSTEM_TABLE* SystemTable) { 4 | SystemTable->ConOut->OutputString(SystemTable->ConOut, L"hello world from windows boot application!"); 5 | return EFI_SUCCESS; 6 | } -------------------------------------------------------------------------------- /BootAppToEfi/efientry.h: -------------------------------------------------------------------------------- 1 | // EFI headers. 2 | #pragma once 3 | 4 | #include 5 | #include "efi.h" 6 | 7 | /// EFI entry point 8 | /// Firmware allocated handle for the EFI boot application (not this application) 9 | /// Pointer to the EFI system table 10 | /// EFI status code. 11 | EFI_STATUS EfiMain(__in EFI_HANDLE ImageHandle, __in EFI_SYSTEM_TABLE* SystemTable); -------------------------------------------------------------------------------- /EfiInstallPolicy/EfiInstallPolicy.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.31919.166 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EfiInstallPolicy", "EfiInstallPolicy.vcxproj", "{6180F99D-9C4D-4A1E-8CF8-DCBC491E9353}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {6180F99D-9C4D-4A1E-8CF8-DCBC491E9353}.Debug|x64.ActiveCfg = Debug|x64 17 | {6180F99D-9C4D-4A1E-8CF8-DCBC491E9353}.Debug|x64.Build.0 = Debug|x64 18 | {6180F99D-9C4D-4A1E-8CF8-DCBC491E9353}.Debug|x86.ActiveCfg = Debug|Win32 19 | {6180F99D-9C4D-4A1E-8CF8-DCBC491E9353}.Debug|x86.Build.0 = Debug|Win32 20 | {6180F99D-9C4D-4A1E-8CF8-DCBC491E9353}.Release|x64.ActiveCfg = Release|x64 21 | {6180F99D-9C4D-4A1E-8CF8-DCBC491E9353}.Release|x64.Build.0 = Release|x64 22 | {6180F99D-9C4D-4A1E-8CF8-DCBC491E9353}.Release|x86.ActiveCfg = Release|Win32 23 | {6180F99D-9C4D-4A1E-8CF8-DCBC491E9353}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {6C1FB1B6-1CEA-4566-A2DD-90F182F8E535} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /EfiInstallPolicy/EfiInstallPolicy.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | 26 | 27 | Source Files 28 | 29 | 30 | -------------------------------------------------------------------------------- /EfiInstallPolicy/SecureBootPolicy.h: -------------------------------------------------------------------------------- 1 | // Secure Boot Policy definitions. 2 | #pragma once 3 | #include "efi.h" 4 | 5 | /* 6 | Structure of an on-disk secure boot policy: 7 | SECUREBOOT_POLICY_HEADER Header; 8 | GUID CanUpdate[Header.CanUpdateCount]; 9 | SECUREBOOT_POLICY_NECK Neck; 10 | SECUREBOOT_POLICY_BCD_RULE BcdRules[Neck.BcdRulesCount]; 11 | SECUREBOOT_POLICY_REGISTRY_RULE RegistryRules[Neck.RegistryRulesCount]; 12 | BYTE Body[...]; // all offsets in substructures/etc are from the body 13 | */ 14 | #pragma pack(push, 1) 15 | typedef struct _SECUREBOOT_POLICY_HEADER { 16 | UINT16 FormatVersion; 17 | UINT32 PolicyVersion; 18 | EFI_GUID PolicyPublisher; 19 | UINT16 CanUpdateCount; 20 | } SECUREBOOT_POLICY_HEADER, *PSECUREBOOT_POLICY_HEADER; 21 | 22 | typedef struct _SECUREBOOT_POLICY_NECK { 23 | UINT32 OptionFlags; 24 | UINT16 BcdRulesCount; 25 | UINT16 RegistryRulesCount; 26 | } SECUREBOOT_POLICY_NECK, *PSECUREBOOT_POLICY_NECK; 27 | 28 | typedef struct _SECUREBOOT_POLICY_BCD_RULE { 29 | UINT32 ObjectType; 30 | UINT32 Element; 31 | UINT32 ValueOffset; 32 | } SECUREBOOT_POLICY_BCD_RULE, *PSECUREBOOT_POLICY_BCD_RULE; 33 | 34 | typedef struct _SECUREBOOT_POLICY_REGISTRY_RULE { 35 | UINT32 RootKey; 36 | UINT32 SubkeyNameOffset; 37 | UINT32 ValueNameOffset; 38 | UINT32 ValueOffset; 39 | } SECUREBOOT_POLICY_REGISTRY_RULE, *PSECUREBOOT_POLICY_REGISTRY_RULE; 40 | 41 | typedef struct _SECUREBOOT_POLICY_VALUE_HEADER { 42 | union { 43 | UINT16 Raw; 44 | struct { 45 | UINT16 Type : 5; 46 | UINT16 ForFveTpm : 1; 47 | UINT16 ForVbs : 1; 48 | }; 49 | } Flags; 50 | } SECUREBOOT_POLICY_VALUE_HEADER, *PSECUREBOOT_POLICY_VALUE_HEADER; 51 | 52 | typedef struct _SECUREBOOT_POLICY_STRING { 53 | UINT16 Length; 54 | CHAR16 String[1]; 55 | } SECUREBOOT_POLICY_STRING, *PSECUREBOOT_POLICY_STRING; 56 | 57 | typedef struct _SECUREBOOT_POLICY_VALUE_QWORD { 58 | SECUREBOOT_POLICY_VALUE_HEADER Header; 59 | UINT64 Value; 60 | } SECUREBOOT_POLICY_VALUE_QWORD, *PSECUREBOOT_POLICY_VALUE_QWORD; 61 | 62 | #pragma pack(pop) 63 | 64 | #define SECUREBOOT_POLICY_MAX_VERSION 2 // 3 and above is for SiPolicies. Nice work as usual MS. 65 | #define HKEY_SECUREBOOT_POLICY_ROOT 0x81000000 66 | #define SECUREBOOT_POLICY_VALUE_TYPE_QWORD 5 -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/Makefile: -------------------------------------------------------------------------------- 1 | SRCDIR = . 2 | 3 | VPATH = $(SRCDIR) 4 | 5 | include $(SRCDIR)/../Make.defaults 6 | 7 | TOPDIR = $(SRCDIR)/.. 8 | 9 | CDIR=$(TOPDIR)/.. 10 | 11 | all: 12 | 13 | clean: 14 | 15 | install: 16 | mkdir -p $(INSTALLROOT)$(PREFIX)/include/efi 17 | mkdir -p $(INSTALLROOT)$(PREFIX)/include/efi/protocol 18 | mkdir -p $(INSTALLROOT)$(PREFIX)/include/efi/$(ARCH) 19 | $(INSTALL) -m 644 $(SRCDIR)/*.h $(INSTALLROOT)$(PREFIX)/include/efi 20 | $(INSTALL) -m 644 $(SRCDIR)/protocol/*.h $(INSTALLROOT)$(PREFIX)/include/efi/protocol 21 | $(INSTALL) -m 644 $(SRCDIR)/$(ARCH)/*.h $(INSTALLROOT)$(PREFIX)/include/efi/$(ARCH) 22 | ifeq ($(ARCH),ia64) 23 | mkdir -p $(INSTALLROOT)$(PREFIX)/include/efi/protocol/ia64 24 | $(INSTALL) -m 644 $(SRCDIR)/protocol/ia64/*.h $(INSTALLROOT)$(PREFIX)/include/efi/protocol/ia64 25 | endif 26 | 27 | include $(SRCDIR)/../Make.rules 28 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/aarch64/efilibplat.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 1998 Intel Corporation 4 | 5 | Module Name: 6 | 7 | efilibplat.h 8 | 9 | Abstract: 10 | 11 | EFI to compile bindings 12 | 13 | 14 | 15 | 16 | Revision History 17 | 18 | --*/ 19 | 20 | VOID 21 | InitializeLibPlatform ( 22 | IN EFI_HANDLE ImageHandle, 23 | IN EFI_SYSTEM_TABLE *SystemTable 24 | ); 25 | 26 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/aarch64/efisetjmp_arch.h: -------------------------------------------------------------------------------- 1 | #ifndef GNU_EFI_AARCH64_SETJMP_H 2 | #define GNU_EFI_AARCH64_SETJMP_H 3 | 4 | #define JMPBUF_ALIGN 8 5 | 6 | typedef struct { 7 | /* GP regs */ 8 | UINT64 X19; 9 | UINT64 X20; 10 | UINT64 X21; 11 | UINT64 X22; 12 | UINT64 X23; 13 | UINT64 X24; 14 | UINT64 X25; 15 | UINT64 X26; 16 | UINT64 X27; 17 | UINT64 X28; 18 | UINT64 FP; 19 | UINT64 LR; 20 | UINT64 IP0; 21 | 22 | /* FP regs */ 23 | UINT64 D8; 24 | UINT64 D9; 25 | UINT64 D10; 26 | UINT64 D11; 27 | UINT64 D12; 28 | UINT64 D13; 29 | UINT64 D14; 30 | UINT64 D15; 31 | } ALIGN(JMPBUF_ALIGN) jmp_buf[1]; 32 | 33 | #endif /* GNU_EFI_AARCH64_SETJMP_H */ 34 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/efi.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 1998 Intel Corporation 4 | 5 | Module Name: 6 | 7 | efi.h 8 | 9 | Abstract: 10 | 11 | Public EFI header files 12 | 13 | 14 | 15 | Revision History 16 | 17 | --*/ 18 | 19 | 20 | // Add a predefined macro to detect usage of the library 21 | #ifndef _GNU_EFI 22 | #define _GNU_EFI 23 | #endif 24 | 25 | // 26 | // Build flags on input 27 | // EFI32 28 | // EFI_DEBUG - Enable debugging code 29 | // EFI_NT_EMULATOR - Building for running under NT 30 | // 31 | 32 | 33 | #ifndef _EFI_INCLUDE_ 34 | #define _EFI_INCLUDE_ 35 | 36 | #define EFI_FIRMWARE_VENDOR L"INTEL" 37 | #define EFI_FIRMWARE_MAJOR_REVISION 12 38 | #define EFI_FIRMWARE_MINOR_REVISION 33 39 | #define EFI_FIRMWARE_REVISION ((EFI_FIRMWARE_MAJOR_REVISION <<16) | (EFI_FIRMWARE_MINOR_REVISION)) 40 | 41 | #if defined(_M_X64) || defined(__x86_64__) || defined(__amd64__) 42 | #include "x86_64/efibind.h" 43 | #elif defined(_M_IX86) || defined(__i386__) 44 | #include "ia32/efibind.h" 45 | #elif defined(_M_IA64) || defined(__ia64__) 46 | #include "ia64/efibind.h" 47 | #elif defined (_M_ARM64) || defined(__aarch64__) 48 | #include "aarch64/efibind.h" 49 | #elif defined (_M_ARM) || defined(__arm__) 50 | #include "arm/efibind.h" 51 | #elif defined (_M_MIPS64) || defined(__mips64__) 52 | #include "mips64el/efibind.h" 53 | #elif defined (__riscv) && __riscv_xlen == 64 54 | #include "riscv64/efibind.h" 55 | #else 56 | #error Usupported architecture 57 | #endif 58 | 59 | #include "eficompiler.h" 60 | #include "efidef.h" 61 | #include "efidevp.h" 62 | #include "efipciio.h" 63 | #include "efiprot.h" 64 | #include "eficon.h" 65 | #include "eficonex.h" 66 | #include "efiser.h" 67 | #include "efi_nii.h" 68 | #include "efipxebc.h" 69 | #include "efinet.h" 70 | #include "efiapi.h" 71 | #include "efifs.h" 72 | #include "efierr.h" 73 | #include "efiui.h" 74 | #include "efiip.h" 75 | #include "efiudp.h" 76 | #include "efitcp.h" 77 | #include "efipoint.h" 78 | #include "efishell.h" 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/efi_nii.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_NII_H 2 | #define _EFI_NII_H 3 | 4 | /*++ 5 | Copyright (c) 2000 Intel Corporation 6 | 7 | Module name: 8 | efi_nii.h 9 | 10 | Abstract: 11 | 12 | Revision history: 13 | 2000-Feb-18 M(f)J GUID updated. 14 | Structure order changed for machine word alignment. 15 | Added StringId[4] to structure. 16 | 17 | 2000-Feb-14 M(f)J Genesis. 18 | --*/ 19 | 20 | #define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID \ 21 | { 0xE18541CD, 0xF755, 0x4f73, {0x92, 0x8D, 0x64, 0x3C, 0x8A, 0x79, 0xB2, 0x29} } 22 | 23 | #define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION 0x00010000 24 | #define EFI_NETWORK_INTERFACE_IDENTIFIER_INTERFACE_REVISION EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION 25 | 26 | typedef enum { 27 | EfiNetworkInterfaceUndi = 1 28 | } EFI_NETWORK_INTERFACE_TYPE; 29 | 30 | typedef struct _EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL { 31 | 32 | UINT64 Revision; 33 | // Revision of the network interface identifier protocol interface. 34 | 35 | UINT64 ID; 36 | // Address of the first byte of the identifying structure for this 37 | // network interface. This is set to zero if there is no structure. 38 | // 39 | // For PXE/UNDI this is the first byte of the !PXE structure. 40 | 41 | UINT64 ImageAddr; 42 | // Address of the UNrelocated driver/ROM image. This is set 43 | // to zero if there is no driver/ROM image. 44 | // 45 | // For 16-bit UNDI, this is the first byte of the option ROM in 46 | // upper memory. 47 | // 48 | // For 32/64-bit S/W UNDI, this is the first byte of the EFI ROM 49 | // image. 50 | // 51 | // For H/W UNDI, this is set to zero. 52 | 53 | UINT32 ImageSize; 54 | // Size of the UNrelocated driver/ROM image of this network interface. 55 | // This is set to zero if there is no driver/ROM image. 56 | 57 | CHAR8 StringId[4]; 58 | // 4 char ASCII string to go in class identifier (option 60) in DHCP 59 | // and Boot Server discover packets. 60 | // For EfiNetworkInterfaceUndi this field is "UNDI". 61 | // For EfiNetworkInterfaceSnp this field is "SNPN". 62 | 63 | UINT8 Type; 64 | UINT8 MajorVer; 65 | UINT8 MinorVer; 66 | // Information to be placed into the PXE DHCP and Discover packets. 67 | // This is the network interface type and version number that will 68 | // be placed into DHCP option 94 (client network interface identifier). 69 | BOOLEAN Ipv6Supported; 70 | UINT8 IfNum; // interface number to be used with pxeid structure 71 | } EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL, EFI_NETWORK_INTERFACE_IDENTIFIER_INTERFACE; 72 | 73 | // Note: Because it conflicted with the EDK2 struct name, the 74 | // 'EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL' GUID definition, 75 | // from older versions of gnu-efi, is now obsoleted. 76 | // Use 'EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID' instead. 77 | 78 | #endif // _EFI_NII_H 79 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/eficompiler.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Pete Batard 4 | 5 | Module Name: 6 | 7 | eficompiler.h 8 | 9 | Abstract: 10 | 11 | Compiler specific adjustments 12 | 13 | --*/ 14 | 15 | #ifdef _MSC_EXTENSIONS 16 | #define EFI_UNUSED 17 | #else 18 | #define EFI_UNUSED __attribute__((__unused__)) 19 | #endif 20 | 21 | #ifdef _MSC_EXTENSIONS 22 | #define ALIGN(x) __declspec(align(x)) 23 | #else 24 | #define ALIGN(x) __attribute__((__aligned__(x))) 25 | #endif 26 | 27 | /* Also add a catch-all on __attribute__() for MS compilers */ 28 | #ifdef _MSC_EXTENSIONS 29 | #define __attribute__(x) 30 | #endif 31 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/eficonex.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_CONEX_H 2 | #define _EFI_CONEX_H 3 | 4 | /*++ 5 | 6 | Copyright (c) 2020 Kagurazaka Kotori 7 | 8 | Module Name: 9 | 10 | eficonex.h 11 | 12 | Abstract: 13 | 14 | EFI console extension protocols 15 | 16 | --*/ 17 | 18 | // 19 | // Simple Text Input Ex Protocol 20 | // 21 | 22 | #define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \ 23 | { 0xdd9e7534, 0x7762, 0x4698, {0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa} } 24 | 25 | INTERFACE_DECL(_EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL); 26 | 27 | typedef UINT8 EFI_KEY_TOGGLE_STATE; 28 | 29 | typedef struct EFI_KEY_STATE { 30 | UINT32 KeyShiftState; 31 | EFI_KEY_TOGGLE_STATE KeyToggleState; 32 | } EFI_KEY_STATE; 33 | 34 | typedef struct { 35 | EFI_INPUT_KEY Key; 36 | EFI_KEY_STATE KeyState; 37 | } EFI_KEY_DATA; 38 | 39 | // Shift states 40 | #define EFI_SHIFT_STATE_VALID 0x80000000 41 | #define EFI_RIGHT_SHIFT_PRESSED 0x00000001 42 | #define EFI_LEFT_SHIFT_PRESSED 0x00000002 43 | #define EFI_RIGHT_CONTROL_PRESSED 0x00000004 44 | #define EFI_LEFT_CONTROL_PRESSED 0x00000008 45 | #define EFI_RIGHT_ALT_PRESSED 0x00000010 46 | #define EFI_LEFT_ALT_PRESSED 0x00000020 47 | #define EFI_RIGHT_LOGO_PRESSED 0x00000040 48 | #define EFI_LEFT_LOGO_PRESSED 0x00000080 49 | #define EFI_MENU_KEY_PRESSED 0x00000100 50 | #define EFI_SYS_REQ_PRESSED 0x00000200 51 | 52 | // Toggle states 53 | #define EFI_TOGGLE_STATE_VALID 0x80 54 | #define EFI_KEY_STATE_EXPOSED 0x40 55 | #define EFI_SCROLL_LOCK_ACTIVE 0x01 56 | #define EFI_NUM_LOCK_ACTIVE 0x02 57 | #define EFI_CAPS_LOCK_ACTIVE 0x04 58 | 59 | typedef 60 | EFI_STATUS 61 | (EFIAPI *EFI_INPUT_RESET_EX) ( 62 | IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, 63 | IN BOOLEAN ExtendedVerification 64 | ); 65 | 66 | typedef 67 | EFI_STATUS 68 | (EFIAPI *EFI_INPUT_READ_KEY_EX) ( 69 | IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, 70 | OUT EFI_KEY_DATA *KeyData 71 | ); 72 | 73 | typedef 74 | EFI_STATUS 75 | (EFIAPI *EFI_SET_STATE) ( 76 | IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, 77 | IN EFI_KEY_TOGGLE_STATE *KeyToggleState 78 | ); 79 | 80 | typedef 81 | EFI_STATUS 82 | (EFIAPI *EFI_KEY_NOTIFY_FUNCTION) ( 83 | IN EFI_KEY_DATA *KeyData 84 | ); 85 | 86 | typedef 87 | EFI_STATUS 88 | (EFIAPI *EFI_REGISTER_KEYSTROKE_NOTIFY) ( 89 | IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, 90 | IN EFI_KEY_DATA *KeyData, 91 | IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction, 92 | OUT VOID **NotifyHandle 93 | ); 94 | 95 | typedef 96 | EFI_STATUS 97 | (EFIAPI *EFI_UNREGISTER_KEYSTROKE_NOTIFY) ( 98 | IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, 99 | IN VOID *NotificationHandle 100 | ); 101 | 102 | typedef struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL{ 103 | EFI_INPUT_RESET_EX Reset; 104 | EFI_INPUT_READ_KEY_EX ReadKeyStrokeEx; 105 | EFI_EVENT WaitForKeyEx; 106 | EFI_SET_STATE SetState; 107 | EFI_REGISTER_KEYSTROKE_NOTIFY RegisterKeyNotify; 108 | EFI_UNREGISTER_KEYSTROKE_NOTIFY UnregisterKeyNotify; 109 | } EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL; 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/efierr.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_ERR_H 2 | #define _EFI_ERR_H 3 | 4 | /*++ 5 | 6 | Copyright (c) 1998 Intel Corporation 7 | 8 | Module Name: 9 | 10 | efierr.h 11 | 12 | Abstract: 13 | 14 | EFI error codes 15 | 16 | 17 | 18 | 19 | Revision History 20 | 21 | --*/ 22 | 23 | 24 | #define EFIWARN(a) (a) 25 | #define EFI_ERROR(a) (((INTN) a) < 0) 26 | 27 | 28 | #define EFI_SUCCESS 0 29 | #define EFI_LOAD_ERROR EFIERR(1) 30 | #define EFI_INVALID_PARAMETER EFIERR(2) 31 | #define EFI_UNSUPPORTED EFIERR(3) 32 | #define EFI_BAD_BUFFER_SIZE EFIERR(4) 33 | #define EFI_BUFFER_TOO_SMALL EFIERR(5) 34 | #define EFI_NOT_READY EFIERR(6) 35 | #define EFI_DEVICE_ERROR EFIERR(7) 36 | #define EFI_WRITE_PROTECTED EFIERR(8) 37 | #define EFI_OUT_OF_RESOURCES EFIERR(9) 38 | #define EFI_VOLUME_CORRUPTED EFIERR(10) 39 | #define EFI_VOLUME_FULL EFIERR(11) 40 | #define EFI_NO_MEDIA EFIERR(12) 41 | #define EFI_MEDIA_CHANGED EFIERR(13) 42 | #define EFI_NOT_FOUND EFIERR(14) 43 | #define EFI_ACCESS_DENIED EFIERR(15) 44 | #define EFI_NO_RESPONSE EFIERR(16) 45 | #define EFI_NO_MAPPING EFIERR(17) 46 | #define EFI_TIMEOUT EFIERR(18) 47 | #define EFI_NOT_STARTED EFIERR(19) 48 | #define EFI_ALREADY_STARTED EFIERR(20) 49 | #define EFI_ABORTED EFIERR(21) 50 | #define EFI_ICMP_ERROR EFIERR(22) 51 | #define EFI_TFTP_ERROR EFIERR(23) 52 | #define EFI_PROTOCOL_ERROR EFIERR(24) 53 | #define EFI_INCOMPATIBLE_VERSION EFIERR(25) 54 | #define EFI_SECURITY_VIOLATION EFIERR(26) 55 | #define EFI_CRC_ERROR EFIERR(27) 56 | #define EFI_END_OF_MEDIA EFIERR(28) 57 | #define EFI_END_OF_FILE EFIERR(31) 58 | #define EFI_INVALID_LANGUAGE EFIERR(32) 59 | #define EFI_COMPROMISED_DATA EFIERR(33) 60 | 61 | #define EFI_WARN_UNKOWN_GLYPH EFIWARN(1) 62 | #define EFI_WARN_UNKNOWN_GLYPH EFIWARN(1) 63 | #define EFI_WARN_DELETE_FAILURE EFIWARN(2) 64 | #define EFI_WARN_WRITE_FAILURE EFIWARN(3) 65 | #define EFI_WARN_BUFFER_TOO_SMALL EFIWARN(4) 66 | 67 | #endif 68 | 69 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/efifs.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_FS_H 2 | #define _EFI_FS_H 3 | 4 | /*++ 5 | 6 | Copyright (c) 1998 Intel Corporation 7 | 8 | Module Name: 9 | 10 | efifs.h 11 | 12 | Abstract: 13 | 14 | EFI File System structures 15 | 16 | 17 | 18 | Revision History 19 | 20 | --*/ 21 | 22 | 23 | // 24 | // EFI Partition header (normaly starts in LBA 1) 25 | // 26 | 27 | #define EFI_PARTITION_SIGNATURE 0x5053595320494249 28 | #define EFI_PARTITION_REVISION 0x00010001 29 | #define MIN_EFI_PARTITION_BLOCK_SIZE 512 30 | #define EFI_PARTITION_LBA 1 31 | 32 | typedef struct _EFI_PARTITION_HEADER { 33 | EFI_TABLE_HEADER Hdr; 34 | UINT32 DirectoryAllocationNumber; 35 | UINT32 BlockSize; 36 | EFI_LBA FirstUsableLba; 37 | EFI_LBA LastUsableLba; 38 | EFI_LBA UnusableSpace; 39 | EFI_LBA FreeSpace; 40 | EFI_LBA RootFile; 41 | EFI_LBA SecutiryFile; 42 | } EFI_PARTITION_HEADER; 43 | 44 | 45 | // 46 | // File header 47 | // 48 | 49 | #define EFI_FILE_HEADER_SIGNATURE 0x454c494620494249 50 | #define EFI_FILE_HEADER_REVISION 0x00010000 51 | #define EFI_FILE_STRING_SIZE 260 52 | 53 | typedef struct _EFI_FILE_HEADER { 54 | EFI_TABLE_HEADER Hdr; 55 | UINT32 Class; 56 | UINT32 LBALOffset; 57 | EFI_LBA Parent; 58 | UINT64 FileSize; 59 | UINT64 FileAttributes; 60 | EFI_TIME FileCreateTime; 61 | EFI_TIME FileModificationTime; 62 | EFI_GUID VendorGuid; 63 | CHAR16 FileString[EFI_FILE_STRING_SIZE]; 64 | } EFI_FILE_HEADER; 65 | 66 | 67 | // 68 | // Return the file's first LBAL which is in the same 69 | // logical block as the file header 70 | // 71 | 72 | #define EFI_FILE_LBAL(a) ((EFI_LBAL *) (((CHAR8 *) (a)) + (a)->LBALOffset)) 73 | 74 | #define EFI_FILE_CLASS_FREE_SPACE 1 75 | #define EFI_FILE_CLASS_EMPTY 2 76 | #define EFI_FILE_CLASS_NORMAL 3 77 | 78 | 79 | // 80 | // Logical Block Address List - the fundemental block 81 | // description structure 82 | // 83 | 84 | #define EFI_LBAL_SIGNATURE 0x4c41424c20494249 85 | #define EFI_LBAL_REVISION 0x00010000 86 | 87 | typedef struct _EFI_LBAL { 88 | EFI_TABLE_HEADER Hdr; 89 | UINT32 Class; 90 | EFI_LBA Parent; 91 | EFI_LBA Next; 92 | UINT32 ArraySize; 93 | UINT32 ArrayCount; 94 | } EFI_LBAL; 95 | 96 | // Array size 97 | #define EFI_LBAL_ARRAY_SIZE(lbal,offs,blks) \ 98 | (((blks) - (offs) - (lbal)->Hdr.HeaderSize) / sizeof(EFI_RL)) 99 | 100 | // 101 | // Logical Block run-length 102 | // 103 | 104 | typedef struct { 105 | EFI_LBA Start; 106 | UINT64 Length; 107 | } EFI_RL; 108 | 109 | // 110 | // Return the run-length structure from an LBAL header 111 | // 112 | 113 | #define EFI_LBAL_RL(a) ((EFI_RL*) (((CHAR8 *) (a)) + (a)->Hdr.HeaderSize)) 114 | 115 | #endif 116 | 117 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/efigpt.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_GPT_H 2 | #define _EFI_GPT_H 3 | /*++ 4 | 5 | Copyright (c) 1998 Intel Corporation 6 | 7 | Module Name: 8 | 9 | EfiGpt.h 10 | 11 | Abstract: 12 | Include file for EFI partitioning scheme 13 | 14 | 15 | 16 | Revision History 17 | 18 | --*/ 19 | 20 | #define PRIMARY_PART_HEADER_LBA 1 21 | 22 | typedef struct { 23 | EFI_TABLE_HEADER Header; 24 | EFI_LBA MyLBA; 25 | EFI_LBA AlternateLBA; 26 | EFI_LBA FirstUsableLBA; 27 | EFI_LBA LastUsableLBA; 28 | EFI_GUID DiskGUID; 29 | EFI_LBA PartitionEntryLBA; 30 | UINT32 NumberOfPartitionEntries; 31 | UINT32 SizeOfPartitionEntry; 32 | UINT32 PartitionEntryArrayCRC32; 33 | } EFI_PARTITION_TABLE_HEADER; 34 | 35 | #define EFI_PTAB_HEADER_ID "EFI PART" 36 | 37 | typedef struct { 38 | EFI_GUID PartitionTypeGUID; 39 | EFI_GUID UniquePartitionGUID; 40 | EFI_LBA StartingLBA; 41 | EFI_LBA EndingLBA; 42 | UINT64 Attributes; 43 | CHAR16 PartitionName[36]; 44 | } EFI_PARTITION_ENTRY; 45 | 46 | // 47 | // EFI Partition Attributes 48 | // 49 | #define EFI_PART_USED_BY_EFI 0x0000000000000001 50 | #define EFI_PART_REQUIRED_TO_FUNCTION 0x0000000000000002 51 | #define EFI_PART_USED_BY_OS 0x0000000000000004 52 | #define EFI_PART_REQUIRED_BY_OS 0x0000000000000008 53 | #define EFI_PART_BACKUP_REQUIRED 0x0000000000000010 54 | #define EFI_PART_USER_DATA 0x0000000000000020 55 | #define EFI_PART_CRITICAL_USER_DATA 0x0000000000000040 56 | #define EFI_PART_REDUNDANT_PARTITION 0x0000000000000080 57 | 58 | #define EFI_PART_TYPE_UNUSED_GUID \ 59 | { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} } 60 | 61 | #define EFI_PART_TYPE_EFI_SYSTEM_PART_GUID \ 62 | { 0xc12a7328, 0xf81f, 0x11d2, {0xba, 0x4b, 0x00, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b} } 63 | 64 | #define EFI_PART_TYPE_LEGACY_MBR_GUID \ 65 | { 0x024dee41, 0x33e7, 0x11d3, {0x9d, 0x69, 0x00, 0x08, 0xc7, 0x81, 0xf3, 0x9f} } 66 | 67 | #endif 68 | 69 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/efilink.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_LINK_H 2 | #define _EFI_LINK_H 3 | 4 | /*++ 5 | 6 | Copyright (c) 1998 Intel Corporation 7 | 8 | Module Name: 9 | 10 | link.h (renamed efilink.h to avoid conflicts) 11 | 12 | Abstract: 13 | 14 | EFI link list macro's 15 | 16 | 17 | 18 | Revision History 19 | 20 | --*/ 21 | 22 | #ifndef EFI_NT_EMUL 23 | 24 | // 25 | // List entry - doubly linked list 26 | // 27 | 28 | typedef struct _LIST_ENTRY { 29 | struct _LIST_ENTRY *Flink; 30 | struct _LIST_ENTRY *Blink; 31 | } LIST_ENTRY, EFI_LIST_ENTRY; 32 | 33 | #endif 34 | 35 | 36 | // 37 | // VOID 38 | // InitializeListHead( 39 | // LIST_ENTRY *ListHead 40 | // ); 41 | // 42 | 43 | #define InitializeListHead(ListHead) \ 44 | (ListHead)->Flink = ListHead; \ 45 | (ListHead)->Blink = ListHead; 46 | 47 | // 48 | // BOOLEAN 49 | // IsListEmpty( 50 | // PLIST_ENTRY ListHead 51 | // ); 52 | // 53 | 54 | #define IsListEmpty(ListHead) \ 55 | ((ListHead)->Flink == (ListHead)) 56 | 57 | // 58 | // VOID 59 | // RemoveEntryList( 60 | // PLIST_ENTRY Entry 61 | // ); 62 | // 63 | 64 | #define _RemoveEntryList(Entry) { \ 65 | LIST_ENTRY *_Blink, *_Flink; \ 66 | _Flink = (Entry)->Flink; \ 67 | _Blink = (Entry)->Blink; \ 68 | _Blink->Flink = _Flink; \ 69 | _Flink->Blink = _Blink; \ 70 | } 71 | 72 | #if EFI_DEBUG 73 | #define RemoveEntryList(Entry) \ 74 | _RemoveEntryList(Entry); \ 75 | (Entry)->Flink = (LIST_ENTRY *) BAD_POINTER; \ 76 | (Entry)->Blink = (LIST_ENTRY *) BAD_POINTER; 77 | #else 78 | #define RemoveEntryList(Entry) \ 79 | _RemoveEntryList(Entry); 80 | #endif 81 | 82 | // 83 | // VOID 84 | // InsertTailList( 85 | // PLIST_ENTRY ListHead, 86 | // PLIST_ENTRY Entry 87 | // ); 88 | // 89 | 90 | #define InsertTailList(ListHead,Entry) {\ 91 | LIST_ENTRY *_ListHead, *_Blink; \ 92 | _ListHead = (ListHead); \ 93 | _Blink = _ListHead->Blink; \ 94 | (Entry)->Flink = _ListHead; \ 95 | (Entry)->Blink = _Blink; \ 96 | _Blink->Flink = (Entry); \ 97 | _ListHead->Blink = (Entry); \ 98 | } 99 | 100 | // 101 | // VOID 102 | // InsertHeadList( 103 | // PLIST_ENTRY ListHead, 104 | // PLIST_ENTRY Entry 105 | // ); 106 | // 107 | 108 | #define InsertHeadList(ListHead,Entry) {\ 109 | LIST_ENTRY *_ListHead, *_Flink; \ 110 | _ListHead = (ListHead); \ 111 | _Flink = _ListHead->Flink; \ 112 | (Entry)->Flink = _Flink; \ 113 | (Entry)->Blink = _ListHead; \ 114 | _Flink->Blink = (Entry); \ 115 | _ListHead->Flink = (Entry); \ 116 | } 117 | 118 | // VOID 119 | // SwapListEntries( 120 | // PLIST_ENTRY Entry1, 121 | // PLIST_ENTRY Entry2 122 | // ); 123 | // 124 | // Put Entry2 before Entry1 125 | // 126 | #define SwapListEntries(Entry1,Entry2) {\ 127 | LIST_ENTRY *Entry1Flink, *Entry1Blink; \ 128 | LIST_ENTRY *Entry2Flink, *Entry2Blink; \ 129 | Entry2Flink = (Entry2)->Flink; \ 130 | Entry2Blink = (Entry2)->Blink; \ 131 | Entry1Flink = (Entry1)->Flink; \ 132 | Entry1Blink = (Entry1)->Blink; \ 133 | Entry2Blink->Flink = Entry2Flink; \ 134 | Entry2Flink->Blink = Entry2Blink; \ 135 | (Entry2)->Flink = Entry1; \ 136 | (Entry2)->Blink = Entry1Blink; \ 137 | Entry1Blink->Flink = (Entry2); \ 138 | (Entry1)->Blink = (Entry2); \ 139 | } 140 | 141 | // 142 | // EFI_FIELD_OFFSET - returns the byte offset to a field within a structure 143 | // 144 | 145 | #define EFI_FIELD_OFFSET(TYPE,Field) ((UINTN)(intptr_t)(&(((TYPE *) 0)->Field))) 146 | 147 | // 148 | // CONTAINING_RECORD - returns a pointer to the structure 149 | // from one of it's elements. 150 | // 151 | 152 | #define _CR(Record, TYPE, Field) \ 153 | ((TYPE *) ( (CHAR8 *)(Record) - (CHAR8 *) &(((TYPE *) 0)->Field))) 154 | 155 | // 156 | // EDK2 uses BASE_CR for the above 157 | // 158 | #define BASE_CR _CR 159 | 160 | #if EFI_DEBUG 161 | #define CR(Record, TYPE, Field, Sig) \ 162 | _CR(Record, TYPE, Field)->Signature != Sig ? \ 163 | (TYPE *) ASSERT_STRUCT(_CR(Record, TYPE, Field), Record) : \ 164 | _CR(Record, TYPE, Field) 165 | #else 166 | #define CR(Record, TYPE, Field, Signature) \ 167 | _CR(Record, TYPE, Field) 168 | #endif 169 | 170 | 171 | // 172 | // A lock structure 173 | // 174 | 175 | typedef struct _FLOCK { 176 | EFI_TPL Tpl; 177 | EFI_TPL OwnerTpl; 178 | UINTN Lock; 179 | } FLOCK; 180 | 181 | #endif 182 | 183 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/efipart.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_PART_H 2 | #define _EFI_PART_H 3 | 4 | /*++ 5 | 6 | Copyright (c) 1998 Intel Corporation 7 | 8 | Module Name: 9 | 10 | efipart.h 11 | 12 | Abstract: 13 | Info about disk partitions and Master Boot Records 14 | 15 | 16 | 17 | 18 | Revision History 19 | 20 | --*/ 21 | 22 | // 23 | // 24 | // 25 | 26 | #define EFI_PARTITION 0xef 27 | #define MBR_SIZE 512 28 | 29 | #pragma pack(1) 30 | 31 | typedef struct { 32 | UINT8 BootIndicator; 33 | UINT8 StartHead; 34 | UINT8 StartSector; 35 | UINT8 StartTrack; 36 | UINT8 OSIndicator; 37 | UINT8 EndHead; 38 | UINT8 EndSector; 39 | UINT8 EndTrack; 40 | UINT8 StartingLBA[4]; 41 | UINT8 SizeInLBA[4]; 42 | } MBR_PARTITION_RECORD; 43 | 44 | #define EXTRACT_UINT32(D) (UINT32)(D[0] | (D[1] << 8) | (D[2] << 16) | (D[3] << 24)) 45 | 46 | #define MBR_SIGNATURE 0xaa55 47 | #define MIN_MBR_DEVICE_SIZE 0x80000 48 | #define MBR_ERRATA_PAD 0x40000 // 128 MB 49 | 50 | #define MAX_MBR_PARTITIONS 4 51 | typedef struct { 52 | UINT8 BootStrapCode[440]; 53 | UINT8 UniqueMbrSignature[4]; 54 | UINT8 Unknown[2]; 55 | MBR_PARTITION_RECORD Partition[MAX_MBR_PARTITIONS]; 56 | UINT16 Signature; 57 | } MASTER_BOOT_RECORD; 58 | #pragma pack() 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/efipoint.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 by John Cronin 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | * THE SOFTWARE. 20 | */ 21 | 22 | #ifndef _EFI_POINT_H 23 | #define _EFI_POINT_H 24 | 25 | #define EFI_SIMPLE_POINTER_PROTOCOL_GUID \ 26 | { 0x31878c87, 0xb75, 0x11d5, { 0x9a, 0x4f, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } } 27 | 28 | INTERFACE_DECL(_EFI_SIMPLE_POINTER); 29 | 30 | typedef struct { 31 | INT32 RelativeMovementX; 32 | INT32 RelativeMovementY; 33 | INT32 RelativeMovementZ; 34 | BOOLEAN LeftButton; 35 | BOOLEAN RightButton; 36 | } EFI_SIMPLE_POINTER_STATE; 37 | 38 | typedef struct { 39 | UINT64 ResolutionX; 40 | UINT64 ResolutionY; 41 | UINT64 ResolutionZ; 42 | BOOLEAN LeftButton; 43 | BOOLEAN RightButton; 44 | } EFI_SIMPLE_POINTER_MODE; 45 | 46 | typedef 47 | EFI_STATUS 48 | (EFIAPI *EFI_SIMPLE_POINTER_RESET) ( 49 | IN struct _EFI_SIMPLE_POINTER *This, 50 | IN BOOLEAN ExtendedVerification 51 | ); 52 | 53 | typedef 54 | EFI_STATUS 55 | (EFIAPI *EFI_SIMPLE_POINTER_GET_STATE) ( 56 | IN struct _EFI_SIMPLE_POINTER *This, 57 | IN OUT EFI_SIMPLE_POINTER_STATE *State 58 | ); 59 | 60 | typedef struct _EFI_SIMPLE_POINTER { 61 | EFI_SIMPLE_POINTER_RESET Reset; 62 | EFI_SIMPLE_POINTER_GET_STATE GetState; 63 | EFI_EVENT WaitForInput; 64 | EFI_SIMPLE_POINTER_MODE *Mode; 65 | } EFI_SIMPLE_POINTER_PROTOCOL; 66 | 67 | #define EFI_ABSOLUTE_POINTER_PROTOCOL_GUID \ 68 | { 0x8D59D32B, 0xC655, 0x4AE9, { 0x9B, 0x15, 0xF2, 0x59, 0x04, 0x99, 0x2A, 0x43 } } 69 | 70 | INTERFACE_DECL(_EFI_ABSOLUTE_POINTER_PROTOCOL); 71 | 72 | typedef struct { 73 | UINT64 AbsoluteMinX; 74 | UINT64 AbsoluteMinY; 75 | UINT64 AbsoluteMinZ; 76 | UINT64 AbsoluteMaxX; 77 | UINT64 AbsoluteMaxY; 78 | UINT64 AbsoluteMaxZ; 79 | UINT32 Attributes; 80 | } EFI_ABSOLUTE_POINTER_MODE; 81 | 82 | typedef struct { 83 | UINT64 CurrentX; 84 | UINT64 CurrentY; 85 | UINT64 CurrentZ; 86 | UINT32 ActiveButtons; 87 | } EFI_ABSOLUTE_POINTER_STATE; 88 | 89 | #define EFI_ABSP_SupportsAltActive 0x00000001 90 | #define EFI_ABSP_SupportsPressureAsZ 0x00000002 91 | #define EFI_ABSP_TouchActive 0x00000001 92 | #define EFI_ABS_AltActive 0x00000002 93 | 94 | typedef 95 | EFI_STATUS 96 | (EFIAPI *EFI_ABSOLUTE_POINTER_RESET) ( 97 | IN struct _EFI_ABSOLUTE_POINTER_PROTOCOL *This, 98 | IN BOOLEAN ExtendedVerification 99 | ); 100 | 101 | typedef 102 | EFI_STATUS 103 | (EFIAPI *EFI_ABSOLUTE_POINTER_GET_STATE) ( 104 | IN struct _EFI_ABSOLUTE_POINTER_PROTOCOL *This, 105 | IN OUT EFI_ABSOLUTE_POINTER_STATE *State 106 | ); 107 | 108 | typedef struct _EFI_ABSOLUTE_POINTER_PROTOCOL { 109 | EFI_ABSOLUTE_POINTER_RESET Reset; 110 | EFI_ABSOLUTE_POINTER_GET_STATE GetState; 111 | EFI_EVENT WaitForInput; 112 | EFI_ABSOLUTE_POINTER_MODE *Mode; 113 | } EFI_ABSOLUTE_POINTER_PROTOCOL; 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/efirtlib.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_RT_LIB_INCLUDE_ 2 | #define _EFI_RT_LIB_INCLUDE_ 3 | /*++ 4 | 5 | Copyright (c) 1998 Intel Corporation 6 | 7 | Module Name: 8 | 9 | efilib.h 10 | 11 | Abstract: 12 | 13 | EFI Runtime library functions 14 | 15 | 16 | 17 | Revision History 18 | 19 | --*/ 20 | 21 | #include "efidebug.h" 22 | #include "efipart.h" 23 | #if defined(_M_X64) || defined(__x86_64__) || defined(__amd64__) 24 | #include "x86_64/efilibplat.h" 25 | #elif defined(_M_IX86) || defined(__i386__) 26 | #include "ia32/efilibplat.h" 27 | #elif defined(_M_IA64) || defined(__ia64__) 28 | #include "ia64/efilibplat.h" 29 | #elif defined (_M_ARM64) || defined(__aarch64__) 30 | #include "aarch64/efilibplat.h" 31 | #elif defined (_M_ARM) || defined(__arm__) 32 | #include "arm/efilibplat.h" 33 | #elif defined (_M_MIPS64) || defined(__mips64__) 34 | #include "mips64el/efilibplat.h" 35 | #elif defined (__riscv) && __riscv_xlen == 64 36 | #include "riscv64/efilibplat.h" 37 | #endif 38 | 39 | 40 | VOID 41 | RUNTIMEFUNCTION 42 | RtZeroMem ( 43 | IN VOID *Buffer, 44 | IN UINTN Size 45 | ); 46 | 47 | VOID 48 | RUNTIMEFUNCTION 49 | RtSetMem ( 50 | IN VOID *Buffer, 51 | IN UINTN Size, 52 | IN UINT8 Value 53 | ); 54 | 55 | VOID 56 | RUNTIMEFUNCTION 57 | RtCopyMem ( 58 | IN VOID *Dest, 59 | IN CONST VOID *Src, 60 | IN UINTN len 61 | ); 62 | 63 | INTN 64 | RUNTIMEFUNCTION 65 | RtCompareMem ( 66 | IN CONST VOID *Dest, 67 | IN CONST VOID *Src, 68 | IN UINTN len 69 | ); 70 | 71 | INTN 72 | RUNTIMEFUNCTION 73 | RtStrCmp ( 74 | IN CONST CHAR16 *s1, 75 | IN CONST CHAR16 *s2 76 | ); 77 | 78 | 79 | VOID 80 | RUNTIMEFUNCTION 81 | RtStrCpy ( 82 | IN CHAR16 *Dest, 83 | IN CONST CHAR16 *Src 84 | ); 85 | 86 | VOID 87 | RUNTIMEFUNCTION 88 | RtStrnCpy ( 89 | IN CHAR16 *Dest, 90 | IN CONST CHAR16 *Src, 91 | IN UINTN Len 92 | ); 93 | 94 | CHAR16 * 95 | RUNTIMEFUNCTION 96 | RtStpCpy ( 97 | IN CHAR16 *Dest, 98 | IN CONST CHAR16 *Src 99 | ); 100 | 101 | CHAR16 * 102 | RUNTIMEFUNCTION 103 | RtStpnCpy ( 104 | IN CHAR16 *Dest, 105 | IN CONST CHAR16 *Src, 106 | IN UINTN Len 107 | ); 108 | 109 | VOID 110 | RUNTIMEFUNCTION 111 | RtStrCat ( 112 | IN CHAR16 *Dest, 113 | IN CONST CHAR16 *Src 114 | ); 115 | 116 | VOID 117 | RUNTIMEFUNCTION 118 | RtStrnCat ( 119 | IN CHAR16 *Dest, 120 | IN CONST CHAR16 *Src, 121 | IN UINTN Len 122 | ); 123 | 124 | UINTN 125 | RUNTIMEFUNCTION 126 | RtStrLen ( 127 | IN CONST CHAR16 *s1 128 | ); 129 | 130 | UINTN 131 | RUNTIMEFUNCTION 132 | RtStrnLen ( 133 | IN CONST CHAR16 *s1, 134 | IN UINTN Len 135 | ); 136 | 137 | UINTN 138 | RUNTIMEFUNCTION 139 | RtStrSize ( 140 | IN CONST CHAR16 *s1 141 | ); 142 | 143 | INTN 144 | RUNTIMEFUNCTION 145 | RtCompareGuid ( 146 | IN EFI_GUID *Guid1, 147 | IN EFI_GUID *Guid2 148 | ); 149 | 150 | UINT8 151 | RUNTIMEFUNCTION 152 | RtDecimaltoBCD( 153 | IN UINT8 BcdValue 154 | ); 155 | 156 | UINT8 157 | RUNTIMEFUNCTION 158 | RtBCDtoDecimal( 159 | IN UINT8 BcdValue 160 | ); 161 | 162 | // 163 | // Virtual mapping transition support. (Only used during 164 | // the virtual address change transisition) 165 | // 166 | 167 | VOID 168 | RUNTIMEFUNCTION 169 | RtLibEnableVirtualMappings ( 170 | VOID 171 | ); 172 | 173 | VOID 174 | RUNTIMEFUNCTION 175 | RtConvertList ( 176 | IN UINTN DebugDisposition, 177 | IN OUT LIST_ENTRY *ListHead 178 | ); 179 | 180 | VOID 181 | RUNTIMEFUNCTION 182 | RtAcquireLock ( 183 | IN FLOCK *Lock 184 | ); 185 | 186 | VOID 187 | RUNTIMEFUNCTION 188 | RtReleaseLock ( 189 | IN FLOCK *Lock 190 | ); 191 | 192 | 193 | #endif 194 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/efiser.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_SER_H 2 | #define _EFI_SER_H 3 | 4 | /*++ 5 | 6 | Copyright (c) 1998 Intel Corporation 7 | 8 | Module Name: 9 | 10 | efiser.h 11 | 12 | Abstract: 13 | 14 | EFI serial protocol 15 | 16 | Revision History 17 | 18 | --*/ 19 | 20 | // 21 | // Serial protocol 22 | // 23 | 24 | #define EFI_SERIAL_IO_PROTOCOL_GUID \ 25 | { 0xBB25CF6F, 0xF1D4, 0x11D2, {0x9A, 0x0C, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0xFD} } 26 | #define SERIAL_IO_PROTOCOL EFI_SERIAL_IO_PROTOCOL_GUID 27 | 28 | INTERFACE_DECL(_EFI_SERIAL_IO_PROTOCOL); 29 | 30 | typedef enum { 31 | DefaultParity, 32 | NoParity, 33 | EvenParity, 34 | OddParity, 35 | MarkParity, 36 | SpaceParity 37 | } EFI_PARITY_TYPE; 38 | 39 | typedef enum { 40 | DefaultStopBits, 41 | OneStopBit, // 1 stop bit 42 | OneFiveStopBits, // 1.5 stop bits 43 | TwoStopBits // 2 stop bits 44 | } EFI_STOP_BITS_TYPE; 45 | 46 | #define EFI_SERIAL_CLEAR_TO_SEND 0x0010 // RO 47 | #define EFI_SERIAL_DATA_SET_READY 0x0020 // RO 48 | #define EFI_SERIAL_RING_INDICATE 0x0040 // RO 49 | #define EFI_SERIAL_CARRIER_DETECT 0x0080 // RO 50 | #define EFI_SERIAL_REQUEST_TO_SEND 0x0002 // WO 51 | #define EFI_SERIAL_DATA_TERMINAL_READY 0x0001 // WO 52 | #define EFI_SERIAL_INPUT_BUFFER_EMPTY 0x0100 // RO 53 | #define EFI_SERIAL_OUTPUT_BUFFER_EMPTY 0x0200 // RO 54 | #define EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE 0x1000 // RW 55 | #define EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE 0x2000 // RW 56 | #define EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE 0x4000 // RW 57 | 58 | typedef 59 | EFI_STATUS 60 | (EFIAPI *EFI_SERIAL_RESET) ( 61 | IN struct _EFI_SERIAL_IO_PROTOCOL *This 62 | ); 63 | 64 | typedef 65 | EFI_STATUS 66 | (EFIAPI *EFI_SERIAL_SET_ATTRIBUTES) ( 67 | IN struct _EFI_SERIAL_IO_PROTOCOL *This, 68 | IN UINT64 BaudRate, 69 | IN UINT32 ReceiveFifoDepth, 70 | IN UINT32 Timeout, 71 | IN EFI_PARITY_TYPE Parity, 72 | IN UINT8 DataBits, 73 | IN EFI_STOP_BITS_TYPE StopBits 74 | ); 75 | 76 | typedef 77 | EFI_STATUS 78 | (EFIAPI *EFI_SERIAL_SET_CONTROL_BITS) ( 79 | IN struct _EFI_SERIAL_IO_PROTOCOL *This, 80 | IN UINT32 Control 81 | ); 82 | 83 | typedef 84 | EFI_STATUS 85 | (EFIAPI *EFI_SERIAL_GET_CONTROL_BITS) ( 86 | IN struct _EFI_SERIAL_IO_PROTOCOL *This, 87 | OUT UINT32 *Control 88 | ); 89 | 90 | typedef 91 | EFI_STATUS 92 | (EFIAPI *EFI_SERIAL_WRITE) ( 93 | IN struct _EFI_SERIAL_IO_PROTOCOL *This, 94 | IN OUT UINTN *BufferSize, 95 | IN VOID *Buffer 96 | ); 97 | 98 | typedef 99 | EFI_STATUS 100 | (EFIAPI *EFI_SERIAL_READ) ( 101 | IN struct _EFI_SERIAL_IO_PROTOCOL *This, 102 | IN OUT UINTN *BufferSize, 103 | OUT VOID *Buffer 104 | ); 105 | 106 | typedef struct { 107 | UINT32 ControlMask; 108 | 109 | // current Attributes 110 | UINT32 Timeout; 111 | UINT64 BaudRate; 112 | UINT32 ReceiveFifoDepth; 113 | UINT32 DataBits; 114 | UINT32 Parity; 115 | UINT32 StopBits; 116 | } SERIAL_IO_MODE; 117 | 118 | #define SERIAL_IO_INTERFACE_REVISION 0x00010000 119 | 120 | typedef struct _EFI_SERIAL_IO_PROTOCOL { 121 | UINT32 Revision; 122 | EFI_SERIAL_RESET Reset; 123 | EFI_SERIAL_SET_ATTRIBUTES SetAttributes; 124 | EFI_SERIAL_SET_CONTROL_BITS SetControl; 125 | EFI_SERIAL_GET_CONTROL_BITS GetControl; 126 | EFI_SERIAL_WRITE Write; 127 | EFI_SERIAL_READ Read; 128 | 129 | SERIAL_IO_MODE *Mode; 130 | } EFI_SERIAL_IO_PROTOCOL; 131 | 132 | typedef struct _EFI_SERIAL_IO_PROTOCOL _SERIAL_IO_INTERFACE; 133 | typedef EFI_SERIAL_IO_PROTOCOL SERIAL_IO_INTERFACE; 134 | 135 | #endif 136 | 137 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/efisetjmp.h: -------------------------------------------------------------------------------- 1 | #ifndef GNU_EFI_SETJMP_H 2 | #define GNU_EFI_SETJMP_H 3 | 4 | #include "eficompiler.h" 5 | #include "efisetjmp_arch.h" 6 | 7 | extern UINTN setjmp(jmp_buf env) __attribute__((returns_twice)); 8 | extern VOID longjmp(jmp_buf env, UINTN value) __attribute__((noreturn)); 9 | 10 | #endif /* GNU_EFI_SETJMP_H */ 11 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/efishellintf.h: -------------------------------------------------------------------------------- 1 | /** @file 2 | SHELL_INTERFACE_PROTOCOL from EDK shell (no spec). 3 | 4 | Shell Interface - additional information (over image_info) provided 5 | to an application started by the shell. 6 | 7 | ConIo provides a file-style interface to the console. 8 | 9 | The shell interface's and data (including ConIo) are only valid during 10 | the applications Entry Point. Once the application returns from it's 11 | entry point the data is freed by the invoking shell. 12 | 13 | Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
14 | This program and the accompanying materials 15 | are licensed and made available under the terms and conditions of the BSD License 16 | which accompanies this distribution. The full text of the license may be found at 17 | http://opensource.org/licenses/bsd-license.php 18 | 19 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 20 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 21 | 22 | **/ 23 | /* 24 | * This is based on ShellPkg/Include/Protocol/EfiShellInterface.h from EDK II. 25 | */ 26 | 27 | #ifndef _SHELLINTERFACE_H_ 28 | #define _SHELLINTERFACE_H_ 29 | 30 | 31 | #define SHELL_INTERFACE_PROTOCOL_GUID \ 32 | { \ 33 | 0x47c7b223, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} \ 34 | } 35 | 36 | /// 37 | /// Bit definitions for EFI_SHELL_ARG_INFO 38 | /// 39 | typedef enum { 40 | ARG_NO_ATTRIB = 0x0, 41 | ARG_IS_QUOTED = 1<<0, 42 | ARG_PARTIALLY_QUOTED = 1<<1, 43 | ARG_FIRST_HALF_QUOTED = 1<<2, 44 | ARG_FIRST_CHAR_IS_ESC = 1<<3 45 | } EFI_SHELL_ARG_INFO_TYPES; 46 | 47 | /// 48 | /// Attributes for an argument. 49 | /// 50 | typedef struct _EFI_SHELL_ARG_INFO { 51 | UINT32 Attributes; 52 | } EFI_SHELL_ARG_INFO; 53 | 54 | /// 55 | /// This protocol provides access to additional information about a shell application. 56 | /// 57 | typedef struct { 58 | /// 59 | /// Handle back to original image handle & image information. 60 | /// 61 | EFI_HANDLE ImageHandle; 62 | EFI_LOADED_IMAGE *Info; 63 | 64 | /// 65 | /// Parsed arg list converted more C-like format. 66 | /// 67 | CHAR16 **Argv; 68 | UINTN Argc; 69 | 70 | /// 71 | /// Storage for file redirection args after parsing. 72 | /// 73 | CHAR16 **RedirArgv; 74 | UINTN RedirArgc; 75 | 76 | /// 77 | /// A file style handle for console io. 78 | /// 79 | EFI_FILE *StdIn; 80 | EFI_FILE *StdOut; 81 | EFI_FILE *StdErr; 82 | 83 | /// 84 | /// List of attributes for each argument. 85 | /// 86 | EFI_SHELL_ARG_INFO *ArgInfo; 87 | 88 | /// 89 | /// Whether we are echoing. 90 | /// 91 | BOOLEAN EchoOn; 92 | } EFI_SHELL_INTERFACE; 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/efistdarg.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFISTDARG_H_ 2 | #define _EFISTDARG_H_ 3 | 4 | /*++ 5 | 6 | Copyright (c) 1998 Intel Corporation 7 | 8 | Module Name: 9 | 10 | devpath.h 11 | 12 | Abstract: 13 | 14 | Defines for parsing the EFI Device Path structures 15 | 16 | 17 | 18 | Revision History 19 | 20 | --*/ 21 | 22 | #if !defined(GNU_EFI_USE_EXTERNAL_STDARG) && !defined(_MSC_VER) 23 | typedef __builtin_va_list va_list; 24 | 25 | # define va_start(v,l) __builtin_va_start(v,l) 26 | # define va_end(v) __builtin_va_end(v) 27 | # define va_arg(v,l) __builtin_va_arg(v,l) 28 | # define va_copy(d,s) __builtin_va_copy(d,s) 29 | #else 30 | # include 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/efiui.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_UI_H 2 | #define _EFI_UI_H 3 | 4 | /*++ 5 | 6 | Copyright (c) 200 Intel Corporation 7 | 8 | Module Name: 9 | 10 | EfiUi.h 11 | 12 | Abstract: 13 | Protocol used to build User Interface (UI) stuff. 14 | 15 | This protocol is just data. It is a multi dimentional array. 16 | For each string there is an array of UI_STRING_ENTRY. Each string 17 | is for a different language translation of the same string. The list 18 | is terminated by a NULL UiString. There can be any number of 19 | UI_STRING_ENTRY arrays. A NULL array terminates the list. A NULL array 20 | entry contains all zeros. 21 | 22 | Thus the shortest possible EFI_UI_PROTOCOL has three UI_STRING_ENTRY. 23 | The String, it's NULL terminator, and the NULL terminator for the entire 24 | thing. 25 | 26 | 27 | Revision History 28 | 29 | --*/ 30 | 31 | #define EFI_UI_INTERFACE_PROTOCOL_GUID \ 32 | { 0x32dd7981, 0x2d27, 0x11d4, {0xbc, 0x8b, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} } 33 | #define EFI_UI_PROTOCOL EFI_UI_INTERFACE_PROTOCOL_GUID 34 | 35 | 36 | typedef enum { 37 | UiDeviceString, 38 | UiVendorString, 39 | UiMaxString 40 | } UI_STRING_TYPE; 41 | 42 | typedef struct { 43 | ISO_639_2 *LangCode; 44 | CHAR16 *UiString; 45 | } UI_STRING_ENTRY; 46 | 47 | #define EFI_UI_INTERFACE_PROTOCOL_VERSION 0x00010000 48 | #define EFI_UI_VERSION EFI_UI_INTERFACE_PROTOCOL_VERSION 49 | 50 | typedef struct _EFI_UI_INTERFACE_PROTOCOL { 51 | UINT32 Version; 52 | UI_STRING_ENTRY *Entry; 53 | } EFI_UI_INTERFACE_PROTOCOL; 54 | 55 | typedef struct _EFI_UI_INTERFACE_PROTOCOL _UI_INTERFACE; 56 | typedef EFI_UI_INTERFACE_PROTOCOL UI_INTERFACE; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/ia32/efilibplat.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 1998 Intel Corporation 4 | 5 | Module Name: 6 | 7 | efilibplat.h 8 | 9 | Abstract: 10 | 11 | EFI to compile bindings 12 | 13 | 14 | 15 | 16 | Revision History 17 | 18 | --*/ 19 | 20 | VOID 21 | InitializeLibPlatform ( 22 | IN EFI_HANDLE ImageHandle, 23 | IN EFI_SYSTEM_TABLE *SystemTable 24 | ); 25 | 26 | 27 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/ia32/efisetjmp_arch.h: -------------------------------------------------------------------------------- 1 | #ifndef GNU_EFI_IA32_SETJMP_H 2 | #define GNU_EFI_IA32_SETJMP_H 3 | 4 | #define JMPBUF_ALIGN 4 5 | 6 | typedef struct { 7 | UINT32 Ebx; 8 | UINT32 Esi; 9 | UINT32 Edi; 10 | UINT32 Ebp; 11 | UINT32 Esp; 12 | UINT32 Eip; 13 | } ALIGN(JMPBUF_ALIGN) jmp_buf[1]; 14 | 15 | #endif /* GNU_EFI_IA32_SETJMP_H */ 16 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/ia64/efilibplat.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_LIB_PLAT_H 2 | #define _EFI_LIB_PLAT_H 3 | /*++ 4 | 5 | Copyright (c) 1998 Intel Corporation 6 | 7 | Module Name: 8 | 9 | efilibplat.h 10 | 11 | Abstract: 12 | 13 | EFI to compile bindings 14 | 15 | 16 | 17 | Revision History 18 | 19 | --*/ 20 | 21 | #include "salproc.h" 22 | 23 | 24 | VOID 25 | InitializeLibPlatform ( 26 | IN EFI_HANDLE ImageHandle, 27 | IN EFI_SYSTEM_TABLE *SystemTable 28 | ); 29 | 30 | VOID 31 | LibInitSalAndPalProc( 32 | OUT PLABEL *SalPlabel, 33 | OUT UINT64 *PalEntry 34 | ); 35 | 36 | EFI_STATUS 37 | LibGetSalIoPortMapping ( 38 | OUT UINT64 *IoPortMapping 39 | ); 40 | 41 | EFI_STATUS 42 | LibGetSalIpiBlock ( 43 | OUT UINT64 *IpiBlock 44 | ); 45 | 46 | EFI_STATUS 47 | LibGetSalWakeupVector ( 48 | OUT UINT64 *WakeVector 49 | ); 50 | 51 | VOID * 52 | LibSearchSalSystemTable ( 53 | IN UINT8 EntryType 54 | ); 55 | 56 | 57 | VOID 58 | LibSalProc ( 59 | IN UINT64 Arg1, 60 | IN UINT64 Arg2, 61 | IN UINT64 Arg3, 62 | IN UINT64 Arg4, 63 | IN UINT64 Arg5, 64 | IN UINT64 Arg6, 65 | IN UINT64 Arg7, 66 | IN UINT64 Arg8, 67 | OUT rArg *Results OPTIONAL 68 | ); 69 | 70 | VOID 71 | LibPalProc ( 72 | IN UINT64 Arg1, 73 | IN UINT64 Arg2, 74 | IN UINT64 Arg3, 75 | IN UINT64 Arg4, 76 | OUT rArg *Results OPTIONAL 77 | ); 78 | 79 | #endif 80 | 81 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/ia64/efisetjmp_arch.h: -------------------------------------------------------------------------------- 1 | #ifndef GNU_EFI_IA64_SETJMP_H 2 | #define GNU_EFI_IA64_SETJMP_H 3 | 4 | #define JMPBUF_ALIGN 0x10 5 | 6 | typedef struct { 7 | UINT64 F2[2]; 8 | UINT64 F3[2]; 9 | UINT64 F4[2]; 10 | UINT64 F5[2]; 11 | UINT64 F16[2]; 12 | UINT64 F17[2]; 13 | UINT64 F18[2]; 14 | UINT64 F19[2]; 15 | UINT64 F20[2]; 16 | UINT64 F21[2]; 17 | UINT64 F22[2]; 18 | UINT64 F23[2]; 19 | UINT64 F24[2]; 20 | UINT64 F25[2]; 21 | UINT64 F26[2]; 22 | UINT64 F27[2]; 23 | UINT64 F28[2]; 24 | UINT64 F29[2]; 25 | UINT64 F30[2]; 26 | UINT64 F31[2]; 27 | UINT64 R4; 28 | UINT64 R5; 29 | UINT64 R6; 30 | UINT64 R7; 31 | UINT64 SP; 32 | UINT64 BR0; 33 | UINT64 BR1; 34 | UINT64 BR2; 35 | UINT64 BR3; 36 | UINT64 BR4; 37 | UINT64 BR5; 38 | UINT64 InitialUNAT; 39 | UINT64 AfterSpillUNAT; 40 | UINT64 PFS; 41 | UINT64 BSP; 42 | UINT64 Predicates; 43 | UINT64 LoopCount; 44 | UINT64 FPSR; 45 | } ALIGN(JMPBUF_ALIGN) jmp_buf[1]; 46 | 47 | #endif /* GNU_EFI_IA64_SETJMP_H */ 48 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/inc.mak: -------------------------------------------------------------------------------- 1 | 2 | 3 | INC_DEPS = $(INC_DEPS) \ 4 | efi.h \ 5 | efiapi.h \ 6 | efibind.h \ 7 | eficon.h \ 8 | efidebug.h \ 9 | efidef.h \ 10 | efidevp.h \ 11 | efierr.h \ 12 | efifs.h \ 13 | efilib.h \ 14 | efipart.h \ 15 | efipciio.h \ 16 | efiprot.h \ 17 | efipxe.h \ 18 | efivar.h \ 19 | pe.h \ 20 | efiip.h \ 21 | efiudp.h \ 22 | efitcp.h \ 23 | stdarg.h 24 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/lib.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 1998 Intel Corporation 4 | 5 | Module Name: 6 | 7 | lib.h 8 | 9 | Abstract: 10 | 11 | EFI library header files 12 | 13 | 14 | 15 | Revision History 16 | 17 | --*/ 18 | 19 | #ifdef __GNUC__ 20 | #pragma GCC visibility push(hidden) 21 | #endif 22 | 23 | #include "efi.h" 24 | #include "efilib.h" 25 | #include "efirtlib.h" 26 | 27 | // 28 | // Include non architectural protocols 29 | // 30 | #include "protocol/efivar.h" 31 | #include "protocol/legacyboot.h" 32 | #include "protocol/intload.h" 33 | #include "protocol/vgaclass.h" 34 | #include "protocol/eficonsplit.h" 35 | #include "protocol/adapterdebug.h" 36 | #include "protocol/intload.h" 37 | 38 | #include "efigpt.h" 39 | #include "libsmbios.h" 40 | 41 | // 42 | // Prototypes 43 | // 44 | 45 | VOID 46 | InitializeGuid ( 47 | VOID 48 | ); 49 | 50 | INTN EFIAPI 51 | LibStubStriCmp ( 52 | IN EFI_UNICODE_COLLATION_INTERFACE *This, 53 | IN CHAR16 *S1, 54 | IN CHAR16 *S2 55 | ); 56 | 57 | BOOLEAN EFIAPI 58 | LibStubMetaiMatch ( 59 | IN EFI_UNICODE_COLLATION_INTERFACE *This, 60 | IN CHAR16 *String, 61 | IN CHAR16 *Pattern 62 | ); 63 | 64 | VOID EFIAPI 65 | LibStubStrLwrUpr ( 66 | IN EFI_UNICODE_COLLATION_INTERFACE *This, 67 | IN CHAR16 *Str 68 | ); 69 | 70 | BOOLEAN 71 | LibMatchDevicePaths ( 72 | IN EFI_DEVICE_PATH *Multi, 73 | IN EFI_DEVICE_PATH *Single 74 | ); 75 | 76 | EFI_DEVICE_PATH * 77 | LibDuplicateDevicePathInstance ( 78 | IN EFI_DEVICE_PATH *DevPath 79 | ); 80 | 81 | 82 | // 83 | // Globals 84 | // 85 | extern BOOLEAN LibInitialized; 86 | extern BOOLEAN LibFwInstance; 87 | extern EFI_HANDLE LibImageHandle; 88 | extern SIMPLE_TEXT_OUTPUT_INTERFACE *LibRuntimeDebugOut; 89 | extern EFI_UNICODE_COLLATION_INTERFACE *UnicodeInterface; 90 | extern EFI_UNICODE_COLLATION_INTERFACE LibStubUnicodeInterface; 91 | extern EFI_RAISE_TPL LibRuntimeRaiseTPL; 92 | extern EFI_RESTORE_TPL LibRuntimeRestoreTPL; 93 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/libsmbios.h: -------------------------------------------------------------------------------- 1 | #ifndef _LIB_SMBIOS_H 2 | #define _LIB_SMBIOS_H 3 | /*++ 4 | 5 | Copyright (c) 2000 Intel Corporation 6 | 7 | Module Name: 8 | 9 | LibSmbios.h 10 | 11 | Abstract: 12 | 13 | Lib include for SMBIOS services. Used to get system serial number and GUID 14 | 15 | Revision History 16 | 17 | --*/ 18 | 19 | // 20 | // Define SMBIOS tables. 21 | // 22 | #pragma pack(1) 23 | typedef struct { 24 | UINT8 AnchorString[4]; 25 | UINT8 EntryPointStructureChecksum; 26 | UINT8 EntryPointLength; 27 | UINT8 MajorVersion; 28 | UINT8 MinorVersion; 29 | UINT16 MaxStructureSize; 30 | UINT8 EntryPointRevision; 31 | UINT8 FormattedArea[5]; 32 | UINT8 IntermediateAnchorString[5]; 33 | UINT8 IntermediateChecksum; 34 | UINT16 TableLength; 35 | UINT32 TableAddress; 36 | UINT16 NumberOfSmbiosStructures; 37 | UINT8 SmbiosBcdRevision; 38 | } SMBIOS_STRUCTURE_TABLE; 39 | 40 | typedef struct { 41 | UINT8 AnchorString[5]; 42 | UINT8 EntryPointStructureChecksum; 43 | UINT8 EntryPointLength; 44 | UINT8 MajorVersion; 45 | UINT8 MinorVersion; 46 | UINT8 DocRev; 47 | UINT8 EntryPointRevision; 48 | UINT8 Reserved; 49 | UINT32 TableMaximumSize; 50 | UINT64 TableAddress; 51 | } SMBIOS3_STRUCTURE_TABLE; 52 | 53 | // 54 | // Please note that SMBIOS structures can be odd byte aligned since the 55 | // unformated section of each record is a set of arbitrary size strings. 56 | // 57 | 58 | typedef struct { 59 | UINT8 Type; 60 | UINT8 Length; 61 | UINT8 Handle[2]; 62 | } SMBIOS_HEADER; 63 | 64 | typedef UINT8 SMBIOS_STRING; 65 | 66 | typedef struct { 67 | SMBIOS_HEADER Hdr; 68 | SMBIOS_STRING Vendor; 69 | SMBIOS_STRING BiosVersion; 70 | UINT8 BiosSegment[2]; 71 | SMBIOS_STRING BiosReleaseDate; 72 | UINT8 BiosSize; 73 | UINT8 BiosCharacteristics[8]; 74 | } SMBIOS_TYPE0; 75 | 76 | typedef struct { 77 | SMBIOS_HEADER Hdr; 78 | SMBIOS_STRING Manufacturer; 79 | SMBIOS_STRING ProductName; 80 | SMBIOS_STRING Version; 81 | SMBIOS_STRING SerialNumber; 82 | 83 | // 84 | // always byte copy this data to prevent alignment faults! 85 | // 86 | EFI_GUID Uuid; 87 | 88 | UINT8 WakeUpType; 89 | } SMBIOS_TYPE1; 90 | 91 | typedef struct { 92 | SMBIOS_HEADER Hdr; 93 | SMBIOS_STRING Manufacturer; 94 | SMBIOS_STRING ProductName; 95 | SMBIOS_STRING Version; 96 | SMBIOS_STRING SerialNumber; 97 | } SMBIOS_TYPE2; 98 | 99 | typedef struct { 100 | SMBIOS_HEADER Hdr; 101 | SMBIOS_STRING Manufacturer; 102 | UINT8 Type; 103 | SMBIOS_STRING Version; 104 | SMBIOS_STRING SerialNumber; 105 | SMBIOS_STRING AssetTag; 106 | UINT8 BootupState; 107 | UINT8 PowerSupplyState; 108 | UINT8 ThermalState; 109 | UINT8 SecurityStatus; 110 | UINT8 OemDefined[4]; 111 | } SMBIOS_TYPE3; 112 | 113 | typedef struct { 114 | SMBIOS_HEADER Hdr; 115 | UINT8 Socket; 116 | UINT8 ProcessorType; 117 | UINT8 ProcessorFamily; 118 | SMBIOS_STRING ProcessorManufacture; 119 | UINT8 ProcessorId[8]; 120 | SMBIOS_STRING ProcessorVersion; 121 | UINT8 Voltage; 122 | UINT8 ExternalClock[2]; 123 | UINT8 MaxSpeed[2]; 124 | UINT8 CurrentSpeed[2]; 125 | UINT8 Status; 126 | UINT8 ProcessorUpgrade; 127 | UINT8 L1CacheHandle[2]; 128 | UINT8 L2CacheHandle[2]; 129 | UINT8 L3CacheHandle[2]; 130 | } SMBIOS_TYPE4; 131 | 132 | typedef union { 133 | SMBIOS_HEADER *Hdr; 134 | SMBIOS_TYPE0 *Type0; 135 | SMBIOS_TYPE1 *Type1; 136 | SMBIOS_TYPE2 *Type2; 137 | SMBIOS_TYPE3 *Type3; 138 | SMBIOS_TYPE4 *Type4; 139 | UINT8 *Raw; 140 | } SMBIOS_STRUCTURE_POINTER; 141 | #pragma pack() 142 | 143 | #endif 144 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/make.inf: -------------------------------------------------------------------------------- 1 | # 2 | # 3 | # 4 | 5 | [sources] 6 | efi.h 7 | efiapi.h 8 | eficon.h 9 | efidebug.h 10 | efidef.h 11 | efidevp.h 12 | efierr.h 13 | efifs.h 14 | efilib.h 15 | efipart.h 16 | efipciio.h 17 | efiprot.h 18 | efipxebc.h 19 | efistdarg.h 20 | efinet.h 21 | efiip.h 22 | efiudp.h 23 | efitcp.h 24 | 25 | [ia32sources] 26 | efibind.h 27 | pe.h 28 | efilibplat.h 29 | 30 | [ia64sources] 31 | efibind.h 32 | pe.h 33 | efilibplat.h 34 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/makefile.hdr: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # This is a machine generated file - DO NOT EDIT 4 | # Generated by genmake.exe 5 | # Generated from make.inf 6 | # Copyright (c) 1998 Intel Corporation 7 | # 8 | 9 | INC_DEPS = $(INC_DEPS) \ 10 | $(SDK_INSTALL_DIR)\include\efi\efi.h \ 11 | $(SDK_INSTALL_DIR)\include\efi\efiapi.h \ 12 | $(SDK_INSTALL_DIR)\include\efi\eficon.h \ 13 | $(SDK_INSTALL_DIR)\include\efi\efidebug.h \ 14 | $(SDK_INSTALL_DIR)\include\efi\efidef.h \ 15 | $(SDK_INSTALL_DIR)\include\efi\efidevp.h \ 16 | $(SDK_INSTALL_DIR)\include\efi\efierr.h \ 17 | $(SDK_INSTALL_DIR)\include\efi\efifs.h \ 18 | $(SDK_INSTALL_DIR)\include\efi\efilib.h \ 19 | $(SDK_INSTALL_DIR)\include\efi\efipart.h \ 20 | $(SDK_INSTALL_DIR)\include\efi\efipciio.h \ 21 | $(SDK_INSTALL_DIR)\include\efi\efiprot.h \ 22 | $(SDK_INSTALL_DIR)\include\efi\efipxebc.h \ 23 | $(SDK_INSTALL_DIR)\include\efi\efistdarg.h \ 24 | $(SDK_INSTALL_DIR)\include\efi\efinet.h \ 25 | $(SDK_INSTALL_DIR)\include\efi\efiip.h \ 26 | $(SDK_INSTALL_DIR)\include\efi\efiudp.h \ 27 | $(SDK_INSTALL_DIR)\include\efi\efitcp.h \ 28 | 29 | 30 | !IF "$(PROCESSOR)" == "Ia32" 31 | INC_DEPS = $(INC_DEPS) \ 32 | $(SDK_INSTALL_DIR)\include\efi\Ia32\efibind.h \ 33 | $(SDK_INSTALL_DIR)\include\efi\Ia32\pe.h \ 34 | $(SDK_INSTALL_DIR)\include\efi\Ia32\efilibplat.h \ 35 | 36 | 37 | !ENDIF 38 | 39 | 40 | !IF "$(PROCESSOR)" == "Ia64" 41 | INC_DEPS = $(INC_DEPS) \ 42 | $(SDK_INSTALL_DIR)\include\efi\Ia64\efibind.h \ 43 | $(SDK_INSTALL_DIR)\include\efi\Ia64\pe.h \ 44 | $(SDK_INSTALL_DIR)\include\efi\Ia64\efilibplat.h \ 45 | 46 | 47 | !ENDIF 48 | 49 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/mips64el/efilibplat.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 1998 Intel Corporation 4 | 5 | Module Name: 6 | 7 | efilibplat.h 8 | 9 | Abstract: 10 | 11 | EFI to compile bindings 12 | 13 | 14 | 15 | 16 | Revision History 17 | 18 | --*/ 19 | 20 | VOID 21 | InitializeLibPlatform ( 22 | IN EFI_HANDLE ImageHandle, 23 | IN EFI_SYSTEM_TABLE *SystemTable 24 | ); 25 | 26 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/mips64el/efisetjmp_arch.h: -------------------------------------------------------------------------------- 1 | #ifndef GNU_EFI_MIPS64EL_SETJMP_H 2 | #define GNU_EFI_MIPS64EL_SETJMP_H 3 | 4 | #define JMPBUF_ALIGN 8 5 | 6 | typedef struct { 7 | /* GP regs */ 8 | UINT64 RA; 9 | UINT64 SP; 10 | UINT64 FP; 11 | UINT64 GP; 12 | UINT64 S0; 13 | UINT64 S1; 14 | UINT64 S2; 15 | UINT64 S3; 16 | UINT64 S4; 17 | UINT64 S5; 18 | UINT64 S6; 19 | UINT64 S7; 20 | 21 | #ifdef __mips_hard_float 22 | /* FP regs */ 23 | UINT64 F24; 24 | UINT64 F25; 25 | UINT64 F26; 26 | UINT64 F27; 27 | UINT64 F28; 28 | UINT64 F29; 29 | UINT64 F30; 30 | UINT64 F31; 31 | #endif 32 | } ALIGN(JMPBUF_ALIGN) jmp_buf[1]; 33 | 34 | #endif /* GNU_EFI_MIPS64EL_SETJMP_H */ 35 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/protocol/adapterdebug.h: -------------------------------------------------------------------------------- 1 | #ifndef _ADAPTER_DEBUG_H 2 | #define _ADAPTER_DEBUG_H 3 | 4 | /*++ 5 | 6 | Copyright (c) 1999 Intel Corporation 7 | 8 | Module Name: 9 | 10 | AdapterDebug.h 11 | 12 | Abstract: 13 | 14 | Protocol to debug the EDD 3.0 enablement of BIOS option ROMs 15 | 16 | 17 | 18 | Revision History 19 | 20 | --*/ 21 | 22 | // {82F86881-282B-11d4-BC7D-0080C73C8881} 23 | #define ADAPTER_DEBUG_PROTOCOL \ 24 | { 0x82f86881, 0x282b, 0x11d4, {0xbc, 0x7d, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} } 25 | 26 | // 27 | // This protocol points to the BIOS_LEGACY_DRIVE data structure 28 | // see edd.h for more details 29 | // 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/protocol/eficonsplit.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_CONFORK_H 2 | #define _EFI_CONFORK_H 3 | /*++ 4 | 5 | Copyright (c) 1999 Intel Corporation 6 | 7 | Module Name: 8 | 9 | Abstract: 10 | 11 | 12 | 13 | Revision History 14 | 15 | --*/ 16 | 17 | 18 | 19 | // 20 | // ConOut Forker Protocol 21 | // 22 | 23 | #define TEXT_OUT_SPLITER_PROTOCOL \ 24 | { 0x56d830a0, 0x7e7a, 0x11d3, {0xbb, 0xa0, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } 25 | 26 | #define ERROR_OUT_SPLITER_PROTOCOL \ 27 | { 0xf0ba9039, 0x68f1, 0x425e, {0xaa, 0x7f, 0xd9, 0xaa, 0xf9, 0x1b, 0x82, 0xa1}} 28 | 29 | #define TEXT_IN_SPLITER_PROTOCOL \ 30 | { 0xf9a3c550, 0x7fb5, 0x11d3, {0xbb, 0xa0, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/protocol/efivar.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 1998 Intel Corporation 4 | 5 | Module Name: 6 | 7 | Abstract: 8 | 9 | 10 | 11 | Revision History 12 | 13 | --*/ 14 | 15 | 16 | 17 | // 18 | // The variable store protocol interface is specific to the reference 19 | // implementation. The initialization code adds variable store devices 20 | // to the system, and the FW connects to the devices to provide the 21 | // variable store interfaces through these devices. 22 | // 23 | 24 | // 25 | // Variable Store Device protocol 26 | // 27 | 28 | #define VARIABLE_STORE_PROTOCOL \ 29 | { 0xf088cd91, 0xa046, 0x11d2, {0x8e, 0x42, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } 30 | 31 | INTERFACE_DECL(_EFI_VARIABLE_STORE); 32 | 33 | typedef 34 | EFI_STATUS 35 | (EFIAPI *EFI_STORE_CLEAR) ( 36 | IN struct _EFI_VARIABLE_STORE *This, 37 | IN UINTN BankNo, 38 | IN OUT VOID *Scratch 39 | ); 40 | 41 | 42 | typedef 43 | EFI_STATUS 44 | (EFIAPI *EFI_STORE_READ) ( 45 | IN struct _EFI_VARIABLE_STORE *This, 46 | IN UINTN BankNo, 47 | IN UINTN Offset, 48 | IN UINTN BufferSize, 49 | OUT VOID *Buffer 50 | ); 51 | 52 | typedef 53 | EFI_STATUS 54 | (EFIAPI *EFI_STORE_UPDATE) ( 55 | IN struct _EFI_VARIABLE_STORE *This, 56 | IN UINTN BankNo, 57 | IN UINTN Offset, 58 | IN UINTN BufferSize, 59 | IN VOID *Buffer 60 | ); 61 | 62 | typedef 63 | EFI_STATUS 64 | (EFIAPI *EFI_STORE_SIZE) ( 65 | IN struct _EFI_VARIABLE_STORE *This, 66 | IN UINTN NoBanks 67 | ); 68 | 69 | typedef 70 | EFI_STATUS 71 | (EFIAPI *EFI_TRANSACTION_UPDATE) ( 72 | IN struct _EFI_VARIABLE_STORE *This, 73 | IN UINTN BankNo, 74 | IN VOID *NewContents 75 | ); 76 | 77 | typedef struct _EFI_VARIABLE_STORE { 78 | 79 | // 80 | // Number of banks and bank size 81 | // 82 | 83 | UINT32 Attributes; 84 | UINT32 BankSize; 85 | UINT32 NoBanks; 86 | 87 | // 88 | // Functions to access the storage banks 89 | // 90 | 91 | EFI_STORE_CLEAR ClearStore; 92 | EFI_STORE_READ ReadStore; 93 | EFI_STORE_UPDATE UpdateStore; 94 | EFI_STORE_SIZE SizeStore OPTIONAL; 95 | EFI_TRANSACTION_UPDATE TransactionUpdate OPTIONAL; 96 | 97 | } EFI_VARIABLE_STORE; 98 | 99 | 100 | // 101 | // 102 | // ClearStore() - A function to clear the requested storage bank. A cleared 103 | // bank contains all "on" bits. 104 | // 105 | // ReadStore() - Read data from the requested store. 106 | // 107 | // UpdateStore() - Updates data on the requested store. The FW will only 108 | // ever issue updates to clear bits in the store. Updates must be 109 | // performed in LSb to MSb order of the update buffer. 110 | // 111 | // SizeStore() - An optional function for non-runtime stores that can be 112 | // dynamically sized. The FW will only ever increase or decrease the store 113 | // by 1 banksize at a time, and it is always adding or removing a bank from 114 | // the end of the store. 115 | // 116 | // By default the FW will update variables and storage banks in an 117 | // "atomic" manner by keeping 1 old copy of the data during an update, 118 | // and recovering appropiately if the power is lost during the middle 119 | // of an operation. To do this the FW needs to have multiple banks 120 | // of storage dedicated to its use. If that's not possible, the driver 121 | // can implement an atomic bank update function and the FW will allow 122 | // 1 bank in this case. (It will allow any number of banks, 123 | // but it won't require an "extra" bank to provide its bank transaction 124 | // function). 125 | // 126 | // TransactionUpdate() - An optional function that can clear & update an 127 | // entire bank in an "atomic" fashion. If the operation fails in the 128 | // middle the driver is responsible for having either the previous copy 129 | // of the bank's data or the new copy. A copy that's partially written 130 | // is not valid as internal data settings may get lost. Supply this 131 | // function only when needed. 132 | // 133 | 134 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/protocol/intload.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 1999 Intel Corporation 4 | 5 | Module Name: 6 | 7 | intload 8 | 9 | Abstract: 10 | 11 | EFI support for loading internally linked in apps 12 | 13 | 14 | 15 | Revision History 16 | 17 | --*/ 18 | 19 | #ifndef _INTERNAL_LOAD_INCLUDE_ 20 | #define _INTERNAL_LOAD_INCLUDE_ 21 | 22 | // {D65A6B8C-71E5-4df0-A909-F0D2992B5AA9} 23 | #define INTERNAL_SHELL_GUID \ 24 | { 0xd65a6b8c, 0x71e5, 0x4df0, {0xa9, 0x09, 0xf0, 0xd2, 0x99, 0x2b, 0x5a, 0xa9} } 25 | 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/protocol/legacyboot.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 1999 Intel Corporation 4 | 5 | Module Name: 6 | 7 | legacyboot 8 | 9 | Abstract: 10 | 11 | EFI support for legacy boot 12 | 13 | 14 | 15 | Revision History 16 | 17 | --*/ 18 | 19 | #ifndef _LEGACY_BOOT_INCLUDE_ 20 | #define _LEGACY_BOOT_INCLUDE_ 21 | 22 | #define LEGACY_BOOT_PROTOCOL \ 23 | { 0x376e5eb2, 0x30e4, 0x11d3, { 0xba, 0xe5, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } } 24 | 25 | #pragma pack(1) 26 | 27 | // 28 | // BBS 1.01 (See Appendix A) IPL and BCV Table Entry Data structure. 29 | // Seg:Off pointers have been converted to EFI pointers in this data structure 30 | // This is the structure that also maps to the EFI device path for the boot selection 31 | // 32 | typedef struct { 33 | UINT16 DeviceType; 34 | UINT16 StatusFlag; 35 | UINT32 Reserved; 36 | VOID *BootHandler; // Not an EFI entry point 37 | CHAR8 *DescString; 38 | } BBS_TABLE_ENTRY; 39 | #pragma pack() 40 | 41 | typedef 42 | EFI_STATUS 43 | (EFIAPI *LEGACY_BOOT_CALL) ( 44 | IN EFI_DEVICE_PATH *DevicePath 45 | ); 46 | 47 | 48 | // 49 | // BBS support functions 50 | // PnP Call numbers and BiosSelector hidden in implementation 51 | // 52 | 53 | typedef enum { 54 | IplRelative, 55 | BcvRelative 56 | } BBS_TYPE; 57 | 58 | INTERFACE_DECL(_LEGACY_BOOT_INTERFACE); 59 | 60 | // 61 | // == PnP Function 0x60 then BbsVersion == 0x0101 if this call fails then BbsVersion == 0x0000 62 | // 63 | 64 | // 65 | // == PnP Function 0x61 66 | // 67 | typedef 68 | EFI_STATUS 69 | (EFIAPI *GET_DEVICE_COUNT) ( 70 | IN struct _LEGACY_BOOT_INTERFACE *This, 71 | IN BBS_TYPE *TableType, 72 | OUT UINTN *DeviceCount, 73 | OUT UINTN *MaxCount 74 | ); 75 | 76 | // 77 | // == PnP Function 0x62 78 | // 79 | typedef 80 | EFI_STATUS 81 | (EFIAPI *GET_PRIORITY_AND_TABLE) ( 82 | IN struct _LEGACY_BOOT_INTERFACE *This, 83 | IN BBS_TYPE *TableType, 84 | IN OUT UINTN *PrioritySize, // MaxCount * sizeof(UINT8) 85 | OUT UINTN *Priority, 86 | IN OUT UINTN *TableSize, // MaxCount * sizeof(BBS_TABLE_ENTRY) 87 | OUT BBS_TABLE_ENTRY *TableEntrySize 88 | ); 89 | 90 | // 91 | // == PnP Function 0x63 92 | // 93 | typedef 94 | EFI_STATUS 95 | (EFIAPI *SET_PRIORITY) ( 96 | IN struct _LEGACY_BOOT_INTERFACE *This, 97 | IN BBS_TYPE *TableType, 98 | IN OUT UINTN *PrioritySize, 99 | OUT UINTN *Priority 100 | ); 101 | 102 | typedef struct _LEGACY_BOOT_INTERFACE { 103 | LEGACY_BOOT_CALL BootIt; 104 | 105 | // 106 | // New functions to allow BBS booting to be configured from EFI 107 | // 108 | UINTN BbsVersion; // Currently 0x0101 109 | GET_DEVICE_COUNT GetDeviceCount; 110 | GET_PRIORITY_AND_TABLE GetPriorityAndTable; 111 | SET_PRIORITY SetPriority; 112 | } LEGACY_BOOT_INTERFACE; 113 | 114 | EFI_STATUS 115 | PlInitializeLegacyBoot ( 116 | VOID 117 | ); 118 | 119 | #endif 120 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/protocol/make.inf: -------------------------------------------------------------------------------- 1 | # 2 | # 3 | # 4 | 5 | [sources] 6 | efivar.h 7 | legacyboot.h 8 | VgaClass.h 9 | intload.h 10 | 11 | [ia32sources] 12 | 13 | [ia64sources] 14 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/protocol/makefile.hdr: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # This is a machine generated file - DO NOT EDIT 4 | # Generated by genmake.exe 5 | # Generated from make.inf 6 | # Copyright (c) 1998 Intel Corporation 7 | # 8 | 9 | INC_DEPS = $(INC_DEPS) \ 10 | $(SDK_INSTALL_DIR)\include\efi\protocol\efivar.h \ 11 | $(SDK_INSTALL_DIR)\include\efi\protocol\legacyboot.h \ 12 | $(SDK_INSTALL_DIR)\include\efi\protocol\vgaclass.h \ 13 | $(SDK_INSTALL_DIR)\include\efi\protocol\efidbg.h \ 14 | 15 | 16 | !IF "$(PROCESSOR)" == "Ia32" 17 | INC_DEPS = $(INC_DEPS) \ 18 | 19 | 20 | !ENDIF 21 | 22 | 23 | !IF "$(PROCESSOR)" == "Ia64" 24 | INC_DEPS = $(INC_DEPS) \ 25 | $(SDK_INSTALL_DIR)\include\efi\protocol\$(PROCESSOR)\eficontext.h \ 26 | 27 | 28 | !ENDIF 29 | 30 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/protocol/piflash64.h: -------------------------------------------------------------------------------- 1 | #ifndef _PIFLASH64_H 2 | #define _PIFLASH64_H 3 | 4 | /*++ 5 | 6 | Copyright (c) 1999 Intel Corporation 7 | 8 | Module Name: 9 | 10 | PIflash64.h 11 | 12 | Abstract: 13 | 14 | Iflash64.efi protocol to abstract iflash from 15 | the system. 16 | 17 | Revision History 18 | 19 | --*/ 20 | 21 | // 22 | // Guid that identifies the IFLASH protocol 23 | // 24 | #define IFLASH64_PROTOCOL_PROTOCOL \ 25 | { 0x65cba110, 0x74ab, 0x11d3, 0xbb, 0x89, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 }; 26 | 27 | // 28 | // Unlock FLASH from StartAddress to EndAddress and return a LockKey 29 | // 30 | typedef 31 | EFI_STATUS 32 | (EFIAPI *UNLOCK_FLASH_API)( 33 | IN struct _IFLASH64_PROTOCOL_INTERFACE *This 34 | ); 35 | 36 | // 37 | // Lock the flash represented by the LockKey 38 | // 39 | typedef 40 | EFI_STATUS 41 | (EFIAPI *LOCK_FLASH_API)( 42 | IN struct _IFLASH64_PROTOCOL_INTERFACE *This 43 | ); 44 | 45 | // 46 | // Status callback for a utility like IFLASH64 47 | // 48 | // Token would map to a list like Ted proposed. The utility has no idea what 49 | // happens on the other side. 50 | // ErrorStatus - Level of Error or success. Independent of Token. If you 51 | // don't know the token you will at least know pass or fail. 52 | // String - Optional extra information about the error. Could be used for 53 | // debug or future expansion 54 | // 55 | // Attributes - Options screen attributes for String. Could allow the string to be different colors. 56 | // 57 | typedef 58 | EFI_STATUS 59 | (EFIAPI *UTILITY_PROGRESS_API)( 60 | IN struct _IFLASH64_PROTOCOL_INTERFACE *This, 61 | IN UINTN Token, 62 | IN EFI_STATUS ErrorStatus, 63 | IN CHAR16 *String, OPTIONAL 64 | IN UINTN *Attributes OPTIONAL 65 | ); 66 | 67 | // 68 | // Token Values 69 | // 70 | // IFlash64 Token Codes 71 | #define IFLASH_TOKEN_IFLASHSTART 0xB0 // IFlash64 has started 72 | #define IFLASH_TOKEN_READINGFILE 0xB1 // Reading File 73 | #define IFLASH_TOKEN_INITVPP 0xB2 // Initializing Vpp 74 | #define IFLASH_TOKEN_DISABLEVPP 0x10 // Disable Vpp 75 | #define IFLASH_TOKEN_FLASHUNLOCK 0xB3 // Unlocking FLASH Devices 76 | #define IFLASH_TOKEN_FLASHERASE 0xB4 // Erasing FLASH Devices 77 | #define IFLASH_TOKEN_FLASHPROGRAM 0xB5 // Programming FLASH 78 | #define IFLASH_TOKEN_FLASHVERIFY 0xB6 // Verifying FLASH 79 | #define IFLASH_TOKEN_UPDATESUCCES 0xB7 // FLASH Updage Success! 80 | 81 | #define IFLASH_TOKEN_PROGRESS_READINGFILE 0x11 // % Reading File 82 | #define IFLASH_TOKEN_PROGRESS_FLASHUNLOCK 0x13 // % Unlocking FLASH Devices 83 | #define IFLASH_TOKEN_PROGRESS_FLASHERASE 0x14 // % Erasing FLASH Devices 84 | #define IFLASH_TOKEN_PROGRESS_FLASHPROGRAM 0x15 // % Programming FLASH 85 | #define IFLASH_TOKEN_PROGRESS_FLASHVERIFY 0x16 // % Verifying FLASH 86 | 87 | #define IFLASH_TOKEN_READINGFILE_ER 0xB8 // File Read Error 88 | #define IFLASH_TOKEN_INITVPP_ER 0xB9 // Initialization of IFB Error 89 | #define IFLASH_TOKEN_FLASHUNLOCK_ER 0xBA // FLASH Unlock Error 90 | #define IFLASH_TOKEN_FLASHERASE_ER 0xBB // FLASH Erase Error 91 | #define IFLASH_TOKEN_FLASHVERIFY_ER 0xBC // FLASH Verify Error 92 | #define IFLASH_TOKEN_FLASHPROG_ER 0xBD // FLASH Program Error 93 | 94 | #define IFLASH_TABLE_END 0x00 95 | 96 | // 97 | // If this number changes one of the existing API's has changes 98 | // 99 | #define IFLASH_PI_MAJOR_VERSION 0x01 100 | 101 | // 102 | // This number changes when new APIs or data variables get added to the end 103 | // of the data structure 104 | // 105 | #define IFLASH_PI_MINOR_VERSION 0x01 106 | 107 | typedef struct _IFLASH64_PROTOCOL_INTERFACE { 108 | UINT32 MajorVersion; 109 | UINT32 MinorVersion; 110 | UNLOCK_FLASH_API UnlockFlash; 111 | LOCK_FLASH_API LockFlash; 112 | UTILITY_PROGRESS_API Progress; 113 | 114 | // 115 | // Future expansion goes here 116 | // 117 | 118 | } IFLASH64_PROTOCOL_INTERFACE; 119 | 120 | 121 | #endif 122 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/protocol/readme.txt: -------------------------------------------------------------------------------- 1 | The protocol directory contains non Architectural 2 | Protocols that span the FW, Platform, or application 3 | space. -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/protocol/vgaclass.h: -------------------------------------------------------------------------------- 1 | #ifndef _VGA_CLASS_H 2 | #define _VGA_CLASS_H 3 | 4 | /*++ 5 | 6 | Copyright (c) 1999 Intel Corporation 7 | 8 | Module Name: 9 | 10 | VgaClass.h 11 | 12 | Abstract: 13 | 14 | Vga Mini port binding to Vga Class protocol 15 | 16 | 17 | 18 | Revision History 19 | 20 | --*/ 21 | 22 | // 23 | // VGA Device Structure 24 | // 25 | 26 | // {0E3D6310-6FE4-11d3-BB81-0080C73C8881} 27 | #define VGA_CLASS_DRIVER_PROTOCOL \ 28 | { 0xe3d6310, 0x6fe4, 0x11d3, {0xbb, 0x81, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} } 29 | 30 | typedef 31 | EFI_STATUS 32 | (* INIT_VGA_CARD) ( 33 | IN UINTN VgaMode, 34 | IN VOID *Context 35 | ); 36 | 37 | typedef struct { 38 | UINTN MaxColumns; 39 | UINTN MaxRows; 40 | } MAX_CONSOLE_GEOMETRY; 41 | 42 | #define VGA_CON_OUT_DEV_SIGNATURE EFI_SIGNATURE_32('c','v','g','a') 43 | typedef struct { 44 | UINTN Signature; 45 | 46 | EFI_HANDLE Handle; 47 | SIMPLE_TEXT_OUTPUT_INTERFACE ConOut; 48 | SIMPLE_TEXT_OUTPUT_MODE ConOutMode; 49 | EFI_DEVICE_PATH *DevicePath; 50 | 51 | UINT8 *Buffer; 52 | EFI_DEVICE_IO_INTERFACE *DeviceIo; 53 | 54 | // 55 | // Video Card Context 56 | // 57 | INIT_VGA_CARD InitVgaCard; 58 | VOID *VgaCardContext; 59 | MAX_CONSOLE_GEOMETRY *Geometry; 60 | // 61 | // Video buffer normally 0xb8000 62 | // 63 | UINT64 VideoBuffer; 64 | 65 | // 66 | // Clear Screen & Default Attribute 67 | // 68 | UINT32 Attribute; 69 | 70 | // 71 | // -1 means search for active VGA device 72 | // 73 | EFI_PCI_ADDRESS_UNION Pci; 74 | } VGA_CON_OUT_DEV; 75 | 76 | #define VGA_CON_OUT_DEV_FROM_THIS(a) CR(a, VGA_CON_OUT_DEV, ConOut, VGA_CON_OUT_DEV_SIGNATURE) 77 | 78 | // 79 | // Vga Class Driver Protocol. 80 | // GUID defined in EFI Lib 81 | // 82 | 83 | typedef 84 | EFI_STATUS 85 | (EFIAPI *INSTALL_VGA_DRIVER) ( 86 | IN VGA_CON_OUT_DEV *ConOutDev 87 | ); 88 | 89 | typedef struct { 90 | UINT32 Version; 91 | INSTALL_VGA_DRIVER InstallGenericVgaDriver; 92 | } INSTALL_VGA_DRIVER_INTERFACE; 93 | 94 | #endif 95 | 96 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/riscv64/efibind.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copright (C) 2014 - 2015 Linaro Ltd. 3 | * Author: Ard Biesheuvel 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice and this list of conditions, without modification. 10 | * 2. The name of the author may not be used to endorse or promote products 11 | * derived from this software without specific prior written permission. 12 | * 13 | * Alternatively, this software may be distributed under the terms of the 14 | * GNU General Public License as published by the Free Software Foundation; 15 | * either version 2 of the License, or (at your option) any later version. 16 | */ 17 | 18 | #include 19 | 20 | // 21 | // Basic EFI types of various widths 22 | // 23 | 24 | 25 | 26 | typedef uint64_t UINT64; 27 | typedef int64_t INT64; 28 | typedef uint32_t UINT32; 29 | typedef int32_t INT32; 30 | typedef uint16_t UINT16; 31 | typedef int16_t INT16; 32 | typedef uint8_t UINT8; 33 | typedef int8_t INT8; 34 | #ifndef __WCHAR_TYPE__ 35 | #define __WCHAR_TYPE__ short 36 | #endif 37 | typedef __WCHAR_TYPE__ WCHAR; 38 | #ifndef BOOLEAN 39 | typedef uint8_t BOOLEAN; 40 | #endif 41 | #undef VOID 42 | #define VOID void 43 | typedef int64_t INTN; 44 | typedef uint64_t UINTN; 45 | 46 | #define EFI_ERROR_MASK 0x8000000000000000 47 | #define EFIERR(a) (EFI_ERROR_MASK | a) 48 | #define EFIERR_OEM(a) (0xc000000000000000 | a) 49 | 50 | #define BAD_POINTER 0xFBFBFBFBFBFBFBFB 51 | #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFF 52 | 53 | #define BREAKPOINT() while(1); 54 | 55 | // 56 | // Pointers must be aligned to these address to function 57 | // 58 | #define MIN_ALIGNMENT_SIZE 8 59 | 60 | #define ALIGN_VARIABLE(Value, Adjustment) \ 61 | (UINTN)Adjustment = 0; \ 62 | if((UINTN)Value % MIN_ALIGNMENT_SIZE) \ 63 | (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \ 64 | Value = (UINTN)Value + (UINTN)Adjustment 65 | 66 | // 67 | // Define macros to build data structure signatures from characters. 68 | // 69 | #define EFI_SIGNATURE_16(A,B) ((A) | (B<<8)) 70 | #define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16(A,B) | (EFI_SIGNATURE_16(C,D) << 16)) 71 | #define EFI_SIGNATURE_64(A,B,C,D,E,F,G,H) (EFI_SIGNATURE_32(A,B,C,D) | ((UINT64)(EFI_SIGNATURE_32(E,F,G,H)) << 32)) 72 | 73 | // 74 | // EFIAPI - prototype calling convention for EFI function pointers 75 | // BOOTSERVICE - prototype for implementation of a boot service interface 76 | // RUNTIMESERVICE - prototype for implementation of a runtime service interface 77 | // RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service 78 | // RUNTIME_CODE - pragma macro for declaring runtime code 79 | // 80 | #ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options 81 | #define EFIAPI // Substitute expresion to force C calling convention 82 | #endif 83 | #define BOOTSERVICE 84 | #define RUNTIMESERVICE 85 | #define RUNTIMEFUNCTION 86 | #define RUNTIME_CODE(a) alloc_text("rtcode", a) 87 | #define BEGIN_RUNTIME_DATA() data_seg("rtdata") 88 | #define END_RUNTIME_DATA() data_seg("") 89 | 90 | #define VOLATILE volatile 91 | #define MEMORY_FENCE __sync_synchronize 92 | 93 | // 94 | // When build similiar to FW, then link everything together as 95 | // one big module. For the MSVC toolchain, we simply tell the 96 | // linker what our driver init function is using /ENTRY. 97 | // 98 | #if defined(_MSC_EXTENSIONS) 99 | #define EFI_DRIVER_ENTRY_POINT(InitFunction) \ 100 | __pragma(comment(linker, "/ENTRY:" # InitFunction)) 101 | #else 102 | #define EFI_DRIVER_ENTRY_POINT(InitFunction) \ 103 | UINTN \ 104 | InitializeDriver ( \ 105 | VOID *ImageHandle, \ 106 | VOID *SystemTable \ 107 | ) \ 108 | { \ 109 | return InitFunction(ImageHandle, \ 110 | SystemTable); \ 111 | } \ 112 | \ 113 | EFI_STATUS efi_main( \ 114 | EFI_HANDLE image, \ 115 | EFI_SYSTEM_TABLE *systab \ 116 | ) __attribute__((weak, \ 117 | alias ("InitializeDriver"))); 118 | #endif 119 | 120 | #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \ 121 | (_if)->LoadInternal(type, name, entry) 122 | 123 | // 124 | // Some compilers don't support the forward reference construct: 125 | // typedef struct XXXXX 126 | // 127 | // The following macro provide a workaround for such cases. 128 | #define INTERFACE_DECL(x) struct x 129 | 130 | #define uefi_call_wrapper(func, va_num, ...) func(__VA_ARGS__) 131 | #define EFI_FUNCTION 132 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/riscv64/efilibplat.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0+ */ 2 | 3 | VOID 4 | InitializeLibPlatform ( 5 | IN EFI_HANDLE ImageHandle, 6 | IN EFI_SYSTEM_TABLE *SystemTable 7 | ); 8 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/riscv64/efisetjmp_arch.h: -------------------------------------------------------------------------------- 1 | #ifndef GNU_EFI_RISCV64_SETJMP_H 2 | #define GNU_EFI_RISCV64_SETJMP_H 3 | 4 | #define JMPBUF_ALIGN 8 5 | 6 | typedef struct { 7 | /* GP regs */ 8 | UINT64 s0; 9 | UINT64 s1; 10 | UINT64 s2; 11 | UINT64 s3; 12 | UINT64 s4; 13 | UINT64 s5; 14 | UINT64 s6; 15 | UINT64 s7; 16 | UINT64 s8; 17 | UINT64 s9; 18 | UINT64 s10; 19 | UINT64 s11; 20 | UINT64 sp; 21 | UINT64 ra; 22 | 23 | /* FP regs */ 24 | UINT64 fs0; 25 | UINT64 fs1; 26 | UINT64 fs2; 27 | UINT64 fs3; 28 | UINT64 fs4; 29 | UINT64 fs5; 30 | UINT64 fs6; 31 | UINT64 fs7; 32 | UINT64 fs8; 33 | UINT64 fs9; 34 | UINT64 fs10; 35 | UINT64 fs11; 36 | } ALIGN(JMPBUF_ALIGN) jmp_buf[1]; 37 | 38 | #endif /* GNU_EFI_RISCV64_SETJMP_H */ 39 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/romload.h: -------------------------------------------------------------------------------- 1 | #ifndef _EFI_ROMLOAD_H 2 | #define _EFI_ROMLOAD_H 3 | 4 | #define ROM_SIGNATURE 0xaa55 5 | #define PCIDS_SIGNATURE "PCIR" 6 | #pragma pack(push) 7 | #pragma pack(1) 8 | typedef struct 9 | { 10 | UINT8 Pcids_Sig[4]; 11 | UINT16 VendId; 12 | UINT16 DevId; 13 | UINT16 Vpd_Off; 14 | UINT16 Size; 15 | UINT8 Rev; 16 | UINT8 Class_Code[3]; 17 | UINT16 Image_Len; 18 | UINT16 Rev_Lvl; 19 | UINT8 Code_Type; 20 | UINT8 Indi; 21 | UINT16 Rsvd; 22 | }PciDataStructure; 23 | typedef struct 24 | { 25 | UINT16 Size; 26 | UINT32 Header_Sig; 27 | UINT16 SubSystem; 28 | UINT16 MachineType; 29 | UINT8 Resvd[10]; 30 | UINT16 EfiOffset; 31 | }ArchData; 32 | typedef struct 33 | { 34 | UINT16 Rom_Sig; 35 | ArchData Arch_Data; 36 | UINT16 Pcids_Off; 37 | UINT8 resvd[38]; 38 | }RomHeader; 39 | #pragma pack(pop) 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/x86_64/efilibplat.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 1998 Intel Corporation 4 | 5 | Module Name: 6 | 7 | efilibplat.h 8 | 9 | Abstract: 10 | 11 | EFI to compile bindings 12 | 13 | 14 | 15 | 16 | Revision History 17 | 18 | --*/ 19 | 20 | VOID 21 | InitializeLibPlatform ( 22 | IN EFI_HANDLE ImageHandle, 23 | IN EFI_SYSTEM_TABLE *SystemTable 24 | ); 25 | 26 | 27 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efi_inc/x86_64/efisetjmp_arch.h: -------------------------------------------------------------------------------- 1 | #ifndef GNU_EFI_X86_64_SETJMP_H 2 | #define GNU_EFI_X86_64_SETJMP_H 3 | 4 | #define JMPBUF_ALIGN 8 5 | 6 | typedef struct { 7 | UINT64 Rbx; 8 | UINT64 Rsp; 9 | UINT64 Rbp; 10 | 11 | UINT64 Rdi; 12 | UINT64 Rsi; 13 | UINT64 R12; 14 | UINT64 R13; 15 | UINT64 R14; 16 | UINT64 R15; 17 | UINT64 Rip; 18 | UINT64 MxCsr; 19 | UINT8 XmmBuffer[160]; // XMM6 - XMM15 20 | } ALIGN(JMPBUF_ALIGN) jmp_buf[1]; 21 | 22 | #endif /* GNU_EFI_X86_64_SETJMP_H */ 23 | -------------------------------------------------------------------------------- /EfiInstallPolicy/efientry.h: -------------------------------------------------------------------------------- 1 | // EFI headers. 2 | #pragma once 3 | 4 | #include 5 | #include "efi.h" 6 | 7 | /// EFI entry point 8 | /// Firmware allocated handle for the EFI boot application (not this application) 9 | /// Pointer to the EFI system table 10 | /// EFI status code. 11 | EFI_STATUS EfiMain(__in EFI_HANDLE ImageHandle, __in EFI_SYSTEM_TABLE* SystemTable); -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /SecureBootPolicy/SecureBootPolicy.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31624.102 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecureBootPolicy", "SecureBootPolicy\SecureBootPolicy.csproj", "{F1C64582-6EA4-4A32-8E14-0CA13AB90C3D}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecureBootPolicyCompiler", "SecureBootPolicyCompiler\SecureBootPolicyCompiler.csproj", "{2FE209E0-90D9-48A6-A280-BB5B5C8D531E}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {F1C64582-6EA4-4A32-8E14-0CA13AB90C3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {F1C64582-6EA4-4A32-8E14-0CA13AB90C3D}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {F1C64582-6EA4-4A32-8E14-0CA13AB90C3D}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {F1C64582-6EA4-4A32-8E14-0CA13AB90C3D}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {2FE209E0-90D9-48A6-A280-BB5B5C8D531E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {2FE209E0-90D9-48A6-A280-BB5B5C8D531E}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {2FE209E0-90D9-48A6-A280-BB5B5C8D531E}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {2FE209E0-90D9-48A6-A280-BB5B5C8D531E}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {E67F80B5-13CA-4E74-BB5E-BC7F3CD0EDC9} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /SecureBootPolicy/SecureBootPolicy/Binary.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace SecureBootPolicy.Binary 9 | { 10 | /* 11 | * File layout on disk: 12 | * Header 13 | * Header.CanUpdateCount * GUID 14 | * Flags 15 | * Flags.BcdRulesCount * BcdRule 16 | * Flags.RegistryRulesCount * RegistryRule 17 | * Body, all offsets are into this 18 | */ 19 | [StructLayout(LayoutKind.Sequential, Pack = 1)] 20 | struct Header 21 | { 22 | public ushort FormatVersion; 23 | public uint PolicyVersion; 24 | public Guid PolicyPublisher; 25 | public ushort CanUpdateCount; 26 | } 27 | [StructLayout(LayoutKind.Sequential, Pack = 1)] 28 | struct Flags 29 | { 30 | public uint OptionFlags; 31 | public ushort BcdRulesCount; 32 | public ushort RegistryRulesCount; 33 | } 34 | 35 | [StructLayout(LayoutKind.Sequential, Pack = 1)] 36 | struct BcdRule 37 | { 38 | public uint ObjectType; 39 | public uint Element; 40 | public uint ValueOffset; 41 | } 42 | [StructLayout(LayoutKind.Sequential, Pack = 1)] 43 | struct RegistryRule 44 | { 45 | public uint RootKey; 46 | public uint SubkeyNameOffset; 47 | public uint ValueNameOffset; 48 | public uint ValueOffset; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /SecureBootPolicy/SecureBootPolicy/Constants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace SecureBootPolicy 8 | { 9 | internal static class Constants 10 | { 11 | 12 | internal const byte ID_SIGNINGSCENARIO_ENTERPRISE = 2; // used by ci.dll only 13 | internal const byte ID_SIGNINGSCENARIO_CUSTOM1 = 3; // used by ci.dll only 14 | internal const byte ID_SIGNINGSCENARIO_AUTHENTICODE = 4; // used by ci.dll only 15 | internal const byte ID_SIGNINGSCENARIO_CUSTOM2 = 5; // used by ci.dll only 16 | internal const byte ID_SIGNINGSCENARIO_STORE = 6; // used by ci.dll only 17 | internal const byte ID_SIGNINGSCENARIO_ANTIMALWARE = 7; // used by ci.dll only 18 | internal const byte ID_SIGNINGSCENARIO_MICROSOFT = 8; // used by ci.dll only 19 | internal const byte ID_SIGNINGSCENARIO_CUSTOM4 = 9; // used by ci.dll only ; "custom3" is now antimalware 20 | internal const byte ID_SIGNINGSCENARIO_CUSTOM5 = 10; // used by ci.dll only 21 | internal const byte ID_SIGNINGSCENARIO_DYNAMIC_CODEGEN = 11; // used by ci.dll only 22 | internal const byte ID_SIGNINGSCENARIO_WINDOWS = 12; // used by boot applications and ci.dll 23 | internal const byte ID_SIGNINGSCENARIO_CUSTOM7 = 13; // used by ci.dll only 24 | internal const byte ID_SIGNINGSCENARIO_WINDOWS_TCB = 14; // used by ci.dll only 25 | internal const byte ID_SIGNINGSCENARIO_CUSTOM6 = 15; // used by ci.dll only 26 | internal const byte ID_SIGNINGSCENARIO_BOOT_APPS = 128; 27 | internal const byte ID_SIGNINGSCENARIO_HAL_EXTENSIONS = 129; 28 | internal const byte ID_SIGNINGSCENARIO_ELAM_DRIVERS = 130; 29 | internal const byte ID_SIGNINGSCENARIO_DRIVERS = 131; 30 | internal const byte ID_SIGNINGSCENARIO_BOOT_REVOCATION_LIST = 132; 31 | internal const byte ID_SIGNINGSCENARIO_FIRMWARE_UPDATE = 134; 32 | internal const byte ID_SIGNINGSCENARIO_DRM = 135; // used by ci.dll only 33 | internal const byte ID_SIGNINGSCENARIO_CORE_EXTENSIONS = 136; 34 | internal const byte ID_SIGNINGSCENARIO_PLATFORM_MANIFEST_REQUIRED = 137; 35 | internal const byte ID_SIGNINGSCENARIO_RUNTIME_REVOCATION_LIST = 133; // used by boot applications and ci.dll 36 | internal const byte ID_SIGNINGSCENARIO_PLATFORM_MANIFEST = 138; 37 | internal const byte ID_SIGNINGSCENARIO_FLASHING = 139; 38 | 39 | internal const string KEY_CI_SIGNERS = "CI\\Signers"; 40 | internal const string VALUE_CI_SIGNERS_COUNT = "Count"; 41 | 42 | internal const string KEY_CI_SIGNER_FORMAT = "CI\\Signers\\{0}"; 43 | internal const string VALUE_CI_SIGNER_KNOWNROOT = "KnownRoot"; 44 | internal const string VALUE_CI_SIGNER_TBSHASH = "TBS"; 45 | internal const string VALUE_CI_SIGNER_EKUS = "EKUs"; 46 | 47 | internal const string KEY_CI_SCENARIO_FORMAT = "CI\\Scenarios\\{0}"; 48 | internal const string VALUE_CI_SCENARIO_SIGNERS_PRODUCTION = "ProductionSigners"; 49 | internal const string VALUE_CI_SCENARIO_SIGNERS_TEST = "TestSigners"; 50 | internal const string VALUE_CI_SCENARIO_SIGNERS_TESTSIGNING = "TestsigningSigners"; 51 | 52 | internal const string VALUE_CI_HASH_ALGORITHM = "Hash"; 53 | 54 | internal const string KEY_DEVICEID = "Debug"; 55 | internal const string VALUE_DEVICEID = "DeviceID"; 56 | 57 | internal const uint HKEY_SECUREBOOT_POLICIES_ROOT = 0x81000000; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /SecureBootPolicy/SecureBootPolicy/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SecureBootPolicy")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("SecureBootPolicy")] 13 | [assembly: AssemblyCopyright("Copyright © 2021")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("f1c64582-6ea4-4a32-8e14-0ca13ab90c3d")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /SecureBootPolicy/SecureBootPolicy/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace SecureBootPolicy.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SecureBootPolicy.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized resource of type System.IO.UnmanagedMemoryStream similar to System.IO.MemoryStream. 65 | /// 66 | internal static System.IO.UnmanagedMemoryStream SBPolicy { 67 | get { 68 | return ResourceManager.GetStream("SBPolicy", resourceCulture); 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /SecureBootPolicy/SecureBootPolicy/SecureBootPolicy.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {F1C64582-6EA4-4A32-8E14-0CA13AB90C3D} 8 | Library 9 | Properties 10 | SecureBootPolicy 11 | SecureBootPolicy 12 | v4.7.2 13 | 512 14 | true 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | true 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | true 34 | 35 | 36 | 37 | 38 | ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll 39 | 40 | 41 | 42 | ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll 43 | 44 | 45 | 46 | ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll 47 | 48 | 49 | ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | True 63 | True 64 | Resources.resx 65 | 66 | 67 | 68 | 69 | 70 | 71 | SBPolicy.xsd 72 | 73 | 74 | 75 | 76 | Designer 77 | 78 | 79 | 80 | 81 | ResXFileCodeGenerator 82 | Resources.Designer.cs 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /SecureBootPolicy/SecureBootPolicy/SpanExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace SecureBootPolicy 9 | { 10 | internal static class SpanExtensions 11 | { 12 | internal static Span AsSpan(ref T val) where T : unmanaged 13 | { 14 | unsafe 15 | { 16 | void* valPtr = Unsafe.AsPointer(ref val); 17 | return new Span(valPtr, sizeof(T)); 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /SecureBootPolicy/SecureBootPolicy/StreamExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Buffers; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace SecureBootPolicy 10 | { 11 | internal static class StreamExtensions 12 | { 13 | internal static void Write(this Stream thisStream, ReadOnlySpan buffer) 14 | { 15 | byte[] sharedBuffer = ArrayPool.Shared.Rent(buffer.Length); 16 | try 17 | { 18 | buffer.CopyTo(sharedBuffer); 19 | thisStream.Write(sharedBuffer, 0, buffer.Length); 20 | } 21 | finally { ArrayPool.Shared.Return(sharedBuffer); } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SecureBootPolicy/SecureBootPolicy/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /SecureBootPolicy/SecureBootPolicyCompiler/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /SecureBootPolicy/SecureBootPolicyCompiler/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using SecureBootPolicy; 7 | using System.Reflection; 8 | using System.IO; 9 | 10 | namespace SecureBootPolicyCompiler 11 | { 12 | class Program 13 | { 14 | static void Main(string[] args) 15 | { 16 | if (args.Length < 2) 17 | { 18 | Console.WriteLine("Usage: {0} inputPolicy.xml outputPolicy.bin", Path.GetFileName(Assembly.GetExecutingAssembly().Location)); 19 | return; 20 | } 21 | 22 | var input = args[0]; 23 | var output = args[1]; 24 | 25 | var inPolicy = new XmlPolicy(input); 26 | inPolicy.ConvertToBinaryFile(output); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /SecureBootPolicy/SecureBootPolicyCompiler/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SecureBootPolicyCompiler")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("SecureBootPolicyCompiler")] 13 | [assembly: AssemblyCopyright("Copyright © 2021")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("2fe209e0-90d9-48a6-a280-bb5b5c8d531e")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /SecureBootPolicy/SecureBootPolicyCompiler/SecureBootPolicyCompiler.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {2FE209E0-90D9-48A6-A280-BB5B5C8D531E} 8 | Exe 9 | SecureBootPolicyCompiler 10 | SecureBootPolicyCompiler 11 | v4.7.2 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | false 26 | 27 | 28 | AnyCPU 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | {f1c64582-6ea4-4a32-8e14-0ca13ab90c3d} 56 | SecureBootPolicy 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /SecureBootPolicy/readme.md: -------------------------------------------------------------------------------- 1 | # Secure Boot Policy Builder 2 | This is a library and application coded in C# allowing the creation of binary Secure Boot Policy files from an XML format similar to the SiPolicy/CiPolicy XML format. 3 | Two examples are included: 4 | - `SecureBootPolicyDefault.xml` is the default Secure Boot Policy included in the resource data of `bootmgr` starting from RS2 (as far as it can be replicated; publisher is different due to restrictions, and the CanUpdate GUIDs are not present as they were only used by win8beta) 5 | - `SecureBootPolicyExample.xml` gives an example of a custom policy touching on all available parameters. 6 | 7 | ## Why? 8 | `bootmgr` before RS1 can load Secure Boot policies that are signed by PK, with restrictions. 9 | Therefore if you control PK you can control the Secure Boot policy. 10 | A Secure Boot policy can control various things including the valid signers for every PE checked by boot applications (including `bootmgr`, `winload`, `hvloader`, `tcblaunch` etc), and by `ci.dll` and `skci.dll`. 11 | Also, Secure Boot policy binary used by NT gets protected by PatchGuard. 12 | - Want to add your certs to be valid for WinTcb protected process? You can! 13 | - Want to add your certs to Microsoft or Windows signing level and therefore run code in IUM/VTL1 (by signing with `szOID_IUM_SIGNING` EKU), or in a VSM enclave (by signing with `szOID_ENCLAVE_SIGNING` EKU), or run VTL1 driver (by signing with `szOID_NT5_CRYPTO` EKU)? You can! 14 | - Want to add your certs to be valid for boot applications and therefore set up a Linux dualboot through `bootmgr` (which would allow for running shim/grub with bitlocker keys derived and in memory)? You can! 15 | 16 | ## Signing Policy 17 | Signing is exactly the same as [SiPolicy/CiPolicy](https://docs.microsoft.com/en-us/windows/security/threat-protection/windows-defender-application-control/use-signed-policies-to-protect-windows-defender-application-control-against-tampering). 18 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # SecureBootPolicyTools 2 | 3 | Tools for creating and using Secure Boot policies. 4 | 5 | bootmgr prior to RS1 accepts Secure Boot policies signed by PK. 6 | 7 | Thus, if you control PK, you control what Windows Code Integrity trusts. Sign your own Windows Boot Application; hypervisor; securekernel; driver (VTL0/VTL1); protected process; PPL. 8 | 9 | ## Included tools 10 | 11 | - `SecureBootPolicy`: library and compiler for Secure Boot policies. Includes three example policies: 12 | - `SecureBootPolicyDefault.xml` reimplements as much as possible the default Secure Boot policy included in bootmgr starting from RS2. 13 | - `SecureBootPolicyDefaultWithSigners.xml` is the same as above that also reimplements the default signers trusted by CI for easy extensibility 14 | - `SecureBootPolicyExample.xml` adds a custom signer. Replace the TBS hash and enjoy your trusted binaries. 15 | - `EfiInstallPolicy`: EFI application to install a signed Secure Boot policy into UEFI non-volatile variables. 16 | - `BootAppToEfi`: Windows Boot Application that switches back to the EFI environment and calls `EfiMain()`. 17 | 18 | ## Note 19 | 20 | I am not responsible for anything that may happen to your systems/VMs when using these tools; after all, you control the keys! 21 | --------------------------------------------------------------------------------