efi.h revision 1.3
11.3Sriastrad/*     $NetBSD: efi.h,v 1.3 2022/08/20 09:40:13 riastradh Exp $   */
21.1Sjmcneill
31.1Sjmcneill/*-
41.1Sjmcneill * Copyright (c) 2004 Marcel Moolenaar
51.1Sjmcneill * All rights reserved.
61.1Sjmcneill *
71.1Sjmcneill * Redistribution and use in source and binary forms, with or without
81.1Sjmcneill * modification, are permitted provided that the following conditions
91.1Sjmcneill * are met:
101.1Sjmcneill *
111.1Sjmcneill * 1. Redistributions of source code must retain the above copyright
121.1Sjmcneill *    notice, this list of conditions and the following disclaimer.
131.1Sjmcneill * 2. Redistributions in binary form must reproduce the above copyright
141.1Sjmcneill *    notice, this list of conditions and the following disclaimer in the
151.1Sjmcneill *    documentation and/or other materials provided with the distribution.
161.1Sjmcneill *
171.1Sjmcneill * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
181.1Sjmcneill * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
191.1Sjmcneill * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
201.1Sjmcneill * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
211.1Sjmcneill * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
221.1Sjmcneill * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
231.1Sjmcneill * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
241.1Sjmcneill * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
251.1Sjmcneill * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
261.1Sjmcneill * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
271.1Sjmcneill *
281.1Sjmcneill * $FreeBSD$
291.1Sjmcneill */
301.1Sjmcneill
311.1Sjmcneill/*
321.1Sjmcneill * This file is mainly x86/include/efi.h, which in turn is mainly
331.1Sjmcneill * ia64/include/efi.h with little modifications.
341.1Sjmcneill */
351.1Sjmcneill
361.1Sjmcneill#ifndef _ARM_EFI_H_
371.1Sjmcneill#define _ARM_EFI_H_
381.1Sjmcneill
391.1Sjmcneill#include <sys/uuid.h>
401.1Sjmcneill
411.3Sriastrad#define	EFI_PAGE_SHIFT		12
421.3Sriastrad#define	EFI_PAGE_SIZE		(1 << EFI_PAGE_SHIFT)
431.3Sriastrad#define	EFI_PAGE_MASK		(EFI_PAGE_SIZE - 1)
441.1Sjmcneill
451.1Sjmcneill#define	EFI_TABLE_ACPI20						\
461.1Sjmcneill	{0x8868e871,0xe4f1,0x11d3,0xbc,0x22,{0x00,0x80,0xc7,0x3c,0x88,0x81}}
471.1Sjmcneill#define	EFI_TABLE_ACPI10						\
481.1Sjmcneill	{0xeb9d2d30,0x2d88,0x11d3,0x9a,0x16,{0x00,0x90,0x27,0x3f,0xc1,0x4d}}
491.1Sjmcneill#define	EFI_TABLE_SMBIOS						\
501.1Sjmcneill	{0xeb9d2d31,0x2d88,0x11d3,0x9a,0x16,{0x00,0x90,0x27,0x3f,0xc1,0x4d}}
511.1Sjmcneill#define	EFI_TABLE_SMBIOS3						\
521.1Sjmcneill	{0xf2fd1544,0x9794,0x4a2c,0x99,0x2e,{0xe5,0xbb,0xcf,0x20,0xe3,0x94}}
531.1Sjmcneill
541.1Sjmcneillextern const struct uuid EFI_UUID_ACPI20;
551.1Sjmcneillextern const struct uuid EFI_UUID_ACPI10;
561.1Sjmcneillextern const struct uuid EFI_UUID_SMBIOS;
571.1Sjmcneillextern const struct uuid EFI_UUID_SMBIOS3;
581.1Sjmcneill
591.1Sjmcneillextern bool bootmethod_efi;
601.1Sjmcneill
611.1Sjmcneillenum efi_reset {
621.1Sjmcneill	EFI_RESET_COLD,
631.1Sjmcneill	EFI_RESET_WARM,
641.1Sjmcneill	EFI_RESET_SHUTDOWN,
651.1Sjmcneill	EFI_RESET_PLATFORM_SPECIFIC,
661.1Sjmcneill};
671.1Sjmcneill
681.3Sriastradtypedef uint16_t	efi_char;
691.1Sjmcneilltypedef unsigned long efi_status;
701.1Sjmcneill
711.1Sjmcneillstruct efi_cfgtbl {
721.3Sriastrad	struct uuid	ct_uuid;
731.3Sriastrad	void		*ct_data;
741.1Sjmcneill};
751.1Sjmcneill
761.1Sjmcneillstruct efi_md {
771.3Sriastrad	uint32_t	md_type;
781.3Sriastrad#define	EFI_MD_TYPE_NULL	0
791.3Sriastrad#define	EFI_MD_TYPE_CODE	1	/* Loader text. */
801.3Sriastrad#define	EFI_MD_TYPE_DATA	2	/* Loader data. */
811.3Sriastrad#define	EFI_MD_TYPE_BS_CODE	3	/* Boot services text. */
821.3Sriastrad#define	EFI_MD_TYPE_BS_DATA	4	/* Boot services data. */
831.3Sriastrad#define	EFI_MD_TYPE_RT_CODE	5	/* Runtime services text. */
841.3Sriastrad#define	EFI_MD_TYPE_RT_DATA	6	/* Runtime services data. */
851.3Sriastrad#define	EFI_MD_TYPE_FREE	7	/* Unused/free memory. */
861.3Sriastrad#define	EFI_MD_TYPE_BAD		8	/* Bad memory */
871.3Sriastrad#define	EFI_MD_TYPE_RECLAIM	9	/* ACPI reclaimable memory. */
881.3Sriastrad#define	EFI_MD_TYPE_FIRMWARE	10	/* ACPI NV memory */
891.3Sriastrad#define	EFI_MD_TYPE_IOMEM	11	/* Memory-mapped I/O. */
901.3Sriastrad#define	EFI_MD_TYPE_IOPORT	12	/* I/O port space. */
911.3Sriastrad#define	EFI_MD_TYPE_PALCODE	13	/* PAL */
921.3Sriastrad#define	EFI_MD_TYPE_PMEM	14	/* Persistent memory. */
931.3Sriastrad	uint32_t	__pad;
941.3Sriastrad	uint64_t	md_phys;
951.3Sriastrad	uint64_t	md_virt;
961.3Sriastrad	uint64_t	md_pages;
971.3Sriastrad	uint64_t	md_attr;
981.3Sriastrad#define	EFI_MD_ATTR_UC		0x0000000000000001UL
991.3Sriastrad#define	EFI_MD_ATTR_WC		0x0000000000000002UL
1001.3Sriastrad#define	EFI_MD_ATTR_WT		0x0000000000000004UL
1011.3Sriastrad#define	EFI_MD_ATTR_WB		0x0000000000000008UL
1021.3Sriastrad#define	EFI_MD_ATTR_UCE		0x0000000000000010UL
1031.3Sriastrad#define	EFI_MD_ATTR_WP		0x0000000000001000UL
1041.3Sriastrad#define	EFI_MD_ATTR_RP		0x0000000000002000UL
1051.3Sriastrad#define	EFI_MD_ATTR_XP		0x0000000000004000UL
1061.3Sriastrad#define	EFI_MD_ATTR_NV		0x0000000000008000UL
1071.3Sriastrad#define	EFI_MD_ATTR_MORE_RELIABLE 0x0000000000010000UL
1081.3Sriastrad#define	EFI_MD_ATTR_RO		0x0000000000020000UL
1091.3Sriastrad#define	EFI_MD_ATTR_SP		0x0000000000040000UL
1101.3Sriastrad#define	EFI_MD_ATTR_CPU_CRYPTO	0x0000000000080000UL
1111.3Sriastrad#define	EFI_MD_ATTR_RT		0x8000000000000000UL
1121.1Sjmcneill};
1131.1Sjmcneill
1141.1Sjmcneillstruct efi_tm {
1151.3Sriastrad	uint16_t	tm_year;		/* 1998 - 20XX */
1161.3Sriastrad	uint8_t		tm_mon;			/* 1 - 12 */
1171.3Sriastrad	uint8_t		tm_mday;		/* 1 - 31 */
1181.3Sriastrad	uint8_t		tm_hour;		/* 0 - 23 */
1191.3Sriastrad	uint8_t		tm_min;			/* 0 - 59 */
1201.3Sriastrad	uint8_t		tm_sec;			/* 0 - 59 */
1211.3Sriastrad	uint8_t		__pad1;
1221.3Sriastrad	uint32_t	tm_nsec;		/* 0 - 999,999,999 */
1231.3Sriastrad	int16_t		tm_tz;			/* -1440 to 1440 or 2047 */
1241.3Sriastrad	uint8_t		tm_dst;
1251.3Sriastrad	uint8_t		__pad2;
1261.1Sjmcneill};
1271.1Sjmcneill
1281.1Sjmcneillstruct efi_tmcap {
1291.3Sriastrad	uint32_t	tc_res;		/* 1e-6 parts per million */
1301.3Sriastrad	uint32_t	tc_prec;	/* hertz */
1311.3Sriastrad	uint8_t		tc_stz;		/* Set clears sub-second time */
1321.1Sjmcneill};
1331.1Sjmcneill
1341.1Sjmcneillstruct efi_tblhdr {
1351.3Sriastrad	uint64_t	th_sig;
1361.3Sriastrad	uint32_t	th_rev;
1371.3Sriastrad	uint32_t	th_hdrsz;
1381.3Sriastrad	uint32_t	th_crc32;
1391.3Sriastrad	uint32_t	__res;
1401.1Sjmcneill};
1411.1Sjmcneill
1421.1Sjmcneillstruct efi_rt {
1431.3Sriastrad	struct efi_tblhdr rt_hdr;
1441.3Sriastrad	efi_status	(*rt_gettime)(struct efi_tm *, struct efi_tmcap *);
1451.3Sriastrad	efi_status	(*rt_settime)(struct efi_tm *);
1461.3Sriastrad	efi_status	(*rt_getwaketime)(uint8_t *, uint8_t *,
1471.3Sriastrad	    struct efi_tm *);
1481.3Sriastrad	efi_status	(*rt_setwaketime)(uint8_t, struct efi_tm *);
1491.3Sriastrad	efi_status	(*rt_setvirtual)(u_long, u_long, uint32_t,
1501.3Sriastrad	    struct efi_md *);
1511.3Sriastrad	efi_status	(*rt_cvtptr)(u_long, void **);
1521.3Sriastrad	efi_status	(*rt_getvar)(efi_char *, struct uuid *, uint32_t *,
1531.3Sriastrad	    u_long *, void *);
1541.3Sriastrad	efi_status	(*rt_scanvar)(u_long *, efi_char *, struct uuid *);
1551.3Sriastrad	efi_status	(*rt_setvar)(efi_char *, struct uuid *, uint32_t,
1561.3Sriastrad	    u_long, void *);
1571.3Sriastrad	efi_status	(*rt_gethicnt)(uint32_t *);
1581.3Sriastrad	efi_status	(*rt_reset)(enum efi_reset, efi_status, u_long,
1591.3Sriastrad	    efi_char *);
1601.1Sjmcneill};
1611.1Sjmcneill
1621.1Sjmcneillstruct efi_systbl {
1631.3Sriastrad	struct efi_tblhdr st_hdr;
1641.3Sriastrad#define	EFI_SYSTBL_SIG	0x5453595320494249UL
1651.3Sriastrad	efi_char	*st_fwvendor;
1661.3Sriastrad	uint32_t	st_fwrev;
1671.3Sriastrad	void		*st_cin;
1681.3Sriastrad	void		*st_cinif;
1691.3Sriastrad	void		*st_cout;
1701.3Sriastrad	void		*st_coutif;
1711.3Sriastrad	void		*st_cerr;
1721.3Sriastrad	void		*st_cerrif;
1731.3Sriastrad	struct efi_rt	*st_rt;
1741.3Sriastrad	void		*st_bs;
1751.3Sriastrad	u_long		st_entries;
1761.3Sriastrad	struct efi_cfgtbl *st_cfgtbl;
1771.1Sjmcneill};
1781.1Sjmcneill
1791.1Sjmcneill#endif /* _ARM_EFI_H_ */
180