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