DevEFI.h revision e1fbd28a3d3f4b5c20c2d653dda8534bee1aed2d
0N/A/* $Id$ */
0N/A/** @file
0N/A * EFI for VirtualBox Common Definitions.
0N/A *
0N/A * WARNING: This header is used by both firmware and VBox device,
2362N/A * thus don't put anything here but numeric constants or helper
0N/A * inline functions.
2362N/A */
0N/A
0N/A/*
0N/A * Copyright (C) 2009-2012 Oracle Corporation
0N/A *
0N/A * This file is part of VirtualBox Open Source Edition (OSE), as
0N/A * available from http://www.virtualbox.org. This file is free software;
0N/A * you can redistribute it and/or modify it under the terms of the GNU
0N/A * General Public License (GPL) as published by the Free Software
0N/A * Foundation, in version 2 as it comes in the "COPYING" file of the
0N/A * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
0N/A * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
2362N/A */
2362N/A
2362N/A#ifndef ___EFI_VBoxEFI_h
0N/A#define ___EFI_VBoxEFI_h
0N/A
0N/A#include <iprt/assert.h>
0N/A
0N/A/** @defgroup grp_devefi DevEFI <-> Firmware Interfaces
0N/A * @{
0N/A */
0N/A
0N/A/** The base of the I/O ports used for interaction between the EFI firmware and DevEFI. */
0N/A#define EFI_PORT_BASE 0xEF10
0N/A/** The number of ports. */
0N/A#define EFI_PORT_COUNT 0x0006
0N/A
0N/A
0N/A/** Information querying.
0N/A * 32-bit write sets the info index and resets the reading, see EfiInfoIndex.
0N/A * 32-bit read returns the size of the info (in bytes).
0N/A * 8-bit reads returns the info as a byte sequence. */
0N/A#define EFI_INFO_PORT (EFI_PORT_BASE+0x0)
0N/A/** Information requests.
0N/A * @todo Put this in DEVEFIINFO, that's much easier to access. */
0N/Atypedef enum
0N/A{
0N/A EFI_INFO_INDEX_INVALID = 0,
0N/A EFI_INFO_INDEX_VOLUME_BASE,
3203N/A EFI_INFO_INDEX_VOLUME_SIZE,
0N/A EFI_INFO_INDEX_TEMPMEM_BASE,
0N/A EFI_INFO_INDEX_TEMPMEM_SIZE,
0N/A EFI_INFO_INDEX_STACK_BASE,
3203N/A EFI_INFO_INDEX_STACK_SIZE,
0N/A EFI_INFO_INDEX_BOOT_ARGS,
3203N/A EFI_INFO_INDEX_DEVICE_PROPS,
0N/A EFI_INFO_INDEX_FSB_FREQUENCY,
0N/A EFI_INFO_INDEX_CPU_FREQUENCY,
0N/A EFI_INFO_INDEX_TSC_FREQUENCY,
0N/A EFI_INFO_INDEX_GOP_MODE,
0N/A EFI_INFO_INDEX_UGA_HORISONTAL_RESOLUTION,
0N/A EFI_INFO_INDEX_UGA_VERTICAL_RESOLUTION,
0N/A EFI_INFO_INDEX_END
3203N/A} EfiInfoIndex;
0N/A
0N/A/** Panic port.
0N/A * Write causes action to be taken according to the value written,
0N/A * see the EFI_PANIC_CMD_* defines below.
0N/A * Reading from the port has no effect. */
0N/A#define EFI_PANIC_PORT (EFI_PORT_BASE+0x1)
0N/A
0N/A/** @defgroup grp_devefi_panic_cmd Panic Commands for EFI_PANIC_PORT
0N/A * @{ */
0N/A/** Used by the EfiThunk.asm to signal ORG inconsistency. */
0N/A#define EFI_PANIC_CMD_BAD_ORG 1
0N/A/** Used by the EfiThunk.asm to signal unexpected trap or interrupt. */
0N/A#define EFI_PANIC_CMD_THUNK_TRAP 2
3203N/A/** Starts a panic message.
0N/A * Makes sure the panic message buffer is empty. */
0N/A#define EFI_PANIC_CMD_START_MSG 3
0N/A/** Ends a panic message and enters guru meditation state. */
0N/A#define EFI_PANIC_CMD_END_MSG 4
0N/A/** The first panic message command.
0N/A * The low byte of the command is the char to be added to the panic message. */
0N/A#define EFI_PANIC_CMD_MSG_FIRST 0x4201
0N/A/** The last panic message command. */
0N/A#define EFI_PANIC_CMD_MSG_LAST 0x427f
0N/A/** Makes a panic message command from a char. */
0N/A#define EFI_PANIC_CMD_MSG_FROM_CHAR(ch) (0x4200 | ((ch) & 0x7f) )
0N/A/** Extracts the char from a panic message command. */
0N/A#define EFI_PANIC_CMD_MSG_GET_CHAR(u32) ((u32) & 0x7f)
0N/A/** @} */
0N/A
0N/A/** Undefined port. */
0N/A#define EFI_PORT_UNDEFINED (EFI_PORT_BASE+0x2)
0N/A
0N/A/** Debug logging.
0N/A * The chars written goes to the log.
0N/A * Reading has no effect.
0N/A * @remarks The port number is the same as on of those used by the PC BIOS. */
0N/A#define EFI_DEBUG_PORT (EFI_PORT_BASE+0x3)
0N/A
0N/A#define VBOX_EFI_DEBUG_BUFFER 512
0N/A/** The top of the EFI stack.
0N/A * The firmware expects a 128KB stack.
0N/A * @todo Move this to 1MB + 128KB and drop the stack relocation the firmware
0N/A * does. It expects the stack to be within the temporary memory that
0N/A * SEC hands to PEI and the VBoxAutoScan PEIM reports. */
0N/A#define VBOX_EFI_TOP_OF_STACK 0x300000
0N/A
0N/A#define EFI_VARIABLE_OP (EFI_PORT_BASE+0x4)
0N/A#define EFI_VARIABLE_PARAM (EFI_PORT_BASE+0x5)
0N/A
0N/A#define EFI_VARIABLE_OP_QUERY 0xdead0001
0N/A#define EFI_VARIABLE_OP_QUERY_NEXT 0xdead0002
0N/A#define EFI_VARIABLE_OP_QUERY_REWIND 0xdead0003
0N/A#define EFI_VARIABLE_OP_ADD 0xdead0010
0N/A
0N/A#define EFI_VARIABLE_OP_STATUS_OK 0xcafe0000
0N/A#define EFI_VARIABLE_OP_STATUS_ERROR 0xcafe0001
0N/A#define EFI_VARIABLE_OP_STATUS_NOT_FOUND 0xcafe0002
0N/A#define EFI_VARIABLE_OP_STATUS_NOT_WP 0xcafe0003
0N/A#define EFI_VARIABLE_OP_STATUS_BSY 0xcafe0010
0N/A
0N/A/** The max number of variables allowed. */
0N/A#define EFI_VARIABLE_MAX 128
0N/A/** The max variable name length (in bytes, including the zero terminator). */
0N/A#define EFI_VARIABLE_NAME_MAX 1024
0N/A/** The max value length (in bytes). */
0N/A#define EFI_VARIABLE_VALUE_MAX 1024
0N/A
0N/Atypedef enum
0N/A{
0N/A EFI_VM_VARIABLE_OP_START = 0,
0N/A EFI_VM_VARIABLE_OP_END, /**< @todo r=bird: What's the point of this one? */
0N/A EFI_VM_VARIABLE_OP_RESERVED_USED_TO_BE_INDEX,
0N/A EFI_VM_VARIABLE_OP_GUID,
0N/A EFI_VM_VARIABLE_OP_ATTRIBUTE,
0N/A EFI_VM_VARIABLE_OP_NAME,
0N/A EFI_VM_VARIABLE_OP_NAME_LENGTH,
0N/A EFI_VM_VARIABLE_OP_VALUE,
0N/A EFI_VM_VARIABLE_OP_VALUE_LENGTH,
0N/A EFI_VM_VARIABLE_OP_ERROR,
0N/A EFI_VM_VARIABLE_OP_NAME_UTF16,
0N/A EFI_VM_VARIABLE_OP_NAME_LENGTH_UTF16,
0N/A EFI_VM_VARIABLE_OP_MAX,
0N/A EFI_VM_VARIABLE_OP_32BIT_HACK = 0x7fffffff
0N/A} EFIVAROP;
0N/A
0N/A/**
0N/A * DevEFI Info stored at DEVEFI_INFO_PHYS_ADDR
0N/A */
0N/Atypedef struct DEVEFIINFO
0N/A{
0N/A /** 0x00 - The physical address of the firmware entry point. */
0N/A uint32_t pfnFirmwareEP;
0N/A /** 0x04 - Spaced reserved for the high part of a 64-bit entrypoint address. */
0N/A uint32_t HighEPAddress;
0N/A /** 0x08 - The address of the firmware volume. */
0N/A RTGCPHYS PhysFwVol;
0N/A /** 0x10 - The size of the firmware volume. */
0N/A uint32_t cbFwVol;
0N/A /** 0x14 - Amount of memory below 4GB (in bytes). */
0N/A uint32_t cbBelow4GB;
0N/A /** 0x18 - Amount of memory above 4GB (in bytes). */
0N/A uint64_t cbAbove4GB;
0N/A /** 0x20 - see flags values below */
0N/A uint32_t fFlags;
0N/A /** 0x24 - The nubmer of Virtual CPUs. */
0N/A uint32_t cCpus;
0N/A /** 0x28 - Reserved for future use, must be zero. */
0N/A uint32_t pfnPeiEP;
0N/A /** 0x2c - Reserved for future use, must be zero. */
0N/A uint32_t u32Reserved2;
0N/A} DEVEFIINFO;
0N/AAssertCompileSize(DEVEFIINFO, 0x30);
0N/A/** Pointer to a DevEFI info structure. */
0N/Atypedef DEVEFIINFO *PDEVEFIINFO;
0N/A/** Pointer to a const DevEFI info structure. */
0N/Atypedef DEVEFIINFO const *PCDEVEFIINFO;
0N/A
0N/A/** The physical address where DEVEFIINFO can be found. */
0N/A#define DEVEFI_INFO_PHYS_ADDR (0xfffff000)
0N/A#define DEVEFI_INFO_FLAGS_AMD64 RT_BIT(0)
0N/A
0N/A/** @} */
0N/A
0N/A#define KB(x) ((x) * 1024)
0N/A#define MB(x) ((KB(x)) * 1024)
0N/A
0N/A#endif
0N/A