1 | /* $Id: DevEFI.h 44601 2013-02-08 12:27:08Z 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-2012 Oracle Corporation
|
---|
12 | *
|
---|
13 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
14 | * available from http://www.virtualbox.org. This file is free software;
|
---|
15 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
16 | * General Public License (GPL) as published by the Free Software
|
---|
17 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
18 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
19 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #ifndef ___EFI_VBoxEFI_h
|
---|
23 | #define ___EFI_VBoxEFI_h
|
---|
24 |
|
---|
25 | #include <iprt/assert.h>
|
---|
26 |
|
---|
27 | /** @defgroup grp_devefi DevEFI <-> Firmware Interfaces
|
---|
28 | * @{
|
---|
29 | */
|
---|
30 |
|
---|
31 | /** The base of the I/O ports used for interaction between the EFI firmware and DevEFI. */
|
---|
32 | #define EFI_PORT_BASE 0xEF10
|
---|
33 | /** The number of ports. */
|
---|
34 | #define EFI_PORT_COUNT 0x0006
|
---|
35 |
|
---|
36 |
|
---|
37 | /** Information querying.
|
---|
38 | * 32-bit write sets the info index and resets the reading, see EfiInfoIndex.
|
---|
39 | * 32-bit read returns the size of the info (in bytes).
|
---|
40 | * 8-bit reads returns the info as a byte sequence. */
|
---|
41 | #define EFI_INFO_PORT (EFI_PORT_BASE+0x0)
|
---|
42 | /** Information requests.
|
---|
43 | * @todo Put this in DEVEFIINFO, that's much easier to access. */
|
---|
44 | typedef enum
|
---|
45 | {
|
---|
46 | EFI_INFO_INDEX_INVALID = 0,
|
---|
47 | EFI_INFO_INDEX_VOLUME_BASE,
|
---|
48 | EFI_INFO_INDEX_VOLUME_SIZE,
|
---|
49 | EFI_INFO_INDEX_TEMPMEM_BASE,
|
---|
50 | EFI_INFO_INDEX_TEMPMEM_SIZE,
|
---|
51 | EFI_INFO_INDEX_STACK_BASE,
|
---|
52 | EFI_INFO_INDEX_STACK_SIZE,
|
---|
53 | EFI_INFO_INDEX_BOOT_ARGS,
|
---|
54 | EFI_INFO_INDEX_DEVICE_PROPS,
|
---|
55 | EFI_INFO_INDEX_FSB_FREQUENCY,
|
---|
56 | EFI_INFO_INDEX_CPU_FREQUENCY,
|
---|
57 | EFI_INFO_INDEX_TSC_FREQUENCY,
|
---|
58 | EFI_INFO_INDEX_GOP_MODE,
|
---|
59 | EFI_INFO_INDEX_UGA_HORISONTAL_RESOLUTION,
|
---|
60 | EFI_INFO_INDEX_UGA_VERTICAL_RESOLUTION,
|
---|
61 | EFI_INFO_INDEX_END
|
---|
62 | } EfiInfoIndex;
|
---|
63 |
|
---|
64 | /** Panic port.
|
---|
65 | * Write causes action to be taken according to the value written,
|
---|
66 | * see the EFI_PANIC_CMD_* defines below.
|
---|
67 | * Reading from the port has no effect. */
|
---|
68 | #define EFI_PANIC_PORT (EFI_PORT_BASE+0x1)
|
---|
69 |
|
---|
70 | /** @defgroup grp_devefi_panic_cmd Panic Commands for EFI_PANIC_PORT
|
---|
71 | * @{ */
|
---|
72 | /** Used by the EfiThunk.asm to signal ORG inconsistency. */
|
---|
73 | #define EFI_PANIC_CMD_BAD_ORG 1
|
---|
74 | /** Used by the EfiThunk.asm to signal unexpected trap or interrupt. */
|
---|
75 | #define EFI_PANIC_CMD_THUNK_TRAP 2
|
---|
76 | /** Starts a panic message.
|
---|
77 | * Makes sure the panic message buffer is empty. */
|
---|
78 | #define EFI_PANIC_CMD_START_MSG 3
|
---|
79 | /** Ends a panic message and enters guru meditation state. */
|
---|
80 | #define EFI_PANIC_CMD_END_MSG 4
|
---|
81 | /** The first panic message command.
|
---|
82 | * The low byte of the command is the char to be added to the panic message. */
|
---|
83 | #define EFI_PANIC_CMD_MSG_FIRST 0x4201
|
---|
84 | /** The last panic message command. */
|
---|
85 | #define EFI_PANIC_CMD_MSG_LAST 0x427f
|
---|
86 | /** Makes a panic message command from a char. */
|
---|
87 | #define EFI_PANIC_CMD_MSG_FROM_CHAR(ch) (0x4200 | ((ch) & 0x7f) )
|
---|
88 | /** Extracts the char from a panic message command. */
|
---|
89 | #define EFI_PANIC_CMD_MSG_GET_CHAR(u32) ((u32) & 0x7f)
|
---|
90 | /** @} */
|
---|
91 |
|
---|
92 | /** Undefined port. */
|
---|
93 | #define EFI_PORT_UNDEFINED (EFI_PORT_BASE+0x2)
|
---|
94 |
|
---|
95 | /** Debug logging.
|
---|
96 | * The chars written goes to the log.
|
---|
97 | * Reading has no effect.
|
---|
98 | * @remarks The port number is the same as on of those used by the PC BIOS. */
|
---|
99 | #define EFI_DEBUG_PORT (EFI_PORT_BASE+0x3)
|
---|
100 |
|
---|
101 | #define VBOX_EFI_DEBUG_BUFFER 512
|
---|
102 | /** The top of the EFI stack.
|
---|
103 | * The firmware expects a 128KB stack.
|
---|
104 | * @todo Move this to 1MB + 128KB and drop the stack relocation the firmware
|
---|
105 | * does. It expects the stack to be within the temporary memory that
|
---|
106 | * SEC hands to PEI and the VBoxAutoScan PEIM reports. */
|
---|
107 | #define VBOX_EFI_TOP_OF_STACK 0x300000
|
---|
108 |
|
---|
109 | #define EFI_VARIABLE_OP (EFI_PORT_BASE+0x4)
|
---|
110 | #define EFI_VARIABLE_PARAM (EFI_PORT_BASE+0x5)
|
---|
111 |
|
---|
112 | #define EFI_VARIABLE_OP_QUERY 0xdead0001
|
---|
113 | #define EFI_VARIABLE_OP_QUERY_NEXT 0xdead0002
|
---|
114 | #define EFI_VARIABLE_OP_QUERY_REWIND 0xdead0003
|
---|
115 | #define EFI_VARIABLE_OP_ADD 0xdead0010
|
---|
116 |
|
---|
117 | #define EFI_VARIABLE_OP_STATUS_OK 0xcafe0000
|
---|
118 | #define EFI_VARIABLE_OP_STATUS_ERROR 0xcafe0001
|
---|
119 | #define EFI_VARIABLE_OP_STATUS_NOT_FOUND 0xcafe0002
|
---|
120 | #define EFI_VARIABLE_OP_STATUS_NOT_WP 0xcafe0003
|
---|
121 | #define EFI_VARIABLE_OP_STATUS_BSY 0xcafe0010
|
---|
122 |
|
---|
123 | /** The max number of variables allowed. */
|
---|
124 | #define EFI_VARIABLE_MAX 128
|
---|
125 | /** The max variable name length (in bytes, including the zero terminator). */
|
---|
126 | #define EFI_VARIABLE_NAME_MAX 1024
|
---|
127 | /** The max value length (in bytes). */
|
---|
128 | #define EFI_VARIABLE_VALUE_MAX 1024
|
---|
129 |
|
---|
130 | typedef enum
|
---|
131 | {
|
---|
132 | EFI_VM_VARIABLE_OP_START = 0,
|
---|
133 | EFI_VM_VARIABLE_OP_END, /**< @todo r=bird: What's the point of this one? */
|
---|
134 | EFI_VM_VARIABLE_OP_RESERVED_USED_TO_BE_INDEX,
|
---|
135 | EFI_VM_VARIABLE_OP_GUID,
|
---|
136 | EFI_VM_VARIABLE_OP_ATTRIBUTE,
|
---|
137 | EFI_VM_VARIABLE_OP_NAME,
|
---|
138 | EFI_VM_VARIABLE_OP_NAME_LENGTH,
|
---|
139 | EFI_VM_VARIABLE_OP_VALUE,
|
---|
140 | EFI_VM_VARIABLE_OP_VALUE_LENGTH,
|
---|
141 | EFI_VM_VARIABLE_OP_ERROR,
|
---|
142 | EFI_VM_VARIABLE_OP_NAME_UTF16,
|
---|
143 | EFI_VM_VARIABLE_OP_NAME_LENGTH_UTF16,
|
---|
144 | EFI_VM_VARIABLE_OP_MAX,
|
---|
145 | EFI_VM_VARIABLE_OP_32BIT_HACK = 0x7fffffff
|
---|
146 | } EFIVAROP;
|
---|
147 |
|
---|
148 | /**
|
---|
149 | * DevEFI Info stored at DEVEFI_INFO_PHYS_ADDR
|
---|
150 | */
|
---|
151 | typedef struct DEVEFIINFO
|
---|
152 | {
|
---|
153 | /** 0x00 - The physical address of the firmware entry point. */
|
---|
154 | uint32_t pfnFirmwareEP;
|
---|
155 | /** 0x04 - Spaced reserved for the high part of a 64-bit entrypoint address. */
|
---|
156 | uint32_t HighEPAddress;
|
---|
157 | /** 0x08 - The address of the firmware volume. */
|
---|
158 | RTGCPHYS PhysFwVol;
|
---|
159 | /** 0x10 - The size of the firmware volume. */
|
---|
160 | uint32_t cbFwVol;
|
---|
161 | /** 0x14 - Amount of memory below 4GB (in bytes). */
|
---|
162 | uint32_t cbBelow4GB;
|
---|
163 | /** 0x18 - Amount of memory above 4GB (in bytes). */
|
---|
164 | uint64_t cbAbove4GB;
|
---|
165 | /** 0x20 - see flags values below */
|
---|
166 | uint32_t fFlags;
|
---|
167 | /** 0x24 - The nubmer of Virtual CPUs. */
|
---|
168 | uint32_t cCpus;
|
---|
169 | /** 0x28 - Reserved for future use, must be zero. */
|
---|
170 | uint32_t pfnPeiEP;
|
---|
171 | /** 0x2c - Reserved for future use, must be zero. */
|
---|
172 | uint32_t u32Reserved2;
|
---|
173 | } DEVEFIINFO;
|
---|
174 | AssertCompileSize(DEVEFIINFO, 0x30);
|
---|
175 | /** Pointer to a DevEFI info structure. */
|
---|
176 | typedef DEVEFIINFO *PDEVEFIINFO;
|
---|
177 | /** Pointer to a const DevEFI info structure. */
|
---|
178 | typedef DEVEFIINFO const *PCDEVEFIINFO;
|
---|
179 |
|
---|
180 | /** The physical address where DEVEFIINFO can be found. */
|
---|
181 | #define DEVEFI_INFO_PHYS_ADDR (0xfffff000)
|
---|
182 | #define DEVEFI_INFO_FLAGS_AMD64 RT_BIT(0)
|
---|
183 |
|
---|
184 | /** @} */
|
---|
185 |
|
---|
186 | #define KB(x) ((x) * 1024)
|
---|
187 | #define MB(x) ((KB(x)) * 1024)
|
---|
188 |
|
---|
189 | #endif
|
---|