xref: /dragonfly/sys/sys/efi.h (revision 2be007da)
1a1f54debSImre Vadasz /*-
2a1f54debSImre Vadasz  * Copyright (c) 2004 Marcel Moolenaar
3a1f54debSImre Vadasz  * All rights reserved.
4a1f54debSImre Vadasz  *
5a1f54debSImre Vadasz  * Redistribution and use in source and binary forms, with or without
6a1f54debSImre Vadasz  * modification, are permitted provided that the following conditions
7a1f54debSImre Vadasz  * are met:
8a1f54debSImre Vadasz  *
9a1f54debSImre Vadasz  * 1. Redistributions of source code must retain the above copyright
10a1f54debSImre Vadasz  *    notice, this list of conditions and the following disclaimer.
11a1f54debSImre Vadasz  * 2. Redistributions in binary form must reproduce the above copyright
12a1f54debSImre Vadasz  *    notice, this list of conditions and the following disclaimer in the
13a1f54debSImre Vadasz  *    documentation and/or other materials provided with the distribution.
14a1f54debSImre Vadasz  *
15a1f54debSImre Vadasz  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16a1f54debSImre Vadasz  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17a1f54debSImre Vadasz  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18a1f54debSImre Vadasz  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19a1f54debSImre Vadasz  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20a1f54debSImre Vadasz  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21a1f54debSImre Vadasz  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22a1f54debSImre Vadasz  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23a1f54debSImre Vadasz  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24a1f54debSImre Vadasz  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25a1f54debSImre Vadasz  *
26a1f54debSImre Vadasz  * $FreeBSD: head/sys/sys/efi.h 292472 2015-12-19 19:01:43Z imp	$
27a1f54debSImre Vadasz  */
28a1f54debSImre Vadasz 
29a1f54debSImre Vadasz #ifndef _SYS_EFI_H_
30a1f54debSImre Vadasz #define _SYS_EFI_H_
31a1f54debSImre Vadasz 
32a1f54debSImre Vadasz #include <sys/uuid.h>
33a1f54debSImre Vadasz 
34a1f54debSImre Vadasz #define	EFI_PAGE_SHIFT		12
35a1f54debSImre Vadasz #define	EFI_PAGE_SIZE		(1 << EFI_PAGE_SHIFT)
36a1f54debSImre Vadasz #define	EFI_PAGE_MASK		(EFI_PAGE_SIZE - 1)
37a1f54debSImre Vadasz 
38a1f54debSImre Vadasz #define	EFI_TABLE_ACPI20			\
39a1f54debSImre Vadasz 	{0x8868e871,0xe4f1,0x11d3,0xbc,0x22,{0x00,0x80,0xc7,0x3c,0x88,0x81}}
40a1f54debSImre Vadasz #define	EFI_TABLE_SAL				\
41a1f54debSImre Vadasz 	{0xeb9d2d32,0x2d88,0x11d3,0x9a,0x16,{0x00,0x90,0x27,0x3f,0xc1,0x4d}}
42a1f54debSImre Vadasz 
43a1f54debSImre Vadasz enum efi_reset {
44a1f54debSImre Vadasz 	EFI_RESET_COLD,
45a1f54debSImre Vadasz 	EFI_RESET_WARM
46a1f54debSImre Vadasz };
47a1f54debSImre Vadasz 
48a1f54debSImre Vadasz typedef uint16_t	efi_char;
49a1f54debSImre Vadasz typedef unsigned long efi_status;
50a1f54debSImre Vadasz 
51a1f54debSImre Vadasz struct efi_cfgtbl {
52a1f54debSImre Vadasz 	struct uuid	ct_uuid;
53a1f54debSImre Vadasz 	uint64_t	ct_data;
54a1f54debSImre Vadasz };
55a1f54debSImre Vadasz 
56a1f54debSImre Vadasz struct efi_md {
57a1f54debSImre Vadasz 	uint32_t	md_type;
58a1f54debSImre Vadasz #define	EFI_MD_TYPE_NULL	0
59a1f54debSImre Vadasz #define	EFI_MD_TYPE_CODE	1	/* Loader text. */
60a1f54debSImre Vadasz #define	EFI_MD_TYPE_DATA	2	/* Loader data. */
61a1f54debSImre Vadasz #define	EFI_MD_TYPE_BS_CODE	3	/* Boot services text. */
62a1f54debSImre Vadasz #define	EFI_MD_TYPE_BS_DATA	4	/* Boot services data. */
63a1f54debSImre Vadasz #define	EFI_MD_TYPE_RT_CODE	5	/* Runtime services text. */
64a1f54debSImre Vadasz #define	EFI_MD_TYPE_RT_DATA	6	/* Runtime services data. */
65a1f54debSImre Vadasz #define	EFI_MD_TYPE_FREE	7	/* Unused/free memory. */
66a1f54debSImre Vadasz #define	EFI_MD_TYPE_BAD		8	/* Bad memory */
67a1f54debSImre Vadasz #define	EFI_MD_TYPE_RECLAIM	9	/* ACPI reclaimable memory. */
68a1f54debSImre Vadasz #define	EFI_MD_TYPE_FIRMWARE	10	/* ACPI NV memory */
69a1f54debSImre Vadasz #define	EFI_MD_TYPE_IOMEM	11	/* Memory-mapped I/O. */
70a1f54debSImre Vadasz #define	EFI_MD_TYPE_IOPORT	12	/* I/O port space. */
71a1f54debSImre Vadasz #define	EFI_MD_TYPE_PALCODE	13	/* PAL */
72a1f54debSImre Vadasz 	uint32_t	__pad;
73a1f54debSImre Vadasz 	uint64_t	md_phys;
74a1f54debSImre Vadasz 	void		*md_virt;
75a1f54debSImre Vadasz 	uint64_t	md_pages;
76a1f54debSImre Vadasz 	uint64_t	md_attr;
77a1f54debSImre Vadasz #define	EFI_MD_ATTR_UC		0x0000000000000001UL
78a1f54debSImre Vadasz #define	EFI_MD_ATTR_WC		0x0000000000000002UL
79a1f54debSImre Vadasz #define	EFI_MD_ATTR_WT		0x0000000000000004UL
80a1f54debSImre Vadasz #define	EFI_MD_ATTR_WB		0x0000000000000008UL
81a1f54debSImre Vadasz #define	EFI_MD_ATTR_UCE		0x0000000000000010UL
82a1f54debSImre Vadasz #define	EFI_MD_ATTR_WP		0x0000000000001000UL
83a1f54debSImre Vadasz #define	EFI_MD_ATTR_RP		0x0000000000002000UL
84a1f54debSImre Vadasz #define	EFI_MD_ATTR_XP		0x0000000000004000UL
85a1f54debSImre Vadasz #define	EFI_MD_ATTR_RT		0x8000000000000000UL
86a1f54debSImre Vadasz };
87a1f54debSImre Vadasz 
88cd4cccbcSSascha Wildner #define efi_next_descriptor(ptr, size) \
89cd4cccbcSSascha Wildner     ((struct efi_md *)(((uint8_t *)(ptr)) + (size)))
90cd4cccbcSSascha Wildner 
91a1f54debSImre Vadasz struct efi_tm {
92a1f54debSImre Vadasz 	uint16_t	tm_year;		/* 1998 - 20XX */
93a1f54debSImre Vadasz 	uint8_t		tm_mon;			/* 1 - 12 */
94a1f54debSImre Vadasz 	uint8_t		tm_mday;		/* 1 - 31 */
95a1f54debSImre Vadasz 	uint8_t		tm_hour;		/* 0 - 23 */
96a1f54debSImre Vadasz 	uint8_t		tm_min;			/* 0 - 59 */
97a1f54debSImre Vadasz 	uint8_t		tm_sec;			/* 0 - 59 */
98a1f54debSImre Vadasz 	uint8_t		__pad1;
99a1f54debSImre Vadasz 	uint32_t	tm_nsec;		/* 0 - 999,999,999 */
100a1f54debSImre Vadasz 	int16_t		tm_tz;			/* -1440 to 1440 or 2047 */
101a1f54debSImre Vadasz 	uint8_t		tm_dst;
102a1f54debSImre Vadasz 	uint8_t		__pad2;
103a1f54debSImre Vadasz };
104a1f54debSImre Vadasz 
105a1f54debSImre Vadasz struct efi_tmcap {
106a1f54debSImre Vadasz 	uint32_t	tc_res;		/* 1e-6 parts per million */
107a1f54debSImre Vadasz 	uint32_t	tc_prec;	/* hertz */
108a1f54debSImre Vadasz 	uint8_t		tc_stz;		/* Set clears sub-second time */
109a1f54debSImre Vadasz };
110a1f54debSImre Vadasz 
111a1f54debSImre Vadasz struct efi_tblhdr {
112a1f54debSImre Vadasz 	uint64_t	th_sig;
113a1f54debSImre Vadasz 	uint32_t	th_rev;
114a1f54debSImre Vadasz 	uint32_t	th_hdrsz;
115a1f54debSImre Vadasz 	uint32_t	th_crc32;
116a1f54debSImre Vadasz 	uint32_t	__res;
117a1f54debSImre Vadasz };
118a1f54debSImre Vadasz 
119*2be007daSMatthew Dillon #define EFIABI	__attribute__((ms_abi))
120*2be007daSMatthew Dillon 
121a1f54debSImre Vadasz struct efi_rt {
122a1f54debSImre Vadasz 	struct efi_tblhdr rt_hdr;
123*2be007daSMatthew Dillon 	efi_status	(*rt_gettime)(struct efi_tm *, struct efi_tmcap *)
124*2be007daSMatthew Dillon 				EFIABI;
125*2be007daSMatthew Dillon 	efi_status	(*rt_settime)(struct efi_tm *)
126*2be007daSMatthew Dillon 				EFIABI;
127a1f54debSImre Vadasz 	efi_status	(*rt_getwaketime)(uint8_t *, uint8_t *,
128*2be007daSMatthew Dillon 				struct efi_tm *) EFIABI;
129*2be007daSMatthew Dillon 	efi_status	(*rt_setwaketime)(uint8_t, struct efi_tm *)
130*2be007daSMatthew Dillon 				EFIABI;
131a1f54debSImre Vadasz 	efi_status	(*rt_setvirtual)(u_long, u_long, uint32_t,
132*2be007daSMatthew Dillon 				struct efi_md *) EFIABI;
133*2be007daSMatthew Dillon 	efi_status	(*rt_cvtptr)(u_long, void **)
134*2be007daSMatthew Dillon 				EFIABI;
135a1f54debSImre Vadasz 	efi_status	(*rt_getvar)(efi_char *, struct uuid *, uint32_t *,
136*2be007daSMatthew Dillon 				u_long *, void *) EFIABI;
137*2be007daSMatthew Dillon 	efi_status	(*rt_scanvar)(u_long *, efi_char *, struct uuid *)
138*2be007daSMatthew Dillon 				EFIABI;
139a1f54debSImre Vadasz 	efi_status	(*rt_setvar)(efi_char *, struct uuid *, uint32_t,
140*2be007daSMatthew Dillon 				u_long, void *) EFIABI;
141*2be007daSMatthew Dillon 	efi_status	(*rt_gethicnt)(uint32_t *)
142*2be007daSMatthew Dillon 				EFIABI;
143a1f54debSImre Vadasz 	efi_status	(*rt_reset)(enum efi_reset, efi_status, u_long,
144*2be007daSMatthew Dillon 				efi_char *) EFIABI;
145a1f54debSImre Vadasz };
146a1f54debSImre Vadasz 
147a1f54debSImre Vadasz struct efi_systbl {
148a1f54debSImre Vadasz 	struct efi_tblhdr st_hdr;
149a1f54debSImre Vadasz #define	EFI_SYSTBL_SIG	0x5453595320494249UL
150a1f54debSImre Vadasz 	efi_char	*st_fwvendor;
151a1f54debSImre Vadasz 	uint32_t	st_fwrev;
152a1f54debSImre Vadasz 	uint32_t	__pad;
153a1f54debSImre Vadasz 	void		*st_cin;
154a1f54debSImre Vadasz 	void		*st_cinif;
155a1f54debSImre Vadasz 	void		*st_cout;
156a1f54debSImre Vadasz 	void		*st_coutif;
157a1f54debSImre Vadasz 	void		*st_cerr;
158a1f54debSImre Vadasz 	void		*st_cerrif;
159a1f54debSImre Vadasz 	uint64_t	st_rt;
160a1f54debSImre Vadasz 	void		*st_bs;
161a1f54debSImre Vadasz 	u_long		st_entries;
162a1f54debSImre Vadasz 	uint64_t	st_cfgtbl;
163a1f54debSImre Vadasz };
164a1f54debSImre Vadasz 
165cd4cccbcSSascha Wildner #ifdef _KERNEL
166cd4cccbcSSascha Wildner extern vm_paddr_t efi_systbl_phys;
167cd4cccbcSSascha Wildner #endif	/* _KERNEL */
168cd4cccbcSSascha Wildner 
169a1f54debSImre Vadasz #endif /* _SYS_EFI_H_ */
170