/* $Id$ */
/** @file
*/
/*
* Copyright (C) 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.
*
* 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.
*/
/** @file
Implment all four UEFI runtime variable services and
install variable architeture protocol.
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "Variable.h"
#ifdef VBOX
# include <Library/PrintLib.h>
# include <Library/TimerLib.h>
# include "VBoxPkg.h"
# include "DevEFI.h"
{
return idxBuffer;
}
{
}
{
return idxParam;
}
{
UINTN i;
for (i = 0; i <= cwcName; i++)
}
{
}
{
{
#if 0
MicroSecondDelay (400);
#endif
/* @todo: sleep here. bird: won't ever happen, so don't bother. */
}
return u32Rc;
}
#endif
/**
This code finds variable in storage blocks (Volatile or Non-Volatile).
@param VariableName Name of Variable to be found.
@param VendorGuid Variable vendor GUID.
@param Attributes Attribute value of the variable found.
@param DataSize Size of Data found. If size is less than the
data, this value contains the required size.
@param Data Data pointer.
@return EFI_INVALID_PARAMETER Invalid parameter
@return EFI_SUCCESS Find the specified variable
@return EFI_NOT_FOUND Not found
@return EFI_BUFFER_TO_SMALL DataSize is too small for the result
**/
)
{
#ifndef VBOX
return EmuGetVariable (
Data,
);
#else
/*
* Tell DevEFI to look for the specified variable.
*/
if (u32Rc == EFI_VARIABLE_OP_STATUS_OK)
{
/*
* Check if we got enought space for the value.
*/
&& Data)
{
/*
* We do, then read it and, if requrest, the attribute.
*/
if (Attributes)
{
}
rc = EFI_SUCCESS;
}
else
{
}
}
else
{
rc = EFI_NOT_FOUND;
}
return rc;
#endif
}
/**
This code Finds the Next available variable.
@param VariableNameSize Size of the variable name
@param VariableName Pointer to variable name
@param VendorGuid Variable Vendor Guid
@return EFI_INVALID_PARAMETER Invalid parameter
@return EFI_SUCCESS Find the specified variable
@return EFI_NOT_FOUND Not found
@return EFI_BUFFER_TO_SMALL DataSize is too small for the result
**/
)
{
#ifndef VBOX
return EmuGetNextVariableName (
);
#else
/*
* Validate inputs.
*/
{
return EFI_INVALID_PARAMETER;
}
/*
* Tell DevEFI which the current variable is, then ask for the next one.
*/
if (!VariableName[0])
else
{
}
if (u32Rc == EFI_VARIABLE_OP_STATUS_OK)
/** @todo We're supposed to skip stuff depending on attributes and
* to go by... */
if (u32Rc == EFI_VARIABLE_OP_STATUS_OK)
{
/*
* Output buffer check.
*/
{
UINT32 i;
/*
* Read back the result.
*/
for (i = 0; i < cwcName; i++)
VariableName[i] = '\0';
rc = EFI_SUCCESS;
}
else
}
else
return rc;
#endif
}
/**
This code sets variable in storage blocks (Volatile or Non-Volatile).
@param VariableName Name of Variable to be found
@param VendorGuid Variable vendor GUID
@param Attributes Attribute value of the variable found
@param DataSize Size of Data found. If size is less than the
data, this value contains the required size.
@param Data Data pointer
@return EFI_INVALID_PARAMETER Invalid parameter
@return EFI_SUCCESS Set successfully
@return EFI_OUT_OF_RESOURCES Resource not enough to set variable
@return EFI_NOT_FOUND Not found
@return EFI_WRITE_PROTECTED Variable is read-only
**/
)
{
#ifndef VBOX
return EmuSetVariable (
Data,
);
#else
/* set guid */
/* set name */
/* set attribute */
/* set value length */
/* fill value bytes */
/* start fetch operation */
/* process errors */
switch (u32Rc)
{
return EFI_SUCCESS;
default:
return EFI_WRITE_PROTECTED;
}
#endif
}
/**
This code returns information about the EFI variables.
@param Attributes Attributes bitmask to specify the type of variables
on which to return information.
@param MaximumVariableStorageSize Pointer to the maximum size of the storage space available
for the EFI variables associated with the attributes specified.
@param RemainingVariableStorageSize Pointer to the remaining size of the storage space available
for EFI variables associated with the attributes specified.
@param MaximumVariableSize Pointer to the maximum size of an individual EFI variables
associated with the attributes specified.
@return EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied.
@return EFI_SUCCESS Query successfully.
@return EFI_UNSUPPORTED The attribute is not supported on this platform.
**/
)
{
#ifndef VBOX
return EmuQueryVariableInfo (
);
#else
*MaximumVariableSize = 1024;
return EFI_SUCCESS;
#endif
}
/**
Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.
This is a notification function registered on EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.
It convers pointer to new virtual address.
@param Event Event whose notification function is being invoked.
@param Context Pointer to the notification function's context.
**/
)
{
#ifndef VBOX
0x0,
);
0x0,
);
#endif
}
/**
EmuVariable Driver main entry point. The Variable driver places the 4 EFI
runtime services in the EFI System Table and installs arch protocols
for variable read and write services being available. It also registers
notification function for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.
@param[in] ImageHandle The firmware allocated handle for the EFI image.
@param[in] SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS Variable service successfully initialized.
**/
)
{
//
// Now install the Variable Runtime Architectural Protocol on a new handle
//
NULL,
NULL,
);
NULL,
);
/* Self Test */
{
#if 0
NULL ,
0,
NULL );
#endif
L"Test0" ,
&TestUUID,
(void *)pszVariable0);
L"Test0" ,
&TestUUID,
NULL,
&size,
(void *)szTestVariable);
L"Test1" ,
&TestUUID,
(void *)pszVariable1);
L"Test1" ,
&TestUUID,
NULL,
&size,
(void *)szTestVariable);
}
return EFI_SUCCESS;
}