]> git.proxmox.com Git - mirror_edk2.git/blob - StdLib/Include/Ipf/machine/efi.h
Standard Libraries for EDK II.
[mirror_edk2.git] / StdLib / Include / Ipf / machine / efi.h
1 /* $NetBSD: efi.h,v 1.1 2006/04/07 14:21:18 cherry 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 #ifndef _MACHINE_EFI_H_
32 #define _MACHINE_EFI_H_
33
34 #include <sys/uuid.h>
35
36 #define EFI_PAGE_SHIFT 12
37 #define EFI_PAGE_SIZE (1 << EFI_PAGE_SHIFT)
38 #define EFI_PAGE_MASK (EFI_PAGE_SIZE - 1)
39
40 #define EFI_TABLE_ACPI20 \
41 {0x8868e871,0xe4f1,0x11d3,0xbc,0x22,{0x00,0x80,0xc7,0x3c,0x88,0x81}}
42 #define EFI_TABLE_SAL \
43 {0xeb9d2d32,0x2d88,0x11d3,0x9a,0x16,{0x00,0x90,0x27,0x3f,0xc1,0x4d}}
44
45 enum efi_reset {
46 EFI_RESET_COLD,
47 EFI_RESET_WARM
48 };
49
50 typedef uint16_t efi_char;
51 typedef unsigned long efi_status;
52
53 struct efi_cfgtbl {
54 struct uuid ct_uuid;
55 uint64_t ct_data;
56 };
57
58 struct efi_md {
59 uint32_t md_type;
60 #define EFI_MD_TYPE_NULL 0
61 #define EFI_MD_TYPE_CODE 1 /* Loader text. */
62 #define EFI_MD_TYPE_DATA 2 /* Loader data. */
63 #define EFI_MD_TYPE_BS_CODE 3 /* Boot services text. */
64 #define EFI_MD_TYPE_BS_DATA 4 /* Boot services data. */
65 #define EFI_MD_TYPE_RT_CODE 5 /* Runtime services text. */
66 #define EFI_MD_TYPE_RT_DATA 6 /* Runtime services data. */
67 #define EFI_MD_TYPE_FREE 7 /* Unused/free memory. */
68 #define EFI_MD_TYPE_BAD 8 /* Bad memory */
69 #define EFI_MD_TYPE_RECLAIM 9 /* ACPI reclaimable memory. */
70 #define EFI_MD_TYPE_FIRMWARE 10 /* ACPI NV memory */
71 #define EFI_MD_TYPE_IOMEM 11 /* Memory-mapped I/O. */
72 #define EFI_MD_TYPE_IOPORT 12 /* I/O port space. */
73 #define EFI_MD_TYPE_PALCODE 13 /* PAL */
74 uint32_t __pad;
75 uint64_t md_phys;
76 void *md_virt;
77 uint64_t md_pages;
78 uint64_t md_attr;
79 #define EFI_MD_ATTR_UC 0x0000000000000001UL
80 #define EFI_MD_ATTR_WC 0x0000000000000002UL
81 #define EFI_MD_ATTR_WT 0x0000000000000004UL
82 #define EFI_MD_ATTR_WB 0x0000000000000008UL
83 #define EFI_MD_ATTR_UCE 0x0000000000000010UL
84 #define EFI_MD_ATTR_WP 0x0000000000001000UL
85 #define EFI_MD_ATTR_RP 0x0000000000002000UL
86 #define EFI_MD_ATTR_XP 0x0000000000004000UL
87 #define EFI_MD_ATTR_RT 0x8000000000000000UL
88 };
89
90 struct efi_tm {
91 uint16_t tm_year; /* 1998 - 20XX */
92 uint8_t tm_mon; /* 1 - 12 */
93 uint8_t tm_mday; /* 1 - 31 */
94 uint8_t tm_hour; /* 0 - 23 */
95 uint8_t tm_min; /* 0 - 59 */
96 uint8_t tm_sec; /* 0 - 59 */
97 uint8_t __pad1;
98 uint32_t tm_nsec; /* 0 - 999,999,999 */
99 int16_t tm_tz; /* -1440 to 1440 or 2047 */
100 uint8_t tm_dst;
101 uint8_t __pad2;
102 };
103
104 struct efi_tmcap {
105 uint32_t tc_res; /* 1e-6 parts per million */
106 uint32_t tc_prec; /* hertz */
107 uint8_t tc_stz; /* Set clears sub-second time */
108 };
109
110 struct efi_tblhdr {
111 uint64_t th_sig;
112 uint32_t th_rev;
113 uint32_t th_hdrsz;
114 uint32_t th_crc32;
115 uint32_t __res;
116 };
117
118 struct efi_rt {
119 struct efi_tblhdr rt_hdr;
120 efi_status (*rt_gettime)(struct efi_tm *, struct efi_tmcap *);
121 efi_status (*rt_settime)(struct efi_tm *);
122 efi_status (*rt_getwaketime)(uint8_t *, uint8_t *,
123 struct efi_tm *);
124 efi_status (*rt_setwaketime)(uint8_t, struct efi_tm *);
125 efi_status (*rt_setvirtual)(u_long, u_long, uint32_t,
126 struct efi_md *);
127 efi_status (*rt_cvtptr)(u_long, void **);
128 efi_status (*rt_getvar)(efi_char *, struct uuid *, uint32_t *,
129 u_long *, void *);
130 efi_status (*rt_scanvar)(u_long *, efi_char *, struct uuid *);
131 efi_status (*rt_setvar)(efi_char *, struct uuid *, uint32_t,
132 u_long, void *);
133 efi_status (*rt_gethicnt)(uint32_t *);
134 efi_status (*rt_reset)(enum efi_reset, efi_status, u_long,
135 efi_char *);
136 };
137
138 struct efi_systbl {
139 struct efi_tblhdr st_hdr;
140 #define EFI_SYSTBL_SIG 0x5453595320494249UL
141 efi_char *st_fwvendor;
142 uint32_t st_fwrev;
143 uint32_t __pad;
144 void *st_cin;
145 void *st_cinif;
146 void *st_cout;
147 void *st_coutif;
148 void *st_cerr;
149 void *st_cerrif;
150 uint64_t st_rt;
151 void *st_bs;
152 u_long st_entries;
153 uint64_t st_cfgtbl;
154 };
155
156 void efi_boot_finish(void);
157 int efi_boot_minimal(uint64_t);
158 void *efi_get_table(struct uuid *);
159 void efi_get_time(struct efi_tm *);
160 struct efi_md *efi_md_first(void);
161 struct efi_md *efi_md_next(struct efi_md *);
162 void efi_reset_system(void);
163 efi_status efi_set_time(struct efi_tm *);
164
165 #endif /* _MACHINE_EFI_H_ */