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