├── .gitignore ├── LICENSE ├── README.md ├── dub.json ├── sample ├── build.sh ├── photo.jpg └── source │ └── uefihelloworld.d ├── source └── uefi │ ├── acpi.d │ ├── acpi10.d │ ├── acpi20.d │ ├── acpi30.d │ ├── acpi40.d │ ├── acpi50.d │ ├── acpi51.d │ ├── acpi60.d │ ├── acpiaml.d │ ├── acpidatatable.d │ ├── base.d │ ├── base_type.d │ ├── bind.d │ ├── gpt.d │ ├── guids.d │ ├── ia32 │ └── bind.d │ ├── package.d │ ├── protocols │ ├── devicepath.d │ ├── graphicsoutput.d │ ├── hash.d │ ├── hash2.d │ ├── loadedimage.d │ ├── loadfile2.d │ ├── simplefilesystem.d │ ├── simplenetwork.d │ ├── simplepointer.d │ ├── simpletextin.d │ ├── simpletextinex.d │ └── simpletextout.d │ ├── pxe.d │ ├── spec.d │ └── x64 │ └── bind.d └── tools └── efihdrtool.d /.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | *.o 5 | *.obj 6 | dub.selections.json 7 | *.a 8 | *.lib 9 | *.dll 10 | *.so 11 | tools/efihdrtool 12 | *.EFI 13 | *.efi -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016, kubasz 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # uefi-d 2 | D bindings for UEFI specifications, based on the headers from [EDK II 2015](http://www.tianocore.org/edk2/). 3 | They allow to compile fully functional EFI executables without assembly or C bootstrapping, it boots directly to D :-) 4 | They can be used to build UEFI-compatible applications and drivers in the D Programming Language. 5 | Sample "Hello, world" program is provided, with source and a linux script to compile: 6 | ![My laptop booting to D UEFI executable](sample/photo.jpg?raw=true) 7 | 8 | ## Compilation of D UEFI projects 9 | I'm pretty sure dub won't be able to handle your projects, the best way is to use either [reggae](https://github.com/atilaneves/reggae) or another custom build system. 10 | The executables must not require the D runtime or standard library, suggested ldc2 compiler options for 64-bit compiles: 11 | ``` 12 | ldc2 -mtriple=x86_64-unknown-windows-coff -boundscheck=off -nogc -defaultlib= -debuglib= -code-model=large 13 | ``` 14 | And GNU linker options: 15 | ``` 16 | x86_64-w64-mingw32-gcc -nostdlib -Wl,-dll -shared -Wl,--subsystem,10 -e efi_main 17 | ``` 18 | It probably would be possible to write a minimal D runtime, but this is not a goal for this project in the near future (unless somebody wants to contribute one). -------------------------------------------------------------------------------- /dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "uefi-d", 3 | "description": "Bindings for UEFI API (Based on EDK2 2015)", 4 | "copyright": "Copyright © 2016, Jakub Szewczyk", 5 | "authors": ["Jakub Szewczyk"], 6 | "license": "BSD 2-clause", 7 | "homepage": "https://github.com/kubasz/uefi-d", 8 | "dependencies": { 9 | }, 10 | "targetType": "sourceLibrary" 11 | } 12 | -------------------------------------------------------------------------------- /sample/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Compile D file 4 | ldc2 -mtriple=x86_64-unknown-windows-coff -boundscheck=off -nogc -defaultlib= -debuglib= -code-model=large -I../source -c ./source/uefihelloworld.d -of=uefihelloworld.obj && 5 | # Link EFI executable 6 | x86_64-w64-mingw32-gcc -nostdlib -Wl,-dll -shared -Wl,--subsystem,10 -e efi_main -o BOOTX64.EFI uefihelloworld.obj 7 | -------------------------------------------------------------------------------- /sample/photo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eigenraven/uefi-d/e70959ce8ad1b113b5f7aa2111ea4d88f6b6ea63/sample/photo.jpg -------------------------------------------------------------------------------- /sample/source/uefihelloworld.d: -------------------------------------------------------------------------------- 1 | /** 2 | A sample UEFI application that prints "Hello, world!" to the console and waits for key input. 3 | **/ 4 | module uefihelloworld; 5 | 6 | import uefi; 7 | 8 | /// Dummy symbols 9 | extern (C) void* _Dmodule_ref; 10 | /// ditto 11 | extern (C) void* _tls_index = null; 12 | 13 | /// Helper function for showing D string on the screen 14 | void showBootString(EFI_SYSTEM_TABLE* ST, const(wchar)[] lstr) @nogc nothrow 15 | { 16 | ST.ConOut.OutputString(ST.ConOut, cast(CHAR16*)(lstr.ptr)); 17 | } 18 | 19 | /// UEFI Entry Point 20 | extern (C) EFI_STATUS efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* ST) @nogc nothrow 21 | { 22 | // Show hello world message 23 | showBootString(ST, "Hello, D UEFI world!\r\n\r\n"w); 24 | 25 | // Prompt for a key press 26 | showBootString(ST, "Press key..."w); 27 | // Clear the input buffer 28 | ST.ConIn.Reset(ST.ConIn, FALSE); 29 | // Wait for a key press 30 | EFI_INPUT_KEY Key = void; 31 | while (ST.ConIn.ReadKeyStroke(ST.ConIn, &Key) == EFI_NOT_READY) 32 | { 33 | } 34 | return EFI_SUCCESS; 35 | } 36 | -------------------------------------------------------------------------------- /source/uefi/acpi.d: -------------------------------------------------------------------------------- 1 | /// Imports all ACPI modules 2 | module uefi.acpi; 3 | 4 | public import uefi.acpiaml; 5 | public import uefi.acpi10; 6 | public import uefi.acpi20; 7 | public import uefi.acpi30; 8 | public import uefi.acpi40; 9 | public import uefi.acpi50; 10 | public import uefi.acpi51; 11 | public import uefi.acpi60; 12 | public import uefi.acpidatatable; 13 | -------------------------------------------------------------------------------- /source/uefi/acpi10.d: -------------------------------------------------------------------------------- 1 | /** 2 | Based on IndustryStandard/Acpi10.h, original notice: 3 | 4 | ACPI 1.0b definitions from the ACPI Specification, revision 1.0b 5 | 6 | Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved. 7 | This program and the accompanying materials are licensed and made available under 8 | the terms and conditions of the BSD License that accompanies this distribution. 9 | The full text of the license may be found at 10 | http://opensource.org/licenses/bsd-license.php. 11 | 12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 14 | **/ 15 | module uefi.acpi10; 16 | import uefi.base; 17 | import uefi.base_type; 18 | public import uefi.acpiaml; 19 | 20 | public: 21 | extern (C): 22 | 23 | /// Common table header, this prefaces all ACPI tables, including FACS, but 24 | /// excluding the RSD PTR structure. 25 | struct EFI_ACPI_COMMON_HEADER 26 | { 27 | UINT32 Signature; 28 | UINT32 Length; 29 | } 30 | /// The common ACPI description table header. This structure prefaces most ACPI tables. 31 | struct EFI_ACPI_DESCRIPTION_HEADER 32 | { 33 | align(1): 34 | UINT32 Signature; 35 | UINT32 Length; 36 | UINT8 Revision; 37 | UINT8 Checksum; 38 | UINT8[6] OemId; 39 | UINT64 OemTableId; 40 | UINT32 OemRevision; 41 | UINT32 CreatorId; 42 | UINT32 CreatorRevision; 43 | } 44 | 45 | enum ACPI_SMALL_ITEM_FLAG = 0x00; 46 | enum ACPI_LARGE_ITEM_FLAG = 0x01; 47 | enum ACPI_SMALL_IRQ_DESCRIPTOR_NAME = 0x04; 48 | enum ACPI_SMALL_DMA_DESCRIPTOR_NAME = 0x05; 49 | enum ACPI_SMALL_START_DEPENDENT_DESCRIPTOR_NAME = 0x06; 50 | enum ACPI_SMALL_END_DEPENDENT_DESCRIPTOR_NAME = 0x07; 51 | enum ACPI_SMALL_IO_PORT_DESCRIPTOR_NAME = 0x08; 52 | enum ACPI_SMALL_FIXED_IO_PORT_DESCRIPTOR_NAME = 0x09; 53 | enum ACPI_SMALL_VENDOR_DEFINED_DESCRIPTOR_NAME = 0x0E; 54 | enum ACPI_SMALL_END_TAG_DESCRIPTOR_NAME = 0x0F; 55 | enum ACPI_LARGE_24_BIT_MEMORY_RANGE_DESCRIPTOR_NAME = 0x01; 56 | enum ACPI_LARGE_VENDOR_DEFINED_DESCRIPTOR_NAME = 0x04; 57 | enum ACPI_LARGE_32_BIT_MEMORY_RANGE_DESCRIPTOR_NAME = 0x05; 58 | enum ACPI_LARGE_32_BIT_FIXED_MEMORY_RANGE_DESCRIPTOR_NAME = 0x06; 59 | enum ACPI_LARGE_DWORD_ADDRESS_SPACE_DESCRIPTOR_NAME = 0x07; 60 | enum ACPI_LARGE_WORD_ADDRESS_SPACE_DESCRIPTOR_NAME = 0x08; 61 | enum ACPI_LARGE_EXTENDED_IRQ_DESCRIPTOR_NAME = 0x09; 62 | enum ACPI_LARGE_QWORD_ADDRESS_SPACE_DESCRIPTOR_NAME = 0x0A; 63 | enum ACPI_IRQ_NOFLAG_DESCRIPTOR = 0x22; 64 | enum ACPI_IRQ_DESCRIPTOR = 0x23; 65 | enum ACPI_DMA_DESCRIPTOR = 0x2A; 66 | enum ACPI_START_DEPENDENT_DESCRIPTOR = 0x30; 67 | enum ACPI_START_DEPENDENT_EX_DESCRIPTOR = 0x31; 68 | enum ACPI_END_DEPENDENT_DESCRIPTOR = 0x38; 69 | enum ACPI_IO_PORT_DESCRIPTOR = 0x47; 70 | enum ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR = 0x4B; 71 | enum ACPI_END_TAG_DESCRIPTOR = 0x79; 72 | enum ACPI_24_BIT_MEMORY_RANGE_DESCRIPTOR = 0x81; 73 | enum ACPI_32_BIT_MEMORY_RANGE_DESCRIPTOR = 0x85; 74 | enum ACPI_32_BIT_FIXED_MEMORY_RANGE_DESCRIPTOR = 0x86; 75 | enum ACPI_DWORD_ADDRESS_SPACE_DESCRIPTOR = 0x87; 76 | enum ACPI_WORD_ADDRESS_SPACE_DESCRIPTOR = 0x88; 77 | enum ACPI_EXTENDED_INTERRUPT_DESCRIPTOR = 0x89; 78 | enum ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR = 0x8A; 79 | enum ACPI_ADDRESS_SPACE_DESCRIPTOR = 0x8A; 80 | enum ACPI_ADDRESS_SPACE_TYPE_MEM = 0x00; 81 | enum ACPI_ADDRESS_SPACE_TYPE_IO = 0x01; 82 | enum ACPI_ADDRESS_SPACE_TYPE_BUS = 0x02; 83 | /// Power Management Timer frequency is fixed at 3.579545MHz. 84 | enum ACPI_TIMER_FREQUENCY = 3579545; 85 | /// The commond definition of QWORD, DWORD, and WORD 86 | /// Address Space Descriptors. 87 | struct EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR 88 | { 89 | align(1): 90 | UINT8 Desc; 91 | UINT16 Len; 92 | UINT8 ResType; 93 | UINT8 GenFlag; 94 | UINT8 SpecificFlag; 95 | UINT64 AddrSpaceGranularity; 96 | UINT64 AddrRangeMin; 97 | UINT64 AddrRangeMax; 98 | UINT64 AddrTranslationOffset; 99 | UINT64 AddrLen; 100 | } 101 | 102 | union ACPI_SMALL_RESOURCE_HEADER 103 | { 104 | UINT8 Byte; 105 | struct Bits 106 | { 107 | mixin(bitfields!(UINT8, "Length", 3, UINT8, "Name", 4, UINT8, "Type", 1)); 108 | } 109 | } 110 | 111 | struct ACPI_LARGE_RESOURCE_HEADER 112 | { 113 | align(1): 114 | union Header 115 | { 116 | UINT8 Byte; 117 | struct Bits 118 | { 119 | mixin(bitfields!(UINT8, "Name", 7, UINT8, "Type", 1)); 120 | } 121 | } 122 | 123 | UINT16 Length; 124 | } 125 | /// IRQ Descriptor. 126 | struct EFI_ACPI_IRQ_NOFLAG_DESCRIPTOR 127 | { 128 | align(1): 129 | ACPI_SMALL_RESOURCE_HEADER Header; 130 | UINT16 Mask; 131 | } 132 | /// IRQ Descriptor. 133 | struct EFI_ACPI_IRQ_DESCRIPTOR 134 | { 135 | align(1): 136 | ACPI_SMALL_RESOURCE_HEADER Header; 137 | UINT16 Mask; 138 | UINT8 Information; 139 | } 140 | /// DMA Descriptor. 141 | struct EFI_ACPI_DMA_DESCRIPTOR 142 | { 143 | align(1): 144 | ACPI_SMALL_RESOURCE_HEADER Header; 145 | UINT8 ChannelMask; 146 | UINT8 Information; 147 | } 148 | /// I/O Port Descriptor 149 | struct EFI_ACPI_IO_PORT_DESCRIPTOR 150 | { 151 | align(1): 152 | ACPI_SMALL_RESOURCE_HEADER Header; 153 | UINT8 Information; 154 | UINT16 BaseAddressMin; 155 | UINT16 BaseAddressMax; 156 | UINT8 Alignment; 157 | UINT8 Length; 158 | } 159 | /// Fixed Location I/O Port Descriptor. 160 | struct EFI_ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR 161 | { 162 | align(1): 163 | ACPI_SMALL_RESOURCE_HEADER Header; 164 | UINT16 BaseAddress; 165 | UINT8 Length; 166 | } 167 | /// 24-Bit Memory Range Descriptor 168 | struct EFI_ACPI_24_BIT_MEMORY_RANGE_DESCRIPTOR 169 | { 170 | align(1): 171 | ACPI_LARGE_RESOURCE_HEADER Header; 172 | UINT8 Information; 173 | UINT16 BaseAddressMin; 174 | UINT16 BaseAddressMax; 175 | UINT16 Alignment; 176 | UINT16 Length; 177 | } 178 | /// 32-Bit Memory Range Descriptor 179 | struct EFI_ACPI_32_BIT_MEMORY_RANGE_DESCRIPTOR 180 | { 181 | align(1): 182 | ACPI_LARGE_RESOURCE_HEADER Header; 183 | UINT8 Information; 184 | UINT32 BaseAddressMin; 185 | UINT32 BaseAddressMax; 186 | UINT32 Alignment; 187 | UINT32 Length; 188 | } 189 | /// Fixed 32-Bit Fixed Memory Range Descriptor 190 | struct EFI_ACPI_32_BIT_FIXED_MEMORY_RANGE_DESCRIPTOR 191 | { 192 | align(1): 193 | ACPI_LARGE_RESOURCE_HEADER Header; 194 | UINT8 Information; 195 | UINT32 BaseAddress; 196 | UINT32 Length; 197 | } 198 | /// QWORD Address Space Descriptor 199 | struct EFI_ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR 200 | { 201 | align(1): 202 | ACPI_LARGE_RESOURCE_HEADER Header; 203 | UINT8 ResType; 204 | UINT8 GenFlag; 205 | UINT8 SpecificFlag; 206 | UINT64 AddrSpaceGranularity; 207 | UINT64 AddrRangeMin; 208 | UINT64 AddrRangeMax; 209 | UINT64 AddrTranslationOffset; 210 | UINT64 AddrLen; 211 | } 212 | /// DWORD Address Space Descriptor 213 | struct EFI_ACPI_DWORD_ADDRESS_SPACE_DESCRIPTOR 214 | { 215 | align(1): 216 | ACPI_LARGE_RESOURCE_HEADER Header; 217 | UINT8 ResType; 218 | UINT8 GenFlag; 219 | UINT8 SpecificFlag; 220 | UINT32 AddrSpaceGranularity; 221 | UINT32 AddrRangeMin; 222 | UINT32 AddrRangeMax; 223 | UINT32 AddrTranslationOffset; 224 | UINT32 AddrLen; 225 | } 226 | /// WORD Address Space Descriptor 227 | struct EFI_ACPI_WORD_ADDRESS_SPACE_DESCRIPTOR 228 | { 229 | align(1): 230 | ACPI_LARGE_RESOURCE_HEADER Header; 231 | UINT8 ResType; 232 | UINT8 GenFlag; 233 | UINT8 SpecificFlag; 234 | UINT16 AddrSpaceGranularity; 235 | UINT16 AddrRangeMin; 236 | UINT16 AddrRangeMax; 237 | UINT16 AddrTranslationOffset; 238 | UINT16 AddrLen; 239 | } 240 | /// Extended Interrupt Descriptor 241 | struct EFI_ACPI_EXTENDED_INTERRUPT_DESCRIPTOR 242 | { 243 | align(1): 244 | ACPI_LARGE_RESOURCE_HEADER Header; 245 | UINT8 InterruptVectorFlags; 246 | UINT8 InterruptTableLength; 247 | UINT32[1] InterruptNumber; 248 | } 249 | /// The End tag identifies an end of resource data. 250 | struct EFI_ACPI_END_TAG_DESCRIPTOR 251 | { 252 | UINT8 Desc; 253 | UINT8 Checksum; 254 | } 255 | 256 | enum EFI_ACPI_RESERVED_BYTE = 0x00; 257 | enum EFI_ACPI_RESERVED_WORD = 0x0000; 258 | enum EFI_ACPI_RESERVED_DWORD = 0x00000000; 259 | enum EFI_ACPI_RESERVED_QWORD = 0x0000000000000000; 260 | enum EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_READ_WRITE = (1 << 0); 261 | enum EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_READ_ONLY = (0 << 0); 262 | enum EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_NON_CACHEABLE = (0 << 1); 263 | enum EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE = (1 << 1); 264 | enum EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_WRITE_COMBINING = (2 << 1); 265 | enum EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE = (3 << 1); 266 | enum EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_MEMORY = (0 << 3); 267 | enum EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_RESERVED = (1 << 3); 268 | enum EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_ACPI = (2 << 3); 269 | enum EFI_APCI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_NVS = (3 << 3); 270 | enum EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_TYPE_TRANSLATION = (1 << 5); 271 | enum EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_TYPE_STATIC = (0 << 5); 272 | enum EFI_ACPI_IRQ_SHARABLE_MASK = 0x10; 273 | enum EFI_ACPI_IRQ_SHARABLE = 0x10; 274 | enum EFI_ACPI_IRQ_POLARITY_MASK = 0x08; 275 | enum EFI_ACPI_IRQ_HIGH_TRUE = 0x00; 276 | enum EFI_ACPI_IRQ_LOW_FALSE = 0x08; 277 | enum EFI_ACPI_IRQ_MODE = 0x01; 278 | enum EFI_ACPI_IRQ_LEVEL_TRIGGERED = 0x00; 279 | enum EFI_ACPI_IRQ_EDGE_TRIGGERED = 0x01; 280 | enum EFI_ACPI_DMA_SPEED_TYPE_MASK = 0x60; 281 | enum EFI_ACPI_DMA_SPEED_TYPE_COMPATIBILITY = 0x00; 282 | enum EFI_ACPI_DMA_SPEED_TYPE_A = 0x20; 283 | enum EFI_ACPI_DMA_SPEED_TYPE_B = 0x40; 284 | enum EFI_ACPI_DMA_SPEED_TYPE_F = 0x60; 285 | enum EFI_ACPI_DMA_BUS_MASTER_MASK = 0x04; 286 | enum EFI_ACPI_DMA_BUS_MASTER = 0x04; 287 | enum EFI_ACPI_DMA_TRANSFER_TYPE_MASK = 0x03; 288 | enum EFI_ACPI_DMA_TRANSFER_TYPE_8_BIT = 0x00; 289 | enum EFI_ACPI_DMA_TRANSFER_TYPE_8_BIT_AND_16_BIT = 0x01; 290 | enum EFI_ACPI_DMA_TRANSFER_TYPE_16_BIT = 0x10; 291 | enum EFI_ACPI_IO_DECODE_MASK = 0x01; 292 | enum EFI_ACPI_IO_DECODE_16_BIT = 0x01; 293 | enum EFI_ACPI_IO_DECODE_10_BIT = 0x00; 294 | enum EFI_ACPI_MEMORY_WRITE_STATUS_MASK = 0x01; 295 | enum EFI_ACPI_MEMORY_WRITABLE = 0x01; 296 | enum EFI_ACPI_MEMORY_NON_WRITABLE = 0x00; 297 | /// Root System Description Pointer Structure. 298 | struct EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER 299 | { 300 | align(1): 301 | UINT64 Signature; 302 | UINT8 Checksum; 303 | UINT8[6] OemId; 304 | UINT8 Reserved; 305 | UINT32 RsdtAddress; 306 | } 307 | /// RSDT Revision (as defined in ACPI 1.0b specification). 308 | enum EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_REVISION = 0x01; 309 | /// Fixed ACPI Description Table Structure (FADT). 310 | struct EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE 311 | { 312 | align(1): 313 | EFI_ACPI_DESCRIPTION_HEADER Header; 314 | UINT32 FirmwareCtrl; 315 | UINT32 Dsdt; 316 | UINT8 IntModel; 317 | UINT8 Reserved1; 318 | UINT16 SciInt; 319 | UINT32 SmiCmd; 320 | UINT8 AcpiEnable; 321 | UINT8 AcpiDisable; 322 | UINT8 S4BiosReq; 323 | UINT8 Reserved2; 324 | UINT32 Pm1aEvtBlk; 325 | UINT32 Pm1bEvtBlk; 326 | UINT32 Pm1aCntBlk; 327 | UINT32 Pm1bCntBlk; 328 | UINT32 Pm2CntBlk; 329 | UINT32 PmTmrBlk; 330 | UINT32 Gpe0Blk; 331 | UINT32 Gpe1Blk; 332 | UINT8 Pm1EvtLen; 333 | UINT8 Pm1CntLen; 334 | UINT8 Pm2CntLen; 335 | UINT8 PmTmLen; 336 | UINT8 Gpe0BlkLen; 337 | UINT8 Gpe1BlkLen; 338 | UINT8 Gpe1Base; 339 | UINT8 Reserved3; 340 | UINT16 PLvl2Lat; 341 | UINT16 PLvl3Lat; 342 | UINT16 FlushSize; 343 | UINT16 FlushStride; 344 | UINT8 DutyOffset; 345 | UINT8 DutyWidth; 346 | UINT8 DayAlrm; 347 | UINT8 MonAlrm; 348 | UINT8 Century; 349 | UINT8 Reserved4; 350 | UINT8 Reserved5; 351 | UINT8 Reserved6; 352 | UINT32 Flags; 353 | } 354 | /// FADT Version (as defined in ACPI 1.0b specification). 355 | enum EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION = 0x01; 356 | enum EFI_ACPI_1_0_INT_MODE_DUAL_PIC = 0; 357 | enum EFI_ACPI_1_0_INT_MODE_MULTIPLE_APIC = 1; 358 | enum EFI_ACPI_1_0_WBINVD = BIT0; 359 | enum EFI_ACPI_1_0_WBINVD_FLUSH = BIT1; 360 | enum EFI_ACPI_1_0_PROC_C1 = BIT2; 361 | enum EFI_ACPI_1_0_P_LVL2_UP = BIT3; 362 | enum EFI_ACPI_1_0_PWR_BUTTON = BIT4; 363 | enum EFI_ACPI_1_0_SLP_BUTTON = BIT5; 364 | enum EFI_ACPI_1_0_FIX_RTC = BIT6; 365 | enum EFI_ACPI_1_0_RTC_S4 = BIT7; 366 | enum EFI_ACPI_1_0_TMR_VAL_EXT = BIT8; 367 | enum EFI_ACPI_1_0_DCK_CAP = BIT9; 368 | /// Firmware ACPI Control Structure. 369 | struct EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE 370 | { 371 | align(1): 372 | UINT32 Signature; 373 | UINT32 Length; 374 | UINT32 HardwareSignature; 375 | UINT32 FirmwareWakingVector; 376 | UINT32 GlobalLock; 377 | UINT32 Flags; 378 | UINT8[40] Reserved; 379 | } 380 | /// Firmware Control Structure Feature Flags. 381 | /// All other bits are reserved and must be set to 0. 382 | enum EFI_ACPI_1_0_S4BIOS_F = BIT0; 383 | /// Multiple APIC Description Table header definition. The rest of the table 384 | /// must be defined in a platform-specific manner. 385 | struct EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER 386 | { 387 | align(1): 388 | EFI_ACPI_DESCRIPTION_HEADER Header; 389 | UINT32 LocalApicAddress; 390 | UINT32 Flags; 391 | } 392 | /// MADT Revision (as defined in ACPI 1.0b specification). 393 | enum EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION = 0x01; 394 | /// Multiple APIC Flags 395 | /// All other bits are reserved and must be set to 0. 396 | enum EFI_ACPI_1_0_PCAT_COMPAT = BIT0; 397 | enum EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC = 0x00; 398 | enum EFI_ACPI_1_0_IO_APIC = 0x01; 399 | enum EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE = 0x02; 400 | enum EFI_ACPI_1_0_NON_MASKABLE_INTERRUPT_SOURCE = 0x03; 401 | enum EFI_ACPI_1_0_LOCAL_APIC_NMI = 0x04; 402 | /// Processor Local APIC Structure Definition. 403 | struct EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC_STRUCTURE 404 | { 405 | align(1): 406 | UINT8 Type; 407 | UINT8 Length; 408 | UINT8 AcpiProcessorId; 409 | UINT8 ApicId; 410 | UINT32 Flags; 411 | } 412 | /// Local APIC Flags. All other bits are reserved and must be 0. 413 | enum EFI_ACPI_1_0_LOCAL_APIC_ENABLED = BIT0; 414 | /// IO APIC Structure. 415 | struct EFI_ACPI_1_0_IO_APIC_STRUCTURE 416 | { 417 | align(1): 418 | UINT8 Type; 419 | UINT8 Length; 420 | UINT8 IoApicId; 421 | UINT8 Reserved; 422 | UINT32 IoApicAddress; 423 | UINT32 SystemVectorBase; 424 | } 425 | /// Interrupt Source Override Structure. 426 | struct EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE 427 | { 428 | align(1): 429 | UINT8 Type; 430 | UINT8 Length; 431 | UINT8 Bus; 432 | UINT8 Source; 433 | UINT32 GlobalSystemInterruptVector; 434 | UINT16 Flags; 435 | } 436 | /// Non-Maskable Interrupt Source Structure. 437 | struct EFI_ACPI_1_0_NON_MASKABLE_INTERRUPT_SOURCE_STRUCTURE 438 | { 439 | align(1): 440 | UINT8 Type; 441 | UINT8 Length; 442 | UINT16 Flags; 443 | UINT32 GlobalSystemInterruptVector; 444 | } 445 | /// Local APIC NMI Structure. 446 | struct EFI_ACPI_1_0_LOCAL_APIC_NMI_STRUCTURE 447 | { 448 | align(1): 449 | UINT8 Type; 450 | UINT8 Length; 451 | UINT8 AcpiProcessorId; 452 | UINT16 Flags; 453 | UINT8 LocalApicInti; 454 | } 455 | /// Smart Battery Description Table (SBST) 456 | struct EFI_ACPI_1_0_SMART_BATTERY_DESCRIPTION_TABLE 457 | { 458 | align(1): 459 | EFI_ACPI_DESCRIPTION_HEADER Header; 460 | UINT32 WarningEnergyLevel; 461 | UINT32 LowEnergyLevel; 462 | UINT32 CriticalEnergyLevel; 463 | } 464 | /// "RSD PTR " Root System Description Pointer. 465 | enum EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE = SIGNATURE_64('R', 466 | 'S', 'D', ' ', 'P', 'T', 'R', ' '); 467 | /// "APIC" Multiple APIC Description Table. 468 | enum EFI_ACPI_1_0_APIC_SIGNATURE = SIGNATURE_32('A', 'P', 'I', 'C'); 469 | /// "DSDT" Differentiated System Description Table. 470 | enum EFI_ACPI_1_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE = SIGNATURE_32( 471 | 'D', 'S', 'D', 'T'); 472 | /// "FACS" Firmware ACPI Control Structure. 473 | enum EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE = SIGNATURE_32('F', 'A', 474 | 'C', 'S'); 475 | /// "FACP" Fixed ACPI Description Table. 476 | enum EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE = SIGNATURE_32('F', 'A', 'C', 477 | 'P'); 478 | /// "PSDT" Persistent System Description Table. 479 | enum EFI_ACPI_1_0_PERSISTENT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE = SIGNATURE_32('P', 480 | 'S', 'D', 'T'); 481 | /// "RSDT" Root System Description Table. 482 | enum EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE = SIGNATURE_32('R', 'S', 483 | 'D', 'T'); 484 | /// "SBST" Smart Battery Specification Table. 485 | enum EFI_ACPI_1_0_SMART_BATTERY_SPECIFICATION_TABLE_SIGNATURE = SIGNATURE_32('S', 'B', 486 | 'S', 'T'); 487 | /// "SSDT" Secondary System Description Table. 488 | enum EFI_ACPI_1_0_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE = SIGNATURE_32('S', 489 | 'S', 'D', 'T'); 490 | -------------------------------------------------------------------------------- /source/uefi/acpi20.d: -------------------------------------------------------------------------------- 1 | /** 2 | Based on IndustryStandard/Acpi20.h, original notice: 3 | 4 | ACPI 2.0 definitions from the ACPI Specification, revision 2.0 5 | 6 | Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved. 7 | This program and the accompanying materials 8 | are licensed and made available under the terms and conditions of the BSD License 9 | which accompanies this distribution. The full text of the license may be found at 10 | http://opensource.org/licenses/bsd-license.php 11 | 12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 14 | **/ 15 | module uefi.acpi20; 16 | import uefi.base; 17 | import uefi.base_type; 18 | import uefi.acpiaml; 19 | import uefi.acpi10; 20 | 21 | public: 22 | extern (C): 23 | 24 | enum ACPI_LARGE_GENERIC_REGISTER_DESCRIPTOR_NAME = 0x02; 25 | enum ACPI_GENERIC_REGISTER_DESCRIPTOR = 0x82; 26 | /// Generic Register Descriptor 27 | struct EFI_ACPI_GENERIC_REGISTER_DESCRIPTOR 28 | { 29 | align(1): 30 | ACPI_LARGE_RESOURCE_HEADER Header; 31 | UINT8 AddressSpaceId; 32 | UINT8 RegisterBitWidth; 33 | UINT8 RegisterBitOffset; 34 | UINT8 AddressSize; 35 | UINT64 RegisterAddress; 36 | } 37 | /// ACPI 2.0 Generic Address Space definition 38 | struct EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE 39 | { 40 | align(1): 41 | UINT8 AddressSpaceId; 42 | UINT8 RegisterBitWidth; 43 | UINT8 RegisterBitOffset; 44 | UINT8 Reserved; 45 | UINT64 Address; 46 | } 47 | 48 | enum EFI_ACPI_2_0_SYSTEM_MEMORY = 0; 49 | enum EFI_ACPI_2_0_SYSTEM_IO = 1; 50 | enum EFI_ACPI_2_0_PCI_CONFIGURATION_SPACE = 2; 51 | enum EFI_ACPI_2_0_EMBEDDED_CONTROLLER = 3; 52 | enum EFI_ACPI_2_0_SMBUS = 4; 53 | enum EFI_ACPI_2_0_FUNCTIONAL_FIXED_HARDWARE = 0x7F; 54 | /// Root System Description Pointer Structure 55 | struct EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER 56 | { 57 | align(1): 58 | UINT64 Signature; 59 | UINT8 Checksum; 60 | UINT8[6] OemId; 61 | UINT8 Revision; 62 | UINT32 RsdtAddress; 63 | UINT32 Length; 64 | UINT64 XsdtAddress; 65 | UINT8 ExtendedChecksum; 66 | UINT8[3] Reserved; 67 | } 68 | /// RSD_PTR Revision (as defined in ACPI 2.0 spec.) 69 | enum EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION = 0x02; 70 | /// Common table header, this prefaces all ACPI tables, including FACS, but 71 | /// excluding the RSD PTR structure 72 | struct EFI_ACPI_2_0_COMMON_HEADER 73 | { 74 | align(1): 75 | UINT32 Signature; 76 | UINT32 Length; 77 | } 78 | /// RSDT Revision (as defined in ACPI 2.0 spec.) 79 | enum EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_TABLE_REVISION = 0x01; 80 | /// XSDT Revision (as defined in ACPI 2.0 spec.) 81 | enum EFI_ACPI_2_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_REVISION = 0x01; 82 | /// Fixed ACPI Description Table Structure (FADT) 83 | struct EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE 84 | { 85 | align(1): 86 | EFI_ACPI_DESCRIPTION_HEADER Header; 87 | UINT32 FirmwareCtrl; 88 | UINT32 Dsdt; 89 | UINT8 Reserved0; 90 | UINT8 PreferredPmProfile; 91 | UINT16 SciInt; 92 | UINT32 SmiCmd; 93 | UINT8 AcpiEnable; 94 | UINT8 AcpiDisable; 95 | UINT8 S4BiosReq; 96 | UINT8 PstateCnt; 97 | UINT32 Pm1aEvtBlk; 98 | UINT32 Pm1bEvtBlk; 99 | UINT32 Pm1aCntBlk; 100 | UINT32 Pm1bCntBlk; 101 | UINT32 Pm2CntBlk; 102 | UINT32 PmTmrBlk; 103 | UINT32 Gpe0Blk; 104 | UINT32 Gpe1Blk; 105 | UINT8 Pm1EvtLen; 106 | UINT8 Pm1CntLen; 107 | UINT8 Pm2CntLen; 108 | UINT8 PmTmrLen; 109 | UINT8 Gpe0BlkLen; 110 | UINT8 Gpe1BlkLen; 111 | UINT8 Gpe1Base; 112 | UINT8 CstCnt; 113 | UINT16 PLvl2Lat; 114 | UINT16 PLvl3Lat; 115 | UINT16 FlushSize; 116 | UINT16 FlushStride; 117 | UINT8 DutyOffset; 118 | UINT8 DutyWidth; 119 | UINT8 DayAlrm; 120 | UINT8 MonAlrm; 121 | UINT8 Century; 122 | UINT16 IaPcBootArch; 123 | UINT8 Reserved1; 124 | UINT32 Flags; 125 | EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE ResetReg; 126 | UINT8 ResetValue; 127 | UINT8[3] Reserved2; 128 | UINT64 XFirmwareCtrl; 129 | UINT64 XDsdt; 130 | EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE XPm1aEvtBlk; 131 | EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE XPm1bEvtBlk; 132 | EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE XPm1aCntBlk; 133 | EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE XPm1bCntBlk; 134 | EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE XPm2CntBlk; 135 | EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE XPmTmrBlk; 136 | EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE XGpe0Blk; 137 | EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE XGpe1Blk; 138 | } 139 | /// FADT Version (as defined in ACPI 2.0 spec.) 140 | enum EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION = 0x03; 141 | enum EFI_ACPI_2_0_PM_PROFILE_UNSPECIFIED = 0; 142 | enum EFI_ACPI_2_0_PM_PROFILE_DESKTOP = 1; 143 | enum EFI_ACPI_2_0_PM_PROFILE_MOBILE = 2; 144 | enum EFI_ACPI_2_0_PM_PROFILE_WORKSTATION = 3; 145 | enum EFI_ACPI_2_0_PM_PROFILE_ENTERPRISE_SERVER = 4; 146 | enum EFI_ACPI_2_0_PM_PROFILE_SOHO_SERVER = 5; 147 | enum EFI_ACPI_2_0_PM_PROFILE_APPLIANCE_PC = 6; 148 | enum EFI_ACPI_2_0_LEGACY_DEVICES = BIT0; 149 | enum EFI_ACPI_2_0_8042 = BIT1; 150 | enum EFI_ACPI_2_0_WBINVD = BIT0; 151 | enum EFI_ACPI_2_0_WBINVD_FLUSH = BIT1; 152 | enum EFI_ACPI_2_0_PROC_C1 = BIT2; 153 | enum EFI_ACPI_2_0_P_LVL2_UP = BIT3; 154 | enum EFI_ACPI_2_0_PWR_BUTTON = BIT4; 155 | enum EFI_ACPI_2_0_SLP_BUTTON = BIT5; 156 | enum EFI_ACPI_2_0_FIX_RTC = BIT6; 157 | enum EFI_ACPI_2_0_RTC_S4 = BIT7; 158 | enum EFI_ACPI_2_0_TMR_VAL_EXT = BIT8; 159 | enum EFI_ACPI_2_0_DCK_CAP = BIT9; 160 | enum EFI_ACPI_2_0_RESET_REG_SUP = BIT10; 161 | enum EFI_ACPI_2_0_SEALED_CASE = BIT11; 162 | enum EFI_ACPI_2_0_HEADLESS = BIT12; 163 | enum EFI_ACPI_2_0_CPU_SW_SLP = BIT13; 164 | /// Firmware ACPI Control Structure 165 | struct EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE 166 | { 167 | align(1): 168 | UINT32 Signature; 169 | UINT32 Length; 170 | UINT32 HardwareSignature; 171 | UINT32 FirmwareWakingVector; 172 | UINT32 GlobalLock; 173 | UINT32 Flags; 174 | UINT64 XFirmwareWakingVector; 175 | UINT8 Version; 176 | UINT8[31] Reserved; 177 | } 178 | /// FACS Version (as defined in ACPI 2.0 spec.) 179 | enum EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION = 0x01; 180 | /// Firmware Control Structure Feature Flags 181 | /// All other bits are reserved and must be set to 0. 182 | enum EFI_ACPI_2_0_S4BIOS_F = BIT0; 183 | /// Multiple APIC Description Table header definition. The rest of the table 184 | /// must be defined in a platform specific manner. 185 | struct EFI_ACPI_2_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER 186 | { 187 | align(1): 188 | EFI_ACPI_DESCRIPTION_HEADER Header; 189 | UINT32 LocalApicAddress; 190 | UINT32 Flags; 191 | } 192 | /// MADT Revision (as defined in ACPI 2.0 spec.) 193 | enum EFI_ACPI_2_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION = 0x01; 194 | /// Multiple APIC Flags 195 | /// All other bits are reserved and must be set to 0. 196 | enum EFI_ACPI_2_0_PCAT_COMPAT = BIT0; 197 | enum EFI_ACPI_2_0_PROCESSOR_LOCAL_APIC = 0x00; 198 | enum EFI_ACPI_2_0_IO_APIC = 0x01; 199 | enum EFI_ACPI_2_0_INTERRUPT_SOURCE_OVERRIDE = 0x02; 200 | enum EFI_ACPI_2_0_NON_MASKABLE_INTERRUPT_SOURCE = 0x03; 201 | enum EFI_ACPI_2_0_LOCAL_APIC_NMI = 0x04; 202 | enum EFI_ACPI_2_0_LOCAL_APIC_ADDRESS_OVERRIDE = 0x05; 203 | enum EFI_ACPI_2_0_IO_SAPIC = 0x06; 204 | enum EFI_ACPI_2_0_PROCESSOR_LOCAL_SAPIC = 0x07; 205 | enum EFI_ACPI_2_0_PLATFORM_INTERRUPT_SOURCES = 0x08; 206 | /// Processor Local APIC Structure Definition 207 | struct EFI_ACPI_2_0_PROCESSOR_LOCAL_APIC_STRUCTURE 208 | { 209 | align(1): 210 | UINT8 Type; 211 | UINT8 Length; 212 | UINT8 AcpiProcessorId; 213 | UINT8 ApicId; 214 | UINT32 Flags; 215 | } 216 | /// Local APIC Flags. All other bits are reserved and must be 0. 217 | enum EFI_ACPI_2_0_LOCAL_APIC_ENABLED = BIT0; 218 | /// IO APIC Structure 219 | struct EFI_ACPI_2_0_IO_APIC_STRUCTURE 220 | { 221 | align(1): 222 | UINT8 Type; 223 | UINT8 Length; 224 | UINT8 IoApicId; 225 | UINT8 Reserved; 226 | UINT32 IoApicAddress; 227 | UINT32 GlobalSystemInterruptBase; 228 | } 229 | /// Interrupt Source Override Structure 230 | struct EFI_ACPI_2_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE 231 | { 232 | align(1): 233 | UINT8 Type; 234 | UINT8 Length; 235 | UINT8 Bus; 236 | UINT8 Source; 237 | UINT32 GlobalSystemInterrupt; 238 | UINT16 Flags; 239 | } 240 | /// Non-Maskable Interrupt Source Structure 241 | struct EFI_ACPI_2_0_NON_MASKABLE_INTERRUPT_SOURCE_STRUCTURE 242 | { 243 | align(1): 244 | UINT8 Type; 245 | UINT8 Length; 246 | UINT16 Flags; 247 | UINT32 GlobalSystemInterrupt; 248 | } 249 | /// Local APIC NMI Structure 250 | struct EFI_ACPI_2_0_LOCAL_APIC_NMI_STRUCTURE 251 | { 252 | align(1): 253 | UINT8 Type; 254 | UINT8 Length; 255 | UINT8 AcpiProcessorId; 256 | UINT16 Flags; 257 | UINT8 LocalApicLint; 258 | } 259 | /// Local APIC Address Override Structure 260 | struct EFI_ACPI_2_0_LOCAL_APIC_ADDRESS_OVERRIDE_STRUCTURE 261 | { 262 | align(1): 263 | UINT8 Type; 264 | UINT8 Length; 265 | UINT16 Reserved; 266 | UINT64 LocalApicAddress; 267 | } 268 | /// IO SAPIC Structure 269 | struct EFI_ACPI_2_0_IO_SAPIC_STRUCTURE 270 | { 271 | align(1): 272 | UINT8 Type; 273 | UINT8 Length; 274 | UINT8 IoApicId; 275 | UINT8 Reserved; 276 | UINT32 GlobalSystemInterruptBase; 277 | UINT64 IoSapicAddress; 278 | } 279 | /// Local SAPIC Structure 280 | struct EFI_ACPI_2_0_PROCESSOR_LOCAL_SAPIC_STRUCTURE 281 | { 282 | align(1): 283 | UINT8 Type; 284 | UINT8 Length; 285 | UINT8 AcpiProcessorId; 286 | UINT8 LocalSapicId; 287 | UINT8 LocalSapicEid; 288 | UINT8[3] Reserved; 289 | UINT32 Flags; 290 | } 291 | /// Platform Interrupt Sources Structure 292 | struct EFI_ACPI_2_0_PLATFORM_INTERRUPT_SOURCES_STRUCTURE 293 | { 294 | align(1): 295 | UINT8 Type; 296 | UINT8 Length; 297 | UINT16 Flags; 298 | UINT8 InterruptType; 299 | UINT8 ProcessorId; 300 | UINT8 ProcessorEid; 301 | UINT8 IoSapicVector; 302 | UINT32 GlobalSystemInterrupt; 303 | UINT32 Reserved; 304 | } 305 | /// Smart Battery Description Table (SBST) 306 | struct EFI_ACPI_2_0_SMART_BATTERY_DESCRIPTION_TABLE 307 | { 308 | align(1): 309 | EFI_ACPI_DESCRIPTION_HEADER Header; 310 | UINT32 WarningEnergyLevel; 311 | UINT32 LowEnergyLevel; 312 | UINT32 CriticalEnergyLevel; 313 | } 314 | /// SBST Version (as defined in ACPI 2.0 spec.) 315 | enum EFI_ACPI_2_0_SMART_BATTERY_DESCRIPTION_TABLE_REVISION = 0x01; 316 | /// Embedded Controller Boot Resources Table (ECDT) 317 | /// The table is followed by a null terminated ASCII string that contains 318 | /// a fully qualified reference to the name space object. 319 | struct EFI_ACPI_2_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE 320 | { 321 | align(1): 322 | EFI_ACPI_DESCRIPTION_HEADER Header; 323 | EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE EcControl; 324 | EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE EcData; 325 | UINT32 Uid; 326 | UINT8 GpeBit; 327 | } 328 | /// ECDT Version (as defined in ACPI 2.0 spec.) 329 | enum EFI_ACPI_2_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE_REVISION = 0x01; 330 | /// "RSD PTR " Root System Description Pointer 331 | enum EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE = SIGNATURE_64('R', 332 | 'S', 'D', ' ', 'P', 'T', 'R', ' '); 333 | /// "SPIC" Multiple SAPIC Description Table 334 | /// BUGBUG: Don't know where this came from except SR870BN4 uses it. 335 | /// #define EFI_ACPI_2_0_MULTIPLE_SAPIC_DESCRIPTION_TABLE_SIGNATURE 0x43495053 336 | enum EFI_ACPI_2_0_MULTIPLE_SAPIC_DESCRIPTION_TABLE_SIGNATURE = SIGNATURE_32('A', 'P', 337 | 'I', 'C'); 338 | /// "BOOT" MS Simple Boot Spec 339 | enum EFI_ACPI_2_0_SIMPLE_BOOT_FLAG_TABLE_SIGNATURE = SIGNATURE_32('B', 'O', 'O', 'T'); 340 | /// "DBGP" MS Bebug Port Spec 341 | enum EFI_ACPI_2_0_DEBUG_PORT_TABLE_SIGNATURE = SIGNATURE_32('D', 'B', 'G', 'P'); 342 | /// "DSDT" Differentiated System Description Table 343 | enum EFI_ACPI_2_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE = SIGNATURE_32( 344 | 'D', 'S', 'D', 'T'); 345 | /// "ECDT" Embedded Controller Boot Resources Table 346 | enum EFI_ACPI_2_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE_SIGNATURE = SIGNATURE_32( 347 | 'E', 'C', 'D', 'T'); 348 | /// "ETDT" Event Timer Description Table 349 | enum EFI_ACPI_2_0_EVENT_TIMER_DESCRIPTION_TABLE_SIGNATURE = SIGNATURE_32('E', 'T', 350 | 'D', 'T'); 351 | /// "FACS" Firmware ACPI Control Structure 352 | enum EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE = SIGNATURE_32('F', 'A', 353 | 'C', 'S'); 354 | /// "FACP" Fixed ACPI Description Table 355 | enum EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE = SIGNATURE_32('F', 'A', 'C', 356 | 'P'); 357 | /// "APIC" Multiple APIC Description Table 358 | enum EFI_ACPI_2_0_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE = SIGNATURE_32('A', 'P', 359 | 'I', 'C'); 360 | /// "PSDT" Persistent System Description Table 361 | enum EFI_ACPI_2_0_PERSISTENT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE = SIGNATURE_32('P', 362 | 'S', 'D', 'T'); 363 | /// "RSDT" Root System Description Table 364 | enum EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE = SIGNATURE_32('R', 'S', 365 | 'D', 'T'); 366 | /// "SBST" Smart Battery Specification Table 367 | enum EFI_ACPI_2_0_SMART_BATTERY_SPECIFICATION_TABLE_SIGNATURE = SIGNATURE_32('S', 'B', 368 | 'S', 'T'); 369 | /// "SLIT" System Locality Information Table 370 | enum EFI_ACPI_2_0_SYSTEM_LOCALITY_INFORMATION_TABLE_SIGNATURE = SIGNATURE_32('S', 'L', 371 | 'I', 'T'); 372 | /// "SPCR" Serial Port Concole Redirection Table 373 | enum EFI_ACPI_2_0_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE = SIGNATURE_32('S', 374 | 'P', 'C', 'R'); 375 | /// "SRAT" Static Resource Affinity Table 376 | enum EFI_ACPI_2_0_STATIC_RESOURCE_AFFINITY_TABLE_SIGNATURE = SIGNATURE_32('S', 'R', 377 | 'A', 'T'); 378 | /// "SSDT" Secondary System Description Table 379 | enum EFI_ACPI_2_0_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE = SIGNATURE_32('S', 380 | 'S', 'D', 'T'); 381 | /// "SPMI" Server Platform Management Interface Table 382 | enum EFI_ACPI_2_0_SERVER_PLATFORM_MANAGEMENT_INTERFACE_SIGNATURE = SIGNATURE_32('S', 383 | 'P', 'M', 'I'); 384 | /// "XSDT" Extended System Description Table 385 | enum EFI_ACPI_2_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE = SIGNATURE_32('X', 'S', 386 | 'D', 'T'); 387 | /// "MCFG" PCI Express Memory Mapped Configuration Space Base Address Description Table 388 | enum EFI_ACPI_2_0_MEMORY_MAPPED_CONFIGURATION_BASE_ADDRESS_TABLE_SIGNATURE = SIGNATURE_32( 389 | 'M', 'C', 'F', 'G'); 390 | -------------------------------------------------------------------------------- /source/uefi/acpi30.d: -------------------------------------------------------------------------------- 1 | /** 2 | Based on IndustryStandard/Acpi30.h, original notice: 3 | 4 | ACPI 3.0 definitions from the ACPI Specification Revision 3.0b October 10, 2006 5 | 6 | Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved. 7 | This program and the accompanying materials 8 | are licensed and made available under the terms and conditions of the BSD License 9 | which accompanies this distribution. The full text of the license may be found at 10 | http://opensource.org/licenses/bsd-license.php 11 | 12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 14 | **/ 15 | module uefi.acpi30; 16 | import uefi.base; 17 | import uefi.base_type; 18 | import uefi.acpiaml; 19 | import uefi.acpi10; 20 | import uefi.acpi20; 21 | 22 | public: 23 | extern (C): 24 | // FIXME: INCLUDE 25 | enum ACPI_LARGE_EXTENDED_ADDRESS_SPACE_DESCRIPTOR_NAME = 0x0B; 26 | enum ACPI_EXTENDED_ADDRESS_SPACE_DESCRIPTOR = 0x8B; 27 | /// Extended Address Space Descriptor 28 | struct EFI_ACPI_EXTENDED_ADDRESS_SPACE_DESCRIPTOR 29 | { 30 | align(1): 31 | ACPI_LARGE_RESOURCE_HEADER Header; 32 | UINT8 ResType; 33 | UINT8 GenFlag; 34 | UINT8 SpecificFlag; 35 | UINT8 RevisionId; 36 | UINT8 Reserved; 37 | UINT64 AddrSpaceGranularity; 38 | UINT64 AddrRangeMin; 39 | UINT64 AddrRangeMax; 40 | UINT64 AddrTranslationOffset; 41 | UINT64 AddrLen; 42 | UINT64 TypeSpecificAttribute; 43 | } 44 | 45 | enum EFI_ACPI_MEMORY_TYPE_SPECIFIC_ATTRIBUTES_UC = 0x0000000000000001; 46 | enum EFI_ACPI_MEMORY_TYPE_SPECIFIC_ATTRIBUTES_WC = 0x0000000000000002; 47 | enum EFI_ACPI_MEMORY_TYPE_SPECIFIC_ATTRIBUTES_WT = 0x0000000000000004; 48 | enum EFI_ACPI_MEMORY_TYPE_SPECIFIC_ATTRIBUTES_WB = 0x0000000000000008; 49 | enum EFI_ACPI_MEMORY_TYPE_SPECIFIC_ATTRIBUTES_UCE = 0x0000000000000010; 50 | enum EFI_ACPI_MEMORY_TYPE_SPECIFIC_ATTRIBUTES_NV = 0x0000000000008000; 51 | /// ACPI 3.0 Generic Address Space definition 52 | struct EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE 53 | { 54 | align(1): 55 | UINT8 AddressSpaceId; 56 | UINT8 RegisterBitWidth; 57 | UINT8 RegisterBitOffset; 58 | UINT8 AccessSize; 59 | UINT64 Address; 60 | } 61 | 62 | enum EFI_ACPI_3_0_SYSTEM_MEMORY = 0; 63 | enum EFI_ACPI_3_0_SYSTEM_IO = 1; 64 | enum EFI_ACPI_3_0_PCI_CONFIGURATION_SPACE = 2; 65 | enum EFI_ACPI_3_0_EMBEDDED_CONTROLLER = 3; 66 | enum EFI_ACPI_3_0_SMBUS = 4; 67 | enum EFI_ACPI_3_0_FUNCTIONAL_FIXED_HARDWARE = 0x7F; 68 | enum EFI_ACPI_3_0_UNDEFINED = 0; 69 | enum EFI_ACPI_3_0_BYTE = 1; 70 | enum EFI_ACPI_3_0_WORD = 2; 71 | enum EFI_ACPI_3_0_DWORD = 3; 72 | enum EFI_ACPI_3_0_QWORD = 4; 73 | /// Root System Description Pointer Structure 74 | struct EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER 75 | { 76 | align(1): 77 | UINT64 Signature; 78 | UINT8 Checksum; 79 | UINT8[6] OemId; 80 | UINT8 Revision; 81 | UINT32 RsdtAddress; 82 | UINT32 Length; 83 | UINT64 XsdtAddress; 84 | UINT8 ExtendedChecksum; 85 | UINT8[3] Reserved; 86 | } 87 | /// RSD_PTR Revision (as defined in ACPI 3.0b spec.) 88 | enum EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION = 0x02; ///< ACPISpec (Revision 3.0b) says current value is 2 89 | /// Common table header, this prefaces all ACPI tables, including FACS, but 90 | /// excluding the RSD PTR structure 91 | struct EFI_ACPI_3_0_COMMON_HEADER 92 | { 93 | align(1): 94 | UINT32 Signature; 95 | UINT32 Length; 96 | } 97 | /// RSDT Revision (as defined in ACPI 3.0 spec.) 98 | enum EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_TABLE_REVISION = 0x01; 99 | /// XSDT Revision (as defined in ACPI 3.0 spec.) 100 | enum EFI_ACPI_3_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_REVISION = 0x01; 101 | /// Fixed ACPI Description Table Structure (FADT) 102 | struct EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE 103 | { 104 | align(1): 105 | EFI_ACPI_DESCRIPTION_HEADER Header; 106 | UINT32 FirmwareCtrl; 107 | UINT32 Dsdt; 108 | UINT8 Reserved0; 109 | UINT8 PreferredPmProfile; 110 | UINT16 SciInt; 111 | UINT32 SmiCmd; 112 | UINT8 AcpiEnable; 113 | UINT8 AcpiDisable; 114 | UINT8 S4BiosReq; 115 | UINT8 PstateCnt; 116 | UINT32 Pm1aEvtBlk; 117 | UINT32 Pm1bEvtBlk; 118 | UINT32 Pm1aCntBlk; 119 | UINT32 Pm1bCntBlk; 120 | UINT32 Pm2CntBlk; 121 | UINT32 PmTmrBlk; 122 | UINT32 Gpe0Blk; 123 | UINT32 Gpe1Blk; 124 | UINT8 Pm1EvtLen; 125 | UINT8 Pm1CntLen; 126 | UINT8 Pm2CntLen; 127 | UINT8 PmTmrLen; 128 | UINT8 Gpe0BlkLen; 129 | UINT8 Gpe1BlkLen; 130 | UINT8 Gpe1Base; 131 | UINT8 CstCnt; 132 | UINT16 PLvl2Lat; 133 | UINT16 PLvl3Lat; 134 | UINT16 FlushSize; 135 | UINT16 FlushStride; 136 | UINT8 DutyOffset; 137 | UINT8 DutyWidth; 138 | UINT8 DayAlrm; 139 | UINT8 MonAlrm; 140 | UINT8 Century; 141 | UINT16 IaPcBootArch; 142 | UINT8 Reserved1; 143 | UINT32 Flags; 144 | EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE ResetReg; 145 | UINT8 ResetValue; 146 | UINT8[3] Reserved2; 147 | UINT64 XFirmwareCtrl; 148 | UINT64 XDsdt; 149 | EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE XPm1aEvtBlk; 150 | EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE XPm1bEvtBlk; 151 | EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE XPm1aCntBlk; 152 | EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE XPm1bCntBlk; 153 | EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE XPm2CntBlk; 154 | EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE XPmTmrBlk; 155 | EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE XGpe0Blk; 156 | EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE XGpe1Blk; 157 | } 158 | /// FADT Version (as defined in ACPI 3.0 spec.) 159 | enum EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION = 0x04; 160 | enum EFI_ACPI_3_0_PM_PROFILE_UNSPECIFIED = 0; 161 | enum EFI_ACPI_3_0_PM_PROFILE_DESKTOP = 1; 162 | enum EFI_ACPI_3_0_PM_PROFILE_MOBILE = 2; 163 | enum EFI_ACPI_3_0_PM_PROFILE_WORKSTATION = 3; 164 | enum EFI_ACPI_3_0_PM_PROFILE_ENTERPRISE_SERVER = 4; 165 | enum EFI_ACPI_3_0_PM_PROFILE_SOHO_SERVER = 5; 166 | enum EFI_ACPI_3_0_PM_PROFILE_APPLIANCE_PC = 6; 167 | enum EFI_ACPI_3_0_PM_PROFILE_PERFORMANCE_SERVER = 7; 168 | enum EFI_ACPI_3_0_LEGACY_DEVICES = BIT0; 169 | enum EFI_ACPI_3_0_8042 = BIT1; 170 | enum EFI_ACPI_3_0_VGA_NOT_PRESENT = BIT2; 171 | enum EFI_ACPI_3_0_MSI_NOT_SUPPORTED = BIT3; 172 | enum EFI_ACPI_3_0_PCIE_ASPM_CONTROLS = BIT4; 173 | enum EFI_ACPI_3_0_WBINVD = BIT0; 174 | enum EFI_ACPI_3_0_WBINVD_FLUSH = BIT1; 175 | enum EFI_ACPI_3_0_PROC_C1 = BIT2; 176 | enum EFI_ACPI_3_0_P_LVL2_UP = BIT3; 177 | enum EFI_ACPI_3_0_PWR_BUTTON = BIT4; 178 | enum EFI_ACPI_3_0_SLP_BUTTON = BIT5; 179 | enum EFI_ACPI_3_0_FIX_RTC = BIT6; 180 | enum EFI_ACPI_3_0_RTC_S4 = BIT7; 181 | enum EFI_ACPI_3_0_TMR_VAL_EXT = BIT8; 182 | enum EFI_ACPI_3_0_DCK_CAP = BIT9; 183 | enum EFI_ACPI_3_0_RESET_REG_SUP = BIT10; 184 | enum EFI_ACPI_3_0_SEALED_CASE = BIT11; 185 | enum EFI_ACPI_3_0_HEADLESS = BIT12; 186 | enum EFI_ACPI_3_0_CPU_SW_SLP = BIT13; 187 | enum EFI_ACPI_3_0_PCI_EXP_WAK = BIT14; 188 | enum EFI_ACPI_3_0_USE_PLATFORM_CLOCK = BIT15; 189 | enum EFI_ACPI_3_0_S4_RTC_STS_VALID = BIT16; 190 | enum EFI_ACPI_3_0_REMOTE_POWER_ON_CAPABLE = BIT17; 191 | enum EFI_ACPI_3_0_FORCE_APIC_CLUSTER_MODEL = BIT18; 192 | enum EFI_ACPI_3_0_FORCE_APIC_PHYSICAL_DESTINATION_MODE = BIT19; 193 | /// Firmware ACPI Control Structure 194 | struct EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE 195 | { 196 | align(1): 197 | UINT32 Signature; 198 | UINT32 Length; 199 | UINT32 HardwareSignature; 200 | UINT32 FirmwareWakingVector; 201 | UINT32 GlobalLock; 202 | UINT32 Flags; 203 | UINT64 XFirmwareWakingVector; 204 | UINT8 Version; 205 | UINT8[31] Reserved; 206 | } 207 | /// FACS Version (as defined in ACPI 3.0 spec.) 208 | enum EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION = 0x01; 209 | /// Firmware Control Structure Feature Flags 210 | /// All other bits are reserved and must be set to 0. 211 | enum EFI_ACPI_3_0_S4BIOS_F = BIT0; 212 | enum EFI_ACPI_3_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_REVISION = 0x02; 213 | enum EFI_ACPI_3_0_SECONDARY_SYSTEM_DESCRIPTION_TABLE_REVISION = 0x02; 214 | /// Multiple APIC Description Table header definition. The rest of the table 215 | /// must be defined in a platform specific manner. 216 | struct EFI_ACPI_3_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER 217 | { 218 | align(1): 219 | EFI_ACPI_DESCRIPTION_HEADER Header; 220 | UINT32 LocalApicAddress; 221 | UINT32 Flags; 222 | } 223 | /// MADT Revision (as defined in ACPI 3.0 spec.) 224 | enum EFI_ACPI_3_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION = 0x02; 225 | /// Multiple APIC Flags 226 | /// All other bits are reserved and must be set to 0. 227 | enum EFI_ACPI_3_0_PCAT_COMPAT = BIT0; 228 | enum EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC = 0x00; 229 | enum EFI_ACPI_3_0_IO_APIC = 0x01; 230 | enum EFI_ACPI_3_0_INTERRUPT_SOURCE_OVERRIDE = 0x02; 231 | enum EFI_ACPI_3_0_NON_MASKABLE_INTERRUPT_SOURCE = 0x03; 232 | enum EFI_ACPI_3_0_LOCAL_APIC_NMI = 0x04; 233 | enum EFI_ACPI_3_0_LOCAL_APIC_ADDRESS_OVERRIDE = 0x05; 234 | enum EFI_ACPI_3_0_IO_SAPIC = 0x06; 235 | enum EFI_ACPI_3_0_LOCAL_SAPIC = 0x07; 236 | enum EFI_ACPI_3_0_PLATFORM_INTERRUPT_SOURCES = 0x08; 237 | /// Processor Local APIC Structure Definition 238 | struct EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC_STRUCTURE 239 | { 240 | align(1): 241 | UINT8 Type; 242 | UINT8 Length; 243 | UINT8 AcpiProcessorId; 244 | UINT8 ApicId; 245 | UINT32 Flags; 246 | } 247 | /// Local APIC Flags. All other bits are reserved and must be 0. 248 | enum EFI_ACPI_3_0_LOCAL_APIC_ENABLED = BIT0; 249 | /// IO APIC Structure 250 | struct EFI_ACPI_3_0_IO_APIC_STRUCTURE 251 | { 252 | align(1): 253 | UINT8 Type; 254 | UINT8 Length; 255 | UINT8 IoApicId; 256 | UINT8 Reserved; 257 | UINT32 IoApicAddress; 258 | UINT32 GlobalSystemInterruptBase; 259 | } 260 | /// Interrupt Source Override Structure 261 | struct EFI_ACPI_3_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE 262 | { 263 | align(1): 264 | UINT8 Type; 265 | UINT8 Length; 266 | UINT8 Bus; 267 | UINT8 Source; 268 | UINT32 GlobalSystemInterrupt; 269 | UINT16 Flags; 270 | } 271 | /// Platform Interrupt Sources Structure Definition 272 | struct EFI_ACPI_3_0_PLATFORM_INTERRUPT_APIC_STRUCTURE 273 | { 274 | align(1): 275 | UINT8 Type; 276 | UINT8 Length; 277 | UINT16 Flags; 278 | UINT8 InterruptType; 279 | UINT8 ProcessorId; 280 | UINT8 ProcessorEid; 281 | UINT8 IoSapicVector; 282 | UINT32 GlobalSystemInterrupt; 283 | UINT32 PlatformInterruptSourceFlags; 284 | UINT8 CpeiProcessorOverride; 285 | UINT8[31] Reserved; 286 | } 287 | 288 | enum EFI_ACPI_3_0_POLARITY = (3 << 0); 289 | enum EFI_ACPI_3_0_TRIGGER_MODE = (3 << 2); 290 | /// Non-Maskable Interrupt Source Structure 291 | struct EFI_ACPI_3_0_NON_MASKABLE_INTERRUPT_SOURCE_STRUCTURE 292 | { 293 | align(1): 294 | UINT8 Type; 295 | UINT8 Length; 296 | UINT16 Flags; 297 | UINT32 GlobalSystemInterrupt; 298 | } 299 | /// Local APIC NMI Structure 300 | struct EFI_ACPI_3_0_LOCAL_APIC_NMI_STRUCTURE 301 | { 302 | align(1): 303 | UINT8 Type; 304 | UINT8 Length; 305 | UINT8 AcpiProcessorId; 306 | UINT16 Flags; 307 | UINT8 LocalApicLint; 308 | } 309 | /// Local APIC Address Override Structure 310 | struct EFI_ACPI_3_0_LOCAL_APIC_ADDRESS_OVERRIDE_STRUCTURE 311 | { 312 | align(1): 313 | UINT8 Type; 314 | UINT8 Length; 315 | UINT16 Reserved; 316 | UINT64 LocalApicAddress; 317 | } 318 | /// IO SAPIC Structure 319 | struct EFI_ACPI_3_0_IO_SAPIC_STRUCTURE 320 | { 321 | align(1): 322 | UINT8 Type; 323 | UINT8 Length; 324 | UINT8 IoApicId; 325 | UINT8 Reserved; 326 | UINT32 GlobalSystemInterruptBase; 327 | UINT64 IoSapicAddress; 328 | } 329 | /// Local SAPIC Structure 330 | /// This struct followed by a null-terminated ASCII string - ACPI Processor UID String 331 | struct EFI_ACPI_3_0_PROCESSOR_LOCAL_SAPIC_STRUCTURE 332 | { 333 | align(1): 334 | UINT8 Type; 335 | UINT8 Length; 336 | UINT8 AcpiProcessorId; 337 | UINT8 LocalSapicId; 338 | UINT8 LocalSapicEid; 339 | UINT8[3] Reserved; 340 | UINT32 Flags; 341 | UINT32 ACPIProcessorUIDValue; 342 | } 343 | /// Platform Interrupt Sources Structure 344 | struct EFI_ACPI_3_0_PLATFORM_INTERRUPT_SOURCES_STRUCTURE 345 | { 346 | align(1): 347 | UINT8 Type; 348 | UINT8 Length; 349 | UINT16 Flags; 350 | UINT8 InterruptType; 351 | UINT8 ProcessorId; 352 | UINT8 ProcessorEid; 353 | UINT8 IoSapicVector; 354 | UINT32 GlobalSystemInterrupt; 355 | UINT32 PlatformInterruptSourceFlags; 356 | } 357 | /// Platform Interrupt Source Flags. 358 | /// All other bits are reserved and must be set to 0. 359 | enum EFI_ACPI_3_0_CPEI_PROCESSOR_OVERRIDE = BIT0; 360 | /// Smart Battery Description Table (SBST) 361 | struct EFI_ACPI_3_0_SMART_BATTERY_DESCRIPTION_TABLE 362 | { 363 | align(1): 364 | EFI_ACPI_DESCRIPTION_HEADER Header; 365 | UINT32 WarningEnergyLevel; 366 | UINT32 LowEnergyLevel; 367 | UINT32 CriticalEnergyLevel; 368 | } 369 | /// SBST Version (as defined in ACPI 3.0 spec.) 370 | enum EFI_ACPI_3_0_SMART_BATTERY_DESCRIPTION_TABLE_REVISION = 0x01; 371 | /// Embedded Controller Boot Resources Table (ECDT) 372 | /// The table is followed by a null terminated ASCII string that contains 373 | /// a fully qualified reference to the name space object. 374 | struct EFI_ACPI_3_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE 375 | { 376 | align(1): 377 | EFI_ACPI_DESCRIPTION_HEADER Header; 378 | EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE EcControl; 379 | EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE EcData; 380 | UINT32 Uid; 381 | UINT8 GpeBit; 382 | } 383 | /// ECDT Version (as defined in ACPI 3.0 spec.) 384 | enum EFI_ACPI_3_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE_REVISION = 0x01; 385 | /// System Resource Affinity Table (SRAT. The rest of the table 386 | /// must be defined in a platform specific manner. 387 | struct EFI_ACPI_3_0_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER 388 | { 389 | align(1): 390 | EFI_ACPI_DESCRIPTION_HEADER Header; 391 | UINT32 Reserved1; ///< Must be set to 1 392 | UINT64 Reserved2; 393 | } 394 | /// SRAT Version (as defined in ACPI 3.0 spec.) 395 | enum EFI_ACPI_3_0_SYSTEM_RESOURCE_AFFINITY_TABLE_REVISION = 0x02; 396 | enum EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC_SAPIC_AFFINITY = 0x00; 397 | enum EFI_ACPI_3_0_MEMORY_AFFINITY = 0x01; 398 | /// Processor Local APIC/SAPIC Affinity Structure Definition 399 | struct EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC_SAPIC_AFFINITY_STRUCTURE 400 | { 401 | align(1): 402 | UINT8 Type; 403 | UINT8 Length; 404 | UINT8 ProximityDomain7To0; 405 | UINT8 ApicId; 406 | UINT32 Flags; 407 | UINT8 LocalSapicEid; 408 | UINT8[3] ProximityDomain31To8; 409 | UINT8[4] Reserved; 410 | } 411 | /// Local APIC/SAPIC Flags. All other bits are reserved and must be 0. 412 | enum EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC_SAPIC_ENABLED = (1 << 0); 413 | /// Memory Affinity Structure Definition 414 | struct EFI_ACPI_3_0_MEMORY_AFFINITY_STRUCTURE 415 | { 416 | align(1): 417 | UINT8 Type; 418 | UINT8 Length; 419 | UINT32 ProximityDomain; 420 | UINT16 Reserved1; 421 | UINT32 AddressBaseLow; 422 | UINT32 AddressBaseHigh; 423 | UINT32 LengthLow; 424 | UINT32 LengthHigh; 425 | UINT32 Reserved2; 426 | UINT32 Flags; 427 | UINT64 Reserved3; 428 | } 429 | 430 | enum EFI_ACPI_3_0_MEMORY_ENABLED = (1 << 0); 431 | enum EFI_ACPI_3_0_MEMORY_HOT_PLUGGABLE = (1 << 1); 432 | enum EFI_ACPI_3_0_MEMORY_NONVOLATILE = (1 << 2); 433 | /// System Locality Distance Information Table (SLIT). 434 | /// The rest of the table is a matrix. 435 | struct EFI_ACPI_3_0_SYSTEM_LOCALITY_DISTANCE_INFORMATION_TABLE_HEADER 436 | { 437 | align(1): 438 | EFI_ACPI_DESCRIPTION_HEADER Header; 439 | UINT64 NumberOfSystemLocalities; 440 | } 441 | /// SLIT Version (as defined in ACPI 3.0 spec.) 442 | enum EFI_ACPI_3_0_SYSTEM_LOCALITY_DISTANCE_INFORMATION_TABLE_REVISION = 0x01; 443 | /// "RSD PTR " Root System Description Pointer 444 | enum EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE = SIGNATURE_64('R', 445 | 'S', 'D', ' ', 'P', 'T', 'R', ' '); 446 | /// "APIC" Multiple APIC Description Table 447 | enum EFI_ACPI_3_0_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE = SIGNATURE_32('A', 'P', 448 | 'I', 'C'); 449 | /// "DSDT" Differentiated System Description Table 450 | enum EFI_ACPI_3_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE = SIGNATURE_32( 451 | 'D', 'S', 'D', 'T'); 452 | /// "ECDT" Embedded Controller Boot Resources Table 453 | enum EFI_ACPI_3_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE_SIGNATURE = SIGNATURE_32( 454 | 'E', 'C', 'D', 'T'); 455 | /// "FACP" Fixed ACPI Description Table 456 | enum EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE = SIGNATURE_32('F', 'A', 'C', 457 | 'P'); 458 | /// "FACS" Firmware ACPI Control Structure 459 | enum EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE = SIGNATURE_32('F', 'A', 460 | 'C', 'S'); 461 | /// "PSDT" Persistent System Description Table 462 | enum EFI_ACPI_3_0_PERSISTENT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE = SIGNATURE_32('P', 463 | 'S', 'D', 'T'); 464 | /// "RSDT" Root System Description Table 465 | enum EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE = SIGNATURE_32('R', 'S', 466 | 'D', 'T'); 467 | /// "SBST" Smart Battery Specification Table 468 | enum EFI_ACPI_3_0_SMART_BATTERY_SPECIFICATION_TABLE_SIGNATURE = SIGNATURE_32('S', 'B', 469 | 'S', 'T'); 470 | /// "SLIT" System Locality Information Table 471 | enum EFI_ACPI_3_0_SYSTEM_LOCALITY_INFORMATION_TABLE_SIGNATURE = SIGNATURE_32('S', 'L', 472 | 'I', 'T'); 473 | /// "SRAT" System Resource Affinity Table 474 | enum EFI_ACPI_3_0_SYSTEM_RESOURCE_AFFINITY_TABLE_SIGNATURE = SIGNATURE_32('S', 'R', 475 | 'A', 'T'); 476 | /// "SSDT" Secondary System Description Table 477 | enum EFI_ACPI_3_0_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE = SIGNATURE_32('S', 478 | 'S', 'D', 'T'); 479 | /// "XSDT" Extended System Description Table 480 | enum EFI_ACPI_3_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE = SIGNATURE_32('X', 'S', 481 | 'D', 'T'); 482 | /// "BOOT" MS Simple Boot Spec 483 | enum EFI_ACPI_3_0_SIMPLE_BOOT_FLAG_TABLE_SIGNATURE = SIGNATURE_32('B', 'O', 'O', 'T'); 484 | /// "CPEP" Corrected Platform Error Polling Table 485 | enum EFI_ACPI_3_0_CORRECTED_PLATFORM_ERROR_POLLING_TABLE_SIGNATURE = SIGNATURE_32( 486 | 'C', 'P', 'E', 'P'); 487 | /// "DBGP" MS Debug Port Spec 488 | enum EFI_ACPI_3_0_DEBUG_PORT_TABLE_SIGNATURE = SIGNATURE_32('D', 'B', 'G', 'P'); 489 | /// "ETDT" Event Timer Description Table 490 | enum EFI_ACPI_3_0_EVENT_TIMER_DESCRIPTION_TABLE_SIGNATURE = SIGNATURE_32('E', 'T', 491 | 'D', 'T'); 492 | /// "HPET" IA-PC High Precision Event Timer Table 493 | enum EFI_ACPI_3_0_HIGH_PRECISION_EVENT_TIMER_TABLE_SIGNATURE = SIGNATURE_32('H', 'P', 494 | 'E', 'T'); 495 | /// "MCFG" PCI Express Memory Mapped Configuration Space Base Address Description Table 496 | enum EFI_ACPI_3_0_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE = SIGNATURE_32( 497 | 'M', 'C', 'F', 'G'); 498 | /// "SPCR" Serial Port Concole Redirection Table 499 | enum EFI_ACPI_3_0_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE = SIGNATURE_32('S', 500 | 'P', 'C', 'R'); 501 | /// "SPMI" Server Platform Management Interface Table 502 | enum EFI_ACPI_3_0_SERVER_PLATFORM_MANAGEMENT_INTERFACE_TABLE_SIGNATURE = SIGNATURE_32( 503 | 'S', 'P', 'M', 'I'); 504 | /// "TCPA" Trusted Computing Platform Alliance Capabilities Table 505 | enum EFI_ACPI_3_0_TRUSTED_COMPUTING_PLATFORM_ALLIANCE_CAPABILITIES_TABLE_SIGNATURE = SIGNATURE_32( 506 | 'T', 'C', 'P', 'A'); 507 | /// "WDRT" Watchdog Resource Table 508 | enum EFI_ACPI_3_0_WATCHDOG_RESOURCE_TABLE_SIGNATURE = SIGNATURE_32('W', 'D', 'R', 'T'); 509 | /// "WDAT" Watchdog Action Table 510 | enum EFI_ACPI_3_0_WATCHDOG_ACTION_TABLE_SIGNATURE = SIGNATURE_32('W', 'D', 'A', 'T'); 511 | /// "WSPT" Windows Specific Properties Table 512 | enum EFI_ACPI_3_0_WINDOWS_SPECIFIC_PROPERTIES_TABLE_SIGNATURE = SIGNATURE_32('W', 'S', 513 | 'P', 'T'); 514 | /// "iBFT" iSCSI Boot Firmware Table 515 | enum EFI_ACPI_3_0_ISCSI_BOOT_FIRMWARE_TABLE_SIGNATURE = SIGNATURE_32('i', 'B', 'F', 516 | 'T'); 517 | -------------------------------------------------------------------------------- /source/uefi/acpiaml.d: -------------------------------------------------------------------------------- 1 | /** 2 | Based on IndustryStandard/AcpiAml.h, original notice: 3 | 4 | This file contains AML code definition in the latest ACPI spec. 5 | 6 | Copyright (c) 2011, Intel Corporation. All rights reserved. 7 | This program and the accompanying materials 8 | are licensed and made available under the terms and conditions of the BSD License 9 | which accompanies this distribution. The full text of the license may be found at 10 | http://opensource.org/licenses/bsd-license.php 11 | 12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 14 | 15 | **/ 16 | module uefi.acpiaml; 17 | import uefi.base; 18 | import uefi.base_type; 19 | 20 | public: 21 | extern (C): 22 | enum AML_ZERO_OP = 0x00; 23 | enum AML_ONE_OP = 0x01; 24 | enum AML_ALIAS_OP = 0x06; 25 | enum AML_NAME_OP = 0x08; 26 | enum AML_BYTE_PREFIX = 0x0a; 27 | enum AML_WORD_PREFIX = 0x0b; 28 | enum AML_DWORD_PREFIX = 0x0c; 29 | enum AML_STRING_PREFIX = 0x0d; 30 | enum AML_QWORD_PREFIX = 0x0e; 31 | enum AML_SCOPE_OP = 0x10; 32 | enum AML_BUFFER_OP = 0x11; 33 | enum AML_PACKAGE_OP = 0x12; 34 | enum AML_VAR_PACKAGE_OP = 0x13; 35 | enum AML_METHOD_OP = 0x14; 36 | enum AML_DUAL_NAME_PREFIX = 0x2e; 37 | enum AML_MULTI_NAME_PREFIX = 0x2f; 38 | enum AML_NAME_CHAR_A = 0x41; 39 | enum AML_NAME_CHAR_B = 0x42; 40 | enum AML_NAME_CHAR_C = 0x43; 41 | enum AML_NAME_CHAR_D = 0x44; 42 | enum AML_NAME_CHAR_E = 0x45; 43 | enum AML_NAME_CHAR_F = 0x46; 44 | enum AML_NAME_CHAR_G = 0x47; 45 | enum AML_NAME_CHAR_H = 0x48; 46 | enum AML_NAME_CHAR_I = 0x49; 47 | enum AML_NAME_CHAR_J = 0x4a; 48 | enum AML_NAME_CHAR_K = 0x4b; 49 | enum AML_NAME_CHAR_L = 0x4c; 50 | enum AML_NAME_CHAR_M = 0x4d; 51 | enum AML_NAME_CHAR_N = 0x4e; 52 | enum AML_NAME_CHAR_O = 0x4f; 53 | enum AML_NAME_CHAR_P = 0x50; 54 | enum AML_NAME_CHAR_Q = 0x51; 55 | enum AML_NAME_CHAR_R = 0x52; 56 | enum AML_NAME_CHAR_S = 0x53; 57 | enum AML_NAME_CHAR_T = 0x54; 58 | enum AML_NAME_CHAR_U = 0x55; 59 | enum AML_NAME_CHAR_V = 0x56; 60 | enum AML_NAME_CHAR_W = 0x57; 61 | enum AML_NAME_CHAR_X = 0x58; 62 | enum AML_NAME_CHAR_Y = 0x59; 63 | enum AML_NAME_CHAR_Z = 0x5a; 64 | enum AML_ROOT_CHAR = 0x5c; 65 | enum AML_PARENT_PREFIX_CHAR = 0x5e; 66 | enum AML_NAME_CHAR__ = 0x5f; 67 | enum AML_LOCAL0 = 0x60; 68 | enum AML_LOCAL1 = 0x61; 69 | enum AML_LOCAL2 = 0x62; 70 | enum AML_LOCAL3 = 0x63; 71 | enum AML_LOCAL4 = 0x64; 72 | enum AML_LOCAL5 = 0x65; 73 | enum AML_LOCAL6 = 0x66; 74 | enum AML_LOCAL7 = 0x67; 75 | enum AML_ARG0 = 0x68; 76 | enum AML_ARG1 = 0x69; 77 | enum AML_ARG2 = 0x6a; 78 | enum AML_ARG3 = 0x6b; 79 | enum AML_ARG4 = 0x6c; 80 | enum AML_ARG5 = 0x6d; 81 | enum AML_ARG6 = 0x6e; 82 | enum AML_STORE_OP = 0x70; 83 | enum AML_REF_OF_OP = 0x71; 84 | enum AML_ADD_OP = 0x72; 85 | enum AML_CONCAT_OP = 0x73; 86 | enum AML_SUBTRACT_OP = 0x74; 87 | enum AML_INCREMENT_OP = 0x75; 88 | enum AML_DECREMENT_OP = 0x76; 89 | enum AML_MULTIPLY_OP = 0x77; 90 | enum AML_DIVIDE_OP = 0x78; 91 | enum AML_SHIFT_LEFT_OP = 0x79; 92 | enum AML_SHIFT_RIGHT_OP = 0x7a; 93 | enum AML_AND_OP = 0x7b; 94 | enum AML_NAND_OP = 0x7c; 95 | enum AML_OR_OP = 0x7d; 96 | enum AML_NOR_OP = 0x7e; 97 | enum AML_XOR_OP = 0x7f; 98 | enum AML_NOT_OP = 0x80; 99 | enum AML_FIND_SET_LEFT_BIT_OP = 0x81; 100 | enum AML_FIND_SET_RIGHT_BIT_OP = 0x82; 101 | enum AML_DEREF_OF_OP = 0x83; 102 | enum AML_CONCAT_RES_OP = 0x84; 103 | enum AML_MOD_OP = 0x85; 104 | enum AML_NOTIFY_OP = 0x86; 105 | enum AML_SIZE_OF_OP = 0x87; 106 | enum AML_INDEX_OP = 0x88; 107 | enum AML_MATCH_OP = 0x89; 108 | enum AML_CREATE_DWORD_FIELD_OP = 0x8a; 109 | enum AML_CREATE_WORD_FIELD_OP = 0x8b; 110 | enum AML_CREATE_BYTE_FIELD_OP = 0x8c; 111 | enum AML_CREATE_BIT_FIELD_OP = 0x8d; 112 | enum AML_OBJECT_TYPE_OP = 0x8e; 113 | enum AML_CREATE_QWORD_FIELD_OP = 0x8f; 114 | enum AML_LAND_OP = 0x90; 115 | enum AML_LOR_OP = 0x91; 116 | enum AML_LNOT_OP = 0x92; 117 | enum AML_LEQUAL_OP = 0x93; 118 | enum AML_LGREATER_OP = 0x94; 119 | enum AML_LLESS_OP = 0x95; 120 | enum AML_TO_BUFFER_OP = 0x96; 121 | enum AML_TO_DEC_STRING_OP = 0x97; 122 | enum AML_TO_HEX_STRING_OP = 0x98; 123 | enum AML_TO_INTEGER_OP = 0x99; 124 | enum AML_TO_STRING_OP = 0x9c; 125 | enum AML_COPY_OBJECT_OP = 0x9d; 126 | enum AML_MID_OP = 0x9e; 127 | enum AML_CONTINUE_OP = 0x9f; 128 | enum AML_IF_OP = 0xa0; 129 | enum AML_ELSE_OP = 0xa1; 130 | enum AML_WHILE_OP = 0xa2; 131 | enum AML_NOOP_OP = 0xa3; 132 | enum AML_RETURN_OP = 0xa4; 133 | enum AML_BREAK_OP = 0xa5; 134 | enum AML_BREAK_POINT_OP = 0xcc; 135 | enum AML_ONES_OP = 0xff; 136 | enum AML_EXT_OP = 0x5b; 137 | enum AML_EXT_MUTEX_OP = 0x01; 138 | enum AML_EXT_EVENT_OP = 0x02; 139 | enum AML_EXT_COND_REF_OF_OP = 0x12; 140 | enum AML_EXT_CREATE_FIELD_OP = 0x13; 141 | enum AML_EXT_LOAD_TABLE_OP = 0x1f; 142 | enum AML_EXT_LOAD_OP = 0x20; 143 | enum AML_EXT_STALL_OP = 0x21; 144 | enum AML_EXT_SLEEP_OP = 0x22; 145 | enum AML_EXT_ACQUIRE_OP = 0x23; 146 | enum AML_EXT_SIGNAL_OP = 0x24; 147 | enum AML_EXT_WAIT_OP = 0x25; 148 | enum AML_EXT_RESET_OP = 0x26; 149 | enum AML_EXT_RELEASE_OP = 0x27; 150 | enum AML_EXT_FROM_BCD_OP = 0x28; 151 | enum AML_EXT_TO_BCD_OP = 0x29; 152 | enum AML_EXT_UNLOAD_OP = 0x2a; 153 | enum AML_EXT_REVISION_OP = 0x30; 154 | enum AML_EXT_DEBUG_OP = 0x31; 155 | enum AML_EXT_FATAL_OP = 0x32; 156 | enum AML_EXT_TIMER_OP = 0x33; 157 | enum AML_EXT_REGION_OP = 0x80; 158 | enum AML_EXT_FIELD_OP = 0x81; 159 | enum AML_EXT_DEVICE_OP = 0x82; 160 | enum AML_EXT_PROCESSOR_OP = 0x83; 161 | enum AML_EXT_POWER_RES_OP = 0x84; 162 | enum AML_EXT_THERMAL_ZONE_OP = 0x85; 163 | enum AML_EXT_INDEX_FIELD_OP = 0x86; 164 | enum AML_EXT_BANK_FIELD_OP = 0x87; 165 | enum AML_EXT_DATA_REGION_OP = 0x88; 166 | -------------------------------------------------------------------------------- /source/uefi/acpidatatable.d: -------------------------------------------------------------------------------- 1 | /** 2 | Based on Uefi/UefiAcpiDataTable.h, original notice: 3 | 4 | UEFI ACPI Data Table Definition. 5 | 6 | Copyright (c) 2011, Intel Corporation. All rights reserved. 7 | This program and the accompanying materials are licensed and made available under 8 | the terms and conditions of the BSD License that accompanies this distribution. 9 | The full text of the license may be found at 10 | http://opensource.org/licenses/bsd-license.php. 11 | 12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 14 | 15 | **/ 16 | module uefi.acpidatatable; 17 | import uefi.base; 18 | import uefi.base_type; 19 | 20 | public: 21 | extern (C): 22 | public import uefi.acpi; 23 | 24 | struct EFI_ACPI_DATA_TABLE 25 | { 26 | align(1): 27 | EFI_ACPI_DESCRIPTION_HEADER Header; 28 | GUID Identifier; 29 | UINT16 DataOffset; 30 | } 31 | 32 | struct EFI_SMM_COMMUNICATION_ACPI_TABLE 33 | { 34 | align(1): 35 | EFI_ACPI_DATA_TABLE UefiAcpiDataTable; 36 | UINT32 SwSmiNumber; 37 | UINT64 BufferPtrAddress; 38 | } 39 | /// To avoid confusion in interpreting frames, the communication buffer should always 40 | /// begin with EFI_SMM_COMMUNICATE_HEADER 41 | struct EFI_SMM_COMMUNICATE_HEADER 42 | { 43 | align(1): 44 | /// 45 | /// Allows for disambiguation of the message format. 46 | /// 47 | EFI_GUID HeaderGuid; 48 | /// 49 | /// Describes the size of Data (in bytes) and does not include the size of the header. 50 | /// 51 | UINTN MessageLength; 52 | /// 53 | /// Designates an array of bytes that is MessageLength in size. 54 | /// 55 | UINT8[1] Data; 56 | } 57 | -------------------------------------------------------------------------------- /source/uefi/base.d: -------------------------------------------------------------------------------- 1 | /** 2 | Based on Base.h file, original notice: 3 | 4 | Root include file for Mde Package Base type modules 5 | 6 | This is the include file for any module of type base. Base modules only use 7 | types defined via this include file and can be ported easily to any 8 | environment. There are a set of base libraries in the Mde Package that can 9 | be used to implement base modules. 10 | 11 | Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved. 12 | This program and the accompanying materials 13 | are licensed and made available under the terms and conditions of the BSD License 14 | which accompanies this distribution. The full text of the license may be found at 15 | http://opensource.org/licenses/bsd-license.php 16 | 17 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 19 | **/ 20 | module uefi.base; 21 | 22 | public import uefi.bind; 23 | 24 | public: 25 | extern (C): 26 | 27 | /// Placeholder bitfields implementation, to be fixed 28 | template bitfields(T...) 29 | { 30 | enum string bitfields = T[0].stringof ~ " bitfield_niy;"; 31 | } 32 | 33 | /// 128 bit buffer containing a unique identifier value. 34 | /// Unless otherwise specified, aligned on a 64 bit boundary. 35 | struct GUID 36 | { 37 | UINT32 Data1; 38 | UINT16 Data2; 39 | UINT16 Data3; 40 | UINT8[8] Data4; 41 | this(UINT32 D1, UINT16 D2, UINT16 D3, UINT8[8] D4) 42 | { 43 | Data1 = D1; 44 | Data2 = D2; 45 | Data3 = D3; 46 | Data4 = D4; 47 | } 48 | 49 | this(UINT32 D1, UINT16 D2, UINT16 D3, UINT8 D4_0, UINT8 D4_1, UINT8 D4_2, 50 | UINT8 D4_3, UINT8 D4_4, UINT8 D4_5, UINT8 D4_6, UINT8 D4_7) 51 | { 52 | Data1 = D1; 53 | Data2 = D2; 54 | Data3 = D3; 55 | Data4[0] = D4_0; 56 | Data4[1] = D4_1; 57 | Data4[2] = D4_2; 58 | Data4[3] = D4_3; 59 | Data4[4] = D4_4; 60 | Data4[5] = D4_5; 61 | Data4[6] = D4_6; 62 | Data4[7] = D4_7; 63 | } 64 | } 65 | 66 | /// 8-bytes unsigned value that represents a physical system address. 67 | alias PHYSICAL_ADDRESS = UINT64; 68 | 69 | /// LIST_ENTRY structure definition. 70 | struct LIST_ENTRY 71 | { 72 | LIST_ENTRY* ForwardLink; 73 | LIST_ENTRY* BackwardLink; 74 | } 75 | 76 | /// Boolean true value. 77 | enum BOOLEAN TRUE = 1; 78 | 79 | /// Boolean false value. 80 | enum BOOLEAN FALSE = 0; 81 | 82 | /// 83 | enum : UINT32 84 | { 85 | BIT0 = 0x00000001, 86 | BIT1 = 0x00000002, 87 | BIT2 = 0x00000004, 88 | BIT3 = 0x00000008, 89 | BIT4 = 0x00000010, 90 | BIT5 = 0x00000020, 91 | BIT6 = 0x00000040, 92 | BIT7 = 0x00000080, 93 | BIT8 = 0x00000100, 94 | BIT9 = 0x00000200, 95 | BIT10 = 0x00000400, 96 | BIT11 = 0x00000800, 97 | BIT12 = 0x00001000, 98 | BIT13 = 0x00002000, 99 | BIT14 = 0x00004000, 100 | BIT15 = 0x00008000, 101 | BIT16 = 0x00010000, 102 | BIT17 = 0x00020000, 103 | BIT18 = 0x00040000, 104 | BIT19 = 0x00080000, 105 | BIT20 = 0x00100000, 106 | BIT21 = 0x00200000, 107 | BIT22 = 0x00400000, 108 | BIT23 = 0x00800000, 109 | BIT24 = 0x01000000, 110 | BIT25 = 0x02000000, 111 | BIT26 = 0x04000000, 112 | BIT27 = 0x08000000, 113 | BIT28 = 0x10000000, 114 | BIT29 = 0x20000000, 115 | BIT30 = 0x40000000, 116 | BIT31 = 0x80000000, 117 | 118 | SIZE_1KB = 0x00000400, 119 | SIZE_2KB = 0x00000800, 120 | SIZE_4KB = 0x00001000, 121 | SIZE_8KB = 0x00002000, 122 | SIZE_16KB = 0x00004000, 123 | SIZE_32KB = 0x00008000, 124 | SIZE_64KB = 0x00010000, 125 | SIZE_128KB = 0x00020000, 126 | SIZE_256KB = 0x00040000, 127 | SIZE_512KB = 0x00080000, 128 | SIZE_1MB = 0x00100000, 129 | SIZE_2MB = 0x00200000, 130 | SIZE_4MB = 0x00400000, 131 | SIZE_8MB = 0x00800000, 132 | SIZE_16MB = 0x01000000, 133 | SIZE_32MB = 0x02000000, 134 | SIZE_64MB = 0x04000000, 135 | SIZE_128MB = 0x08000000, 136 | SIZE_256MB = 0x10000000, 137 | SIZE_512MB = 0x20000000, 138 | SIZE_1GB = 0x40000000, 139 | SIZE_2GB = 0x80000000, 140 | 141 | BASE_1KB = 0x00000400, 142 | BASE_2KB = 0x00000800, 143 | BASE_4KB = 0x00001000, 144 | BASE_8KB = 0x00002000, 145 | BASE_16KB = 0x00004000, 146 | BASE_32KB = 0x00008000, 147 | BASE_64KB = 0x00010000, 148 | BASE_128KB = 0x00020000, 149 | BASE_256KB = 0x00040000, 150 | BASE_512KB = 0x00080000, 151 | BASE_1MB = 0x00100000, 152 | BASE_2MB = 0x00200000, 153 | BASE_4MB = 0x00400000, 154 | BASE_8MB = 0x00800000, 155 | BASE_16MB = 0x01000000, 156 | BASE_32MB = 0x02000000, 157 | BASE_64MB = 0x04000000, 158 | BASE_128MB = 0x08000000, 159 | BASE_256MB = 0x10000000, 160 | BASE_512MB = 0x20000000, 161 | BASE_1GB = 0x40000000, 162 | BASE_2GB = 0x80000000 163 | } 164 | /// ditto 165 | enum : UINT64 166 | { 167 | BIT32 = 0x0000000100000000UL, 168 | BIT33 = 0x0000000200000000UL, 169 | BIT34 = 0x0000000400000000UL, 170 | BIT35 = 0x0000000800000000UL, 171 | BIT36 = 0x0000001000000000UL, 172 | BIT37 = 0x0000002000000000UL, 173 | BIT38 = 0x0000004000000000UL, 174 | BIT39 = 0x0000008000000000UL, 175 | BIT40 = 0x0000010000000000UL, 176 | BIT41 = 0x0000020000000000UL, 177 | BIT42 = 0x0000040000000000UL, 178 | BIT43 = 0x0000080000000000UL, 179 | BIT44 = 0x0000100000000000UL, 180 | BIT45 = 0x0000200000000000UL, 181 | BIT46 = 0x0000400000000000UL, 182 | BIT47 = 0x0000800000000000UL, 183 | BIT48 = 0x0001000000000000UL, 184 | BIT49 = 0x0002000000000000UL, 185 | BIT50 = 0x0004000000000000UL, 186 | BIT51 = 0x0008000000000000UL, 187 | BIT52 = 0x0010000000000000UL, 188 | BIT53 = 0x0020000000000000UL, 189 | BIT54 = 0x0040000000000000UL, 190 | BIT55 = 0x0080000000000000UL, 191 | BIT56 = 0x0100000000000000UL, 192 | BIT57 = 0x0200000000000000UL, 193 | BIT58 = 0x0400000000000000UL, 194 | BIT59 = 0x0800000000000000UL, 195 | BIT60 = 0x1000000000000000UL, 196 | BIT61 = 0x2000000000000000UL, 197 | BIT62 = 0x4000000000000000UL, 198 | BIT63 = 0x8000000000000000UL, 199 | 200 | SIZE_4GB = 0x0000000100000000UL, 201 | SIZE_8GB = 0x0000000200000000UL, 202 | SIZE_16GB = 0x0000000400000000UL, 203 | SIZE_32GB = 0x0000000800000000UL, 204 | SIZE_64GB = 0x0000001000000000UL, 205 | SIZE_128GB = 0x0000002000000000UL, 206 | SIZE_256GB = 0x0000004000000000UL, 207 | SIZE_512GB = 0x0000008000000000UL, 208 | SIZE_1TB = 0x0000010000000000UL, 209 | SIZE_2TB = 0x0000020000000000UL, 210 | SIZE_4TB = 0x0000040000000000UL, 211 | SIZE_8TB = 0x0000080000000000UL, 212 | SIZE_16TB = 0x0000100000000000UL, 213 | SIZE_32TB = 0x0000200000000000UL, 214 | SIZE_64TB = 0x0000400000000000UL, 215 | SIZE_128TB = 0x0000800000000000UL, 216 | SIZE_256TB = 0x0001000000000000UL, 217 | SIZE_512TB = 0x0002000000000000UL, 218 | SIZE_1PB = 0x0004000000000000UL, 219 | SIZE_2PB = 0x0008000000000000UL, 220 | SIZE_4PB = 0x0010000000000000UL, 221 | SIZE_8PB = 0x0020000000000000UL, 222 | SIZE_16PB = 0x0040000000000000UL, 223 | SIZE_32PB = 0x0080000000000000UL, 224 | SIZE_64PB = 0x0100000000000000UL, 225 | SIZE_128PB = 0x0200000000000000UL, 226 | SIZE_256PB = 0x0400000000000000UL, 227 | SIZE_512PB = 0x0800000000000000UL, 228 | SIZE_1EB = 0x1000000000000000UL, 229 | SIZE_2EB = 0x2000000000000000UL, 230 | SIZE_4EB = 0x4000000000000000UL, 231 | SIZE_8EB = 0x8000000000000000UL, 232 | 233 | BASE_4GB = 0x0000000100000000UL, 234 | BASE_8GB = 0x0000000200000000UL, 235 | BASE_16GB = 0x0000000400000000UL, 236 | BASE_32GB = 0x0000000800000000UL, 237 | BASE_64GB = 0x0000001000000000UL, 238 | BASE_128GB = 0x0000002000000000UL, 239 | BASE_256GB = 0x0000004000000000UL, 240 | BASE_512GB = 0x0000008000000000UL, 241 | BASE_1TB = 0x0000010000000000UL, 242 | BASE_2TB = 0x0000020000000000UL, 243 | BASE_4TB = 0x0000040000000000UL, 244 | BASE_8TB = 0x0000080000000000UL, 245 | BASE_16TB = 0x0000100000000000UL, 246 | BASE_32TB = 0x0000200000000000UL, 247 | BASE_64TB = 0x0000400000000000UL, 248 | BASE_128TB = 0x0000800000000000UL, 249 | BASE_256TB = 0x0001000000000000UL, 250 | BASE_512TB = 0x0002000000000000UL, 251 | BASE_1PB = 0x0004000000000000UL, 252 | BASE_2PB = 0x0008000000000000UL, 253 | BASE_4PB = 0x0010000000000000UL, 254 | BASE_8PB = 0x0020000000000000UL, 255 | BASE_16PB = 0x0040000000000000UL, 256 | BASE_32PB = 0x0080000000000000UL, 257 | BASE_64PB = 0x0100000000000000UL, 258 | BASE_128PB = 0x0200000000000000UL, 259 | BASE_256PB = 0x0400000000000000UL, 260 | BASE_512PB = 0x0800000000000000UL, 261 | BASE_1EB = 0x1000000000000000UL, 262 | BASE_2EB = 0x2000000000000000UL, 263 | BASE_4EB = 0x4000000000000000UL, 264 | BASE_8EB = 0x8000000000000000UL 265 | } 266 | 267 | /// Variable used to traverse the list of arguments. This type can vary by 268 | /// implementation and could be an array or structure. 269 | alias VA_LIST = ubyte*; 270 | 271 | /// Pointer to the start of a variable argument list stored in a memory buffer. Same as UINT8 *. 272 | alias BASE_LIST = UINTN*; 273 | 274 | /** 275 | Rounds a value up to the next boundary using a specified alignment. 276 | 277 | This function rounds Value up to the next boundary using the specified Alignment. 278 | This aligned value is returned. 279 | 280 | Params: 281 | Value = The value to round up. 282 | Alignment = The alignment boundary used to return the aligned value. 283 | 284 | Returns: A value up to the next boundary. 285 | 286 | **/ 287 | auto ALIGN_VALUE(T)(T Value, T Alignment) 288 | { 289 | return ((Value) + (((Alignment) - (Value)) & ((Alignment) - 1))); 290 | } 291 | 292 | /** 293 | Adjust a pointer by adding the minimum offset required for it to be aligned on 294 | a specified alignment boundary. 295 | 296 | This function rounds the pointer specified by Pointer to the next alignment boundary 297 | specified by Alignment. The pointer to the aligned address is returned. 298 | 299 | Params: 300 | Pointer The pointer to round up. 301 | Alignment The alignment boundary to use to return an aligned pointer. 302 | 303 | Returns: Pointer to the aligned address. 304 | 305 | **/ 306 | T* ALIGN_POINTER(T)(T* Pointer, INTN Alignment) 307 | { 308 | return (cast(VOID*)(ALIGN_VALUE(cast(UINTN)(Pointer), (Alignment)))); 309 | } 310 | 311 | /** 312 | Rounds a value up to the next natural boundary for the current CPU. 313 | This is 4-bytes for 32-bit CPUs and 8-bytes for 64-bit CPUs. 314 | 315 | This function rounds the value specified by Value up to the next natural boundary for the 316 | current CPU. This rounded value is returned. 317 | 318 | @param Value The value to round up. 319 | 320 | @return Rounded value specified by Value. 321 | 322 | **/ 323 | auto ALIGN_VARIABLE(T)(T Value) 324 | { 325 | return ALIGN_VALUE((Value), UINTN.sizeof); 326 | } 327 | 328 | /** 329 | Return the maximum of two operands. 330 | 331 | Params: 332 | a = The first operand with any numerical type. 333 | b = The second operand. 334 | 335 | Returns: Maximum of two operands. 336 | 337 | **/ 338 | auto MAX(T, U)(T A, U B) 339 | { 340 | return (A > B) ? A : B; 341 | } 342 | 343 | /** 344 | Return the minimum of two operands. 345 | 346 | Params: 347 | a = The first operand with any numerical type. 348 | b = The second operand. 349 | 350 | Returns: Minimum of two operands. 351 | 352 | **/ 353 | auto MIN(T, U)(T A, U B) 354 | { 355 | return (A < B) ? A : B; 356 | } 357 | 358 | /** 359 | Return the absolute value of a signed operand. 360 | 361 | Params: 362 | a = The signed operand. 363 | 364 | Returns: The absolute value of the signed operand. 365 | 366 | **/ 367 | auto ABS(T)(T A) 368 | { 369 | return (A < 0) ? (-A) : (A); 370 | } 371 | 372 | /// Status codes common to all execution phases 373 | alias RETURN_STATUS = UINTN; 374 | 375 | /** 376 | Returns true if a specified RETURN_STATUS code is an error code. 377 | 378 | This function returns TRUE if StatusCode has the high bit set. Otherwise, false is returned. 379 | 380 | Params: 381 | StatusCode = The status code value to evaluate. 382 | 383 | Returns: true if The high bit of StatusCode is set. 384 | false if The high bit of StatusCode is clear. 385 | 386 | **/ 387 | bool RETURN_ERROR(T)(T StatusCode) 388 | { 389 | return cast(INTN)(cast(RETURN_STATUS)(StatusCode)) < 0; 390 | } 391 | 392 | /** 393 | Produces a RETURN_STATUS code with the highest bit set. 394 | 395 | Params: 396 | StatusCode = The status code value to convert into a warning code. 397 | StatusCode must be in the range 0x00000000..0x7FFFFFFF. 398 | 399 | Returns: The value specified by StatusCode with the highest bit set. 400 | 401 | **/ 402 | template ENCODE_ERROR(UINTN StatusCode) 403 | { 404 | enum RETURN_STATUS ENCODE_ERROR = StatusCode | MAX_BIT; 405 | } 406 | 407 | /** 408 | Produces a RETURN_STATUS code with the highest bit clear. 409 | 410 | Params: 411 | StatusCode = The status code value to convert into a warning code. 412 | StatusCode must be in the range 0x00000000..0x7FFFFFFF. 413 | 414 | Returns: The value specified by StatusCode with the highest bit clear. 415 | 416 | **/ 417 | template ENCODE_WARNING(UINTN StatusCode) 418 | { 419 | enum RETURN_STATUS ENCODE_WARNING = StatusCode | MAX_BIT; 420 | } 421 | 422 | /// Return status codes 423 | enum : RETURN_STATUS 424 | { 425 | 426 | /// 427 | /// The operation completed successfully. 428 | /// 429 | RETURN_SUCCESS = 0, 430 | /// 431 | /// The image failed to load. 432 | /// 433 | RETURN_LOAD_ERROR = ENCODE_ERROR!(1), 434 | 435 | /// 436 | /// The parameter was incorrect. 437 | /// 438 | RETURN_INVALID_PARAMETER = ENCODE_ERROR!(2), 439 | 440 | /// 441 | /// The operation is not supported. 442 | /// 443 | RETURN_UNSUPPORTED = ENCODE_ERROR!(3), 444 | 445 | /// 446 | /// The buffer was not the proper size for the request. 447 | /// 448 | RETURN_BAD_BUFFER_SIZE = ENCODE_ERROR!(4), 449 | 450 | /// 451 | /// The buffer was not large enough to hold the requested data. 452 | /// The required buffer size is returned in the appropriate 453 | /// parameter when this error occurs. 454 | /// 455 | RETURN_BUFFER_TOO_SMALL = ENCODE_ERROR!(5), 456 | 457 | /// 458 | /// There is no data pending upon return. 459 | /// 460 | RETURN_NOT_READY = ENCODE_ERROR!(6), 461 | 462 | /// 463 | /// The physical device reported an error while attempting the 464 | /// operation. 465 | /// 466 | RETURN_DEVICE_ERROR = ENCODE_ERROR!(7), 467 | 468 | /// 469 | /// The device can not be written to. 470 | /// 471 | RETURN_WRITE_PROTECTED = ENCODE_ERROR!(8), 472 | 473 | /// 474 | /// The resource has run out. 475 | /// 476 | RETURN_OUT_OF_RESOURCES = ENCODE_ERROR!(9), 477 | 478 | /// 479 | /// An inconsistency was detected on the file system causing the 480 | /// operation to fail. 481 | /// 482 | RETURN_VOLUME_CORRUPTED = ENCODE_ERROR!(10), 483 | 484 | /// 485 | /// There is no more space on the file system. 486 | /// 487 | RETURN_VOLUME_FULL = ENCODE_ERROR!(11), 488 | 489 | /// 490 | /// The device does not contain any medium to perform the 491 | /// operation. 492 | /// 493 | RETURN_NO_MEDIA = ENCODE_ERROR!(12), 494 | 495 | /// 496 | /// The medium in the device has changed since the last 497 | /// access. 498 | /// 499 | RETURN_MEDIA_CHANGED = ENCODE_ERROR!(13), 500 | 501 | /// 502 | /// The item was not found. 503 | /// 504 | RETURN_NOT_FOUND = ENCODE_ERROR!(14), 505 | 506 | /// 507 | /// Access was denied. 508 | /// 509 | RETURN_ACCESS_DENIED = ENCODE_ERROR!(15), 510 | 511 | /// 512 | /// The server was not found or did not respond to the request. 513 | /// 514 | RETURN_NO_RESPONSE = ENCODE_ERROR!(16), 515 | 516 | /// 517 | /// A mapping to the device does not exist. 518 | /// 519 | RETURN_NO_MAPPING = ENCODE_ERROR!(17), 520 | 521 | /// 522 | /// A timeout time expired. 523 | /// 524 | RETURN_TIMEOUT = ENCODE_ERROR!(18), 525 | 526 | /// 527 | /// The protocol has not been started. 528 | /// 529 | RETURN_NOT_STARTED = ENCODE_ERROR!(19), 530 | 531 | /// 532 | /// The protocol has already been started. 533 | /// 534 | RETURN_ALREADY_STARTED = ENCODE_ERROR!(20), 535 | 536 | /// 537 | /// The operation was aborted. 538 | /// 539 | RETURN_ABORTED = ENCODE_ERROR!(21), 540 | 541 | /// 542 | /// An ICMP error occurred during the network operation. 543 | /// 544 | RETURN_ICMP_ERROR = ENCODE_ERROR!(22), 545 | 546 | /// 547 | /// A TFTP error occurred during the network operation. 548 | /// 549 | RETURN_TFTP_ERROR = ENCODE_ERROR!(23), 550 | 551 | /// 552 | /// A protocol error occurred during the network operation. 553 | /// 554 | RETURN_PROTOCOL_ERROR = ENCODE_ERROR!(24), 555 | 556 | /// 557 | /// A function encountered an internal version that was 558 | /// incompatible with a version requested by the caller. 559 | /// 560 | RETURN_INCOMPATIBLE_VERSION = ENCODE_ERROR!(25), 561 | 562 | /// 563 | /// The function was not performed due to a security violation. 564 | /// 565 | RETURN_SECURITY_VIOLATION = ENCODE_ERROR!(26), 566 | 567 | /// 568 | /// A CRC error was detected. 569 | /// 570 | RETURN_CRC_ERROR = ENCODE_ERROR!(27), 571 | 572 | /// 573 | /// The beginning or end of media was reached. 574 | /// 575 | RETURN_END_OF_MEDIA = ENCODE_ERROR!(28), 576 | 577 | /// 578 | /// The end of the file was reached. 579 | /// 580 | RETURN_END_OF_FILE = ENCODE_ERROR!(31), 581 | 582 | /// 583 | /// The language specified was invalid. 584 | /// 585 | RETURN_INVALID_LANGUAGE = ENCODE_ERROR!(32), 586 | 587 | /// 588 | /// The security status of the data is unknown or compromised 589 | /// and the data must be updated or replaced to restore a valid 590 | /// security status. 591 | /// 592 | RETURN_COMPROMISED_DATA = ENCODE_ERROR!(33), 593 | 594 | /// 595 | /// The string contained one or more characters that 596 | /// the device could not render and were skipped. 597 | /// 598 | RETURN_WARN_UNKNOWN_GLYPH = ENCODE_WARNING!(1), 599 | 600 | /// 601 | /// The handle was closed, but the file was not deleted. 602 | /// 603 | RETURN_WARN_DELETE_FAILURE = ENCODE_WARNING!(2), 604 | 605 | /// 606 | /// The handle was closed, but the data to the file was not 607 | /// flushed properly. 608 | /// 609 | RETURN_WARN_WRITE_FAILURE = ENCODE_WARNING!(3), 610 | 611 | /// 612 | /// The resulting buffer was too small, and the data was 613 | /// truncated to the buffer size. 614 | /// 615 | RETURN_WARN_BUFFER_TOO_SMALL = ENCODE_WARNING!(4), 616 | 617 | /// 618 | /// The data has not been updated within the timeframe set by 619 | /// local policy for this type of data. 620 | /// 621 | RETURN_WARN_STALE_DATA = ENCODE_WARNING!(5), 622 | 623 | } 624 | 625 | /** 626 | Returns a 16-bit signature built from 2 ASCII characters. 627 | 628 | This macro returns a 16-bit value built from the two ASCII characters specified 629 | by A and B. 630 | 631 | Params: 632 | A = The first ASCII character. 633 | B = The second ASCII character. 634 | 635 | Returns: A 16-bit value built from the two ASCII characters specified by A and B. 636 | 637 | **/ 638 | auto SIGNATURE_16(T)(T A, T B) 639 | { 640 | return ((A) | (B << 8)); 641 | } 642 | 643 | /** 644 | Returns a 32-bit signature built from 2 ASCII characters. 645 | 646 | This macro returns a 32-bit value built from the four ASCII characters specified 647 | by A, B, C, and D. 648 | 649 | Params: 650 | A = The first ASCII character. 651 | B = The second ASCII character. 652 | C = The third ASCII character. 653 | D = The fourth ASCII character. 654 | 655 | Returns: A 32-bit value built from the two ASCII characters specified by A, B, C and D. 656 | 657 | **/ 658 | auto SIGNATURE_32(T)(T A, T B, T C, T D) 659 | { 660 | return (SIGNATURE_16(A, B) | (SIGNATURE_16(C, D) << 16)); 661 | } 662 | 663 | /** 664 | Returns a 64-bit signature built from 8 ASCII characters. 665 | 666 | This macro returns a 64-bit value built from the eight ASCII characters specified 667 | by A, B, C, D, E, F, G,and H. 668 | 669 | Params: 670 | A = The first ASCII character. 671 | B = The second ASCII character. 672 | C = The third ASCII character. 673 | D = The fourth ASCII character. 674 | E = The fifth ASCII character. 675 | F = The sixth ASCII character. 676 | G = The seventh ASCII character. 677 | H = The eighth ASCII character. 678 | 679 | Returns: A 64-bit value built from the two ASCII characters specified by A, B, 680 | C, D, E, F, G and H. 681 | 682 | **/ 683 | auto SIGNATURE_64(T)(T A, T B, T C, T D, T E, T F, T G, T H) 684 | { 685 | return (SIGNATURE_32(A, B, C, D) | (cast(UINT64)(SIGNATURE_32(E, F, G, H)) << 32)); 686 | } 687 | -------------------------------------------------------------------------------- /source/uefi/base_type.d: -------------------------------------------------------------------------------- 1 | /** 2 | Based on Uefi/UefiBaseType.h file, original notice: 3 | 4 | Defines data types and constants introduced in UEFI. 5 | 6 | Also based on Uefi/UefiMultiPhase.h file, original notice: 7 | This includes some definitions introduced in UEFI that will be used in both PEI and DXE phases. 8 | 9 | Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved. 10 | This program and the accompanying materials 11 | are licensed and made available under the terms and conditions of the BSD License 12 | which accompanies this distribution. The full text of the license may be found at 13 | http://opensource.org/licenses/bsd-license.php 14 | 15 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 17 | **/ 18 | module uefi.base_type; 19 | 20 | import uefi.bind; 21 | import uefi.base; 22 | 23 | public: 24 | extern (C): 25 | 26 | // 27 | // Basic data type definitions introduced in UEFI. 28 | // 29 | 30 | /// 31 | /// 128-bit buffer containing a unique identifier value. 32 | /// 33 | alias EFI_GUID = GUID; 34 | /// 35 | /// Function return status for EFI API. 36 | /// 37 | alias EFI_STATUS = RETURN_STATUS; 38 | /// 39 | /// A collection of related interfaces. 40 | /// 41 | alias EFI_HANDLE = VOID*; 42 | /// 43 | /// Handle to an event structure. 44 | /// 45 | alias EFI_EVENT = VOID*; 46 | /// 47 | /// Task priority level. 48 | /// 49 | alias EFI_TPL = UINTN; 50 | /// 51 | /// Logical block address. 52 | /// 53 | alias EFI_LBA = UINT64; 54 | 55 | /// 56 | /// 64-bit physical memory address. 57 | /// 58 | alias EFI_PHYSICAL_ADDRESS = UINT64; 59 | 60 | /// 61 | /// 64-bit virtual memory address. 62 | /// 63 | alias EFI_VIRTUAL_ADDRESS = UINT64; 64 | 65 | /// EFI Time Abstraction: 66 | struct EFI_TIME 67 | { 68 | /// Year: 1900 - 9999 69 | UINT16 Year; 70 | /// Month: 1 - 12 71 | UINT8 Month; 72 | /// Day: 1 - 31 73 | UINT8 Day; 74 | /// Hour: 0 - 23 75 | UINT8 Hour; 76 | /// Minute: 0 - 59 77 | UINT8 Minute; 78 | /// Second: 0 - 59 79 | UINT8 Second; 80 | /// - 81 | UINT8 Pad1; 82 | /// Nanosecond: 0 - 999,999,999 83 | UINT32 Nanosecond; 84 | /// TimeZone: -1440 to 1440 or 2047 85 | INT16 TimeZone; 86 | /// - 87 | UINT8 Daylight; 88 | /// - 89 | UINT8 Pad2; 90 | } 91 | 92 | /// 93 | /// 4-byte buffer. An IPv4 internet protocol address. 94 | /// 95 | struct EFI_IPv4_ADDRESS 96 | { 97 | UINT8[4] Addr; 98 | } 99 | 100 | /// 101 | /// 16-byte buffer. An IPv6 internet protocol address. 102 | /// 103 | struct EFI_IPv6_ADDRESS 104 | { 105 | UINT8[16] Addr; 106 | } 107 | 108 | /// 109 | /// 32-byte buffer containing a network Media Access Control address. 110 | /// 111 | struct EFI_MAC_ADDRESS 112 | { 113 | UINT8[32] Addr; 114 | } 115 | 116 | /// 117 | /// 16-byte buffer aligned on a 4-byte boundary. 118 | /// An IPv4 or IPv6 internet protocol address. 119 | /// 120 | union EFI_IP_ADDRESS 121 | { 122 | UINT32[4] Addr; 123 | EFI_IPv4_ADDRESS v4; 124 | EFI_IPv6_ADDRESS v6; 125 | } 126 | 127 | /// 128 | /// Enumeration of EFI_STATUS. 129 | /// 130 | enum : EFI_STATUS 131 | { 132 | EFI_SUCCESS = RETURN_SUCCESS, 133 | EFI_LOAD_ERROR = RETURN_LOAD_ERROR, 134 | EFI_INVALID_PARAMETER = RETURN_INVALID_PARAMETER, 135 | EFI_UNSUPPORTED = RETURN_UNSUPPORTED, 136 | EFI_BAD_BUFFER_SIZE = RETURN_BAD_BUFFER_SIZE, 137 | EFI_BUFFER_TOO_SMALL = RETURN_BUFFER_TOO_SMALL, 138 | EFI_NOT_READY = RETURN_NOT_READY, 139 | EFI_DEVICE_ERROR = RETURN_DEVICE_ERROR, 140 | EFI_WRITE_PROTECTED = RETURN_WRITE_PROTECTED, 141 | EFI_OUT_OF_RESOURCES = RETURN_OUT_OF_RESOURCES, 142 | EFI_VOLUME_CORRUPTED = RETURN_VOLUME_CORRUPTED, 143 | EFI_VOLUME_FULL = RETURN_VOLUME_FULL, 144 | EFI_NO_MEDIA = RETURN_NO_MEDIA, 145 | EFI_MEDIA_CHANGED = RETURN_MEDIA_CHANGED, 146 | EFI_NOT_FOUND = RETURN_NOT_FOUND, 147 | EFI_ACCESS_DENIED = RETURN_ACCESS_DENIED, 148 | EFI_NO_RESPONSE = RETURN_NO_RESPONSE, 149 | EFI_NO_MAPPING = RETURN_NO_MAPPING, 150 | EFI_TIMEOUT = RETURN_TIMEOUT, 151 | EFI_NOT_STARTED = RETURN_NOT_STARTED, 152 | EFI_ALREADY_STARTED = RETURN_ALREADY_STARTED, 153 | EFI_ABORTED = RETURN_ABORTED, 154 | EFI_ICMP_ERROR = RETURN_ICMP_ERROR, 155 | EFI_TFTP_ERROR = RETURN_TFTP_ERROR, 156 | EFI_PROTOCOL_ERROR = RETURN_PROTOCOL_ERROR, 157 | EFI_INCOMPATIBLE_VERSION = RETURN_INCOMPATIBLE_VERSION, 158 | EFI_SECURITY_VIOLATION = RETURN_SECURITY_VIOLATION, 159 | EFI_CRC_ERROR = RETURN_CRC_ERROR, 160 | EFI_END_OF_MEDIA = RETURN_END_OF_MEDIA, 161 | EFI_END_OF_FILE = RETURN_END_OF_FILE, 162 | EFI_INVALID_LANGUAGE = RETURN_INVALID_LANGUAGE, 163 | EFI_COMPROMISED_DATA = RETURN_COMPROMISED_DATA, 164 | EFI_WARN_UNKNOWN_GLYPH = RETURN_WARN_UNKNOWN_GLYPH, 165 | EFI_WARN_DELETE_FAILURE = RETURN_WARN_DELETE_FAILURE, 166 | EFI_WARN_WRITE_FAILURE = RETURN_WARN_WRITE_FAILURE, 167 | EFI_WARN_BUFFER_TOO_SMALL = RETURN_WARN_BUFFER_TOO_SMALL, 168 | EFI_WARN_STALE_DATA = RETURN_WARN_STALE_DATA 169 | } 170 | 171 | /// 172 | /// Define macro to encode the status code. 173 | /// 174 | alias EFIERR = ENCODE_ERROR; 175 | alias EFI_ERROR = RETURN_ERROR; 176 | 177 | enum : EFI_STATUS 178 | { 179 | /// ICMP error definitions 180 | EFI_NETWORK_UNREACHABLE = EFIERR!(100), 181 | /// ditto 182 | EFI_HOST_UNREACHABLE = EFIERR!(101), 183 | /// ditto 184 | EFI_PROTOCOL_UNREACHABLE = EFIERR!(102), 185 | /// ditto 186 | EFI_PORT_UNREACHABLE = EFIERR!(103), 187 | 188 | /// Tcp connection status definitions 189 | EFI_CONNECTION_FIN = EFIERR!(104), 190 | /// ditto 191 | EFI_CONNECTION_RESET = EFIERR!(105), 192 | /// ditto 193 | EFI_CONNECTION_REFUSED = EFIERR!(106) 194 | } 195 | 196 | /// The EFI memory allocation functions work in units of EFI_PAGEs that are 197 | /// 4KB. This should in no way be confused with the page size of the processor. 198 | /// An EFI_PAGE is just the quanta of memory in EFI. 199 | enum EFI_PAGE_SIZE = SIZE_4KB; 200 | enum EFI_PAGE_MASK = 0xFFF; 201 | enum EFI_PAGE_SHIFT = 12; 202 | 203 | /** 204 | Macro that converts a size, in bytes, to a number of EFI_PAGESs. 205 | 206 | Params: 207 | Size = A size in bytes. This parameter is assumed to be type UINTN. 208 | Passing in a parameter that is larger than UINTN may produce 209 | unexpected results. 210 | 211 | Returns: The number of EFI_PAGESs associated with the number of bytes specified 212 | by Size. 213 | 214 | **/ 215 | auto EFI_SIZE_TO_PAGES(T)(T Size) 216 | { 217 | return ((Size) >> EFI_PAGE_SHIFT) + (((Size) & EFI_PAGE_MASK) ? 1 : 0); 218 | } 219 | 220 | /** 221 | Macro that converts a number of EFI_PAGEs to a size in bytes. 222 | 223 | Params: 224 | Pages = The number of EFI_PAGES. This parameter is assumed to be 225 | type UINTN. Passing in a parameter that is larger than 226 | UINTN may produce unexpected results. 227 | 228 | Returns: The number of bytes associated with the number of EFI_PAGEs specified 229 | by Pages. 230 | 231 | **/ 232 | auto EFI_PAGES_TO_SIZE(T)(T Pages) 233 | { 234 | return (Pages) << EFI_PAGE_SHIFT; 235 | } 236 | 237 | /// 238 | /// PE32+ Machine type for IA32 UEFI images. 239 | /// 240 | enum EFI_IMAGE_MACHINE_IA32 = 0x014C; 241 | 242 | /// 243 | /// PE32+ Machine type for IA64 UEFI images. 244 | /// 245 | enum EFI_IMAGE_MACHINE_IA64 = 0x0200; 246 | 247 | /// 248 | /// PE32+ Machine type for EBC UEFI images. 249 | /// 250 | enum EFI_IMAGE_MACHINE_EBC = 0x0EBC; 251 | 252 | /// 253 | /// PE32+ Machine type for X64 UEFI images. 254 | /// 255 | enum EFI_IMAGE_MACHINE_X64 = 0x8664; 256 | 257 | /// 258 | /// PE32+ Machine type for ARM mixed ARM and Thumb/Thumb2 images. 259 | /// 260 | enum EFI_IMAGE_MACHINE_ARMTHUMB_MIXED = 0x01C2; 261 | 262 | /// 263 | /// PE32+ Machine type for AARCH64 A64 images. 264 | /// 265 | enum EFI_IMAGE_MACHINE_AARCH64 = 0xAA64; 266 | 267 | // UEFI Multi Phase 268 | 269 | alias EFI_MEMORY_TYPE = UINT32; 270 | /// 271 | /// Enumeration of memory types introduced in UEFI. 272 | /// 273 | enum : EFI_MEMORY_TYPE 274 | { 275 | /// 276 | /// Not used. 277 | /// 278 | EfiReservedMemoryType, 279 | /// 280 | /// The code portions of a loaded application. 281 | /// (Note that UEFI OS loaders are UEFI applications.) 282 | /// 283 | EfiLoaderCode, 284 | /// 285 | /// The data portions of a loaded application and the default data allocation 286 | /// type used by an application to allocate pool memory. 287 | /// 288 | EfiLoaderData, 289 | /// 290 | /// The code portions of a loaded Boot Services Driver. 291 | /// 292 | EfiBootServicesCode, 293 | /// 294 | /// The data portions of a loaded Boot Serves Driver, and the default data 295 | /// allocation type used by a Boot Services Driver to allocate pool memory. 296 | /// 297 | EfiBootServicesData, 298 | /// 299 | /// The code portions of a loaded Runtime Services Driver. 300 | /// 301 | EfiRuntimeServicesCode, 302 | /// 303 | /// The data portions of a loaded Runtime Services Driver and the default 304 | /// data allocation type used by a Runtime Services Driver to allocate pool memory. 305 | /// 306 | EfiRuntimeServicesData, 307 | /// 308 | /// Free (unallocated) memory. 309 | /// 310 | EfiConventionalMemory, 311 | /// 312 | /// Memory in which errors have been detected. 313 | /// 314 | EfiUnusableMemory, 315 | /// 316 | /// Memory that holds the ACPI tables. 317 | /// 318 | EfiACPIReclaimMemory, 319 | /// 320 | /// Address space reserved for use by the firmware. 321 | /// 322 | EfiACPIMemoryNVS, 323 | /// 324 | /// Used by system firmware to request that a memory-mapped IO region 325 | /// be mapped by the OS to a virtual address so it can be accessed by EFI runtime services. 326 | /// 327 | EfiMemoryMappedIO, 328 | /// 329 | /// System memory-mapped IO region that is used to translate memory 330 | /// cycles to IO cycles by the processor. 331 | /// 332 | EfiMemoryMappedIOPortSpace, 333 | /// 334 | /// Address space reserved by the firmware for code that is part of the processor. 335 | /// 336 | EfiPalCode, 337 | /// 338 | /// A memory region that operates as EfiConventionalMemory, 339 | /// however it happens to also support byte-addressable non-volatility. 340 | /// 341 | EfiPersistentMemory, 342 | EfiMaxMemoryType 343 | } 344 | 345 | alias EFI_RESET_TYPE = UINT32; 346 | /// 347 | /// Enumeration of reset types. 348 | /// 349 | enum : EFI_RESET_TYPE 350 | { 351 | /// 352 | /// Used to induce a system-wide reset. This sets all circuitry within the 353 | /// system to its initial state. This type of reset is asynchronous to system 354 | /// operation and operates withgout regard to cycle boundaries. EfiColdReset 355 | /// is tantamount to a system power cycle. 356 | /// 357 | EfiResetCold, 358 | /// 359 | /// Used to induce a system-wide initialization. The processors are set to their 360 | /// initial state, and pending cycles are not corrupted. If the system does 361 | /// not support this reset type, then an EfiResetCold must be performed. 362 | /// 363 | EfiResetWarm, 364 | /// 365 | /// Used to induce an entry into a power state equivalent to the ACPI G2/S5 or G3 366 | /// state. If the system does not support this reset type, then when the system 367 | /// is rebooted, it should exhibit the EfiResetCold attributes. 368 | /// 369 | EfiResetShutdown, 370 | /// 371 | /// Used to induce a system-wide reset. The exact type of the reset is defined by 372 | /// the EFI_GUID that follows the Null-terminated Unicode string passed into 373 | /// ResetData. If the platform does not recognize the EFI_GUID in ResetData the 374 | /// platform must pick a supported reset type to perform. The platform may 375 | /// optionally log the parameters from any non-normal reset that occurs. 376 | /// 377 | EfiResetPlatformSpecific 378 | } 379 | 380 | /// 381 | /// Data structure that precedes all of the standard EFI table types. 382 | /// 383 | struct EFI_TABLE_HEADER 384 | { 385 | /// 386 | /// A 64-bit signature that identifies the type of table that follows. 387 | /// Unique signatures have been generated for the EFI System Table, 388 | /// the EFI Boot Services Table, and the EFI Runtime Services Table. 389 | /// 390 | UINT64 Signature; 391 | /// 392 | /// The revision of the EFI Specification to which this table 393 | /// conforms. The upper 16 bits of this field contain the major 394 | /// revision value, and the lower 16 bits contain the minor revision 395 | /// value. The minor revision values are limited to the range of 00..99. 396 | /// 397 | UINT32 Revision; 398 | /// 399 | /// The size, in bytes, of the entire table including the EFI_TABLE_HEADER. 400 | /// 401 | UINT32 HeaderSize; 402 | /// 403 | /// The 32-bit CRC for the entire table. This value is computed by 404 | /// setting this field to 0, and computing the 32-bit CRC for HeaderSize bytes. 405 | /// 406 | UINT32 CRC32; 407 | /// 408 | /// Reserved field that must be set to 0. 409 | /// 410 | UINT32 Reserved; 411 | } 412 | 413 | /// 414 | /// Attributes of variable. 415 | /// 416 | enum EFI_VARIABLE_NON_VOLATILE = 0x00000001; 417 | enum EFI_VARIABLE_BOOTSERVICE_ACCESS = 0x00000002; 418 | enum EFI_VARIABLE_RUNTIME_ACCESS = 0x00000004; 419 | /// 420 | /// This attribute is identified by the mnemonic 'HR' 421 | /// elsewhere in this specification. 422 | /// 423 | enum EFI_VARIABLE_HARDWARE_ERROR_RECORD = 0x00000008; 424 | /// 425 | /// Attributes of Authenticated Variable 426 | /// 427 | enum EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS = 0x00000010; 428 | enum EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS = 0x00000020; 429 | enum EFI_VARIABLE_APPEND_WRITE = 0x00000040; 430 | 431 | // TODO: WIN_CERTIFICATE_UEFI_GUID-dependent structures 432 | -------------------------------------------------------------------------------- /source/uefi/bind.d: -------------------------------------------------------------------------------- 1 | /** 2 | Contains code to select appropriate bind module. 3 | **/ 4 | module uefi.bind; 5 | 6 | version (X86_64) 7 | { 8 | /// An import statement for the bind module 9 | enum string UEFI_BindImportString = `import uefi.x64.bind;`; 10 | /// An public import statement for the bind module 11 | enum string UEFI_BindPublicImportString = `public ` ~ UEFI_BindImportString; 12 | } 13 | else version (X86) 14 | { 15 | /// An import statement for the bind module 16 | enum string UEFI_BindImportString = `import uefi.ia32.bind;`; 17 | /// An public import statement for the bind module 18 | enum string UEFI_BindPublicImportString = `public ` ~ UEFI_BindImportString; 19 | } 20 | else 21 | { 22 | /// An import statement for the bind module 23 | enum string UEFI_BindImportString = ``; 24 | /// An public import statement for the bind module 25 | enum string UEFI_BindPublicImportString = ``; 26 | } 27 | 28 | mixin(UEFI_BindPublicImportString); 29 | -------------------------------------------------------------------------------- /source/uefi/gpt.d: -------------------------------------------------------------------------------- 1 | /** 2 | Based on Uefi/UefiGpt.h file, original notice: 3 | 4 | EFI Guid Partition Table Format Definition. 5 | 6 | This is the include file for any module of type base. Base modules only use 7 | types defined via this include file and can be ported easily to any 8 | environment. There are a set of base libraries in the Mde Package that can 9 | be used to implement base modules. 10 | 11 | Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved. 12 | This program and the accompanying materials 13 | are licensed and made available under the terms and conditions of the BSD License 14 | which accompanies this distribution. The full text of the license may be found at 15 | http://opensource.org/licenses/bsd-license.php 16 | 17 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 19 | **/ 20 | module uefi.gpt; 21 | 22 | import uefi.bind; 23 | import uefi.base; 24 | import uefi.base_type; 25 | 26 | public: 27 | extern (C): 28 | 29 | /// 30 | /// The primary GUID Partition Table Header must be 31 | /// located in LBA 1 (i.e., the second logical block). 32 | /// 33 | enum PRIMARY_PART_HEADER_LBA = 1; 34 | 35 | /// 36 | /// EFI Partition Table Signature: "EFI PART". 37 | /// 38 | enum EFI_PTAB_HEADER_ID = SIGNATURE_64('E', 'F', 'I', ' ', 'P', 'A', 'R', 'T'); 39 | 40 | /// 41 | /// GPT Partition Table Header. 42 | /// 43 | struct EFI_PARTITION_TABLE_HEADER 44 | { 45 | align(1): 46 | /// 47 | /// The table header for the GPT partition Table. 48 | /// This header contains EFI_PTAB_HEADER_ID. 49 | /// 50 | EFI_TABLE_HEADER Header; 51 | /// 52 | /// The LBA that contains this data structure. 53 | /// 54 | EFI_LBA MyLBA; 55 | /// 56 | /// LBA address of the alternate GUID Partition Table Header. 57 | /// 58 | EFI_LBA AlternateLBA; 59 | /// 60 | /// The first usable logical block that may be used 61 | /// by a partition described by a GUID Partition Entry. 62 | /// 63 | EFI_LBA FirstUsableLBA; 64 | /// 65 | /// The last usable logical block that may be used 66 | /// by a partition described by a GUID Partition Entry. 67 | /// 68 | EFI_LBA LastUsableLBA; 69 | /// 70 | /// GUID that can be used to uniquely identify the disk. 71 | /// 72 | EFI_GUID DiskGUID; 73 | /// 74 | /// The starting LBA of the GUID Partition Entry array. 75 | /// 76 | EFI_LBA PartitionEntryLBA; 77 | /// 78 | /// The number of Partition Entries in the GUID Partition Entry array. 79 | /// 80 | UINT32 NumberOfPartitionEntries; 81 | /// 82 | /// The size, in bytes, of each the GUID Partition 83 | /// Entry structures in the GUID Partition Entry 84 | /// array. This field shall be set to a value of 128 x 2^n where n is 85 | /// an integer greater than or equal to zero (e.g., 128, 256, 512, etc.). 86 | /// 87 | UINT32 SizeOfPartitionEntry; 88 | /// 89 | /// The CRC32 of the GUID Partition Entry array. 90 | /// Starts at PartitionEntryLBA and is 91 | /// computed over a byte length of 92 | /// NumberOfPartitionEntries * SizeOfPartitionEntry. 93 | /// 94 | UINT32 PartitionEntryArrayCRC32; 95 | } 96 | 97 | /// 98 | /// GPT Partition Entry. 99 | /// 100 | struct EFI_PARTITION_ENTRY 101 | { 102 | align(1): 103 | /// 104 | /// Unique ID that defines the purpose and type of this Partition. A value of 105 | /// zero defines that this partition entry is not being used. 106 | /// 107 | EFI_GUID PartitionTypeGUID; 108 | /// 109 | /// GUID that is unique for every partition entry. Every partition ever 110 | /// created will have a unique GUID. 111 | /// This GUID must be assigned when the GUID Partition Entry is created. 112 | /// 113 | EFI_GUID UniquePartitionGUID; 114 | /// 115 | /// Starting LBA of the partition defined by this entry 116 | /// 117 | EFI_LBA StartingLBA; 118 | /// 119 | /// Ending LBA of the partition defined by this entry. 120 | /// 121 | EFI_LBA EndingLBA; 122 | /// 123 | /// Attribute bits, all bits reserved by UEFI 124 | /// Bit 0: If this bit is set, the partition is required for the platform to function. The owner/creator of the 125 | /// partition indicates that deletion or modification of the contents can result in loss of platform 126 | /// features or failure for the platform to boot or operate. The system cannot function normally if 127 | /// this partition is removed, and it should be considered part of the hardware of the system. 128 | /// Actions such as running diagnostics, system recovery, or even OS install or boot, could 129 | /// potentially stop working if this partition is removed. Unless OS software or firmware 130 | /// recognizes this partition, it should never be removed or modified as the UEFI firmware or 131 | /// platform hardware may become non-functional. 132 | /// Bit 1: If this bit is set, then firmware must not produce an EFI_BLOCK_IO_PROTOCOL device for 133 | /// this partition. By not producing an EFI_BLOCK_IO_PROTOCOL partition, file system 134 | /// mappings will not be created for this partition in UEFI. 135 | /// Bit 2: This bit is set aside to let systems with traditional PC-AT BIOS firmware implementations 136 | /// inform certain limited, special-purpose software running on these systems that a GPT 137 | /// partition may be bootable. The UEFI boot manager must ignore this bit when selecting 138 | /// a UEFI-compliant application, e.g., an OS loader. 139 | /// Bits 3-47: Undefined and must be zero. Reserved for expansion by future versions of the UEFI 140 | /// specification. 141 | /// Bits 48-63: Reserved for GUID specific use. The use of these bits will vary depending on the 142 | /// PartitionTypeGUID. Only the owner of the PartitionTypeGUID is allowed 143 | /// to modify these bits. They must be preserved if Bits 0-47 are modified.. 144 | /// 145 | UINT64 Attributes; 146 | /// 147 | /// Null-terminated name of the partition. 148 | /// 149 | CHAR16[36] PartitionName; 150 | } 151 | -------------------------------------------------------------------------------- /source/uefi/ia32/bind.d: -------------------------------------------------------------------------------- 1 | /** 2 | Based on Ia32/ProcessorBind.h file, original notice: 3 | 4 | Processor or Compiler specific defines and types for IA-32 architecture. 5 | 6 | Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved. 7 | This program and the accompanying materials 8 | are licensed and made available under the terms and conditions of the BSD License 9 | which accompanies this distribution. The full text of the license may be found at 10 | http://opensource.org/licenses/bsd-license.php 11 | 12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 14 | **/ 15 | module uefi.ia32.bind; 16 | 17 | version (X86) 18 | { 19 | public: 20 | extern (C): 21 | 22 | /// void 23 | alias VOID = void; 24 | 25 | /// 8-byte unsigned value 26 | alias UINT64 = ulong; 27 | 28 | /// 4-byte unsigned value 29 | alias UINT32 = uint; 30 | 31 | /// 2-byte unsigned value 32 | alias UINT16 = ushort; 33 | 34 | /// 1-byte unsigned value 35 | alias UINT8 = ubyte; 36 | 37 | /// 8-byte signed value 38 | alias INT64 = long; 39 | 40 | /// 4-byte signed value 41 | alias INT32 = int; 42 | 43 | /// 2-byte signed value 44 | alias INT16 = short; 45 | 46 | /// 1-byte signed value 47 | alias INT8 = byte; 48 | 49 | /// 1-byte character 50 | alias CHAR8 = char; 51 | 52 | /// 2-byte Character. Unless otherwise specified all strings are stored in the 53 | /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards. 54 | alias CHAR16 = wchar; 55 | 56 | /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other 57 | /// values are undefined. 58 | alias BOOLEAN = ubyte; 59 | 60 | /// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions, 61 | /// 8 bytes on supported 64-bit processor instructions) 62 | alias UINTN = UINT32; 63 | 64 | /// Signed value of native width. (4 bytes on supported 32-bit processor instructions, 65 | /// 8 bytes on supported 64-bit processor instructions) 66 | alias INTN = INT32; 67 | 68 | /// A value of native width with the highest bit set. 69 | enum MAX_BIT = 0x8000_0000; 70 | 71 | /// A value of native width with the two highest bits set. 72 | enum MAX_2_BITS = 0xC000_0000; 73 | 74 | /// Maximum legal x64 address 75 | enum MAX_ADDRESS = 0xFFFF_FFFF; 76 | 77 | /// Maximum legal x64 INTN and UINTN values. 78 | enum MAX_INTN = INTN.max; 79 | /// ditto 80 | enum MAX_UINTN = UINTN.max; 81 | 82 | /// The stack alignment required for x64 83 | enum CPU_STACK_ALIGNMENT = 4; 84 | 85 | /** 86 | Return the pointer to the first instruction of a function given a function pointer. 87 | On IA-32 CPU architectures, these two pointer values are the same, 88 | so the implementation of this macro is very simple. 89 | 90 | Params: 91 | FunctionPointer = A pointer to a function. 92 | 93 | Returns: The pointer to the first instruction of a function given a function pointer. 94 | 95 | **/ 96 | void* FUNCTION_ENTRY_POINT(T)(T fptr) if (is(T == function)) 97 | { 98 | return cast(void*)(fptr); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /source/uefi/package.d: -------------------------------------------------------------------------------- 1 | /** 2 | Package root module, importing appropriate bind module and other UEFI modules. 3 | **/ 4 | module uefi; 5 | 6 | import uefi.bind; 7 | 8 | mixin(UEFI_BindPublicImportString); 9 | 10 | public import uefi.base; 11 | public import uefi.base_type; 12 | public import uefi.gpt; 13 | public import uefi.guids; 14 | 15 | public import uefi.protocols.hash; 16 | public import uefi.protocols.hash2; 17 | public import uefi.protocols.devicepath; 18 | public import uefi.protocols.simpletextin; 19 | public import uefi.protocols.simpletextinex; 20 | public import uefi.protocols.simpletextout; 21 | public import uefi.protocols.simplepointer; 22 | public import uefi.protocols.simplenetwork; 23 | public import uefi.protocols.simplefilesystem; 24 | public import uefi.protocols.loadfile2; 25 | public import uefi.protocols.loadedimage; 26 | public import uefi.protocols.graphicsoutput; 27 | 28 | public import uefi.acpiaml; 29 | public import uefi.acpi10; 30 | public import uefi.acpi20; 31 | public import uefi.acpi30; 32 | public import uefi.acpi40; 33 | public import uefi.acpi50; 34 | public import uefi.acpi51; 35 | public import uefi.acpi60; 36 | public import uefi.acpidatatable; 37 | 38 | public import uefi.pxe; 39 | public import uefi.spec; 40 | -------------------------------------------------------------------------------- /source/uefi/protocols/graphicsoutput.d: -------------------------------------------------------------------------------- 1 | /** 2 | Based on Protocol/GraphicsOutput.h, original notice: 3 | 4 | Graphics Output Protocol from the UEFI 2.0 specification. 5 | 6 | Abstraction of a very simple graphics device. 7 | 8 | Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved. 9 | This program and the accompanying materials 10 | are licensed and made available under the terms and conditions of the BSD License 11 | which accompanies this distribution. The full text of the license may be found at 12 | http://opensource.org/licenses/bsd-license.php 13 | 14 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 16 | 17 | **/ 18 | module uefi.protocols.graphicsoutput; 19 | import uefi.base; 20 | import uefi.base_type; 21 | 22 | public: 23 | extern (C): 24 | enum EFI_GUID EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID = EFI_GUID(0x9042a9de, 0x23dc, 25 | 0x4a38, [0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a]); 26 | alias EFI_GRAPHICS_OUTPUT_PROTOCOL = _EFI_GRAPHICS_OUTPUT_PROTOCOL; 27 | struct EFI_PIXEL_BITMASK 28 | { 29 | UINT32 RedMask; 30 | UINT32 GreenMask; 31 | UINT32 BlueMask; 32 | UINT32 ReservedMask; 33 | } 34 | 35 | alias EFI_GRAPHICS_PIXEL_FORMAT = UINT32; 36 | enum : EFI_GRAPHICS_PIXEL_FORMAT 37 | { 38 | /// 39 | /// A pixel is 32-bits and byte zero represents red, byte one represents green, 40 | /// byte two represents blue, and byte three is reserved. This is the definition 41 | /// for the physical frame buffer. The byte values for the red, green, and blue 42 | /// components represent the color intensity. This color intensity value range 43 | /// from a minimum intensity of 0 to maximum intensity of 255. 44 | /// 45 | PixelRedGreenBlueReserved8BitPerColor, 46 | /// 47 | /// A pixel is 32-bits and byte zero represents blue, byte one represents green, 48 | /// byte two represents red, and byte three is reserved. This is the definition 49 | /// for the physical frame buffer. The byte values for the red, green, and blue 50 | /// components represent the color intensity. This color intensity value range 51 | /// from a minimum intensity of 0 to maximum intensity of 255. 52 | /// 53 | PixelBlueGreenRedReserved8BitPerColor, 54 | /// 55 | /// The Pixel definition of the physical frame buffer. 56 | /// 57 | PixelBitMask, 58 | /// 59 | /// This mode does not support a physical frame buffer. 60 | /// 61 | PixelBltOnly, 62 | /// 63 | /// Valid EFI_GRAPHICS_PIXEL_FORMAT enum values are less than this value. 64 | /// 65 | PixelFormatMax 66 | } 67 | struct EFI_GRAPHICS_OUTPUT_MODE_INFORMATION 68 | { 69 | /// 70 | /// The version of this data structure. A value of zero represents the 71 | /// EFI_GRAPHICS_OUTPUT_MODE_INFORMATION structure as defined in this specification. 72 | /// 73 | UINT32 Version; 74 | /// 75 | /// The size of video screen in pixels in the X dimension. 76 | /// 77 | UINT32 HorizontalResolution; 78 | /// 79 | /// The size of video screen in pixels in the Y dimension. 80 | /// 81 | UINT32 VerticalResolution; 82 | /// 83 | /// Enumeration that defines the physical format of the pixel. A value of PixelBltOnly 84 | /// implies that a linear frame buffer is not available for this mode. 85 | /// 86 | EFI_GRAPHICS_PIXEL_FORMAT PixelFormat; 87 | /// 88 | /// This bit-mask is only valid if PixelFormat is set to PixelPixelBitMask. 89 | /// A bit being set defines what bits are used for what purpose such as Red, Green, Blue, or Reserved. 90 | /// 91 | EFI_PIXEL_BITMASK PixelInformation; 92 | /// 93 | /// Defines the number of pixel elements per video memory line. 94 | /// 95 | UINT32 PixelsPerScanLine; 96 | } 97 | /** 98 | Returns information for an available graphics mode that the graphics device 99 | and the set of active video output devices supports. 100 | 101 | @param This The EFI_GRAPHICS_OUTPUT_PROTOCOL instance. 102 | @param ModeNumber The mode number to return information on. 103 | @param SizeOfInfo A pointer to the size, in bytes, of the Info buffer. 104 | @param Info A pointer to callee allocated buffer that returns information about ModeNumber. 105 | 106 | @retval EFI_SUCCESS Valid mode information was returned. 107 | @retval EFI_DEVICE_ERROR A hardware error occurred trying to retrieve the video mode. 108 | @retval EFI_INVALID_PARAMETER ModeNumber is not valid. 109 | 110 | **/ 111 | alias EFI_GRAPHICS_OUTPUT_PROTOCOL_QUERY_MODE = EFI_STATUS function( 112 | EFI_GRAPHICS_OUTPUT_PROTOCOL* This, UINT32 ModeNumber, UINTN* SizeOfInfo, 113 | EFI_GRAPHICS_OUTPUT_MODE_INFORMATION** Info) @nogc nothrow; 114 | /** 115 | Set the video device into the specified mode and clears the visible portions of 116 | the output display to black. 117 | 118 | @param This The EFI_GRAPHICS_OUTPUT_PROTOCOL instance. 119 | @param ModeNumber Abstraction that defines the current video mode. 120 | 121 | @retval EFI_SUCCESS The graphics mode specified by ModeNumber was selected. 122 | @retval EFI_DEVICE_ERROR The device had an error and could not complete the request. 123 | @retval EFI_UNSUPPORTED ModeNumber is not supported by this device. 124 | 125 | **/ 126 | alias EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE = EFI_STATUS function( 127 | EFI_GRAPHICS_OUTPUT_PROTOCOL* This, UINT32 ModeNumber) @nogc nothrow; 128 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL 129 | { 130 | UINT8 Blue; 131 | UINT8 Green; 132 | UINT8 Red; 133 | UINT8 Reserved; 134 | } 135 | 136 | union EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION 137 | { 138 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL Pixel; 139 | UINT32 Raw; 140 | } 141 | /// actions for BltOperations 142 | alias EFI_GRAPHICS_OUTPUT_BLT_OPERATION = UINT32; 143 | enum : EFI_GRAPHICS_OUTPUT_BLT_OPERATION 144 | { 145 | /// 146 | /// Write data from the BltBuffer pixel (0, 0) 147 | /// directly to every pixel of the video display rectangle 148 | /// (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height). 149 | /// Only one pixel will be used from the BltBuffer. Delta is NOT used. 150 | /// 151 | EfiBltVideoFill, 152 | 153 | /// 154 | /// Read data from the video display rectangle 155 | /// (SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in 156 | /// the BltBuffer rectangle (DestinationX, DestinationY ) 157 | /// (DestinationX + Width, DestinationY + Height). If DestinationX or 158 | /// DestinationY is not zero then Delta must be set to the length in bytes 159 | /// of a row in the BltBuffer. 160 | /// 161 | EfiBltVideoToBltBuffer, 162 | 163 | /// 164 | /// Write data from the BltBuffer rectangle 165 | /// (SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the 166 | /// video display rectangle (DestinationX, DestinationY) 167 | /// (DestinationX + Width, DestinationY + Height). If SourceX or SourceY is 168 | /// not zero then Delta must be set to the length in bytes of a row in the 169 | /// BltBuffer. 170 | /// 171 | EfiBltBufferToVideo, 172 | 173 | /// 174 | /// Copy from the video display rectangle (SourceX, SourceY) 175 | /// (SourceX + Width, SourceY + Height) to the video display rectangle 176 | /// (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height). 177 | /// The BltBuffer and Delta are not used in this mode. 178 | /// 179 | EfiBltVideoToVideo, 180 | 181 | EfiGraphicsOutputBltOperationMax 182 | } 183 | /** 184 | Blt a rectangle of pixels on the graphics screen. Blt stands for BLock Transfer. 185 | 186 | @param This Protocol instance pointer. 187 | @param BltBuffer The data to transfer to the graphics screen. 188 | Size is at least Width*Height*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL). 189 | @param BltOperation The operation to perform when copying BltBuffer on to the graphics screen. 190 | @param SourceX The X coordinate of source for the BltOperation. 191 | @param SourceY The Y coordinate of source for the BltOperation. 192 | @param DestinationX The X coordinate of destination for the BltOperation. 193 | @param DestinationY The Y coordinate of destination for the BltOperation. 194 | @param Width The width of a rectangle in the blt rectangle in pixels. 195 | @param Height The height of a rectangle in the blt rectangle in pixels. 196 | @param Delta Not used for EfiBltVideoFill or the EfiBltVideoToVideo operation. 197 | If a Delta of zero is used, the entire BltBuffer is being operated on. 198 | If a subrectangle of the BltBuffer is being used then Delta 199 | represents the number of bytes in a row of the BltBuffer. 200 | 201 | @retval EFI_SUCCESS BltBuffer was drawn to the graphics screen. 202 | @retval EFI_INVALID_PARAMETER BltOperation is not valid. 203 | @retval EFI_DEVICE_ERROR The device had an error and could not complete the request. 204 | 205 | **/ 206 | alias EFI_GRAPHICS_OUTPUT_PROTOCOL_BLT = EFI_STATUS function( 207 | EFI_GRAPHICS_OUTPUT_PROTOCOL* This, 208 | EFI_GRAPHICS_OUTPUT_BLT_PIXEL* BltBuffer, 209 | EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation, UINTN SourceX, UINTN SourceY, 210 | UINTN DestinationX, UINTN DestinationY, UINTN Width, UINTN Height, UINTN Delta) @nogc nothrow; 211 | struct EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE 212 | { 213 | /// 214 | /// The number of modes supported by QueryMode() and SetMode(). 215 | /// 216 | UINT32 MaxMode; 217 | /// 218 | /// Current Mode of the graphics device. Valid mode numbers are 0 to MaxMode -1. 219 | /// 220 | UINT32 Mode; 221 | /// 222 | /// Pointer to read-only EFI_GRAPHICS_OUTPUT_MODE_INFORMATION data. 223 | /// 224 | EFI_GRAPHICS_OUTPUT_MODE_INFORMATION* Info; 225 | /// 226 | /// Size of Info structure in bytes. 227 | /// 228 | UINTN SizeOfInfo; 229 | /// 230 | /// Base address of graphics linear frame buffer. 231 | /// Offset zero in FrameBufferBase represents the upper left pixel of the display. 232 | /// 233 | EFI_PHYSICAL_ADDRESS FrameBufferBase; 234 | /// 235 | /// Amount of frame buffer needed to support the active mode as defined by 236 | /// PixelsPerScanLine xVerticalResolution x PixelElementSize. 237 | /// 238 | UINTN FrameBufferSize; 239 | } 240 | /// Provides a basic abstraction to set video modes and copy pixels to and from 241 | /// the graphics controller's frame buffer. The linear address of the hardware 242 | /// frame buffer is also exposed so software can write directly to the video hardware. 243 | struct _EFI_GRAPHICS_OUTPUT_PROTOCOL 244 | { 245 | EFI_GRAPHICS_OUTPUT_PROTOCOL_QUERY_MODE QueryMode; 246 | EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE SetMode; 247 | EFI_GRAPHICS_OUTPUT_PROTOCOL_BLT Blt; 248 | /// 249 | /// Pointer to EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE data. 250 | /// 251 | EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE* Mode; 252 | } 253 | -------------------------------------------------------------------------------- /source/uefi/protocols/hash.d: -------------------------------------------------------------------------------- 1 | /** 2 | Based on Protocol/Hash.h, original notice: 3 | 4 | EFI_HASH_SERVICE_BINDING_PROTOCOL as defined in UEFI 2.0. 5 | EFI_HASH_PROTOCOL as defined in UEFI 2.0. 6 | The EFI Hash Service Binding Protocol is used to locate hashing services support 7 | provided by a driver and to create and destroy instances of the EFI Hash Protocol 8 | so that a multiple drivers can use the underlying hashing services. 9 | 10 | Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved. 11 | This program and the accompanying materials are licensed and made available under 12 | the terms and conditions of the BSD License that accompanies this distribution. 13 | The full text of the license may be found at 14 | http://opensource.org/licenses/bsd-license.php. 15 | 16 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 17 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 18 | 19 | **/ 20 | module uefi.protocols.hash; 21 | import uefi.base; 22 | import uefi.base_type; 23 | 24 | public: 25 | extern (C): 26 | enum EFI_GUID EFI_HASH_SERVICE_BINDING_PROTOCOL_GUID = EFI_GUID(0x42881c98, 27 | 0xa4f3, 0x44b0, [0xa3, 0x9d, 0xdf, 0xa1, 0x86, 0x67, 0xd8, 0xcd]); 28 | enum EFI_GUID EFI_HASH_PROTOCOL_GUID = EFI_GUID(0xc5184932, 0xdba5, 0x46db, 29 | [0xa5, 0xba, 0xcc, 0x0b, 0xda, 0x9c, 0x14, 0x35]); 30 | enum EFI_GUID EFI_HASH_ALGORITHM_SHA1_GUID = EFI_GUID(0x2ae9d80f, 0x3fb2, 31 | 0x4095, [0xb7, 0xb1, 0xe9, 0x31, 0x57, 0xb9, 0x46, 0xb6]); 32 | enum EFI_GUID EFI_HASH_ALGORITHM_SHA224_GUID = EFI_GUID(0x8df01a06, 0x9bd5, 33 | 0x4bf7, [0xb0, 0x21, 0xdb, 0x4f, 0xd9, 0xcc, 0xf4, 0x5b]); 34 | enum EFI_GUID EFI_HASH_ALGORITHM_SHA256_GUID = EFI_GUID(0x51aa59de, 0xfdf2, 35 | 0x4ea3, [0xbc, 0x63, 0x87, 0x5f, 0xb7, 0x84, 0x2e, 0xe9]); 36 | enum EFI_GUID EFI_HASH_ALGORITHM_SHA384_GUID = EFI_GUID(0xefa96432, 0xde33, 37 | 0x4dd2, [0xae, 0xe6, 0x32, 0x8c, 0x33, 0xdf, 0x77, 0x7a]); 38 | enum EFI_GUID EFI_HASH_ALGORITHM_SHA512_GUID = EFI_GUID(0xcaa4381e, 0x750c, 39 | 0x4770, [0xb8, 0x70, 0x7a, 0x23, 0xb4, 0xe4, 0x21, 0x30]); 40 | enum EFI_GUID EFI_HASH_ALGORTIHM_MD5_GUID = EFI_GUID(0xaf7c79c, 0x65b5, 0x4319, 41 | [0xb0, 0xae, 0x44, 0xec, 0x48, 0x4e, 0x4a, 0xd7]); 42 | enum EFI_GUID EFI_HASH_ALGORITHM_SHA1_NOPAD_GUID = EFI_GUID(0x24c5dc2f, 0x53e2, 43 | 0x40ca, [0x9e, 0xd6, 0xa5, 0xd9, 0xa4, 0x9f, 0x46, 0x3b]); 44 | enum EFI_GUID EFI_HASH_ALGORITHM_SHA256_NOPAD_GUID = EFI_GUID(0x8628752a, 45 | 0x6cb7, 0x4814, [0x96, 0xfc, 0x24, 0xa8, 0x15, 0xac, 0x22, 0x26]); 46 | alias EFI_HASH_PROTOCOL = _EFI_HASH_PROTOCOL; 47 | alias EFI_MD5_HASH = UINT8[16]; 48 | alias EFI_SHA1_HASH = UINT8[20]; 49 | alias EFI_SHA224_HASH = UINT8[28]; 50 | alias EFI_SHA256_HASH = UINT8[32]; 51 | alias EFI_SHA384_HASH = UINT8[48]; 52 | alias EFI_SHA512_HASH = UINT8[64]; 53 | union EFI_HASH_OUTPUT 54 | { 55 | EFI_MD5_HASH* Md5Hash; 56 | EFI_SHA1_HASH* Sha1Hash; 57 | EFI_SHA224_HASH* Sha224Hash; 58 | EFI_SHA256_HASH* Sha256Hash; 59 | EFI_SHA384_HASH* Sha384Hash; 60 | EFI_SHA512_HASH* Sha512Hash; 61 | } 62 | /** 63 | Returns the size of the hash which results from a specific algorithm. 64 | 65 | @param[in] This Points to this instance of EFI_HASH_PROTOCOL. 66 | @param[in] HashAlgorithm Points to the EFI_GUID which identifies the algorithm to use. 67 | @param[out] HashSize Holds the returned size of the algorithm's hash. 68 | 69 | @retval EFI_SUCCESS Hash size returned successfully. 70 | @retval EFI_INVALID_PARAMETER HashSize is NULL or HashAlgorithm is NULL. 71 | @retval EFI_UNSUPPORTED The algorithm specified by HashAlgorithm is not supported 72 | by this driver. 73 | 74 | **/ 75 | alias EFI_HASH_GET_HASH_SIZE = EFI_STATUS function(const EFI_HASH_PROTOCOL* This, 76 | const EFI_GUID* HashAlgorithm, UINTN* HashSize) @nogc nothrow; 77 | /** 78 | Creates a hash for the specified message text. 79 | 80 | @param[in] This Points to this instance of EFI_HASH_PROTOCOL. 81 | @param[in] HashAlgorithm Points to the EFI_GUID which identifies the algorithm to use. 82 | @param[in] Extend Specifies whether to create a new hash (FALSE) or extend the specified 83 | existing hash (TRUE). 84 | @param[in] Message Points to the start of the message. 85 | @param[in] MessageSize The size of Message, in bytes. 86 | @param[in,out] Hash On input, if Extend is TRUE, then this parameter holds a pointer 87 | to a pointer to an array containing the hash to extend. If Extend 88 | is FALSE, then this parameter holds a pointer to a pointer to a 89 | caller-allocated array that will receive the result of the hash 90 | computation. On output (regardless of the value of Extend), the 91 | array will contain the result of the hash computation. 92 | 93 | @retval EFI_SUCCESS Hash returned successfully. 94 | @retval EFI_INVALID_PARAMETER Message or Hash, HashAlgorithm is NULL or MessageSize is 0. 95 | MessageSize is not an integer multiple of block size. 96 | @retval EFI_UNSUPPORTED The algorithm specified by HashAlgorithm is not supported by this 97 | driver. Or, Extend is TRUE, and the algorithm doesn't support extending the hash. 98 | 99 | **/ 100 | alias EFI_HASH_HASH = EFI_STATUS function(const EFI_HASH_PROTOCOL* This, 101 | const EFI_GUID* HashAlgorithm, BOOLEAN Extend, const UINT8* Message, 102 | UINT64 MessageSize, EFI_HASH_OUTPUT* Hash) @nogc nothrow; 103 | /// This protocol allows creating a hash of an arbitrary message digest 104 | /// using one or more hash algorithms. 105 | struct _EFI_HASH_PROTOCOL 106 | { 107 | EFI_HASH_GET_HASH_SIZE GetHashSize; 108 | EFI_HASH_HASH Hash; 109 | 110 | } 111 | -------------------------------------------------------------------------------- /source/uefi/protocols/hash2.d: -------------------------------------------------------------------------------- 1 | /** 2 | Based on Protocol/Hash2.h, original notice: 3 | 4 | EFI_HASH2_SERVICE_BINDING_PROTOCOL as defined in UEFI 2.5. 5 | EFI_HASH2_PROTOCOL as defined in UEFI 2.5. 6 | The EFI Hash2 Service Binding Protocol is used to locate hashing services support 7 | provided by a driver and to create and destroy instances of the EFI Hash2 Protocol 8 | so that a multiple drivers can use the underlying hashing services. 9 | EFI_HASH2_PROTOCOL describes hashing functions for which the algorithm-required 10 | message padding and finalization are performed by the supporting driver. 11 | 12 | Copyright (c) 2015, Intel Corporation. All rights reserved. 13 | This program and the accompanying materials are licensed and made available under 14 | the terms and conditions of the BSD License that accompanies this distribution. 15 | The full text of the license may be found at 16 | http://opensource.org/licenses/bsd-license.php. 17 | 18 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 19 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 20 | 21 | **/ 22 | module uefi.protocols.hash2; 23 | import uefi.base; 24 | import uefi.base_type; 25 | import uefi.protocols.hash; 26 | 27 | public: 28 | extern (C): 29 | enum EFI_GUID EFI_HASH2_SERVICE_BINDING_PROTOCOL_GUID = EFI_GUID(0xda836f8d, 30 | 0x217f, 0x4ca0, [0x99, 0xc2, 0x1c, 0xa4, 0xe1, 0x60, 0x77, 0xea]); 31 | enum EFI_GUID EFI_HASH2_PROTOCOL_GUID = EFI_GUID(0x55b1d734, 0xc5e1, 0x49db, 32 | [0x96, 0x47, 0xb1, 0x6a, 0xfb, 0xe, 0x30, 0x5b]); 33 | 34 | alias EFI_HASH2_PROTOCOL = _EFI_HASH2_PROTOCOL; 35 | alias EFI_MD5_HASH2 = UINT8[16]; 36 | alias EFI_SHA1_HASH2 = UINT8[20]; 37 | alias EFI_SHA224_HASH2 = UINT8[28]; 38 | alias EFI_SHA256_HASH2 = UINT8[32]; 39 | alias EFI_SHA384_HASH2 = UINT8[48]; 40 | alias EFI_SHA512_HASH2 = UINT8[64]; 41 | union EFI_HASH2_OUTPUT 42 | { 43 | EFI_MD5_HASH2 Md5Hash; 44 | EFI_SHA1_HASH2 Sha1Hash; 45 | EFI_SHA224_HASH2 Sha224Hash; 46 | EFI_SHA256_HASH2 Sha256Hash; 47 | EFI_SHA384_HASH2 Sha384Hash; 48 | EFI_SHA512_HASH2 Sha512Hash; 49 | } 50 | /** 51 | Returns the size of the hash which results from a specific algorithm. 52 | 53 | @param[in] This Points to this instance of EFI_HASH2_PROTOCOL. 54 | @param[in] HashAlgorithm Points to the EFI_GUID which identifies the algorithm to use. 55 | @param[out] HashSize Holds the returned size of the algorithm's hash. 56 | 57 | @retval EFI_SUCCESS Hash size returned successfully. 58 | @retval EFI_INVALID_PARAMETER This or HashSize is NULL. 59 | @retval EFI_UNSUPPORTED The algorithm specified by HashAlgorithm is not supported by this driver 60 | or HashAlgorithm is null. 61 | 62 | **/ 63 | alias EFI_HASH2_GET_HASH_SIZE = EFI_STATUS function(const EFI_HASH2_PROTOCOL* This, 64 | const EFI_GUID* HashAlgorithm, UINTN* HashSize) @nogc nothrow; 65 | /** 66 | Creates a hash for the specified message text. The hash is not extendable. 67 | The output is final with any algorithm-required padding added by the function. 68 | 69 | @param[in] This Points to this instance of EFI_HASH2_PROTOCOL. 70 | @param[in] HashAlgorithm Points to the EFI_GUID which identifies the algorithm to use. 71 | @param[in] Message Points to the start of the message. 72 | @param[in] MessageSize The size of Message, in bytes. 73 | @param[in,out] Hash On input, points to a caller-allocated buffer of the size 74 | returned by GetHashSize() for the specified HashAlgorithm. 75 | On output, the buffer holds the resulting hash computed from the message. 76 | 77 | @retval EFI_SUCCESS Hash returned successfully. 78 | @retval EFI_INVALID_PARAMETER This or Hash is NULL. 79 | @retval EFI_UNSUPPORTED The algorithm specified by HashAlgorithm is not supported by this driver 80 | or HashAlgorithm is Null. 81 | @retval EFI_OUT_OF_RESOURCES Some resource required by the function is not available 82 | or MessageSize is greater than platform maximum. 83 | 84 | **/ 85 | alias EFI_HASH2_HASH = EFI_STATUS function(const EFI_HASH2_PROTOCOL* This, 86 | const EFI_GUID* HashAlgorithm, const UINT8* Message, UINTN MessageSize, EFI_HASH2_OUTPUT* Hash) @nogc nothrow; 87 | /** 88 | This function must be called to initialize a digest calculation to be subsequently performed using the 89 | EFI_HASH2_PROTOCOL functions HashUpdate() and HashFinal(). 90 | 91 | @param[in] This Points to this instance of EFI_HASH2_PROTOCOL. 92 | @param[in] HashAlgorithm Points to the EFI_GUID which identifies the algorithm to use. 93 | 94 | @retval EFI_SUCCESS Initialized successfully. 95 | @retval EFI_INVALID_PARAMETER This is NULL. 96 | @retval EFI_UNSUPPORTED The algorithm specified by HashAlgorithm is not supported by this driver 97 | or HashAlgorithm is Null. 98 | @retval EFI_OUT_OF_RESOURCES Process failed due to lack of required resource. 99 | @retval EFI_ALREADY_STARTED This function is called when the operation in progress is still in processing Hash(), 100 | or HashInit() is already called before and not terminated by HashFinal() yet on the same instance. 101 | 102 | **/ 103 | alias EFI_HASH2_HASH_INIT = EFI_STATUS function(const EFI_HASH2_PROTOCOL* This, 104 | const EFI_GUID* HashAlgorithm) @nogc nothrow; 105 | /** 106 | Updates the hash of a computation in progress by adding a message text. 107 | 108 | @param[in] This Points to this instance of EFI_HASH2_PROTOCOL. 109 | @param[in] Message Points to the start of the message. 110 | @param[in] MessageSize The size of Message, in bytes. 111 | 112 | @retval EFI_SUCCESS Digest in progress updated successfully. 113 | @retval EFI_INVALID_PARAMETER This or Hash is NULL. 114 | @retval EFI_OUT_OF_RESOURCES Some resource required by the function is not available 115 | or MessageSize is greater than platform maximum. 116 | @retval EFI_NOT_READY This call was not preceded by a valid call to HashInit(), 117 | or the operation in progress was terminated by a call to Hash() or HashFinal() on the same instance. 118 | 119 | **/ 120 | alias EFI_HASH2_HASH_UPDATE = EFI_STATUS function(const EFI_HASH2_PROTOCOL* This, 121 | const UINT8* Message, UINTN MessageSize) @nogc nothrow; 122 | /** 123 | Finalizes a hash operation in progress and returns calculation result. 124 | The output is final with any necessary padding added by the function. 125 | The hash may not be further updated or extended after HashFinal(). 126 | 127 | @param[in] This Points to this instance of EFI_HASH2_PROTOCOL. 128 | @param[in,out] Hash On input, points to a caller-allocated buffer of the size 129 | returned by GetHashSize() for the specified HashAlgorithm specified in preceding HashInit(). 130 | On output, the buffer holds the resulting hash computed from the message. 131 | 132 | @retval EFI_SUCCESS Hash returned successfully. 133 | @retval EFI_INVALID_PARAMETER This or Hash is NULL. 134 | @retval EFI_NOT_READY This call was not preceded by a valid call to HashInit() and at least one call to HashUpdate(), 135 | or the operation in progress was canceled by a call to Hash() on the same instance. 136 | 137 | **/ 138 | alias EFI_HASH2_HASH_FINAL = EFI_STATUS function(const EFI_HASH2_PROTOCOL* This, 139 | EFI_HASH2_OUTPUT* Hash) @nogc nothrow; 140 | /// This protocol describes hashing functions for which the algorithm-required message padding and 141 | /// finalization are performed by the supporting driver. 142 | struct _EFI_HASH2_PROTOCOL 143 | { 144 | EFI_HASH2_GET_HASH_SIZE GetHashSize; 145 | EFI_HASH2_HASH Hash; 146 | EFI_HASH2_HASH_INIT HashInit; 147 | EFI_HASH2_HASH_UPDATE HashUpdate; 148 | EFI_HASH2_HASH_FINAL HashFinal; 149 | 150 | } 151 | -------------------------------------------------------------------------------- /source/uefi/protocols/loadedimage.d: -------------------------------------------------------------------------------- 1 | /** 2 | Based on Protocol/LoadedImage.h, original notice: 3 | 4 | UEFI 2.0 Loaded image protocol definition. 5 | 6 | Every EFI driver and application is passed an image handle when it is loaded. 7 | This image handle will contain a Loaded Image Protocol. 8 | 9 | Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved. 10 | This program and the accompanying materials 11 | are licensed and made available under the terms and conditions of the BSD License 12 | which accompanies this distribution. The full text of the license may be found at 13 | http://opensource.org/licenses/bsd-license.php 14 | 15 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 17 | 18 | **/ 19 | module uefi.protocols.loadedimage; 20 | import uefi.base; 21 | import uefi.base_type; 22 | import uefi.spec; 23 | import uefi.protocols.devicepath; 24 | 25 | public: 26 | extern (C): 27 | enum EFI_GUID EFI_LOADED_IMAGE_PROTOCOL_GUID = EFI_GUID(0x5B1B31A1, 0x9562, 28 | 0x11d2, [0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B]); 29 | enum EFI_GUID EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID = EFI_GUID(0xbc62157e, 30 | 0x3e33, 0x4fec, [0x99, 0x20, 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf]); 31 | /// Protocol GUID defined in EFI1.1. 32 | enum LOADED_IMAGE_PROTOCOL = EFI_LOADED_IMAGE_PROTOCOL_GUID; 33 | /// EFI_SYSTEM_TABLE & EFI_IMAGE_UNLOAD are defined in EfiApi.h 34 | enum EFI_LOADED_IMAGE_PROTOCOL_REVISION = 0x1000; 35 | /// Revision defined in EFI1.1. 36 | enum EFI_LOADED_IMAGE_INFORMATION_REVISION = EFI_LOADED_IMAGE_PROTOCOL_REVISION; 37 | /// Can be used on any image handle to obtain information about the loaded image. 38 | struct EFI_LOADED_IMAGE_PROTOCOL 39 | { 40 | UINT32 Revision; ///< Defines the revision of the EFI_LOADED_IMAGE_PROTOCOL structure. 41 | ///< All future revisions will be backward compatible to the current revision. 42 | EFI_HANDLE ParentHandle; ///< Parent image's image handle. NULL if the image is loaded directly from 43 | ///< the firmware's boot manager. 44 | EFI_SYSTEM_TABLE* SystemTable; ///< the image's EFI system table pointer. 45 | // 46 | // Source location of image 47 | // 48 | EFI_HANDLE DeviceHandle; ///< The device handle that the EFI Image was loaded from. 49 | EFI_DEVICE_PATH_PROTOCOL* FilePath; ///< A pointer to the file path portion specific to DeviceHandle 50 | ///< that the EFI Image was loaded from. 51 | VOID* Reserved; ///< Reserved. DO NOT USE. 52 | // 53 | // Images load options 54 | // 55 | UINT32 LoadOptionsSize; ///< The size in bytes of LoadOptions. 56 | VOID* LoadOptions; ///< A pointer to the image's binary load options. 57 | // 58 | // Location of where image was loaded 59 | // 60 | VOID* ImageBase; ///< The base address at which the image was loaded. 61 | UINT64 ImageSize; ///< The size in bytes of the loaded image. 62 | EFI_MEMORY_TYPE ImageCodeType; ///< The memory type that the code sections were loaded as. 63 | EFI_MEMORY_TYPE ImageDataType; ///< The memory type that the data sections were loaded as. 64 | EFI_IMAGE_UNLOAD Unload; 65 | } 66 | 67 | alias EFI_LOADED_IMAGE = EFI_LOADED_IMAGE_PROTOCOL; 68 | -------------------------------------------------------------------------------- /source/uefi/protocols/loadfile2.d: -------------------------------------------------------------------------------- 1 | /** 2 | Based on Protocol/LoadFile2.h, original notice: 3 | 4 | Load File protocol as defined in the UEFI 2.0 specification. 5 | 6 | Load file protocol exists to supports the addition of new boot devices, 7 | and to support booting from devices that do not map well to file system. 8 | Network boot is done via a LoadFile protocol. 9 | 10 | UEFI 2.0 can boot from any device that produces a LoadFile protocol. 11 | 12 | Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved. 13 | This program and the accompanying materials 14 | are licensed and made available under the terms and conditions of the BSD License 15 | which accompanies this distribution. The full text of the license may be found at 16 | http://opensource.org/licenses/bsd-license.php 17 | 18 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 19 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 20 | 21 | **/ 22 | module uefi.protocols.loadfile2; 23 | import uefi.base; 24 | import uefi.base_type; 25 | import uefi.protocols.devicepath; 26 | 27 | public: 28 | extern (C): 29 | enum EFI_GUID EFI_LOAD_FILE2_PROTOCOL_GUID = EFI_GUID(0x4006c0c1, 0xfcb3, 30 | 0x403e, [0x99, 0x6d, 0x4a, 0x6c, 0x87, 0x24, 0xe0, 0x6d]); 31 | /// Protocol Guid defined by UEFI2.1. 32 | enum LOAD_FILE2_PROTOCOL = EFI_LOAD_FILE2_PROTOCOL_GUID; 33 | alias EFI_LOAD_FILE2_PROTOCOL = _EFI_LOAD_FILE2_PROTOCOL; 34 | /** 35 | Causes the driver to load a specified file. 36 | 37 | @param This Protocol instance pointer. 38 | @param FilePath The device specific path of the file to load. 39 | @param BootPolicy Should always be FALSE. 40 | @param BufferSize On input the size of Buffer in bytes. On output with a return 41 | code of EFI_SUCCESS, the amount of data transferred to 42 | Buffer. On output with a return code of EFI_BUFFER_TOO_SMALL, 43 | the size of Buffer required to retrieve the requested file. 44 | @param Buffer The memory buffer to transfer the file to. IF Buffer is NULL, 45 | then no the size of the requested file is returned in 46 | BufferSize. 47 | 48 | @retval EFI_SUCCESS The file was loaded. 49 | @retval EFI_UNSUPPORTED BootPolicy is TRUE. 50 | @retval EFI_INVALID_PARAMETER FilePath is not a valid device path, or 51 | BufferSize is NULL. 52 | @retval EFI_NO_MEDIA No medium was present to load the file. 53 | @retval EFI_DEVICE_ERROR The file was not loaded due to a device error. 54 | @retval EFI_NO_RESPONSE The remote system did not respond. 55 | @retval EFI_NOT_FOUND The file was not found 56 | @retval EFI_ABORTED The file load process was manually canceled. 57 | @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the current 58 | directory entry. BufferSize has been updated with 59 | the size needed to complete the request. 60 | 61 | 62 | **/ 63 | alias EFI_LOAD_FILE2 = EFI_STATUS function(EFI_LOAD_FILE2_PROTOCOL* This, 64 | EFI_DEVICE_PATH_PROTOCOL* FilePath, BOOLEAN BootPolicy, UINTN* BufferSize, void* Buffer) @nogc nothrow; 65 | /// The EFI_LOAD_FILE_PROTOCOL is a simple protocol used to obtain files from arbitrary devices. 66 | struct _EFI_LOAD_FILE2_PROTOCOL 67 | { 68 | EFI_LOAD_FILE2 LoadFile; 69 | 70 | } 71 | -------------------------------------------------------------------------------- /source/uefi/protocols/simplefilesystem.d: -------------------------------------------------------------------------------- 1 | /** 2 | Based on Protocol/SimpleFileSystem.h, original notice: 3 | 4 | SimpleFileSystem protocol as defined in the UEFI 2.0 specification. 5 | 6 | The SimpleFileSystem protocol is the programmatic access to the FAT (12,16,32) 7 | file system specified in UEFI 2.0. It can also be used to abstract a file 8 | system other than FAT. 9 | 10 | UEFI 2.0 can boot from any valid EFI image contained in a SimpleFileSystem. 11 | 12 | Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved. 13 | This program and the accompanying materials are licensed and made available under 14 | the terms and conditions of the BSD License that accompanies this distribution. 15 | The full text of the license may be found at 16 | http://opensource.org/licenses/bsd-license.php. 17 | 18 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 19 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 20 | 21 | **/ 22 | module uefi.protocols.simplefilesystem; 23 | import uefi.base; 24 | import uefi.base_type; 25 | 26 | public: 27 | extern (C): 28 | enum EFI_GUID EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID = EFI_GUID(0x964e5b22, 29 | 0x6459, 0x11d2, [0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b]); 30 | alias EFI_SIMPLE_FILE_SYSTEM_PROTOCOL = _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL; 31 | alias EFI_FILE_PROTOCOL = _EFI_FILE_PROTOCOL; 32 | alias EFI_FILE_HANDLE = _EFI_FILE_PROTOCOL*; 33 | /// Protocol GUID name defined in EFI1.1. 34 | enum SIMPLE_FILE_SYSTEM_PROTOCOL = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID; 35 | /// Protocol name defined in EFI1.1. 36 | alias EFI_FILE_IO_INTERFACE = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL; 37 | alias EFI_FILE = EFI_FILE_PROTOCOL; 38 | /** 39 | Open the root directory on a volume. 40 | 41 | @param This A pointer to the volume to open the root directory. 42 | @param Root A pointer to the location to return the opened file handle for the 43 | root directory. 44 | 45 | @retval EFI_SUCCESS The device was opened. 46 | @retval EFI_UNSUPPORTED This volume does not support the requested file system type. 47 | @retval EFI_NO_MEDIA The device has no medium. 48 | @retval EFI_DEVICE_ERROR The device reported an error. 49 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted. 50 | @retval EFI_ACCESS_DENIED The service denied access to the file. 51 | @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources. 52 | @retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no 53 | longer supported. Any existing file handles for this volume are 54 | no longer valid. To access the files on the new medium, the 55 | volume must be reopened with OpenVolume(). 56 | 57 | **/ 58 | alias EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME = EFI_STATUS function( 59 | EFI_SIMPLE_FILE_SYSTEM_PROTOCOL* This, EFI_FILE_PROTOCOL** Root) @nogc nothrow; 60 | enum EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION = 0x00010000; 61 | /// Revision defined in EFI1.1 62 | enum EFI_FILE_IO_INTERFACE_REVISION = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION; 63 | struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL 64 | { 65 | /// 66 | /// The version of the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL. The version 67 | /// specified by this specification is 0x00010000. All future revisions 68 | /// must be backwards compatible. 69 | /// 70 | UINT64 Revision; 71 | EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME OpenVolume; 72 | 73 | } 74 | /** 75 | Opens a new file relative to the source file's location. 76 | 77 | @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file 78 | handle to the source location. This would typically be an open 79 | handle to a directory. 80 | @param NewHandle A pointer to the location to return the opened handle for the new 81 | file. 82 | @param FileName The Null-terminated string of the name of the file to be opened. 83 | The file name may contain the following path modifiers: "\", ".", 84 | and "..". 85 | @param OpenMode The mode to open the file. The only valid combinations that the 86 | file may be opened with are: Read, Read/Write, or Create/Read/Write. 87 | @param Attributes Only valid for EFI_FILE_MODE_CREATE, in which case these are the 88 | attribute bits for the newly created file. 89 | 90 | @retval EFI_SUCCESS The file was opened. 91 | @retval EFI_NOT_FOUND The specified file could not be found on the device. 92 | @retval EFI_NO_MEDIA The device has no medium. 93 | @retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no 94 | longer supported. 95 | @retval EFI_DEVICE_ERROR The device reported an error. 96 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted. 97 | @retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open a file for write 98 | when the media is write-protected. 99 | @retval EFI_ACCESS_DENIED The service denied access to the file. 100 | @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file. 101 | @retval EFI_VOLUME_FULL The volume is full. 102 | 103 | **/ 104 | alias EFI_FILE_OPEN = EFI_STATUS function(EFI_FILE_PROTOCOL* This, 105 | EFI_FILE_PROTOCOL** NewHandle, CHAR16* FileName, UINT64 OpenMode, UINT64 Attributes) @nogc nothrow; 106 | enum EFI_FILE_MODE_READ = 0x0000000000000001UL; 107 | enum EFI_FILE_MODE_WRITE = 0x0000000000000002UL; 108 | enum EFI_FILE_MODE_CREATE = 0x8000000000000000UL; 109 | enum EFI_FILE_READ_ONLY = 0x0000000000000001UL; 110 | enum EFI_FILE_HIDDEN = 0x0000000000000002UL; 111 | enum EFI_FILE_SYSTEM = 0x0000000000000004UL; 112 | enum EFI_FILE_RESERVED = 0x0000000000000008UL; 113 | enum EFI_FILE_DIRECTORY = 0x0000000000000010UL; 114 | enum EFI_FILE_ARCHIVE = 0x0000000000000020UL; 115 | enum EFI_FILE_VALID_ATTR = 0x0000000000000037UL; 116 | /** 117 | Closes a specified file handle. 118 | 119 | @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file 120 | handle to close. 121 | 122 | @retval EFI_SUCCESS The file was closed. 123 | 124 | **/ 125 | alias EFI_FILE_CLOSE = EFI_STATUS function(EFI_FILE_PROTOCOL* This) @nogc nothrow; 126 | /** 127 | Close and delete the file handle. 128 | 129 | @param This A pointer to the EFI_FILE_PROTOCOL instance that is the 130 | handle to the file to delete. 131 | 132 | @retval EFI_SUCCESS The file was closed and deleted, and the handle was closed. 133 | @retval EFI_WARN_DELETE_FAILURE The handle was closed, but the file was not deleted. 134 | 135 | **/ 136 | alias EFI_FILE_DELETE = EFI_STATUS function(EFI_FILE_PROTOCOL* This) @nogc nothrow; 137 | /** 138 | Reads data from a file. 139 | 140 | @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file 141 | handle to read data from. 142 | @param BufferSize On input, the size of the Buffer. On output, the amount of data 143 | returned in Buffer. In both cases, the size is measured in bytes. 144 | @param Buffer The buffer into which the data is read. 145 | 146 | @retval EFI_SUCCESS Data was read. 147 | @retval EFI_NO_MEDIA The device has no medium. 148 | @retval EFI_DEVICE_ERROR The device reported an error. 149 | @retval EFI_DEVICE_ERROR An attempt was made to read from a deleted file. 150 | @retval EFI_DEVICE_ERROR On entry, the current file position is beyond the end of the file. 151 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted. 152 | @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the current directory 153 | entry. BufferSize has been updated with the size 154 | needed to complete the request. 155 | 156 | **/ 157 | alias EFI_FILE_READ = EFI_STATUS function(EFI_FILE_PROTOCOL* This, UINTN* BufferSize, 158 | void* Buffer) @nogc nothrow; 159 | /** 160 | Writes data to a file. 161 | 162 | @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file 163 | handle to write data to. 164 | @param BufferSize On input, the size of the Buffer. On output, the amount of data 165 | actually written. In both cases, the size is measured in bytes. 166 | @param Buffer The buffer of data to write. 167 | 168 | @retval EFI_SUCCESS Data was written. 169 | @retval EFI_UNSUPPORTED Writes to open directory files are not supported. 170 | @retval EFI_NO_MEDIA The device has no medium. 171 | @retval EFI_DEVICE_ERROR The device reported an error. 172 | @retval EFI_DEVICE_ERROR An attempt was made to write to a deleted file. 173 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted. 174 | @retval EFI_WRITE_PROTECTED The file or medium is write-protected. 175 | @retval EFI_ACCESS_DENIED The file was opened read only. 176 | @retval EFI_VOLUME_FULL The volume is full. 177 | 178 | **/ 179 | alias EFI_FILE_WRITE = EFI_STATUS function(EFI_FILE_PROTOCOL* This, UINTN* BufferSize, 180 | void* Buffer) @nogc nothrow; 181 | /** 182 | Sets a file's current position. 183 | 184 | @param This A pointer to the EFI_FILE_PROTOCOL instance that is the 185 | file handle to set the requested position on. 186 | @param Position The byte position from the start of the file to set. 187 | 188 | @retval EFI_SUCCESS The position was set. 189 | @retval EFI_UNSUPPORTED The seek request for nonzero is not valid on open 190 | directories. 191 | @retval EFI_DEVICE_ERROR An attempt was made to set the position of a deleted file. 192 | 193 | **/ 194 | alias EFI_FILE_SET_POSITION = EFI_STATUS function(EFI_FILE_PROTOCOL* This, UINT64 Position) @nogc nothrow; 195 | /** 196 | Returns a file's current position. 197 | 198 | @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file 199 | handle to get the current position on. 200 | @param Position The address to return the file's current position value. 201 | 202 | @retval EFI_SUCCESS The position was returned. 203 | @retval EFI_UNSUPPORTED The request is not valid on open directories. 204 | @retval EFI_DEVICE_ERROR An attempt was made to get the position from a deleted file. 205 | 206 | **/ 207 | alias EFI_FILE_GET_POSITION = EFI_STATUS function(EFI_FILE_PROTOCOL* This, UINT64* Position) @nogc nothrow; 208 | /** 209 | Returns information about a file. 210 | 211 | @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file 212 | handle the requested information is for. 213 | @param InformationType The type identifier for the information being requested. 214 | @param BufferSize On input, the size of Buffer. On output, the amount of data 215 | returned in Buffer. In both cases, the size is measured in bytes. 216 | @param Buffer A pointer to the data buffer to return. The buffer's type is 217 | indicated by InformationType. 218 | 219 | @retval EFI_SUCCESS The information was returned. 220 | @retval EFI_UNSUPPORTED The InformationType is not known. 221 | @retval EFI_NO_MEDIA The device has no medium. 222 | @retval EFI_DEVICE_ERROR The device reported an error. 223 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted. 224 | @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the current directory entry. 225 | BufferSize has been updated with the size needed to complete 226 | the request. 227 | **/ 228 | alias EFI_FILE_GET_INFO = EFI_STATUS function(EFI_FILE_PROTOCOL* This, 229 | EFI_GUID* InformationType, UINTN* BufferSize, void* Buffer) @nogc nothrow; 230 | /** 231 | Sets information about a file. 232 | 233 | @param File A pointer to the EFI_FILE_PROTOCOL instance that is the file 234 | handle the information is for. 235 | @param InformationType The type identifier for the information being set. 236 | @param BufferSize The size, in bytes, of Buffer. 237 | @param Buffer A pointer to the data buffer to write. The buffer's type is 238 | indicated by InformationType. 239 | 240 | @retval EFI_SUCCESS The information was set. 241 | @retval EFI_UNSUPPORTED The InformationType is not known. 242 | @retval EFI_NO_MEDIA The device has no medium. 243 | @retval EFI_DEVICE_ERROR The device reported an error. 244 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted. 245 | @retval EFI_WRITE_PROTECTED InformationType is EFI_FILE_INFO_ID and the media is 246 | read-only. 247 | @retval EFI_WRITE_PROTECTED InformationType is EFI_FILE_PROTOCOL_SYSTEM_INFO_ID 248 | and the media is read only. 249 | @retval EFI_WRITE_PROTECTED InformationType is EFI_FILE_SYSTEM_VOLUME_LABEL_ID 250 | and the media is read-only. 251 | @retval EFI_ACCESS_DENIED An attempt is made to change the name of a file to a 252 | file that is already present. 253 | @retval EFI_ACCESS_DENIED An attempt is being made to change the EFI_FILE_DIRECTORY 254 | Attribute. 255 | @retval EFI_ACCESS_DENIED An attempt is being made to change the size of a directory. 256 | @retval EFI_ACCESS_DENIED InformationType is EFI_FILE_INFO_ID and the file was opened 257 | read-only and an attempt is being made to modify a field 258 | other than Attribute. 259 | @retval EFI_VOLUME_FULL The volume is full. 260 | @retval EFI_BAD_BUFFER_SIZE BufferSize is smaller than the size of the type indicated 261 | by InformationType. 262 | 263 | **/ 264 | alias EFI_FILE_SET_INFO = EFI_STATUS function(EFI_FILE_PROTOCOL* This, 265 | EFI_GUID* InformationType, UINTN BufferSize, void* Buffer) @nogc nothrow; 266 | /** 267 | Flushes all modified data associated with a file to a device. 268 | 269 | @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file 270 | handle to flush. 271 | 272 | @retval EFI_SUCCESS The data was flushed. 273 | @retval EFI_NO_MEDIA The device has no medium. 274 | @retval EFI_DEVICE_ERROR The device reported an error. 275 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted. 276 | @retval EFI_WRITE_PROTECTED The file or medium is write-protected. 277 | @retval EFI_ACCESS_DENIED The file was opened read-only. 278 | @retval EFI_VOLUME_FULL The volume is full. 279 | 280 | **/ 281 | alias EFI_FILE_FLUSH = EFI_STATUS function(EFI_FILE_PROTOCOL* This) @nogc nothrow; 282 | struct EFI_FILE_IO_TOKEN 283 | { 284 | // 285 | // If Event is NULL, then blocking I/O is performed. 286 | // If Event is not NULL and non-blocking I/O is supported, then non-blocking I/O is performed, 287 | // and Event will be signaled when the read request is completed. 288 | // The caller must be prepared to handle the case where the callback associated with Event 289 | // occurs before the original asynchronous I/O request call returns. 290 | // 291 | EFI_EVENT Event; 292 | // 293 | // Defines whether or not the signaled event encountered an error. 294 | // 295 | EFI_STATUS Status; 296 | // 297 | // For OpenEx(): Not Used, ignored. 298 | // For ReadEx(): On input, the size of the Buffer. On output, the amount of data returned in Buffer. 299 | // In both cases, the size is measured in bytes. 300 | // For WriteEx(): On input, the size of the Buffer. On output, the amount of data actually written. 301 | // In both cases, the size is measured in bytes. 302 | // For FlushEx(): Not used, ignored. 303 | // 304 | UINTN BufferSize; 305 | // 306 | // For OpenEx(): Not Used, ignored. 307 | // For ReadEx(): The buffer into which the data is read. 308 | // For WriteEx(): The buffer of data to write. 309 | // For FlushEx(): Not Used, ignored. 310 | // 311 | VOID* Buffer; 312 | } 313 | /** 314 | Opens a new file relative to the source directory's location. 315 | 316 | @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file 317 | handle to the source location. 318 | @param NewHandle A pointer to the location to return the opened handle for the new 319 | file. 320 | @param FileName The Null-terminated string of the name of the file to be opened. 321 | The file name may contain the following path modifiers: "\", ".", 322 | and "..". 323 | @param OpenMode The mode to open the file. The only valid combinations that the 324 | file may be opened with are: Read, Read/Write, or Create/Read/Write. 325 | @param Attributes Only valid for EFI_FILE_MODE_CREATE, in which case these are the 326 | attribute bits for the newly created file. 327 | @param Token A pointer to the token associated with the transaction. 328 | 329 | @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was read successfully. 330 | If Event is not NULL (asynchronous I/O): The request was successfully 331 | queued for processing. 332 | @retval EFI_NOT_FOUND The specified file could not be found on the device. 333 | @retval EFI_NO_MEDIA The device has no medium. 334 | @retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no 335 | longer supported. 336 | @retval EFI_DEVICE_ERROR The device reported an error. 337 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted. 338 | @retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open a file for write 339 | when the media is write-protected. 340 | @retval EFI_ACCESS_DENIED The service denied access to the file. 341 | @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file. 342 | @retval EFI_VOLUME_FULL The volume is full. 343 | 344 | **/ 345 | alias EFI_FILE_OPEN_EX = EFI_STATUS function(EFI_FILE_PROTOCOL* This, 346 | EFI_FILE_PROTOCOL** NewHandle, CHAR16* FileName, UINT64 OpenMode, 347 | UINT64 Attributes, EFI_FILE_IO_TOKEN* Token) @nogc nothrow; 348 | /** 349 | Reads data from a file. 350 | 351 | @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file handle to read data from. 352 | @param Token A pointer to the token associated with the transaction. 353 | 354 | @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was read successfully. 355 | If Event is not NULL (asynchronous I/O): The request was successfully 356 | queued for processing. 357 | @retval EFI_NO_MEDIA The device has no medium. 358 | @retval EFI_DEVICE_ERROR The device reported an error. 359 | @retval EFI_DEVICE_ERROR An attempt was made to read from a deleted file. 360 | @retval EFI_DEVICE_ERROR On entry, the current file position is beyond the end of the file. 361 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted. 362 | @retval EFI_OUT_OF_RESOURCES Unable to queue the request due to lack of resources. 363 | **/ 364 | alias EFI_FILE_READ_EX = EFI_STATUS function(EFI_FILE_PROTOCOL* This, EFI_FILE_IO_TOKEN* Token) @nogc nothrow; 365 | /** 366 | Writes data to a file. 367 | 368 | @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file handle to write data to. 369 | @param Token A pointer to the token associated with the transaction. 370 | 371 | @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was read successfully. 372 | If Event is not NULL (asynchronous I/O): The request was successfully 373 | queued for processing. 374 | @retval EFI_UNSUPPORTED Writes to open directory files are not supported. 375 | @retval EFI_NO_MEDIA The device has no medium. 376 | @retval EFI_DEVICE_ERROR The device reported an error. 377 | @retval EFI_DEVICE_ERROR An attempt was made to write to a deleted file. 378 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted. 379 | @retval EFI_WRITE_PROTECTED The file or medium is write-protected. 380 | @retval EFI_ACCESS_DENIED The file was opened read only. 381 | @retval EFI_VOLUME_FULL The volume is full. 382 | @retval EFI_OUT_OF_RESOURCES Unable to queue the request due to lack of resources. 383 | **/ 384 | alias EFI_FILE_WRITE_EX = EFI_STATUS function(EFI_FILE_PROTOCOL* This, EFI_FILE_IO_TOKEN* Token) @nogc nothrow; 385 | /** 386 | Flushes all modified data associated with a file to a device. 387 | 388 | @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file 389 | handle to flush. 390 | @param Token A pointer to the token associated with the transaction. 391 | 392 | @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was read successfully. 393 | If Event is not NULL (asynchronous I/O): The request was successfully 394 | queued for processing. 395 | @retval EFI_NO_MEDIA The device has no medium. 396 | @retval EFI_DEVICE_ERROR The device reported an error. 397 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted. 398 | @retval EFI_WRITE_PROTECTED The file or medium is write-protected. 399 | @retval EFI_ACCESS_DENIED The file was opened read-only. 400 | @retval EFI_VOLUME_FULL The volume is full. 401 | @retval EFI_OUT_OF_RESOURCES Unable to queue the request due to lack of resources. 402 | 403 | **/ 404 | alias EFI_FILE_FLUSH_EX = EFI_STATUS function(EFI_FILE_PROTOCOL* This, EFI_FILE_IO_TOKEN* Token) @nogc nothrow; 405 | enum EFI_FILE_PROTOCOL_REVISION = 0x00010000; 406 | enum EFI_FILE_PROTOCOL_REVISION2 = 0x00020000; 407 | enum EFI_FILE_PROTOCOL_LATEST_REVISION = EFI_FILE_PROTOCOL_REVISION2; 408 | enum EFI_FILE_REVISION = EFI_FILE_PROTOCOL_REVISION; 409 | /// The EFI_FILE_PROTOCOL provides file IO access to supported file systems. 410 | /// An EFI_FILE_PROTOCOL provides access to a file's or directory's contents, 411 | /// and is also a reference to a location in the directory tree of the file system 412 | /// in which the file resides. With any given file handle, other files may be opened 413 | /// relative to this file's location, yielding new file handles. 414 | struct _EFI_FILE_PROTOCOL 415 | { 416 | /// 417 | /// The version of the EFI_FILE_PROTOCOL interface. The version specified 418 | /// by this specification is EFI_FILE_PROTOCOL_LATEST_REVISION. 419 | /// Future versions are required to be backward compatible to version 1.0. 420 | /// 421 | UINT64 Revision; 422 | EFI_FILE_OPEN Open; 423 | EFI_FILE_CLOSE Close; 424 | EFI_FILE_DELETE Delete; 425 | EFI_FILE_READ Read; 426 | EFI_FILE_WRITE Write; 427 | EFI_FILE_GET_POSITION GetPosition; 428 | EFI_FILE_SET_POSITION SetPosition; 429 | EFI_FILE_GET_INFO GetInfo; 430 | EFI_FILE_SET_INFO SetInfo; 431 | EFI_FILE_FLUSH Flush; 432 | EFI_FILE_OPEN_EX OpenEx; 433 | EFI_FILE_READ_EX ReadEx; 434 | EFI_FILE_WRITE_EX WriteEx; 435 | EFI_FILE_FLUSH_EX FlushEx; 436 | 437 | } 438 | -------------------------------------------------------------------------------- /source/uefi/protocols/simplepointer.d: -------------------------------------------------------------------------------- 1 | /** 2 | Based on Protocol/SimplePointer.h, original notice: 3 | 4 | Simple Pointer protocol from the UEFI 2.0 specification. 5 | 6 | Abstraction of a very simple pointer device like a mouse or trackball. 7 | 8 | Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved. 9 | This program and the accompanying materials 10 | are licensed and made available under the terms and conditions of the BSD License 11 | which accompanies this distribution. The full text of the license may be found at 12 | http://opensource.org/licenses/bsd-license.php 13 | 14 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 16 | 17 | **/ 18 | module uefi.protocols.simplepointer; 19 | import uefi.base; 20 | import uefi.base_type; 21 | 22 | public: 23 | extern (C): 24 | enum EFI_GUID EFI_SIMPLE_POINTER_PROTOCOL_GUID = EFI_GUID(0x31878c87, 0xb75, 25 | 0x11d5, [0x9a, 0x4f, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d]); 26 | alias EFI_SIMPLE_POINTER_PROTOCOL = _EFI_SIMPLE_POINTER_PROTOCOL; 27 | struct EFI_SIMPLE_POINTER_STATE 28 | { 29 | /// 30 | /// The signed distance in counts that the pointer device has been moved along the x-axis. 31 | /// 32 | INT32 RelativeMovementX; 33 | /// 34 | /// The signed distance in counts that the pointer device has been moved along the y-axis. 35 | /// 36 | INT32 RelativeMovementY; 37 | /// 38 | /// The signed distance in counts that the pointer device has been moved along the z-axis. 39 | /// 40 | INT32 RelativeMovementZ; 41 | /// 42 | /// If TRUE, then the left button of the pointer device is being 43 | /// pressed. If FALSE, then the left button of the pointer device is not being pressed. 44 | /// 45 | BOOLEAN LeftButton; 46 | /// 47 | /// If TRUE, then the right button of the pointer device is being 48 | /// pressed. If FALSE, then the right button of the pointer device is not being pressed. 49 | /// 50 | BOOLEAN RightButton; 51 | } 52 | 53 | struct EFI_SIMPLE_POINTER_MODE 54 | { 55 | /// 56 | /// The resolution of the pointer device on the x-axis in counts/mm. 57 | /// If 0, then the pointer device does not support an x-axis. 58 | /// 59 | UINT64 ResolutionX; 60 | /// 61 | /// The resolution of the pointer device on the y-axis in counts/mm. 62 | /// If 0, then the pointer device does not support an x-axis. 63 | /// 64 | UINT64 ResolutionY; 65 | /// 66 | /// The resolution of the pointer device on the z-axis in counts/mm. 67 | /// If 0, then the pointer device does not support an x-axis. 68 | /// 69 | UINT64 ResolutionZ; 70 | /// 71 | /// TRUE if a left button is present on the pointer device. Otherwise FALSE. 72 | /// 73 | BOOLEAN LeftButton; 74 | /// 75 | /// TRUE if a right button is present on the pointer device. Otherwise FALSE. 76 | /// 77 | BOOLEAN RightButton; 78 | } 79 | /** 80 | Resets the pointer device hardware. 81 | 82 | @param This A pointer to the EFI_SIMPLE_POINTER_PROTOCOL 83 | instance. 84 | @param ExtendedVerification Indicates that the driver may perform a more exhaustive 85 | verification operation of the device during reset. 86 | 87 | @retval EFI_SUCCESS The device was reset. 88 | @retval EFI_DEVICE_ERROR The device is not functioning correctly and could not be reset. 89 | 90 | **/ 91 | alias EFI_SIMPLE_POINTER_RESET = EFI_STATUS function( 92 | EFI_SIMPLE_POINTER_PROTOCOL* This, BOOLEAN ExtendedVerification) @nogc nothrow; 93 | /** 94 | Retrieves the current state of a pointer device. 95 | 96 | @param This A pointer to the EFI_SIMPLE_POINTER_PROTOCOL 97 | instance. 98 | @param State A pointer to the state information on the pointer device. 99 | 100 | @retval EFI_SUCCESS The state of the pointer device was returned in State. 101 | @retval EFI_NOT_READY The state of the pointer device has not changed since the last call to 102 | GetState(). 103 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to retrieve the pointer device's 104 | current state. 105 | 106 | **/ 107 | alias EFI_SIMPLE_POINTER_GET_STATE = EFI_STATUS function( 108 | EFI_SIMPLE_POINTER_PROTOCOL* This, EFI_SIMPLE_POINTER_STATE* State) @nogc nothrow; 109 | /// The EFI_SIMPLE_POINTER_PROTOCOL provides a set of services for a pointer 110 | /// device that can use used as an input device from an application written 111 | /// to this specification. The services include the ability to reset the 112 | /// pointer device, retrieve get the state of the pointer device, and 113 | /// retrieve the capabilities of the pointer device. 114 | struct _EFI_SIMPLE_POINTER_PROTOCOL 115 | { 116 | EFI_SIMPLE_POINTER_RESET Reset; 117 | EFI_SIMPLE_POINTER_GET_STATE GetState; 118 | /// 119 | /// Event to use with WaitForEvent() to wait for input from the pointer device. 120 | /// 121 | EFI_EVENT WaitForInput; 122 | /// 123 | /// Pointer to EFI_SIMPLE_POINTER_MODE data. 124 | /// 125 | EFI_SIMPLE_POINTER_MODE* Mode; 126 | 127 | } 128 | -------------------------------------------------------------------------------- /source/uefi/protocols/simpletextin.d: -------------------------------------------------------------------------------- 1 | /** 2 | Based on Protocol/SimpleTextIn.h, original notice: 3 | 4 | Simple Text Input protocol from the UEFI 2.0 specification. 5 | 6 | Abstraction of a very simple input device like a keyboard or serial 7 | terminal. 8 | 9 | Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved. 10 | This program and the accompanying materials 11 | are licensed and made available under the terms and conditions of the BSD License 12 | which accompanies this distribution. The full text of the license may be found at 13 | http://opensource.org/licenses/bsd-license.php 14 | 15 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 17 | 18 | **/ 19 | module uefi.protocols.simpletextin; 20 | import uefi.base; 21 | import uefi.base_type; 22 | 23 | public: 24 | extern (C): 25 | enum EFI_GUID EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID = EFI_GUID(0x387477c1, 26 | 0x69c7, 0x11d2, [0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b]); 27 | alias EFI_SIMPLE_TEXT_INPUT_PROTOCOL = _EFI_SIMPLE_TEXT_INPUT_PROTOCOL; 28 | /// Protocol GUID name defined in EFI1.1. 29 | enum SIMPLE_INPUT_PROTOCOL = EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID; 30 | /// Protocol name in EFI1.1 for backward-compatible. 31 | alias SIMPLE_INPUT_INTERFACE = _EFI_SIMPLE_TEXT_INPUT_PROTOCOL; 32 | /// The keystroke information for the key that was pressed. 33 | struct EFI_INPUT_KEY 34 | { 35 | UINT16 ScanCode; 36 | CHAR16 UnicodeChar; 37 | } 38 | 39 | enum CHAR_NULL = 0x0000; 40 | enum CHAR_BACKSPACE = 0x0008; 41 | enum CHAR_TAB = 0x0009; 42 | enum CHAR_LINEFEED = 0x000A; 43 | enum CHAR_CARRIAGE_RETURN = 0x000D; 44 | enum SCAN_NULL = 0x0000; 45 | enum SCAN_UP = 0x0001; 46 | enum SCAN_DOWN = 0x0002; 47 | enum SCAN_RIGHT = 0x0003; 48 | enum SCAN_LEFT = 0x0004; 49 | enum SCAN_HOME = 0x0005; 50 | enum SCAN_END = 0x0006; 51 | enum SCAN_INSERT = 0x0007; 52 | enum SCAN_DELETE = 0x0008; 53 | enum SCAN_PAGE_UP = 0x0009; 54 | enum SCAN_PAGE_DOWN = 0x000A; 55 | enum SCAN_F1 = 0x000B; 56 | enum SCAN_F2 = 0x000C; 57 | enum SCAN_F3 = 0x000D; 58 | enum SCAN_F4 = 0x000E; 59 | enum SCAN_F5 = 0x000F; 60 | enum SCAN_F6 = 0x0010; 61 | enum SCAN_F7 = 0x0011; 62 | enum SCAN_F8 = 0x0012; 63 | enum SCAN_F9 = 0x0013; 64 | enum SCAN_F10 = 0x0014; 65 | enum SCAN_ESC = 0x0017; 66 | /** 67 | Reset the input device and optionally run diagnostics 68 | 69 | @param This Protocol instance pointer. 70 | @param ExtendedVerification Driver may perform diagnostics on reset. 71 | 72 | @retval EFI_SUCCESS The device was reset. 73 | @retval EFI_DEVICE_ERROR The device is not functioning properly and could not be reset. 74 | 75 | **/ 76 | alias EFI_INPUT_RESET = EFI_STATUS function(EFI_SIMPLE_TEXT_INPUT_PROTOCOL* This, 77 | BOOLEAN ExtendedVerification) @nogc nothrow; 78 | /** 79 | Reads the next keystroke from the input device. The WaitForKey Event can 80 | be used to test for existence of a keystroke via WaitForEvent () call. 81 | 82 | @param This Protocol instance pointer. 83 | @param Key A pointer to a buffer that is filled in with the keystroke 84 | information for the key that was pressed. 85 | 86 | @retval EFI_SUCCESS The keystroke information was returned. 87 | @retval EFI_NOT_READY There was no keystroke data available. 88 | @retval EFI_DEVICE_ERROR The keystroke information was not returned due to 89 | hardware errors. 90 | 91 | **/ 92 | alias EFI_INPUT_READ_KEY = EFI_STATUS function( 93 | EFI_SIMPLE_TEXT_INPUT_PROTOCOL* This, EFI_INPUT_KEY* Key) @nogc nothrow; 94 | /// The EFI_SIMPLE_TEXT_INPUT_PROTOCOL is used on the ConsoleIn device. 95 | /// It is the minimum required protocol for ConsoleIn. 96 | struct _EFI_SIMPLE_TEXT_INPUT_PROTOCOL 97 | { 98 | EFI_INPUT_RESET Reset; 99 | EFI_INPUT_READ_KEY ReadKeyStroke; 100 | /// 101 | /// Event to use with WaitForEvent() to wait for a key to be available 102 | /// 103 | EFI_EVENT WaitForKey; 104 | } 105 | -------------------------------------------------------------------------------- /source/uefi/protocols/simpletextinex.d: -------------------------------------------------------------------------------- 1 | /** 2 | Based on Protocol/SimpleTextInEx.h, original notice: 3 | 4 | Simple Text Input Ex protocol from the UEFI 2.0 specification. 5 | 6 | This protocol defines an extension to the EFI_SIMPLE_TEXT_INPUT_PROTOCOL 7 | which exposes much more state and modifier information from the input device, 8 | also allows one to register a notification for a particular keystroke. 9 | 10 | Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved. 11 | This program and the accompanying materials 12 | are licensed and made available under the terms and conditions of the BSD License 13 | which accompanies this distribution. The full text of the license may be found at 14 | http://opensource.org/licenses/bsd-license.php 15 | 16 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 17 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 18 | 19 | **/ 20 | module uefi.protocols.simpletextinex; 21 | import uefi.base; 22 | import uefi.base_type; 23 | import uefi.protocols.simpletextin; 24 | 25 | public: 26 | extern (C): 27 | 28 | enum EFI_GUID EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID = EFI_GUID(0xdd9e7534, 29 | 0x7762, 0x4698, [0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa]); 30 | /** 31 | The Reset() function resets the input device hardware. As part 32 | of initialization process, the firmware/device will make a quick 33 | but reasonable attempt to verify that the device is functioning. 34 | If the ExtendedVerification flag is TRUE the firmware may take 35 | an extended amount of time to verify the device is operating on 36 | reset. Otherwise the reset operation is to occur as quickly as 37 | possible. The hardware verification process is not defined by 38 | this specification and is left up to the platform firmware or 39 | driver to implement. 40 | 41 | @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance. 42 | 43 | @param ExtendedVerification Indicates that the driver may 44 | perform a more exhaustive 45 | verification operation of the 46 | device during reset. 47 | 48 | 49 | @retval EFI_SUCCESS The device was reset. 50 | 51 | @retval EFI_DEVICE_ERROR The device is not functioning 52 | correctly and could not be reset. 53 | 54 | **/ 55 | alias EFI_INPUT_RESET_EX = EFI_STATUS function( 56 | EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL* This, BOOLEAN ExtendedVerification) @nogc nothrow; 57 | /// EFI_KEY_TOGGLE_STATE. The toggle states are defined. 58 | /// They are: EFI_TOGGLE_STATE_VALID, EFI_SCROLL_LOCK_ACTIVE 59 | /// EFI_NUM_LOCK_ACTIVE, EFI_CAPS_LOCK_ACTIVE 60 | alias EFI_KEY_TOGGLE_STATE = UINT8; 61 | struct EFI_KEY_STATE 62 | { 63 | /// 64 | /// Reflects the currently pressed shift 65 | /// modifiers for the input device. The 66 | /// returned value is valid only if the high 67 | /// order bit has been set. 68 | /// 69 | UINT32 KeyShiftState; 70 | /// 71 | /// Reflects the current internal state of 72 | /// various toggled attributes. The returned 73 | /// value is valid only if the high order 74 | /// bit has been set. 75 | /// 76 | EFI_KEY_TOGGLE_STATE KeyToggleState; 77 | } 78 | 79 | struct EFI_KEY_DATA 80 | { 81 | /// 82 | /// The EFI scan code and Unicode value returned from the input device. 83 | /// 84 | EFI_INPUT_KEY Key; 85 | /// 86 | /// The current state of various toggled attributes as well as input modifier values. 87 | /// 88 | EFI_KEY_STATE KeyState; 89 | } 90 | 91 | enum EFI_SHIFT_STATE_VALID = 0x80000000; 92 | enum EFI_RIGHT_SHIFT_PRESSED = 0x00000001; 93 | enum EFI_LEFT_SHIFT_PRESSED = 0x00000002; 94 | enum EFI_RIGHT_CONTROL_PRESSED = 0x00000004; 95 | enum EFI_LEFT_CONTROL_PRESSED = 0x00000008; 96 | enum EFI_RIGHT_ALT_PRESSED = 0x00000010; 97 | enum EFI_LEFT_ALT_PRESSED = 0x00000020; 98 | enum EFI_RIGHT_LOGO_PRESSED = 0x00000040; 99 | enum EFI_LEFT_LOGO_PRESSED = 0x00000080; 100 | enum EFI_MENU_KEY_PRESSED = 0x00000100; 101 | enum EFI_SYS_REQ_PRESSED = 0x00000200; 102 | enum EFI_TOGGLE_STATE_VALID = 0x80; 103 | enum EFI_KEY_STATE_EXPOSED = 0x40; 104 | enum EFI_SCROLL_LOCK_ACTIVE = 0x01; 105 | enum EFI_NUM_LOCK_ACTIVE = 0x02; 106 | enum EFI_CAPS_LOCK_ACTIVE = 0x04; 107 | enum SCAN_F11 = 0x0015; 108 | enum SCAN_F12 = 0x0016; 109 | enum SCAN_PAUSE = 0x0048; 110 | enum SCAN_F13 = 0x0068; 111 | enum SCAN_F14 = 0x0069; 112 | enum SCAN_F15 = 0x006A; 113 | enum SCAN_F16 = 0x006B; 114 | enum SCAN_F17 = 0x006C; 115 | enum SCAN_F18 = 0x006D; 116 | enum SCAN_F19 = 0x006E; 117 | enum SCAN_F20 = 0x006F; 118 | enum SCAN_F21 = 0x0070; 119 | enum SCAN_F22 = 0x0071; 120 | enum SCAN_F23 = 0x0072; 121 | enum SCAN_F24 = 0x0073; 122 | enum SCAN_MUTE = 0x007F; 123 | enum SCAN_VOLUME_UP = 0x0080; 124 | enum SCAN_VOLUME_DOWN = 0x0081; 125 | enum SCAN_BRIGHTNESS_UP = 0x0100; 126 | enum SCAN_BRIGHTNESS_DOWN = 0x0101; 127 | enum SCAN_SUSPEND = 0x0102; 128 | enum SCAN_HIBERNATE = 0x0103; 129 | enum SCAN_TOGGLE_DISPLAY = 0x0104; 130 | enum SCAN_RECOVERY = 0x0105; 131 | enum SCAN_EJECT = 0x0106; 132 | /** 133 | The function reads the next keystroke from the input device. If 134 | there is no pending keystroke the function returns 135 | EFI_NOT_READY. If there is a pending keystroke, then 136 | KeyData.Key.ScanCode is the EFI scan code defined in Error! 137 | Reference source not found. The KeyData.Key.UnicodeChar is the 138 | actual printable character or is zero if the key does not 139 | represent a printable character (control key, function key, 140 | etc.). The KeyData.KeyState is shift state for the character 141 | reflected in KeyData.Key.UnicodeChar or KeyData.Key.ScanCode . 142 | When interpreting the data from this function, it should be 143 | noted that if a class of printable characters that are 144 | normally adjusted by shift modifiers (e.g. Shift Key + "f" 145 | key) would be presented solely as a KeyData.Key.UnicodeChar 146 | without the associated shift state. So in the previous example 147 | of a Shift Key + "f" key being pressed, the only pertinent 148 | data returned would be KeyData.Key.UnicodeChar with the value 149 | of "F". This of course would not typically be the case for 150 | non-printable characters such as the pressing of the Right 151 | Shift Key + F10 key since the corresponding returned data 152 | would be reflected both in the KeyData.KeyState.KeyShiftState 153 | and KeyData.Key.ScanCode values. UEFI drivers which implement 154 | the EFI_SIMPLE_TEXT_INPUT_EX protocol are required to return 155 | KeyData.Key and KeyData.KeyState values. These drivers must 156 | always return the most current state of 157 | KeyData.KeyState.KeyShiftState and 158 | KeyData.KeyState.KeyToggleState. It should also be noted that 159 | certain input devices may not be able to produce shift or toggle 160 | state information, and in those cases the high order bit in the 161 | respective Toggle and Shift state fields should not be active. 162 | 163 | 164 | @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance. 165 | 166 | @param KeyData A pointer to a buffer that is filled in with 167 | the keystroke state data for the key that was 168 | pressed. 169 | 170 | 171 | @retval EFI_SUCCESS The keystroke information was 172 | returned. 173 | 174 | @retval EFI_NOT_READY There was no keystroke data available. 175 | EFI_DEVICE_ERROR The keystroke 176 | information was not returned due to 177 | hardware errors. 178 | 179 | 180 | **/ 181 | alias EFI_INPUT_READ_KEY_EX = EFI_STATUS function( 182 | EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL* This, EFI_KEY_DATA* KeyData) @nogc nothrow; 183 | /** 184 | The SetState() function allows the input device hardware to 185 | have state settings adjusted. 186 | 187 | @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance. 188 | 189 | @param KeyToggleState Pointer to the EFI_KEY_TOGGLE_STATE to 190 | set the state for the input device. 191 | 192 | 193 | @retval EFI_SUCCESS The device state was set appropriately. 194 | 195 | @retval EFI_DEVICE_ERROR The device is not functioning 196 | correctly and could not have the 197 | setting adjusted. 198 | 199 | @retval EFI_UNSUPPORTED The device does not support the 200 | ability to have its state set. 201 | 202 | **/ 203 | alias EFI_SET_STATE = EFI_STATUS function(EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL* This, 204 | EFI_KEY_TOGGLE_STATE* KeyToggleState) @nogc nothrow; 205 | /// The function will be called when the key sequence is typed specified by KeyData. 206 | alias EFI_KEY_NOTIFY_FUNCTION = EFI_STATUS function(EFI_KEY_DATA* KeyData) @nogc nothrow; 207 | /** 208 | The RegisterKeystrokeNotify() function registers a function 209 | which will be called when a specified keystroke will occur. 210 | 211 | @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance. 212 | 213 | @param KeyData A pointer to a buffer that is filled in with 214 | the keystroke information for the key that was 215 | pressed. 216 | 217 | @param KeyNotificationFunction Points to the function to be 218 | called when the key sequence 219 | is typed specified by KeyData. 220 | 221 | 222 | @param NotifyHandle Points to the unique handle assigned to 223 | the registered notification. 224 | 225 | @retval EFI_SUCCESS The device state was set 226 | appropriately. 227 | 228 | @retval EFI_OUT_OF_RESOURCES Unable to allocate necessary 229 | data structures. 230 | 231 | **/ 232 | alias EFI_REGISTER_KEYSTROKE_NOTIFY = EFI_STATUS function( 233 | EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL* This, EFI_KEY_DATA* KeyData, 234 | EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction, void** NotifyHandle) @nogc nothrow; 235 | /** 236 | The UnregisterKeystrokeNotify() function removes the 237 | notification which was previously registered. 238 | 239 | @param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance. 240 | 241 | @param NotificationHandle The handle of the notification 242 | function being unregistered. 243 | 244 | @retval EFI_SUCCESS The device state was set appropriately. 245 | 246 | @retval EFI_INVALID_PARAMETER The NotificationHandle is 247 | invalid. 248 | 249 | **/ 250 | alias EFI_UNREGISTER_KEYSTROKE_NOTIFY = EFI_STATUS function( 251 | EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL* This, void* NotificationHandle) @nogc nothrow; 252 | /// The EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL is used on the ConsoleIn 253 | /// device. It is an extension to the Simple Text Input protocol 254 | /// which allows a variety of extended shift state information to be 255 | /// returned. 256 | struct EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL 257 | { 258 | EFI_INPUT_RESET_EX Reset; 259 | EFI_INPUT_READ_KEY_EX ReadKeyStrokeEx; 260 | /// 261 | /// Event to use with WaitForEvent() to wait for a key to be available. 262 | /// 263 | EFI_EVENT WaitForKeyEx; 264 | EFI_SET_STATE SetState; 265 | EFI_REGISTER_KEYSTROKE_NOTIFY RegisterKeyNotify; 266 | EFI_UNREGISTER_KEYSTROKE_NOTIFY UnregisterKeyNotify; 267 | 268 | } 269 | -------------------------------------------------------------------------------- /source/uefi/protocols/simpletextout.d: -------------------------------------------------------------------------------- 1 | /** 2 | Based on Protocol/SimpleTextOut.h, original notice: 3 | 4 | Simple Text Out protocol from the UEFI 2.0 specification. 5 | 6 | Abstraction of a very simple text based output device like VGA text mode or 7 | a serial terminal. The Simple Text Out protocol instance can represent 8 | a single hardware device or a virtual device that is an aggregation 9 | of multiple physical devices. 10 | 11 | Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved. 12 | This program and the accompanying materials are licensed and made available under 13 | the terms and conditions of the BSD License that accompanies this distribution. 14 | The full text of the license may be found at 15 | http://opensource.org/licenses/bsd-license.php. 16 | 17 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 19 | 20 | **/ 21 | module uefi.protocols.simpletextout; 22 | import uefi.base; 23 | import uefi.base_type; 24 | 25 | public: 26 | extern (C): 27 | enum EFI_GUID EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID = EFI_GUID(0x387477c2, 28 | 0x69c7, 0x11d2, [0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b]); 29 | /// Protocol GUID defined in EFI1.1. 30 | enum SIMPLE_TEXT_OUTPUT_PROTOCOL = EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID; 31 | alias EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL = _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL; 32 | /// Backward-compatible with EFI1.1. 33 | alias SIMPLE_TEXT_OUTPUT_INTERFACE = EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL; 34 | enum BOXDRAW_HORIZONTAL = 0x2500; 35 | enum BOXDRAW_VERTICAL = 0x2502; 36 | enum BOXDRAW_DOWN_RIGHT = 0x250c; 37 | enum BOXDRAW_DOWN_LEFT = 0x2510; 38 | enum BOXDRAW_UP_RIGHT = 0x2514; 39 | enum BOXDRAW_UP_LEFT = 0x2518; 40 | enum BOXDRAW_VERTICAL_RIGHT = 0x251c; 41 | enum BOXDRAW_VERTICAL_LEFT = 0x2524; 42 | enum BOXDRAW_DOWN_HORIZONTAL = 0x252c; 43 | enum BOXDRAW_UP_HORIZONTAL = 0x2534; 44 | enum BOXDRAW_VERTICAL_HORIZONTAL = 0x253c; 45 | enum BOXDRAW_DOUBLE_HORIZONTAL = 0x2550; 46 | enum BOXDRAW_DOUBLE_VERTICAL = 0x2551; 47 | enum BOXDRAW_DOWN_RIGHT_DOUBLE = 0x2552; 48 | enum BOXDRAW_DOWN_DOUBLE_RIGHT = 0x2553; 49 | enum BOXDRAW_DOUBLE_DOWN_RIGHT = 0x2554; 50 | enum BOXDRAW_DOWN_LEFT_DOUBLE = 0x2555; 51 | enum BOXDRAW_DOWN_DOUBLE_LEFT = 0x2556; 52 | enum BOXDRAW_DOUBLE_DOWN_LEFT = 0x2557; 53 | enum BOXDRAW_UP_RIGHT_DOUBLE = 0x2558; 54 | enum BOXDRAW_UP_DOUBLE_RIGHT = 0x2559; 55 | enum BOXDRAW_DOUBLE_UP_RIGHT = 0x255a; 56 | enum BOXDRAW_UP_LEFT_DOUBLE = 0x255b; 57 | enum BOXDRAW_UP_DOUBLE_LEFT = 0x255c; 58 | enum BOXDRAW_DOUBLE_UP_LEFT = 0x255d; 59 | enum BOXDRAW_VERTICAL_RIGHT_DOUBLE = 0x255e; 60 | enum BOXDRAW_VERTICAL_DOUBLE_RIGHT = 0x255f; 61 | enum BOXDRAW_DOUBLE_VERTICAL_RIGHT = 0x2560; 62 | enum BOXDRAW_VERTICAL_LEFT_DOUBLE = 0x2561; 63 | enum BOXDRAW_VERTICAL_DOUBLE_LEFT = 0x2562; 64 | enum BOXDRAW_DOUBLE_VERTICAL_LEFT = 0x2563; 65 | enum BOXDRAW_DOWN_HORIZONTAL_DOUBLE = 0x2564; 66 | enum BOXDRAW_DOWN_DOUBLE_HORIZONTAL = 0x2565; 67 | enum BOXDRAW_DOUBLE_DOWN_HORIZONTAL = 0x2566; 68 | enum BOXDRAW_UP_HORIZONTAL_DOUBLE = 0x2567; 69 | enum BOXDRAW_UP_DOUBLE_HORIZONTAL = 0x2568; 70 | enum BOXDRAW_DOUBLE_UP_HORIZONTAL = 0x2569; 71 | enum BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE = 0x256a; 72 | enum BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL = 0x256b; 73 | enum BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL = 0x256c; 74 | enum BLOCKELEMENT_FULL_BLOCK = 0x2588; 75 | enum BLOCKELEMENT_LIGHT_SHADE = 0x2591; 76 | enum GEOMETRICSHAPE_UP_TRIANGLE = 0x25b2; 77 | enum GEOMETRICSHAPE_RIGHT_TRIANGLE = 0x25ba; 78 | enum GEOMETRICSHAPE_DOWN_TRIANGLE = 0x25bc; 79 | enum GEOMETRICSHAPE_LEFT_TRIANGLE = 0x25c4; 80 | enum ARROW_LEFT = 0x2190; 81 | enum ARROW_UP = 0x2191; 82 | enum ARROW_RIGHT = 0x2192; 83 | enum ARROW_DOWN = 0x2193; 84 | enum EFI_BLACK = 0x00; 85 | enum EFI_BLUE = 0x01; 86 | enum EFI_GREEN = 0x02; 87 | enum EFI_CYAN = (EFI_BLUE | EFI_GREEN); 88 | enum EFI_RED = 0x04; 89 | enum EFI_MAGENTA = (EFI_BLUE | EFI_RED); 90 | enum EFI_BROWN = (EFI_GREEN | EFI_RED); 91 | enum EFI_LIGHTGRAY = (EFI_BLUE | EFI_GREEN | EFI_RED); 92 | enum EFI_BRIGHT = 0x08; 93 | enum EFI_DARKGRAY = (EFI_BLACK | EFI_BRIGHT); 94 | enum EFI_LIGHTBLUE = (EFI_BLUE | EFI_BRIGHT); 95 | enum EFI_LIGHTGREEN = (EFI_GREEN | EFI_BRIGHT); 96 | enum EFI_LIGHTCYAN = (EFI_CYAN | EFI_BRIGHT); 97 | enum EFI_LIGHTRED = (EFI_RED | EFI_BRIGHT); 98 | enum EFI_LIGHTMAGENTA = (EFI_MAGENTA | EFI_BRIGHT); 99 | enum EFI_YELLOW = (EFI_BROWN | EFI_BRIGHT); 100 | enum EFI_WHITE = (EFI_BLUE | EFI_GREEN | EFI_RED | EFI_BRIGHT); 101 | // #define EFI_TEXT_ATTR(Foreground,Background) ((Foreground) | ((Background) << 4)) 102 | enum EFI_BACKGROUND_BLACK = 0x00; 103 | enum EFI_BACKGROUND_BLUE = 0x10; 104 | enum EFI_BACKGROUND_GREEN = 0x20; 105 | enum EFI_BACKGROUND_CYAN = (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN); 106 | enum EFI_BACKGROUND_RED = 0x40; 107 | enum EFI_BACKGROUND_MAGENTA = (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_RED); 108 | enum EFI_BACKGROUND_BROWN = (EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED); 109 | enum EFI_BACKGROUND_LIGHTGRAY = (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED); 110 | enum EFI_WIDE_ATTRIBUTE = 0x80; 111 | /** 112 | Reset the text output device hardware and optionaly run diagnostics 113 | 114 | @param This The protocol instance pointer. 115 | @param ExtendedVerification Driver may perform more exhaustive verfication 116 | operation of the device during reset. 117 | 118 | @retval EFI_SUCCESS The text output device was reset. 119 | @retval EFI_DEVICE_ERROR The text output device is not functioning correctly and 120 | could not be reset. 121 | 122 | **/ 123 | alias EFI_TEXT_RESET = EFI_STATUS function(EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* This, 124 | BOOLEAN ExtendedVerification) @nogc nothrow; 125 | /** 126 | Write a string to the output device. 127 | 128 | @param This The protocol instance pointer. 129 | @param String The NULL-terminated string to be displayed on the output 130 | device(s). All output devices must also support the Unicode 131 | drawing character codes defined in this file. 132 | 133 | @retval EFI_SUCCESS The string was output to the device. 134 | @retval EFI_DEVICE_ERROR The device reported an error while attempting to output 135 | the text. 136 | @retval EFI_UNSUPPORTED The output device's mode is not currently in a 137 | defined text mode. 138 | @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the 139 | characters in the string could not be 140 | rendered and were skipped. 141 | 142 | **/ 143 | alias EFI_TEXT_STRING = EFI_STATUS function(EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* This, 144 | CHAR16* String) @nogc nothrow; 145 | /** 146 | Verifies that all characters in a string can be output to the 147 | target device. 148 | 149 | @param This The protocol instance pointer. 150 | @param String The NULL-terminated string to be examined for the output 151 | device(s). 152 | 153 | @retval EFI_SUCCESS The device(s) are capable of rendering the output string. 154 | @retval EFI_UNSUPPORTED Some of the characters in the string cannot be 155 | rendered by one or more of the output devices mapped 156 | by the EFI handle. 157 | 158 | **/ 159 | alias EFI_TEXT_TEST_STRING = EFI_STATUS function( 160 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* This, CHAR16* String) @nogc nothrow; 161 | /** 162 | Returns information for an available text mode that the output device(s) 163 | supports. 164 | 165 | @param This The protocol instance pointer. 166 | @param ModeNumber The mode number to return information on. 167 | @param Columns Returns the geometry of the text output device for the 168 | requested ModeNumber. 169 | @param Rows Returns the geometry of the text output device for the 170 | requested ModeNumber. 171 | 172 | @retval EFI_SUCCESS The requested mode information was returned. 173 | @retval EFI_DEVICE_ERROR The device had an error and could not complete the request. 174 | @retval EFI_UNSUPPORTED The mode number was not valid. 175 | 176 | **/ 177 | alias EFI_TEXT_QUERY_MODE = EFI_STATUS function( 178 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* This, UINTN ModeNumber, UINTN* Columns, UINTN* Rows) @nogc nothrow; 179 | /** 180 | Sets the output device(s) to a specified mode. 181 | 182 | @param This The protocol instance pointer. 183 | @param ModeNumber The mode number to set. 184 | 185 | @retval EFI_SUCCESS The requested text mode was set. 186 | @retval EFI_DEVICE_ERROR The device had an error and could not complete the request. 187 | @retval EFI_UNSUPPORTED The mode number was not valid. 188 | 189 | **/ 190 | alias EFI_TEXT_SET_MODE = EFI_STATUS function( 191 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* This, UINTN ModeNumber) @nogc nothrow; 192 | /** 193 | Sets the background and foreground colors for the OutputString () and 194 | ClearScreen () functions. 195 | 196 | @param This The protocol instance pointer. 197 | @param Attribute The attribute to set. Bits 0..3 are the foreground color, and 198 | bits 4..6 are the background color. All other bits are undefined 199 | and must be zero. The valid Attributes are defined in this file. 200 | 201 | @retval EFI_SUCCESS The attribute was set. 202 | @retval EFI_DEVICE_ERROR The device had an error and could not complete the request. 203 | @retval EFI_UNSUPPORTED The attribute requested is not defined. 204 | 205 | **/ 206 | alias EFI_TEXT_SET_ATTRIBUTE = EFI_STATUS function( 207 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* This, UINTN Attribute) @nogc nothrow; 208 | /** 209 | Clears the output device(s) display to the currently selected background 210 | color. 211 | 212 | @param This The protocol instance pointer. 213 | 214 | @retval EFI_SUCCESS The operation completed successfully. 215 | @retval EFI_DEVICE_ERROR The device had an error and could not complete the request. 216 | @retval EFI_UNSUPPORTED The output device is not in a valid text mode. 217 | 218 | **/ 219 | alias EFI_TEXT_CLEAR_SCREEN = EFI_STATUS function(EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* This) @nogc nothrow; 220 | /** 221 | Sets the current coordinates of the cursor position 222 | 223 | @param This The protocol instance pointer. 224 | @param Column The position to set the cursor to. Must be greater than or 225 | equal to zero and less than the number of columns and rows 226 | by QueryMode (). 227 | @param Row The position to set the cursor to. Must be greater than or 228 | equal to zero and less than the number of columns and rows 229 | by QueryMode (). 230 | 231 | @retval EFI_SUCCESS The operation completed successfully. 232 | @retval EFI_DEVICE_ERROR The device had an error and could not complete the request. 233 | @retval EFI_UNSUPPORTED The output device is not in a valid text mode, or the 234 | cursor position is invalid for the current mode. 235 | 236 | **/ 237 | alias EFI_TEXT_SET_CURSOR_POSITION = EFI_STATUS function( 238 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* This, UINTN Column, UINTN Row) @nogc nothrow; 239 | /** 240 | Makes the cursor visible or invisible 241 | 242 | @param This The protocol instance pointer. 243 | @param Visible If TRUE, the cursor is set to be visible. If FALSE, the cursor is 244 | set to be invisible. 245 | 246 | @retval EFI_SUCCESS The operation completed successfully. 247 | @retval EFI_DEVICE_ERROR The device had an error and could not complete the 248 | request, or the device does not support changing 249 | the cursor mode. 250 | @retval EFI_UNSUPPORTED The output device is not in a valid text mode. 251 | 252 | **/ 253 | alias EFI_TEXT_ENABLE_CURSOR = EFI_STATUS function( 254 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* This, BOOLEAN Visible) @nogc nothrow; 255 | /** 256 | @par Data Structure Description: 257 | Mode Structure pointed to by Simple Text Out protocol. 258 | **/ 259 | struct EFI_SIMPLE_TEXT_OUTPUT_MODE 260 | { 261 | /// 262 | /// The number of modes supported by QueryMode () and SetMode (). 263 | /// 264 | INT32 MaxMode; 265 | 266 | // 267 | // current settings 268 | // 269 | 270 | /// 271 | /// The text mode of the output device(s). 272 | /// 273 | INT32 Mode; 274 | /// 275 | /// The current character output attribute. 276 | /// 277 | INT32 Attribute; 278 | /// 279 | /// The cursor's column. 280 | /// 281 | INT32 CursorColumn; 282 | /// 283 | /// The cursor's row. 284 | /// 285 | INT32 CursorRow; 286 | /// 287 | /// The cursor is currently visbile or not. 288 | /// 289 | BOOLEAN CursorVisible; 290 | } 291 | /// The SIMPLE_TEXT_OUTPUT protocol is used to control text-based output devices. 292 | /// It is the minimum required protocol for any handle supplied as the ConsoleOut 293 | /// or StandardError device. In addition, the minimum supported text mode of such 294 | /// devices is at least 80 x 25 characters. 295 | struct _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL 296 | { 297 | EFI_TEXT_RESET Reset; 298 | 299 | EFI_TEXT_STRING OutputString; 300 | EFI_TEXT_TEST_STRING TestString; 301 | 302 | EFI_TEXT_QUERY_MODE QueryMode; 303 | EFI_TEXT_SET_MODE SetMode; 304 | EFI_TEXT_SET_ATTRIBUTE SetAttribute; 305 | 306 | EFI_TEXT_CLEAR_SCREEN ClearScreen; 307 | EFI_TEXT_SET_CURSOR_POSITION SetCursorPosition; 308 | EFI_TEXT_ENABLE_CURSOR EnableCursor; 309 | 310 | /// 311 | /// Pointer to SIMPLE_TEXT_OUTPUT_MODE data. 312 | /// 313 | EFI_SIMPLE_TEXT_OUTPUT_MODE* Mode; 314 | } 315 | -------------------------------------------------------------------------------- /source/uefi/x64/bind.d: -------------------------------------------------------------------------------- 1 | /** 2 | Based on X64/ProcessorBind.h file, original notice: 3 | 4 | Processor or Compiler specific defines and types x64 (Intel 64, AMD64). 5 | 6 | Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved. 7 | This program and the accompanying materials 8 | are licensed and made available under the terms and conditions of the BSD License 9 | which accompanies this distribution. The full text of the license may be found at 10 | http://opensource.org/licenses/bsd-license.php 11 | 12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 14 | **/ 15 | module uefi.x64.bind; 16 | 17 | version (X86_64) 18 | { 19 | public: 20 | extern (C): 21 | 22 | /// void 23 | alias VOID = void; 24 | 25 | /// 8-byte unsigned value 26 | alias UINT64 = ulong; 27 | 28 | /// 4-byte unsigned value 29 | alias UINT32 = uint; 30 | 31 | /// 2-byte unsigned value 32 | alias UINT16 = ushort; 33 | 34 | /// 1-byte unsigned value 35 | alias UINT8 = ubyte; 36 | 37 | /// 8-byte signed value 38 | alias INT64 = long; 39 | 40 | /// 4-byte signed value 41 | alias INT32 = int; 42 | 43 | /// 2-byte signed value 44 | alias INT16 = short; 45 | 46 | /// 1-byte signed value 47 | alias INT8 = byte; 48 | 49 | /// 1-byte character 50 | alias CHAR8 = char; 51 | 52 | /// 2-byte Character. Unless otherwise specified all strings are stored in the 53 | /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards. 54 | alias CHAR16 = wchar; 55 | 56 | /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other 57 | /// values are undefined. 58 | alias BOOLEAN = ubyte; 59 | 60 | /// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions, 61 | /// 8 bytes on supported 64-bit processor instructions) 62 | alias UINTN = UINT64; 63 | 64 | /// Signed value of native width. (4 bytes on supported 32-bit processor instructions, 65 | /// 8 bytes on supported 64-bit processor instructions) 66 | alias INTN = INT64; 67 | 68 | /// A value of native width with the highest bit set. 69 | enum MAX_BIT = 0x8000_0000_0000_0000UL; 70 | 71 | /// A value of native width with the two highest bits set. 72 | enum MAX_2_BITS = 0xC000_0000_0000_0000UL; 73 | 74 | /// Maximum legal x64 address 75 | enum MAX_ADDRESS = 0xFFFF_FFFF_FFFF_FFFFUL; 76 | 77 | /// Maximum legal x64 INTN and UINTN values. 78 | enum MAX_INTN = INTN.max; 79 | /// ditto 80 | enum MAX_UINTN = UINTN.max; 81 | 82 | /// The stack alignment required for x64 83 | enum CPU_STACK_ALIGNMENT = 16; 84 | 85 | /** 86 | Return the pointer to the first instruction of a function given a function pointer. 87 | On x64 CPU architectures, these two pointer values are the same, 88 | so the implementation of this macro is very simple. 89 | 90 | Params: 91 | FunctionPointer = A pointer to a function. 92 | 93 | Returns: The pointer to the first instruction of a function given a function pointer. 94 | 95 | **/ 96 | void* FUNCTION_ENTRY_POINT(T)(T fptr) if (is(T == function)) 97 | { 98 | return cast(void*)(fptr); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /tools/efihdrtool.d: -------------------------------------------------------------------------------- 1 | /// A program to simplify the process of translating UEFI headers from C -> D 2 | /// Usage: efihdrtool InFile OutFile 3 | module efihdrtool; 4 | 5 | import std.stdio, std.string, std.array, std.algorithm, std.range, std.math, 6 | std.format, std.conv; 7 | import std.path, std.process; 8 | 9 | File fpIn; 10 | File fpOut; 11 | char[] cLine, nLine; 12 | string moduleName = "0"; 13 | string inFile; 14 | bool moduleDone = false; 15 | 16 | void main(string[] args) 17 | { 18 | if (args.length < 3) 19 | { 20 | stderr.writefln("Usage: %s InFile.h [+] OutFile.d", args[0]); 21 | return; 22 | } 23 | fpOut = File(args[$-1], "w"); 24 | if (args[$-1].startsWith("source/")) 25 | moduleName = args[$-1]["source/uefi/".length .. $ - 2].replace("/", "."); 26 | foreach(iff; args[1..$-1]) 27 | { 28 | stderr.writeln("Processing ",iff); 29 | inFile = iff[iff.indexOf("Include/") + 8 .. $]; 30 | fpIn = File(iff, "r"); 31 | nextLine(); 32 | while (!fpIn.eof()) 33 | { 34 | nextLine(); 35 | process(); 36 | } 37 | fpIn.close(); 38 | } 39 | fpOut.flush(); 40 | fpOut.close(); 41 | writeln(execute(["dfix", args[$-1]])); 42 | writeln(execute(["dfmt", args[$-1], "-i"])); 43 | } 44 | 45 | void nextLine() 46 | { 47 | cLine = nLine; 48 | nLine = []; 49 | fpIn.readln(nLine); 50 | nLine = nLine.strip; 51 | } 52 | 53 | bool startsWith(const(char[]) a, const(char[]) b) 54 | { 55 | size_t bl = b.length; 56 | if (b[$ - 1] == '\0') 57 | bl--; 58 | if (a.length < bl) 59 | return false; 60 | for (int i = 0; i < bl; i++) 61 | { 62 | if (a[i] != b[i]) 63 | return false; 64 | } 65 | return true; 66 | } 67 | 68 | bool endsWith(const(char[]) a, const(char[]) b) 69 | { 70 | size_t bl = b.length; 71 | if (b[$ - 1] == '\0') 72 | bl--; 73 | if (a.length < bl) 74 | return false; 75 | for (int i = 0; i < bl; i++) 76 | { 77 | if (a[$ - bl + i] != b[i]) 78 | return false; 79 | } 80 | return true; 81 | } 82 | 83 | __gshared int pack = 0; 84 | 85 | string chompx(string s, const(dchar)[] chs) 86 | { 87 | foreach(ch; chs) 88 | { 89 | s = s.chomp([ch]).chompPrefix([ch]); 90 | } 91 | return s; 92 | } 93 | 94 | void process() 95 | { 96 | if (cLine.length < 1) 97 | { 98 | //fpOut.writeln(); 99 | return; 100 | } 101 | if (cLine.startsWith("#pragma")) 102 | { 103 | if (cLine.indexOf("pack") > 0) 104 | { 105 | if (cLine.endsWith(`()`)) 106 | { 107 | pack = 0; 108 | } 109 | else 110 | { 111 | pack = 1; 112 | } 113 | } 114 | } 115 | if (cLine == "///") 116 | return; 117 | if (cLine.startsWith("///")) 118 | { 119 | fpOut.writeln(cLine); 120 | } 121 | if (cLine == "/** @file" && !moduleDone) 122 | { 123 | fpOut.writeln("/**"); 124 | fpOut.writefln("\tBased on %s, original notice:\n", inFile); 125 | while (true) 126 | { 127 | nextLine(); 128 | if (cLine != "**/") 129 | { 130 | fpOut.writeln("\t", cLine.replace("
", "")); 131 | } 132 | else 133 | { 134 | break; 135 | } 136 | } 137 | fpOut.writeln("**/"); 138 | fpOut.writefln("module uefi.%s;", moduleName); 139 | fpOut.writeln("import uefi.base;"); 140 | fpOut.writeln("import uefi.base_type;"); 141 | //fpOut.writeln("import std.bitmanip;"); 142 | fpOut.writeln("public:"); 143 | fpOut.writeln("extern (C):"); 144 | moduleDone = true; 145 | return; 146 | } 147 | if (cLine == "/**") 148 | { 149 | fpOut.writeln("/**"); 150 | while (true) 151 | { 152 | nextLine(); 153 | if (!cLine.endsWith("**/")) 154 | { 155 | fpOut.writeln("\t", cLine); 156 | } 157 | else 158 | { 159 | break; 160 | } 161 | } 162 | fpOut.writeln("**/"); 163 | return; 164 | } 165 | if (cLine.startsWith("#ifndef __")) 166 | { 167 | nextLine(); // skip header safeguard 168 | return; 169 | } 170 | if (cLine.startsWith("#include ")) 171 | { 172 | fpOut.writeln("// FIXME: INCLUDE ", cLine[9 .. $]); 173 | stderr.writeln("// FIXME: INCLUDE ", cLine[9 .. $]); 174 | return; 175 | } 176 | if (cLine.startsWith("#define")) 177 | { 178 | if (cLine.endsWith("_H_")) 179 | { 180 | return; 181 | } 182 | if (cLine.endsWith("\\") && nLine.startsWith("{")) 183 | { 184 | string Id = cLine[8 .. $ - 2].idup; 185 | nextLine(); 186 | if(!cLine.canFind(',')) 187 | nextLine(); 188 | string Guid = cLine[0 .. $].idup; 189 | nextLine(); 190 | fpOut.writeln("enum EFI_GUID ", Id, " = EFI_GUID(", 191 | Guid.chompx("\\;[]{}").replace("{", "[").replace("}", "]"), ");"); 192 | } 193 | else 194 | { 195 | // #define abc def 196 | auto Split = cLine.replace("ULL", "UL").split; 197 | if (Split[1].indexOf("(") > 0) 198 | { 199 | fpOut.writeln("// ", cLine); 200 | while (cLine[$ - 1] == '\\') 201 | { 202 | nextLine(); 203 | fpOut.writeln("// ", cLine); 204 | } 205 | } 206 | else 207 | { 208 | fpOut.writef("enum %s = ", Split[1]); //Split[2..$].join(" ") 209 | bool hadSemicolon = false; 210 | foreach (txt; Split[2 .. $]) 211 | { 212 | if (txt.startsWith("//") || txt.startsWith("/*")) 213 | { 214 | hadSemicolon = true; 215 | fpOut.write("; "); 216 | } 217 | if (txt == "{") 218 | { 219 | fpOut.write(txt, "GUID( "); 220 | } 221 | else if (txt == "}") 222 | { 223 | fpOut.write(txt, " );"); 224 | } 225 | else 226 | { 227 | fpOut.write(txt, ' '); 228 | } 229 | } 230 | fpOut.write((hadSemicolon) ? "\n" : ";\n"); 231 | } 232 | } 233 | return; 234 | } 235 | if (cLine.startsWith("typedef ")) 236 | { 237 | cLine = cLine[8 .. $]; 238 | if (cLine.startsWith("PACKED")) 239 | { 240 | cLine = cLine[7 .. $]; 241 | } 242 | if (cLine.startsWith("struct _") && (cLine[$ - 1] != '{')) 243 | cLine = cLine[7 .. $]; 244 | if (cLine.startsWith("union _") && (cLine[$ - 1] != '{')) 245 | cLine = cLine[6 .. $]; 246 | if (cLine.startsWith("struct")) 247 | { 248 | auto app = appender!string; 249 | nextLine(); 250 | handleStructInterior(app); 251 | string Id; 252 | if (cLine.length < 3) 253 | { 254 | nextLine(); 255 | Id = cLine[0 .. $ - 1].idup; 256 | } 257 | else 258 | { 259 | Id = cLine[2 .. $ - 1].idup; 260 | } 261 | fpOut.writeln("struct ", Id, pack ? " {align(1):\n" : " {\n", app.data, 262 | "}"); 263 | } 264 | else if (cLine.startsWith("enum")) 265 | { 266 | auto app = appender!string; 267 | nextLine(); 268 | while (!cLine.startsWith("}")) 269 | { 270 | app ~= cLine.idup; 271 | app ~= '\n'; 272 | nextLine(); 273 | } 274 | string Id; 275 | if (cLine.length < 3) 276 | { 277 | nextLine(); 278 | Id = cLine[0 .. $ - 1].idup; 279 | } 280 | else 281 | { 282 | Id = cLine[2 .. $ - 1].idup; 283 | } 284 | fpOut.writeln("alias ", Id, " = UINT32;"); 285 | fpOut.writeln("enum :", Id, " {\n", app.data, "}"); 286 | } 287 | else if (cLine.startsWith("union")) 288 | { 289 | auto app = appender!string; 290 | nextLine(); 291 | handleStructInterior(app); 292 | string Id; 293 | if (cLine.length < 3) 294 | { 295 | nextLine(); 296 | Id = cLine[0 .. $ - 1].idup; 297 | } 298 | else 299 | { 300 | Id = cLine[2 .. $ - 1].idup; 301 | } 302 | fpOut.writeln("union ", Id, " {\n", app.data, "}"); 303 | } 304 | else 305 | { 306 | auto Split = cLine[0 .. $ - 1].split; 307 | fpOut.writefln("alias %s = %s;", Split[$ - 1], Split[0 .. $ - 1].join(" ")); 308 | } 309 | return; 310 | } 311 | if (cLine == "typedef") // function pointer 312 | { 313 | nextLine(); 314 | string RetType = cLine.idup; 315 | nextLine(); 316 | // (EFIAPI *EFI_TEXT_CLEAR_SCREEN)( 317 | string FunName = cLine[9 .. $ - 2].idup; 318 | nextLine(); 319 | auto Args = appender!string; 320 | while (cLine != ");") 321 | { 322 | auto Kw = cLine.split; 323 | foreach (K; Kw) 324 | { 325 | if ((K == "IN") || (K == "OUT") || (K == "EFIAPI") || (K == "OPTIONAL")) 326 | continue; 327 | if ((K == "IN,") || (K == "OUT,") || (K == "EFIAPI,") || (K == "OPTIONAL,")) 328 | { 329 | Args ~= ','; 330 | continue; 331 | } 332 | if (K == "CONST") 333 | K = "const".dup; 334 | if (K == "VOID") 335 | K = "void".dup; 336 | Args ~= K; 337 | Args ~= ' '; 338 | } 339 | nextLine(); 340 | } 341 | fpOut.writefln("alias %s = %s function(%s) @nogc nothrow;", FunName, RetType, 342 | Args.data); 343 | } 344 | if (cLine.startsWith("struct")) 345 | { 346 | auto app = appender!string; 347 | handleStructInterior(app); 348 | fpOut.writeln(app.data); 349 | fpOut.writeln("}"); 350 | return; 351 | } 352 | } 353 | 354 | void handleStructInterior(T)(T app) 355 | { 356 | int numNests = 1; 357 | bool inBitfields = false; 358 | while (true) 359 | { 360 | if (cLine.length < 1) 361 | { 362 | nextLine(); 363 | continue; 364 | } 365 | if(cLine.startsWith("//")) 366 | { 367 | app ~= cLine.idup; 368 | app ~= '\n'; 369 | nextLine(); 370 | continue; 371 | } 372 | if (cLine.startsWith("PACKED ")) 373 | { 374 | cLine = cLine[7 .. $]; 375 | } 376 | if (cLine.startsWith("union {") || cLine.startsWith("struct {")) 377 | { 378 | app ~= `/* FIX:NESTED STRUCTURES */`; 379 | numNests++; 380 | } 381 | if (cLine.startsWith("}")) 382 | { 383 | numNests--; 384 | } 385 | if (numNests <= 0) 386 | { 387 | break; 388 | } 389 | 390 | if (cLine.indexOf(":") > 0) 391 | { 392 | import std.regex; 393 | cLine = cLine.strip; 394 | auto spl = splitter(cLine, regex(`[ \t:;]+`)).array; 395 | if (!inBitfields) 396 | { 397 | inBitfields = true; 398 | app ~= "mixin(bitfields!(\n"; 399 | } 400 | else 401 | { 402 | app ~= ",\n"; 403 | } 404 | app ~= spl[0].idup; // type 405 | app ~= `,"`; 406 | app ~= spl[1].idup; // fname 407 | app ~= `",`; 408 | app ~= spl[2].idup; // width 409 | } 410 | else 411 | { 412 | if (inBitfields) 413 | { 414 | inBitfields = false; 415 | app ~= "));"; 416 | } 417 | app ~= cLine.idup; 418 | app ~= '\n'; 419 | } 420 | nextLine(); 421 | } 422 | if (inBitfields) 423 | { 424 | inBitfields = false; 425 | app ~= "));"; 426 | } 427 | } 428 | --------------------------------------------------------------------------------