1 | /* $Id: DevEFI.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * EFI for VirtualBox Common Definitions.
|
---|
4 | *
|
---|
5 | * WARNING: This header is used by both firmware and VBox device,
|
---|
6 | * thus don't put anything here but numeric constants or helper
|
---|
7 | * inline functions.
|
---|
8 | */
|
---|
9 |
|
---|
10 | /*
|
---|
11 | * Copyright (C) 2009-2023 Oracle and/or its affiliates.
|
---|
12 | *
|
---|
13 | * This file is part of VirtualBox base platform packages, as
|
---|
14 | * available from https://www.virtualbox.org.
|
---|
15 | *
|
---|
16 | * This program is free software; you can redistribute it and/or
|
---|
17 | * modify it under the terms of the GNU General Public License
|
---|
18 | * as published by the Free Software Foundation, in version 3 of the
|
---|
19 | * License.
|
---|
20 | *
|
---|
21 | * This program is distributed in the hope that it will be useful, but
|
---|
22 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
24 | * General Public License for more details.
|
---|
25 | *
|
---|
26 | * You should have received a copy of the GNU General Public License
|
---|
27 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
28 | *
|
---|
29 | * The contents of this file may alternatively be used under the terms
|
---|
30 | * of the Common Development and Distribution License Version 1.0
|
---|
31 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
32 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
33 | * CDDL are applicable instead of those of the GPL.
|
---|
34 | *
|
---|
35 | * You may elect to license modified versions of this file under the
|
---|
36 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
37 | *
|
---|
38 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
39 | */
|
---|
40 |
|
---|
41 | #ifndef VBOX_INCLUDED_SRC_EFI_DevEFI_h
|
---|
42 | #define VBOX_INCLUDED_SRC_EFI_DevEFI_h
|
---|
43 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
44 | # pragma once
|
---|
45 | #endif
|
---|
46 |
|
---|
47 | /** @defgroup grp_devefi DevEFI <-> Firmware Interfaces
|
---|
48 | * @{
|
---|
49 | */
|
---|
50 |
|
---|
51 | /** The base of the I/O ports used for interaction between the EFI firmware and DevEFI. */
|
---|
52 | #define EFI_PORT_BASE 0xEF10 /**< @todo r=klaus stupid choice which causes trouble with PCI resource allocation in complex bridge setups, change to 0x0400 with appropriate saved state and reset handling */
|
---|
53 | /** The number of ports. */
|
---|
54 | #define EFI_PORT_COUNT 0x0008
|
---|
55 |
|
---|
56 |
|
---|
57 | /** Information querying.
|
---|
58 | * 32-bit write sets the info index and resets the reading, see EfiInfoIndex.
|
---|
59 | * 32-bit read returns the size of the info (in bytes).
|
---|
60 | * 8-bit reads returns the info as a byte sequence. */
|
---|
61 | #define EFI_INFO_PORT (EFI_PORT_BASE+0x0)
|
---|
62 | /**
|
---|
63 | * Information requests.
|
---|
64 | */
|
---|
65 | typedef enum
|
---|
66 | {
|
---|
67 | EFI_INFO_INDEX_INVALID = 0,
|
---|
68 | EFI_INFO_INDEX_VOLUME_BASE,
|
---|
69 | EFI_INFO_INDEX_VOLUME_SIZE,
|
---|
70 | EFI_INFO_INDEX_TEMPMEM_BASE,
|
---|
71 | EFI_INFO_INDEX_TEMPMEM_SIZE,
|
---|
72 | EFI_INFO_INDEX_STACK_BASE,
|
---|
73 | EFI_INFO_INDEX_STACK_SIZE,
|
---|
74 | EFI_INFO_INDEX_BOOT_ARGS,
|
---|
75 | EFI_INFO_INDEX_DEVICE_PROPS,
|
---|
76 | EFI_INFO_INDEX_FSB_FREQUENCY,
|
---|
77 | EFI_INFO_INDEX_CPU_FREQUENCY,
|
---|
78 | EFI_INFO_INDEX_TSC_FREQUENCY,
|
---|
79 | EFI_INFO_INDEX_GRAPHICS_MODE,
|
---|
80 | EFI_INFO_INDEX_HORIZONTAL_RESOLUTION,
|
---|
81 | EFI_INFO_INDEX_VERTICAL_RESOLUTION,
|
---|
82 | EFI_INFO_INDEX_MCFG_BASE,
|
---|
83 | EFI_INFO_INDEX_MCFG_SIZE,
|
---|
84 | EFI_INFO_INDEX_APIC_MODE,
|
---|
85 | EFI_INFO_INDEX_CPU_COUNT_CURRENT,
|
---|
86 | EFI_INFO_INDEX_CPU_COUNT_MAX,
|
---|
87 | EFI_INFO_INDEX_END
|
---|
88 | } EfiInfoIndex;
|
---|
89 |
|
---|
90 | /** @name APIC mode defines as returned by EFI_INFO_INDEX_APIC_MODE
|
---|
91 | * @{ */
|
---|
92 | #define EFI_APIC_MODE_DISABLED 0
|
---|
93 | #define EFI_APIC_MODE_APIC 1
|
---|
94 | #define EFI_APIC_MODE_X2APIC 2
|
---|
95 | /** @} */
|
---|
96 |
|
---|
97 | /** Panic port.
|
---|
98 | * Write causes action to be taken according to the value written,
|
---|
99 | * see the EFI_PANIC_CMD_* defines below.
|
---|
100 | * Reading from the port has no effect. */
|
---|
101 | #define EFI_PANIC_PORT (EFI_PORT_BASE+0x1)
|
---|
102 |
|
---|
103 | /** @defgroup grp_devefi_panic_cmd Panic Commands for EFI_PANIC_PORT
|
---|
104 | * @{ */
|
---|
105 | /** Used by the EfiThunk.asm to signal ORG inconsistency. */
|
---|
106 | #define EFI_PANIC_CMD_BAD_ORG 1
|
---|
107 | /** Used by the EfiThunk.asm to signal unexpected trap or interrupt. */
|
---|
108 | #define EFI_PANIC_CMD_THUNK_TRAP 2
|
---|
109 | /** Starts a panic message.
|
---|
110 | * Makes sure the panic message buffer is empty. */
|
---|
111 | #define EFI_PANIC_CMD_START_MSG 3
|
---|
112 | /** Ends a panic message and enters guru meditation state. */
|
---|
113 | #define EFI_PANIC_CMD_END_MSG 4
|
---|
114 | /** The first panic message command.
|
---|
115 | * The low byte of the command is the char to be added to the panic message. */
|
---|
116 | #define EFI_PANIC_CMD_MSG_FIRST 0x4201
|
---|
117 | /** The last panic message command. */
|
---|
118 | #define EFI_PANIC_CMD_MSG_LAST 0x427f
|
---|
119 | /** Makes a panic message command from a char. */
|
---|
120 | #define EFI_PANIC_CMD_MSG_FROM_CHAR(ch) (0x4200 | ((ch) & 0x7f) )
|
---|
121 | /** Extracts the char from a panic message command. */
|
---|
122 | #define EFI_PANIC_CMD_MSG_GET_CHAR(u32) ((u32) & 0x7f)
|
---|
123 | /** @} */
|
---|
124 |
|
---|
125 | /** Undefined port. */
|
---|
126 | #define EFI_PORT_UNDEFINED (EFI_PORT_BASE+0x2)
|
---|
127 |
|
---|
128 | /** Debug logging.
|
---|
129 | * The chars written goes to the log.
|
---|
130 | * Reading has no effect.
|
---|
131 | * @remarks The port number is the same as on of those used by the PC BIOS. */
|
---|
132 | #define EFI_DEBUG_PORT (EFI_PORT_BASE+0x3)
|
---|
133 |
|
---|
134 | #define VBOX_EFI_DEBUG_BUFFER 512
|
---|
135 | /** The top of the EFI stack.
|
---|
136 | * The firmware expects a 128KB stack.
|
---|
137 | * @todo Move this to 1MB + 128KB and drop the stack relocation the firmware
|
---|
138 | * does. It expects the stack to be within the temporary memory that
|
---|
139 | * SEC hands to PEI and the VBoxAutoScan PEIM reports. */
|
---|
140 | #define VBOX_EFI_TOP_OF_STACK 0x300000
|
---|
141 |
|
---|
142 | #define EFI_PORT_VARIABLE_OP (EFI_PORT_BASE+0x4)
|
---|
143 | #define EFI_PORT_VARIABLE_PARAM (EFI_PORT_BASE+0x5)
|
---|
144 |
|
---|
145 | #define EFI_VARIABLE_OP_QUERY 0xdead0001
|
---|
146 | #define EFI_VARIABLE_OP_QUERY_NEXT 0xdead0002
|
---|
147 | #define EFI_VARIABLE_OP_QUERY_REWIND 0xdead0003
|
---|
148 | #define EFI_VARIABLE_OP_ADD 0xdead0010
|
---|
149 |
|
---|
150 | #define EFI_VARIABLE_OP_STATUS_OK 0xcafe0000
|
---|
151 | #define EFI_VARIABLE_OP_STATUS_ERROR 0xcafe0001
|
---|
152 | #define EFI_VARIABLE_OP_STATUS_NOT_FOUND 0xcafe0002
|
---|
153 | #define EFI_VARIABLE_OP_STATUS_WP 0xcafe0003
|
---|
154 | #define EFI_VARIABLE_OP_STATUS_BSY 0xcafe0010
|
---|
155 |
|
---|
156 | /** The max number of variables allowed. */
|
---|
157 | #define EFI_VARIABLE_MAX 128
|
---|
158 | /** The max variable name length (in bytes, including the zero terminator). */
|
---|
159 | #define EFI_VARIABLE_NAME_MAX 1024
|
---|
160 | /** The max value length (in bytes). */
|
---|
161 | #define EFI_VARIABLE_VALUE_MAX 1024
|
---|
162 |
|
---|
163 | typedef enum
|
---|
164 | {
|
---|
165 | EFI_VM_VARIABLE_OP_START = 0,
|
---|
166 | EFI_VM_VARIABLE_OP_RESERVED_USED_TO_BE_END,
|
---|
167 | EFI_VM_VARIABLE_OP_RESERVED_USED_TO_BE_INDEX,
|
---|
168 | EFI_VM_VARIABLE_OP_GUID,
|
---|
169 | EFI_VM_VARIABLE_OP_ATTRIBUTE,
|
---|
170 | EFI_VM_VARIABLE_OP_NAME,
|
---|
171 | EFI_VM_VARIABLE_OP_NAME_LENGTH,
|
---|
172 | EFI_VM_VARIABLE_OP_VALUE,
|
---|
173 | EFI_VM_VARIABLE_OP_VALUE_LENGTH,
|
---|
174 | EFI_VM_VARIABLE_OP_ERROR,
|
---|
175 | EFI_VM_VARIABLE_OP_NAME_UTF16,
|
---|
176 | EFI_VM_VARIABLE_OP_NAME_LENGTH_UTF16,
|
---|
177 | EFI_VM_VARIABLE_OP_MAX,
|
---|
178 | EFI_VM_VARIABLE_OP_32BIT_HACK = 0x7fffffff
|
---|
179 | } EFIVAROP;
|
---|
180 |
|
---|
181 |
|
---|
182 | /** Debug point. */
|
---|
183 | #define EFI_PORT_DEBUG_POINT (EFI_PORT_BASE + 0x6)
|
---|
184 |
|
---|
185 | /**
|
---|
186 | * EFI debug points.
|
---|
187 | */
|
---|
188 | typedef enum EFIDBGPOINT
|
---|
189 | {
|
---|
190 | /** Invalid. */
|
---|
191 | EFIDBGPOINT_INVALID = 0,
|
---|
192 | /** DEBUG_AGENT_INIT_PREMEM_SEC. */
|
---|
193 | EFIDBGPOINT_SEC_PREMEM = 1,
|
---|
194 | /** DEBUG_AGENT_INIT_POST_SEC. */
|
---|
195 | EFIDBGPOINT_SEC_POSTMEM,
|
---|
196 | /** DEBUG_AGENT_INIT_DXE_CORE. */
|
---|
197 | EFIDBGPOINT_DXE_CORE,
|
---|
198 | /** DEBUG_AGENT_INIT_. */
|
---|
199 | EFIDBGPOINT_SMM,
|
---|
200 | /** DEBUG_AGENT_INIT_ENTER_SMI. */
|
---|
201 | EFIDBGPOINT_SMI_ENTER,
|
---|
202 | /** DEBUG_AGENT_INIT_EXIT_SMI. */
|
---|
203 | EFIDBGPOINT_SMI_EXIT,
|
---|
204 | /** DEBUG_AGENT_INIT_S3. */
|
---|
205 | EFIDBGPOINT_GRAPHICS,
|
---|
206 | /** DEBUG_AGENT_INIT_DXE_AP. */
|
---|
207 | EFIDBGPOINT_DXE_AP,
|
---|
208 | /** End of valid points. */
|
---|
209 | EFIDBGPOINT_END,
|
---|
210 | /** Blow up the type to 32-bits. */
|
---|
211 | EFIDBGPOINT_32BIT_HACK = 0x7fffffff
|
---|
212 | } EFIDBGPOINT;
|
---|
213 |
|
---|
214 |
|
---|
215 | /** EFI image load or unload event. All writes are 32-bit writes. */
|
---|
216 | #define EFI_PORT_IMAGE_EVENT (EFI_PORT_BASE + 0x7)
|
---|
217 |
|
---|
218 | /** @defgroup grp_devefi_image_evt EFI Image Events (EFI_PORT_IMAGE_EVENT).
|
---|
219 | *
|
---|
220 | * The lower 8-bit of the values written to EFI_PORT_IMAGE_EVENT can be seen as
|
---|
221 | * the command. The start and complete commands does not have any additional
|
---|
222 | * payload. The other commands uses bit 8 thru 23 or 8 thru 15 to pass a value.
|
---|
223 | *
|
---|
224 | * @{ */
|
---|
225 |
|
---|
226 | /** The command mask. */
|
---|
227 | #define EFI_IMAGE_EVT_CMD_MASK UINT32_C(0x000000ff)
|
---|
228 | /** Get the payload value. */
|
---|
229 | #define EFI_IMAGE_EVT_GET_PAYLOAD(a_u32) ((a_u32) >> 8)
|
---|
230 | /** Get the payload value as unsigned 16-bit. */
|
---|
231 | #define EFI_IMAGE_EVT_GET_PAYLOAD_U16(a_u32) ( EFI_IMAGE_EVT_GET_PAYLOAD(a_u32) & UINT16_MAX )
|
---|
232 | /** Get the payload value as unsigned 8-bit. */
|
---|
233 | #define EFI_IMAGE_EVT_GET_PAYLOAD_U8(a_u32) ( EFI_IMAGE_EVT_GET_PAYLOAD(a_u32) & UINT8_MAX )
|
---|
234 | /** Combines a command and a payload value. */
|
---|
235 | #define EFI_IMAGE_EVT_MAKE(a_uCmd, a_uPayload) ( ((a_uCmd) & UINT32_C(0xff)) | (uint32_t)((a_uPayload) << 8) )
|
---|
236 |
|
---|
237 | /** Invalid. */
|
---|
238 | #define EFI_IMAGE_EVT_CMD_INVALID UINT32_C(0x00000000)
|
---|
239 | /** The event is complete. */
|
---|
240 | #define EFI_IMAGE_EVT_CMD_COMPLETE UINT32_C(0x00000001)
|
---|
241 | /** Starts a 32-bit load event. Requires name and address, size is optional. */
|
---|
242 | #define EFI_IMAGE_EVT_CMD_START_LOAD32 UINT32_C(0x00000002)
|
---|
243 | /** Starts a 64-bit load event. Requires name and address, size is optional. */
|
---|
244 | #define EFI_IMAGE_EVT_CMD_START_LOAD64 UINT32_C(0x00000003)
|
---|
245 | /** Starts a 32-bit unload event. Requires name and address. */
|
---|
246 | #define EFI_IMAGE_EVT_CMD_START_UNLOAD32 UINT32_C(0x00000004)
|
---|
247 | /** Starts a 64-bit unload event. Requires name and address. */
|
---|
248 | #define EFI_IMAGE_EVT_CMD_START_UNLOAD64 UINT32_C(0x00000005)
|
---|
249 | /** Starts a 32-bit relocation event. RRequires new and old base address. */
|
---|
250 | #define EFI_IMAGE_EVT_CMD_START_RELOC32 UINT32_C(0x0000000A)
|
---|
251 | /** Starts a 64-bit relocation event. Requires new and old base address. */
|
---|
252 | #define EFI_IMAGE_EVT_CMD_START_RELOC64 UINT32_C(0x0000000B)
|
---|
253 |
|
---|
254 | /** The command for writing to the second address register (64-bit).
|
---|
255 | * Takes a 16-bit payload value. The register value is shifted 16-bits
|
---|
256 | * to the left and then the payload is ORed in. */
|
---|
257 | #define EFI_IMAGE_EVT_CMD_ADDR0 UINT32_C(0x00000006)
|
---|
258 | /** The command for writing to the second address register (64-bit).
|
---|
259 | * Takes a 16-bit payload value. The register value is shifted 16-bits
|
---|
260 | * to the left and then the payload is ORed in. */
|
---|
261 | #define EFI_IMAGE_EVT_CMD_ADDR1 UINT32_C(0x00000007)
|
---|
262 | /** The command for writing to the first size register (64-bit).
|
---|
263 | * Takes a 16-bit payload value. The register value is shifted 16-bits
|
---|
264 | * to the left and then the payload is ORed in. */
|
---|
265 | #define EFI_IMAGE_EVT_CMD_SIZE0 UINT32_C(0x00000008)
|
---|
266 | /** The command for appending a character to the module name.
|
---|
267 | * Takes a 7-bit payload value that. The value is appended to the field if
|
---|
268 | * there is room. */
|
---|
269 | #define EFI_IMAGE_EVT_CMD_NAME UINT32_C(0x00000009)
|
---|
270 |
|
---|
271 | /** @} */
|
---|
272 |
|
---|
273 |
|
---|
274 | /** @} */
|
---|
275 |
|
---|
276 | #endif /* !VBOX_INCLUDED_SRC_EFI_DevEFI_h */
|
---|