1 | /* $Id: DevEFI.h 28800 2010-04-27 08:22:32Z 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 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 interfaction between the EFI firmware and DevEFI. */
|
---|
32 | #define EFI_PORT_BASE 0xEF10
|
---|
33 | /** The number of ports. */
|
---|
34 | #define EFI_PORT_COUNT 0x0004
|
---|
35 |
|
---|
36 | /** Information querying.
|
---|
37 | * 32-bit write sets the info index and resets the reading, see EfiInfoIndex.
|
---|
38 | * 32-bit read returns the size of the info (in bytes).
|
---|
39 | * 8-bit reads returns the info as a byte sequence. */
|
---|
40 | #define EFI_INFO_PORT (EFI_PORT_BASE+0x0)
|
---|
41 | /** Information requests.
|
---|
42 | * @todo Put this in DEVEFIINFO, that's much easier to access. */
|
---|
43 | typedef enum
|
---|
44 | {
|
---|
45 | EFI_INFO_INDEX_INVALID = 0,
|
---|
46 | EFI_INFO_INDEX_VOLUME_BASE,
|
---|
47 | EFI_INFO_INDEX_VOLUME_SIZE,
|
---|
48 | EFI_INFO_INDEX_TEMPMEM_BASE,
|
---|
49 | EFI_INFO_INDEX_TEMPMEM_SIZE,
|
---|
50 | EFI_INFO_INDEX_STACK_BASE,
|
---|
51 | EFI_INFO_INDEX_STACK_SIZE,
|
---|
52 | EFI_INFO_INDEX_BOOT_ARGS,
|
---|
53 | EFI_INFO_INDEX_DEVICE_PROPS,
|
---|
54 | EFI_INFO_INDEX_FSB_FREQUENCY,
|
---|
55 | EFI_INFO_INDEX_CPU_FREQUENCY,
|
---|
56 | EFI_INFO_INDEX_TSC_FREQUENCY,
|
---|
57 | EFI_INFO_INDEX_GOP_MODE,
|
---|
58 | EFI_INFO_INDEX_UGA_HORISONTAL_RESOLUTION,
|
---|
59 | EFI_INFO_INDEX_UGA_VERTICAL_RESOLUTION,
|
---|
60 | EFI_INFO_INDEX_END
|
---|
61 | } EfiInfoIndex;
|
---|
62 |
|
---|
63 | /** Panic port.
|
---|
64 | * Write causes action to be taken according to the value written,
|
---|
65 | * see the EFI_PANIC_CMD_* defines below.
|
---|
66 | * Reading from the port has no effect. */
|
---|
67 | #define EFI_PANIC_PORT (EFI_PORT_BASE+0x1)
|
---|
68 | /** @defgroup grp_devefi_panic_cmd Panic Commands for EFI_PANIC_PORT
|
---|
69 | * @{ */
|
---|
70 | /** Used by the EfiThunk.asm to signal ORG inconsistency. */
|
---|
71 | #define EFI_PANIC_CMD_BAD_ORG 1
|
---|
72 | /** Used by the EfiThunk.asm to signal unexpected trap or interrupt. */
|
---|
73 | #define EFI_PANIC_CMD_THUNK_TRAP 2
|
---|
74 | /** Starts a panic message.
|
---|
75 | * Makes sure the panic message buffer is empty. */
|
---|
76 | #define EFI_PANIC_CMD_START_MSG 3
|
---|
77 | /** Ends a panic message and enters guru meditation state. */
|
---|
78 | #define EFI_PANIC_CMD_END_MSG 4
|
---|
79 | /** The first panic message command.
|
---|
80 | * The low byte of the command is the char to be added to the panic message. */
|
---|
81 | #define EFI_PANIC_CMD_MSG_FIRST 0x4201
|
---|
82 | /** The last panic message command. */
|
---|
83 | #define EFI_PANIC_CMD_MSG_LAST 0x427f
|
---|
84 | /** Makes a panic message command from a char. */
|
---|
85 | #define EFI_PANIC_CMD_MSG_FROM_CHAR(ch) (0x4200 | ((ch) & 0x7f) )
|
---|
86 | /** Extracts the char from a panic message command. */
|
---|
87 | #define EFI_PANIC_CMD_MSG_GET_CHAR(u32) ((u32) & 0x7f)
|
---|
88 | /** @} */
|
---|
89 |
|
---|
90 | /** Undefined port. */
|
---|
91 | #define EFI_PORT_UNDEFINED (EFI_PORT_BASE+0x2)
|
---|
92 |
|
---|
93 | /** Debug logging.
|
---|
94 | * The chars written goes to the log.
|
---|
95 | * Reading has no effect.
|
---|
96 | * @remarks The port number is the same as on of those used by the PC BIOS. */
|
---|
97 | #define EFI_DEBUG_PORT (EFI_PORT_BASE+0x3)
|
---|
98 |
|
---|
99 | #define VBOX_EFI_DEBUG_BUFFER 512
|
---|
100 | /** The top of the EFI stack.
|
---|
101 | * The firmware expects a 128KB stack.
|
---|
102 | * @todo Move this to 1MB + 128KB and drop the stack relocation the firmware
|
---|
103 | * does. It expects the stack to be within the temporary memory that
|
---|
104 | * SEC hands to PEI and the VBoxAutoScan PEIM reports. */
|
---|
105 | #define VBOX_EFI_TOP_OF_STACK 0x300000
|
---|
106 |
|
---|
107 | /**
|
---|
108 | * DevEFI Info stored at DEVEFI_INFO_PHYS_ADDR
|
---|
109 | */
|
---|
110 | typedef struct DEVEFIINFO
|
---|
111 | {
|
---|
112 | /** 0x00 - The physical address of the firmware entry point. */
|
---|
113 | uint32_t pfnFirmwareEP;
|
---|
114 | /** 0x04 - Spaced reserved for the high part of a 64-bit entrypoint address. */
|
---|
115 | uint32_t HighEPAddress;
|
---|
116 | /** 0x08 - The address of the firmware volume. */
|
---|
117 | RTGCPHYS PhysFwVol;
|
---|
118 | /** 0x10 - The size of the firmware volume. */
|
---|
119 | uint32_t cbFwVol;
|
---|
120 | /** 0x14 - Amount of memory below 4GB (in bytes). */
|
---|
121 | uint32_t cbBelow4GB;
|
---|
122 | /** 0x18 - Amount of memory above 4GB (in bytes). */
|
---|
123 | uint64_t cbAbove4GB;
|
---|
124 | /** 0x20 - see flags values below */
|
---|
125 | uint32_t fFlags;
|
---|
126 | /** 0x24 - The nubmer of Virtual CPUs. */
|
---|
127 | uint32_t cCpus;
|
---|
128 | /** 0x28 - Reserved for future use, must be zero. */
|
---|
129 | uint32_t pfnPeiEP;
|
---|
130 | /** 0x2c - Reserved for future use, must be zero. */
|
---|
131 | uint32_t u32Reserved2;
|
---|
132 | } DEVEFIINFO;
|
---|
133 | AssertCompileSize(DEVEFIINFO, 0x30);
|
---|
134 | /** Pointer to a DevEFI info structure. */
|
---|
135 | typedef DEVEFIINFO *PDEVEFIINFO;
|
---|
136 | /** Pointer to a const DevEFI info structure. */
|
---|
137 | typedef DEVEFIINFO const *PCDEVEFIINFO;
|
---|
138 |
|
---|
139 | /** The physical address where DEVEFIINFO can be found. */
|
---|
140 | #define DEVEFI_INFO_PHYS_ADDR (0xfffff000)
|
---|
141 | #define DEVEFI_INFO_FLAGS_AMD64 RT_BIT(0)
|
---|
142 |
|
---|
143 | /** @} */
|
---|
144 |
|
---|
145 | #define KB(x) ((x) * 1024)
|
---|
146 | #define MB(x) ((KB(x)) * 1024)
|
---|
147 |
|
---|
148 | #endif
|
---|