2
* This is a short summary of declarations and definitions from different
3
* efi header files of Intels' EFI_Toolkit_1.10.14.62
4
* used for the minimal implementation in mini-os.
5
* Changes: Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com>
7
****************************************************************************
8
* Copyright (C) 2001-2004, Intel Corporation.
9
* THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO WARRANTIES WHATSOEVER,
10
* INCLUDING ANY WARRANTY OF MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR
11
* ANY PARTICULAR PURPOSE, OR ANY WARRANTY OTHERWISE ARISING OUT OF ANY
12
* PROPOSAL, SPECIFICATION OR SAMPLE. Except for a limited copyright license
13
* to copy this specification for internal use only, no license, express or
14
* implied, by estoppel or otherwise, to any intellectual property rights is
15
* granted herein. Intel disclaims all liability, including liability for
16
* infringement of any proprietary rights, relating to implementation of
17
* information in this specification. Intel does not warrant or represent
18
* that such implementation(s) will not infringe such rights. Designers must
19
* not rely on the absence or characteristics of any features or instructions
20
* marked "reserved" or "undefined." Intel reserves these for future
21
* definition and shall have no responsibility whatsoever for conflicts or
22
* incompatibilities arising from future changes to them.
23
* This document is an intermediate draft for comment only and is subject to
24
* change without notice. Readers should not design products based on this
26
* Intel, the Intel logo, and Itanium are trademarks or registered trademarks
27
* of Intel Corporation or its subsidiaries in the United States and other
29
* Other names and brands may be claimed as the property of others.
35
#include <mini-os/types.h>
38
#define EFIWARN(a) (a)
39
#define EFI_ERROR(a) (((int64_t) a) < 0)
43
#define EFI_LOAD_ERROR EFIERR(1)
44
#define EFI_INVALID_PARAMETER EFIERR(2)
45
#define EFI_UNSUPPORTED EFIERR(3)
46
#define EFI_BAD_BUFFER_SIZE EFIERR(4)
47
#define EFI_BUFFER_TOO_SMALL EFIERR(5)
48
#define EFI_NOT_READY EFIERR(6)
49
#define EFI_DEVICE_ERROR EFIERR(7)
50
#define EFI_WRITE_PROTECTED EFIERR(8)
51
#define EFI_OUT_OF_RESOURCES EFIERR(9)
52
#define EFI_VOLUME_CORRUPTED EFIERR(10)
53
#define EFI_VOLUME_FULL EFIERR(11)
54
#define EFI_NO_MEDIA EFIERR(12)
55
#define EFI_MEDIA_CHANGED EFIERR(13)
56
#define EFI_NOT_FOUND EFIERR(14)
57
#define EFI_ACCESS_DENIED EFIERR(15)
58
#define EFI_NO_RESPONSE EFIERR(16)
59
#define EFI_NO_MAPPING EFIERR(17)
60
#define EFI_TIMEOUT EFIERR(18)
61
#define EFI_NOT_STARTED EFIERR(19)
62
#define EFI_ALREADY_STARTED EFIERR(20)
63
#define EFI_ABORTED EFIERR(21)
64
#define EFI_ICMP_ERROR EFIERR(22)
65
#define EFI_TFTP_ERROR EFIERR(23)
66
#define EFI_PROTOCOL_ERROR EFIERR(24)
68
#define EFI_WARN_UNKOWN_GLYPH EFIWARN(1)
69
#define EFI_WARN_DELETE_FAILURE EFIWARN(2)
70
#define EFI_WARN_WRITE_FAILURE EFIWARN(3)
71
#define EFI_WARN_BUFFER_TOO_SMALL EFIWARN(4)
74
typedef uint64_t efi_status_t;
75
typedef void* efi_handle_t;
76
typedef void* efi_event_t;
77
typedef uint16_t efi_char16_t;
81
* Standard EFI table header
84
struct efi_table_header
87
// Revision of EFI table specification,
88
// upper 16 bit - major revision number
89
// lower 16 bit - minor revision number
95
typedef struct efi_table_header efi_table_header_t;
102
uint16_t Year; /* 1998 - 20XX */
103
uint8_t Month; /* 1 - 12 */
104
uint8_t Day; /* 1 - 31 */
105
uint8_t Hour; /* 0 - 23 */
106
uint8_t Minute; /* 0 - 59 */
107
uint8_t Second; /* 0 - 59 */
109
uint32_t Nanosecond; /* 0 - 999,999,999 */
110
int16_t TimeZone; /* -1440 to 1440 or 2047 */
115
/* Bit definitions for efi_time_t.Daylight */
116
#define EFI_TIME_ADJUST_DAYLIGHT 0x01
117
#define EFI_TIME_IN_DAYLIGHT 0x02
119
/* Value definition for efi_time_t.TimeZone */
120
#define EFI_UNSPECIFIED_TIMEZONE 0x07FF
126
uint32_t Resolution; /* 1e-6 parts per million */
127
uint32_t Accuracy; /* hertz */
128
uint8_t SetsToZero; /* Set clears sub-second time */
129
} efi_time_capabilities_t;
132
typedef efi_status_t (*efi_get_time_t) (efi_time_t*, efi_time_capabilities_t*);
133
typedef efi_status_t (*efi_set_time_t) (efi_time_t*);
134
typedef efi_status_t (*efi_get_wakeup_time_t) (uint8_t*, uint8_t*, efi_time_t*);
135
typedef efi_status_t (*efi_set_wakeup_time_t) (uint8_t, efi_time_t*);
139
* Preseve the attr on any range supplied.
140
* ConventialMemory must have WB,SR,SW when supplied.
141
* When allocating from ConventialMemory always make it WB,SR,SW
142
* When returning to ConventialMemory always make it WB,SR,SW
143
* When getting the memory map, or on RT for runtime types
147
EfiReservedMemoryType, /* 0 */
152
EfiRuntimeServicesCode,
153
EfiRuntimeServicesData, /* 6 */
154
EfiConventionalMemory, /* 7 */
156
EfiACPIReclaimMemory, /* 9 */
157
EfiACPIMemoryNVS, /* 10, a */
159
EfiMemoryMappedIOPortSpace, /* 12, c */
160
EfiPalCode, /* 13, d */
161
EfiMaxMemoryType /* 14, e */
164
/* possible caching types for the memory range */
165
#define EFI_MEMORY_UC 0x0000000000000001
166
#define EFI_MEMORY_WC 0x0000000000000002
167
#define EFI_MEMORY_WT 0x0000000000000004
168
#define EFI_MEMORY_WB 0x0000000000000008
169
#define EFI_MEMORY_UCE 0x0000000000000010
170
/* physical memory protection on range */
171
#define EFI_MEMORY_WP 0x0000000000001000
172
#define EFI_MEMORY_RP 0x0000000000002000
173
#define EFI_MEMORY_XP 0x0000000000004000
174
/* range requires a runtime mapping */
175
#define EFI_MEMORY_RUNTIME 0x8000000000000000
177
#define EFI_MEMORY_DESCRIPTOR_VERSION 1
179
typedef uint64_t efi_phys_addr_t;
180
typedef uint64_t efi_virt_addr_t;
184
uint32_t Type; /* 32 bit padding */
185
efi_phys_addr_t PhysicalStart;
186
efi_virt_addr_t VirtualStart;
187
uint64_t NumberOfPages;
189
} efi_memory_descriptor_t;
191
#define NextMemoryDescriptor(Ptr,Size) ((efi_memory_descriptor_t*) (((uint8_t*) Ptr) + Size))
194
typedef efi_status_t (*efi_set_virtual_address_map_t)
196
uint64_t MemoryMapSize,
197
uint64_t DescriptorSize,
198
uint32_t DescriptorVersion,
199
efi_memory_descriptor_t* VirtualMap
202
typedef efi_status_t (*efi_convert_pointer_t)
204
uint64_t DebugDisposition,
221
* EFI Configuration Table and GUID definitions
224
#define MPS_TABLE_GUID \
225
{ 0xeb9d2d2f, 0x2d88, 0x11d3, \
226
{ 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } }
228
#define ACPI_TABLE_GUID \
229
{ 0xeb9d2d30, 0x2d88, 0x11d3, \
230
{ 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } }
232
#define ACPI_20_TABLE_GUID \
233
{ 0x8868e871, 0xe4f1, 0x11d3, \
234
{ 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } }
236
#define SMBIOS_TABLE_GUID \
237
{ 0xeb9d2d31, 0x2d88, 0x11d3, \
238
{ 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } }
240
#define SAL_SYSTEM_TABLE_GUID \
241
{ 0xeb9d2d32, 0x2d88, 0x11d3, \
242
{ 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } }
244
/* DIG64 Headless Console & Debug Port Table. */
245
#define HCDP_TABLE_GUID \
246
{0xf951938d, 0x620b, 0x42ef, \
247
{0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98 } }
250
typedef struct efi_configuration_table
252
efi_guid_t VendorGuid;
254
} efi_configuration_table_t;
258
* EFI platform variables
261
#define EFI_GLOBAL_VARIABLE \
262
{ 0x8BE4DF61, 0x93CA, 0x11d2, 0xAA, 0x0D, 0x00, \
263
0xE0, 0x98, 0x03, 0x2B, 0x8C }
265
/* Variable attributes */
266
#define EFI_VARIABLE_NON_VOLATILE 0x00000001
267
#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
268
#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
270
/* Variable size limitation */
271
#define EFI_MAXIMUM_VARIABLE_SIZE 1024
273
typedef efi_status_t (*efi_get_variable_t)
275
efi_char16_t* VariableName,
276
efi_guid_t *VendorGuid,
277
uint32_t* Attributes,
283
efi_status_t (*efi_get_next_variable_name_t)
285
uint64_t* VariableNameSize,
286
efi_char16_t* VariableName,
287
efi_guid_t* VendorGuid
290
typedef efi_status_t (*efi_set_variable_t)
292
efi_char16_t* VariableName,
293
efi_guid_t* VendorGuid,
311
typedef efi_status_t (*efi_reset_system_t)
313
efi_reset_type_t ResetType,
314
efi_status_t ResetStatus,
316
efi_char16_t* ResetData
319
typedef efi_status_t (*efi_get_next_high_mono_count_t) (uint32_t* HighCount);
323
* EFI Runtime Serivces Table
326
#define EFI_RUNTIME_SERVICES_SIGNATURE 0x5652453544e5552ULL
327
#define EFI_RUNTIME_SERVICES_REVISION ((EFI_SPECIFICATION_MAJOR_REVISION<<16) \
328
| (EFI_SPECIFICATION_MINOR_REVISION))
332
efi_table_header_t Hdr;
334
efi_get_time_t GetTime;
335
efi_set_time_t SetTime;
336
efi_get_wakeup_time_t GetWakeupTime;
337
efi_set_wakeup_time_t SetWakeupTime;
338
/* Virtual memory services */
339
efi_set_virtual_address_map_t SetVirtualAddressMap;
340
efi_convert_pointer_t ConvertPointer;
341
/* Variable serviers */
342
efi_get_variable_t GetVariable;
343
efi_get_next_variable_name_t GetNextVariableName;
344
efi_set_variable_t SetVariable;
346
efi_get_next_high_mono_count_t GetNextHighMonotonicCount;
347
efi_reset_system_t ResetSystem;
349
} efi_runtime_services_t;
352
#define EFI_SPECIFICATION_MAJOR_REVISION 1
353
#define EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249
354
#define EFI_SYSTEM_TABLE_REVISION ((EFI_SPECIFICATION_MAJOR_REVISION<<16) \
355
| (EFI_SPECIFICATION_MINOR_REVISION))
357
struct efi_system_table
359
efi_table_header_t Hdr;
361
uint64_t FirmwareVendor; // phys addr of CHAR16
362
uint32_t FirmwareRevision; // Firmware vendor specific
364
efi_handle_t ConsoleInHandle;
367
efi_handle_t ConsoleOutHandle;
370
efi_handle_t StandardErrorHandle;
373
uint64_t RuntimeServices; // phys addr
374
uint64_t BootServices; // phys addr
376
uint64_t NumberOfTableEntries; // Number of entries in Config
377
uint64_t ConfigurationTable; // phys addr of ConfigTable
380
typedef struct efi_system_table efi_system_table_t;
383
#define EFI_PAGE_SIZE 4096
384
#define EFI_PAGE_MASK 0xFFF
385
#define EFI_PAGE_SHIFT 12
387
#define EFI_SIZE_TO_PAGES(a) \
388
( ((a) >> EFI_PAGE_SHIFT) + ((a) & EFI_PAGE_MASK ? 1 : 0) )
392
int efi_get_time(efi_time_t* tmP);
393
efi_status_t ia64_call_efi_physical(void *, ...);