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