1// Copyright 2016 The Fuchsia Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#pragma once 6 7#include <stddef.h> 8#include <stdint.h> 9 10#define EFIAPI __attribute__((ms_abi)) 11 12#define EFI_ERROR_MASK 0x8000000000000000 13#define EFI_ERR(x) (EFI_ERROR_MASK | x) 14#define EFI_ERROR(x) (((int64_t)x) < 0) 15 16#define EFI_SUCCESS 0 17#define EFI_LOAD_ERROR EFI_ERR(1) 18#define EFI_INVALID_PARAMETER EFI_ERR(2) 19#define EFI_UNSUPPORTED EFI_ERR(3) 20#define EFI_BAD_BUFFER_SIZE EFI_ERR(4) 21#define EFI_BUFFER_TOO_SMALL EFI_ERR(5) 22#define EFI_NOT_READY EFI_ERR(6) 23#define EFI_DEVICE_ERROR EFI_ERR(7) 24#define EFI_WRITE_PROTECTED EFI_ERR(8) 25#define EFI_OUT_OF_RESOURCES EFI_ERR(9) 26#define EFI_VOLUME_CORRUPTED EFI_ERR(10) 27#define EFI_VOLUME_FULL EFI_ERR(11) 28#define EFI_NO_MEDIA EFI_ERR(12) 29#define EFI_MEDIA_CHANGED EFI_ERR(13) 30#define EFI_NOT_FOUND EFI_ERR(14) 31#define EFI_ACCESS_DENIED EFI_ERR(15) 32#define EFI_NO_RESPONSE EFI_ERR(16) 33#define EFI_NO_MAPPING EFI_ERR(17) 34#define EFI_TIMEOUT EFI_ERR(18) 35#define EFI_NOT_STARTED EFI_ERR(19) 36#define EFI_ALREADY_STARTED EFI_ERR(20) 37#define EFI_ABORTED EFI_ERR(21) 38#define EFI_ICMP_ERROR EFI_ERR(22) 39#define EFI_TFTP_ERROR EFI_ERR(23) 40#define EFI_PROTOCOL_ERROR EFI_ERR(24) 41#define EFI_INCOMPATIBLE_VERSION EFI_ERR(25) 42#define EFI_SECURITY_VIOLATION EFI_ERR(26) 43#define EFI_CRC_ERROR EFI_ERR(27) 44#define EFI_END_OF_MEDIA EFI_ERR(28) 45#define EFI_END_OF_FILE EFI_ERR(31) 46#define EFI_INVALID_LANGUAGE EFI_ERR(32) 47#define EFI_COMPROMISED_DATA EFI_ERR(33) 48#define EFI_IP_ADDRESS_CONFLICT EFI_ERR(34) 49#define EFI_HTTP_ERROR EFI_ERR(35) 50 51// TODO: figure out where to put these. They're just mentioned in passing in the 52// spec as some of many industry standard GUIDs but not part of the spec itself. 53#define ACPI_TABLE_GUID \ 54 {0xeb9d2d30, 0x2d88, 0x11d3, {0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d}} 55#define ACPI_20_TABLE_GUID \ 56 {0x8868e871, 0xe4f1, 0x11d3, {0xbc, 0x22, 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81}} 57#define SMBIOS_TABLE_GUID \ 58 {0xeb9d2d31, 0x2d88, 0x11d3, {0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d}} 59#define SMBIOS3_TABLE_GUID \ 60 {0xf2fd1544, 0x9794, 0x4a2c, {0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94}} 61 62typedef struct { 63 uint64_t Signature; 64 uint32_t Revision; 65 uint32_t HeaderSize; 66 uint32_t CRC32; 67 uint32_t Reserved; 68} efi_table_header; 69 70typedef struct efi_guid { 71 uint32_t data1; 72 uint16_t data2; 73 uint16_t data3; 74 uint8_t data4[8]; 75} efi_guid; 76 77typedef void* efi_handle; 78 79typedef size_t efi_status; 80 81typedef struct { 82 uint8_t addr[32]; 83} efi_mac_addr; 84 85typedef struct { 86 uint8_t addr[4]; 87} efi_ipv4_addr; 88 89typedef struct { 90 uint8_t addr[16]; 91} efi_ipv6_addr; 92 93typedef union { 94 efi_ipv4_addr v4; 95 efi_ipv6_addr v6; 96} efi_ip_addr; 97 98// This really belongs in boot-services.h, but causes circular dependencies with 99// device-path.h. 100typedef enum { 101 EfiReservedMemoryType, 102 EfiLoaderCode, 103 EfiLoaderData, 104 EfiBootServicesCode, 105 EfiBootServicesData, 106 EfiRuntimeServicesCode, 107 EfiRuntimeServicesData, 108 EfiConventionalMemory, 109 EfiUnusableMemory, 110 EfiACPIReclaimMemory, 111 EfiACPIMemoryNVS, 112 EfiMemoryMappedIO, 113 EfiMemoryMappedIOPortSpace, 114 EfiPalCode, 115 EfiPersistentMemory, 116 EfiMaxMemoryType 117} efi_memory_type; 118 119typedef uint64_t efi_physical_addr; 120typedef uint64_t efi_virtual_addr; 121 122typedef void* efi_event; 123 124#define EVT_TIMER 0x80000000 125#define EVT_RUNTIME 0x40000000 126#define EVT_NOTIFY_WAIT 0x00000100 127#define EVT_NOTIFY_SIGNAL 0x00000200 128#define EVT_SIGNAL_EXIT_BOOT_SERVICES 0x00000201 129#define EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202 130 131#define EFI_EVENT_GROUP_EXIT_BOOT_SERVICES \ 132 {0x27abf055, 0xb1b8, 0x4c26, {0x80, 0x48, 0x74, 0x8f, 0x37, 0xba, 0xa2, 0xdf}} 133#define EFI_EVENT_GROUP_VIRTUAL_ADDRESS_CHANGE \ 134 {0x13fa7698, 0xc831, 0x49c7, {0x87, 0xea, 0x8f, 0x43, 0xfc, 0xc2, 0x51, 0x96}} 135#define EFI_EVENT_GROUP_MEMORY_MAP_CHANGE \ 136 {0x78bee926, 0x692f, 0x48fd, {0x9e, 0xdb, 0x01, 0x42, 0x2e, 0xf0, 0xd7, 0xab}} 137#define EFI_EVENT_GROUP_READY_TO_BOOT \ 138 {0x7ce88fb3, 0x4bd7, 0x4679, {0x87, 0xa8, 0xa8, 0xd8, 0xde, 0xe5, 0x0d, 0x2b}} 139 140typedef void (*efi_event_notify) (efi_event event, void* ctx) EFIAPI; 141 142typedef enum { 143 TimerCancel, 144 TimerPeriodic, 145 TimerRelative 146} efi_timer_delay; 147 148#ifndef __cplusplus 149typedef unsigned short char16_t; 150#endif 151