xref: /illumos-gate/usr/src/uts/common/sys/efi.h (revision 0192a1da4f5588bb2a0e7534d596f69fedcc3858)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2016 Toomas Soome <tsoome@me.com>
14  */
15 
16 #ifndef _SYS_EFI_H
17 #define	_SYS_EFI_H
18 
19 /*
20  * UEFI related data. Based on UEFI 2.5 specs.
21  */
22 #include <sys/uuid.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /* EFI GUIDS */
29 
30 #define	EFI_GLOBAL_VARIABLE	\
31 	{ 0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, \
32 	{ 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c } }
33 
34 #define	MPS_TABLE_GUID	\
35 	{ 0xeb9d2d2f, 0x2d88, 0x11d3, 0x9a, 0x16, \
36 	{ 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } }
37 
38 #define	ACPI_10_TABLE_GUID	\
39 	{ 0xeb9d2d30, 0x2d88, 0x11d3, 0x9a, 0x16, \
40 	{ 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } }
41 
42 #define	EFI_ACPI_TABLE_GUID	\
43 	{ 0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, \
44 	{ 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81 } }
45 
46 #define	SMBIOS_TABLE_GUID	\
47 	{ 0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, \
48 	{ 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } }
49 
50 #define	SAL_SYSTEM_TABLE_GUID	\
51 	{ 0xeb9d2d32, 0x2d88, 0x11d3, 0x9a, 0x16, \
52 	{ 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } }
53 
54 #define	SMBIOS3_TABLE_GUID	\
55 	{ 0xf2fd1544, 0x9794, 0x4a2c, 0x99, 0x2e, \
56 	{ 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94 } }
57 
58 #define	FDT_TABLE_GUID	\
59 	{ 0xb1b621d5, 0xf19c, 0x41a5, 0x83, 0x0b, \
60 	{ 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 } }
61 
62 #define	DXE_SERVICES_TABLE_GUID	\
63 	{ 0x5ad34ba, 0x6f02, 0x4214, 0x95, 0x2e, \
64 	{ 0x4d, 0xa0, 0x39, 0x8e, 0x2b, 0xb9 } }
65 
66 #define	HOB_LIST_TABLE_GUID	\
67 	{ 0x7739f24c, 0x93d7, 0x11d4, 0x9a, 0x3a, \
68 	{ 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } }
69 
70 #define	MEMORY_TYPE_INFORMATION_TABLE_GUID	\
71 	{ 0x4c19049f, 0x4137, 0x4dd3, 0x9c, 0x10, \
72 	{ 0x8b, 0x97, 0xa8, 0x3f, 0xfd, 0xfa } }
73 
74 #define	DEBUG_IMAGE_INFO_TABLE_GUID	\
75 	{ 0x49152e77, 0x1ada, 0x4764, 0xb7, 0xa2, \
76 	{ 0x7a, 0xfe, 0xfe, 0xd9, 0x5e, 0x8b } }
77 
78 #define	EFI_PROPERTIES_TABLE_GUID	\
79 	{ 0x880aaca3, 0x4adc, 0x4a04, 0x90, 0x79, \
80 	{ 0xb7, 0x47, 0x34, 0x8, 0x25, 0xe5 } }
81 
82 typedef struct uuid efi_guid_t __aligned(8);
83 
84 /* Memory data */
85 typedef uint64_t	EFI_PHYSICAL_ADDRESS;
86 typedef uint64_t	EFI_VIRTUAL_ADDRESS;
87 
88 /*
89  * EFI_MEMORY_TYPE enum is defined in UEFI v2.7 page 185.
90  */
91 typedef enum {
92 	EfiReservedMemoryType,
93 	EfiLoaderCode,
94 	EfiLoaderData,
95 	EfiBootServicesCode,
96 	EfiBootServicesData,
97 	EfiRuntimeServicesCode,
98 	EfiRuntimeServicesData,
99 	EfiConventionalMemory,
100 	EfiUnusableMemory,
101 	EfiACPIReclaimMemory,
102 	EfiACPIMemoryNVS,
103 	EfiMemoryMappedIO,
104 	EfiMemoryMappedIOPortSpace,
105 	EfiPalCode,
106 	EfiPersistentMemory,
107 	EfiMaxMemoryType
108 } EFI_MEMORY_TYPE;
109 
110 /* Possible caching types for the memory range */
111 #define	EFI_MEMORY_UC			0x0000000000000001
112 #define	EFI_MEMORY_WC			0x0000000000000002
113 #define	EFI_MEMORY_WT			0x0000000000000004
114 #define	EFI_MEMORY_WB			0x0000000000000008
115 #define	EFI_MEMORY_UCE			0x0000000000000010
116 
117 /* Physical memory protection on range */
118 #define	EFI_MEMORY_WP			0x0000000000001000
119 #define	EFI_MEMORY_RP			0x0000000000002000
120 #define	EFI_MEMORY_XP			0x0000000000004000
121 #define	EFI_MEMORY_NV			0x0000000000008000
122 #define	EFI_MEMORY_MORE_RELIABLE	0x0000000000010000
123 #define	EFI_MEMORY_RO			0x0000000000020000
124 
125 /* Range requires a runtime mapping */
126 #define	EFI_MEMORY_RUNTIME	0x8000000000000000
127 
128 #define	EFI_MEMORY_DESCRIPTOR_VERSION	1
129 typedef struct {
130 	uint32_t		Type;
131 	uint32_t		Pad;
132 	EFI_PHYSICAL_ADDRESS	PhysicalStart;
133 	EFI_VIRTUAL_ADDRESS	VirtualStart;
134 	uint64_t		NumberOfPages;
135 	uint64_t		Attribute;
136 } __packed EFI_MEMORY_DESCRIPTOR;
137 
138 /* Tables */
139 
140 typedef struct {
141 	uint64_t Signature;
142 	uint32_t Revision;
143 	uint32_t HeaderSize;
144 	uint32_t CRC32;
145 	uint32_t Reserved;
146 } EFI_TABLE_HEADER;
147 
148 /*
149  * The upper 16 bits of the revision contain the major revision value,
150  * and the lower 16 bits contain the minor revision value. The minor revision
151  * values are binary coded decimals and are limited to the range of 00..99.
152  * If the lower digit of the minor revision is 0, the version is printed as:
153  * major.minor upper decimal
154  * Otherwise the version is printed as:
155  * major.minor upper decimal.minor lower decimal
156  */
157 #define	EFI_REV(x, y)		(((x) << 16) || (y))
158 #define	EFI_REV_MAJOR(x)	(((x) >> 16) & 0xffff)
159 #define	EFI_REV_MINOR(x)	((x) & 0xffff)
160 #define	EFI_SYSTEM_TABLE_SIGNATURE	0x5453595320494249
161 
162 typedef uint32_t	efiptr32_t;
163 typedef uint64_t	efiptr64_t;
164 
165 typedef struct _EFI_CONFIGURATION_TABLE32 {
166 	efi_guid_t	VendorGuid;
167 	efiptr32_t	VendorTable;
168 } __packed EFI_CONFIGURATION_TABLE32;
169 
170 typedef struct _EFI_CONFIGURATION_TABLE64 {
171 	efi_guid_t	VendorGuid;
172 	efiptr64_t	VendorTable;
173 } __packed EFI_CONFIGURATION_TABLE64;
174 
175 typedef struct _EFI_SYSTEM_TABLE32 {
176 	EFI_TABLE_HEADER	Hdr;
177 
178 	efiptr32_t		FirmwareVendor;
179 	uint32_t		FirmwareRevision;
180 
181 	efiptr32_t		ConsoleInHandle;
182 	efiptr32_t		ConIn;
183 
184 	efiptr32_t		ConsoleOutHandle;
185 	efiptr32_t		ConOut;
186 
187 	efiptr32_t		StandardErrorHandle;
188 	efiptr32_t		StdErr;
189 
190 	efiptr32_t		RuntimeServices;
191 	efiptr32_t		BootServices;
192 
193 	uint32_t		NumberOfTableEntries;
194 	efiptr32_t		ConfigurationTable;
195 } __packed EFI_SYSTEM_TABLE32;
196 
197 typedef struct _EFI_SYSTEM_TABLE64 {
198 	EFI_TABLE_HEADER	Hdr;
199 
200 	efiptr64_t		FirmwareVendor;
201 	uint32_t		FirmwareRevision;
202 	uint32_t		Pad;
203 
204 	efiptr64_t		ConsoleInHandle;
205 	efiptr64_t		ConIn;
206 
207 	efiptr64_t		ConsoleOutHandle;
208 	efiptr64_t		ConOut;
209 
210 	efiptr64_t		StandardErrorHandle;
211 	efiptr64_t		StdErr;
212 
213 	efiptr64_t		RuntimeServices;
214 	efiptr64_t		BootServices;
215 
216 	uint64_t		NumberOfTableEntries;
217 	efiptr64_t		ConfigurationTable;
218 } __packed EFI_SYSTEM_TABLE64;
219 
220 #ifdef __cplusplus
221 }
222 #endif
223 
224 #endif /* _SYS_EFI_H */
225