/* $Id$ */
/** @file
* VBoxAppleSim.c - VirtualBox Apple Firmware simulation support
*/
/*
* Copyright (C) 2010-2011 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.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/PrintLib.h>
#include <Protocol/DevicePathToText.h>
#include <IndustryStandard/Acpi10.h>
#include <IndustryStandard/Acpi20.h>
#include <IndustryStandard/SmBios.h>
#include "VBoxPkg.h"
#include "DevEFI.h"
/*
* External functions
*/
/*
* Internal Functions
*/
static UINT32
{
return cbVar;
}
/*
* GUIDs
*/
/** The EFI variable GUID for the 'FirmwareFeatures' and friends.
* Also known as AppleFirmwareVariableGuid in other sources. */
0x4D1EDE05, 0x38C7, 0x4A6A, {0x9C, 0xC6, 0x4B, 0xCC, 0xA8, 0xB3, 0x8C, 0x14 }
};
/** The EFI variable GUID for the 'boot-args' variable and others.
* Also known as AppleNVRAMVariableGuid in other sources. */
0x7C436110, 0xAB2A, 0x4BBB, {0xA8, 0x80, 0xFE, 0x41, 0x99, 0x5C, 0x9F, 0x82}
};
/*
* Device Properoty protocol implementation hack.
*/
/** gEfiAppleVarGuid is aka AppleDevicePropertyProtocolGuid in other sources. */
0x91BD12FE, 0xF6C3, 0x44FB, {0xA5, 0xB7, 0x51, 0x22, 0xAB, 0x30, 0x3A, 0xE0}
};
/** APPLE_GETVAR_PROTOCOL is aka APPLE_DEVICE_PROPERTY_PROTOCOL in other sources. */
struct _APPLE_GETVAR_PROTOCOL
{
/** Magic value or some version thingy. boot.efi doesn't check this, I think. */
EFI_STATUS (EFIAPI *pfnGetDevProps)(IN APPLE_GETVAR_PROTOCOL *This, IN CHAR8 *pbBuf, IN OUT UINT32 *pcbBuf);
};
/** The value of APPLE_GETVAR_PROTOCOL::u64Magic. */
{
return EFI_UNSUPPORTED;
}
{
return EFI_UNSUPPORTED;
}
{
return EFI_UNSUPPORTED;
}
/**
* This method obtains the 'device-properties' that get exposed by
* AppleEFIFirmware and parsed by AppleACPIPlatform.
*
* Check out the data in the IORegisteryExplorer, the device-properties property
* under IODeviceTree:/efi.
*
* @retval EFI_SUCCESS, check *pcbBuf or the number of bytes actually returned.
* @retval EFI_BUFFER_TOO_SMALL, check *pcbBuf for the necessary buffer size.
* @param pThis Not used.
* @param pbBuf The output buffer.
* @param pcbBuf On input, the varible pointed to contains the size of the
* buffer. The size is generally 4KB from what we've observed.
* On output, it contains the amount of data available, this
* is always set.
*/
AppleGetVar_GetDeviceProps(IN APPLE_GETVAR_PROTOCOL *pThis, OUT CHAR8 *pbBuf, IN OUT UINT32 *pcbBuf)
{
return EFI_BUFFER_TOO_SMALL;
return EFI_SUCCESS;
}
{
/* Magic = */ APPLE_GETVAR_PROTOCOL_MAGIC,
};
/*
* Unknown Protocol #1.
*/
{
0xDD8E06AC, 0x00E2, 0x49A9, {0x88, 0x8F, 0xFA, 0x46, 0xDE, 0xD4, 0x0A, 0x52}
};
{
#ifdef DEBUG
ASSERT(0);
#endif
Print(L"Unknown called\n");
return EFI_SUCCESS;
}
/* array of pointers to function */
{
};
{
// -legacy acpi=0xffffffff acpi_debug=0xfffffff panic_io_port=0xef11 io=0xfffffffe trace=4096 io=0xffffffef -v serial=2 serialbaud=9600
// 0x10 makes kdb default, thus 0x15e for kdb, 0x14e for gdb
// usb=0x800 is required to work around default behavior of the Apple xHCI driver which rejects high-speed
// USB devices and tries to force them to EHCI when running on the Intel Panther Point chipset.
//static const CHAR8 vBootArgs[] = "debug=0x15e keepsyms=1 acpi=0xffffffff acpi_debug=0xff acpi_level=7 -v -x32 -s"; // or just "debug=0x8 -legacy"
// 0x14e for serial output
//static const CHAR8 vDefBootArgs[] = "debug=0x146 usb=0x800 keepsyms=1 -v -serial=0x1";
if (BootArgsLen <= 1)
{
BootArgsLen = sizeof vDefBootArgs;
}
sizeof(vBackgroundClear), &vBackgroundClear);
sizeof(vFwFeatures), &vFwFeatures);
sizeof(vFwFeaturesMask), &vFwFeaturesMask);
BootArgsLen, &vBootArgs);
return EFI_SUCCESS;
}
/**
* VBoxInitAppleSim entry point.
*
* @returns EFI status code.
*
* @param ImageHandle The image handle.
* @param SystemTable The system table pointer.
*/
{
rc = gBS->InstallMultipleProtocolInterfaces(&ImageHandle, &gEfiAppleVarGuid, &gPrivateVarHandler, NULL);
rc = gBS->InstallMultipleProtocolInterfaces(&ImageHandle, &gEfiUnknown1ProtocolGuid, gUnknownProtoHandler, NULL);
return EFI_SUCCESS;
}
{
return EFI_SUCCESS;
}