2010-03-01 04:26:19 +01:00
|
|
|
/** @file
|
2008-11-10 13:40:07 +01:00
|
|
|
This file implements functions related to Config Access Protocols installed by
|
|
|
|
by HII Thunk Modules. These Config access Protocols are used to thunk UEFI Config
|
|
|
|
Access Callback to Framework HII Callback and EFI Variable Set/Get operations.
|
2008-04-16 09:36:51 +02:00
|
|
|
|
2012-05-10 10:00:22 +02:00
|
|
|
Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>
|
2010-04-24 11:48:54 +02:00
|
|
|
This program and the accompanying materials
|
2008-04-16 09:36:51 +02:00
|
|
|
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
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
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 "HiiDatabase.h"
|
2008-11-10 13:40:07 +01:00
|
|
|
#include "UefiIfrParser.h"
|
2008-04-16 09:36:51 +02:00
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
BOOLEAN mHiiPackageListUpdated = FALSE;
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2009-04-02 10:48:03 +02:00
|
|
|
HII_VENDOR_DEVICE_PATH mUefiHiiVendorDevicePath = {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{
|
2009-04-09 07:03:21 +02:00
|
|
|
HARDWARE_DEVICE_PATH,
|
|
|
|
HW_VENDOR_DP,
|
|
|
|
{
|
|
|
|
(UINT8) (sizeof (HII_VENDOR_DEVICE_PATH_NODE)),
|
|
|
|
(UINT8) ((sizeof (HII_VENDOR_DEVICE_PATH_NODE)) >> 8)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
EFI_CALLER_ID_GUID
|
2009-04-02 10:48:03 +02:00
|
|
|
},
|
2009-04-09 07:03:21 +02:00
|
|
|
0,
|
|
|
|
0
|
2009-04-02 10:48:03 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
END_DEVICE_PATH_TYPE,
|
|
|
|
END_ENTIRE_DEVICE_PATH_SUBTYPE,
|
|
|
|
{
|
2009-04-09 07:03:21 +02:00
|
|
|
(UINT8) (sizeof (EFI_DEVICE_PATH_PROTOCOL)),
|
|
|
|
(UINT8) ((sizeof (EFI_DEVICE_PATH_PROTOCOL)) >> 8)
|
2009-04-02 10:48:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
CONFIG_ACCESS_PRIVATE gConfigAccessPrivateTempate = {
|
|
|
|
CONFIG_ACCESS_PRIVATE_SIGNATURE,
|
2008-04-16 09:36:51 +02:00
|
|
|
{
|
|
|
|
ThunkExtractConfig,
|
|
|
|
ThunkRouteConfig,
|
|
|
|
ThunkCallback
|
|
|
|
}, //ConfigAccessProtocol
|
2008-08-18 07:56:23 +02:00
|
|
|
NULL, //FormCallbackProtocol
|
|
|
|
NULL
|
2008-04-16 09:36:51 +02:00
|
|
|
};
|
|
|
|
|
2008-05-15 11:14:36 +02:00
|
|
|
/**
|
2008-11-10 13:40:07 +01:00
|
|
|
Get the first EFI_IFR_VARSTORE from the FormSet.
|
|
|
|
|
|
|
|
@param FormSet The Form Set.
|
|
|
|
|
|
|
|
@retval FORMSET_STORAGE * Return the first EFI_IFR_VARSTORE.
|
|
|
|
@retval NULL If the Form Set does not have EFI_IFR_VARSTORE.
|
|
|
|
**/
|
|
|
|
FORMSET_STORAGE *
|
|
|
|
GetFirstStorageOfFormSet (
|
|
|
|
IN CONST FORM_BROWSER_FORMSET * FormSet
|
|
|
|
)
|
|
|
|
{
|
|
|
|
LIST_ENTRY *StorageList;
|
|
|
|
FORMSET_STORAGE *Storage;
|
|
|
|
|
|
|
|
StorageList = GetFirstNode (&FormSet->StorageListHead);
|
|
|
|
|
2012-05-10 10:00:22 +02:00
|
|
|
while (!IsNull (&FormSet->StorageListHead, StorageList)) {
|
2008-11-10 13:40:07 +01:00
|
|
|
Storage = FORMSET_STORAGE_FROM_LINK (StorageList);
|
2012-05-10 10:00:22 +02:00
|
|
|
if (Storage->Type == EFI_HII_VARSTORE_BUFFER) {
|
|
|
|
return Storage;
|
|
|
|
}
|
|
|
|
StorageList = GetNextNode (&FormSet->StorageListHead, StorageList);
|
2008-11-10 13:40:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-07-23 11:27:17 +02:00
|
|
|
Get the FORM_BROWSER_STATEMENT that matches the Question's value.
|
2008-05-15 11:14:36 +02:00
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
@param FormSet The Form Set.
|
2009-07-23 11:27:17 +02:00
|
|
|
@param QuestionId QuestionId
|
2008-05-15 11:14:36 +02:00
|
|
|
|
2009-07-23 11:27:17 +02:00
|
|
|
@retval FORM_BROWSER_STATEMENT* FORM_BROWSER_STATEMENT that match Question's value.
|
|
|
|
@retval NULL If the Form Set does not have EFI_IFR_VARSTORE.
|
2008-05-15 11:14:36 +02:00
|
|
|
**/
|
2009-07-23 11:27:17 +02:00
|
|
|
FORM_BROWSER_STATEMENT *
|
2008-11-10 13:40:07 +01:00
|
|
|
GetStorageFromQuestionId (
|
|
|
|
IN CONST FORM_BROWSER_FORMSET * FormSet,
|
|
|
|
IN EFI_QUESTION_ID QuestionId
|
2008-04-16 09:36:51 +02:00
|
|
|
)
|
|
|
|
{
|
2008-11-10 13:40:07 +01:00
|
|
|
LIST_ENTRY *FormList;
|
|
|
|
LIST_ENTRY *StatementList;
|
|
|
|
FORM_BROWSER_FORM *Form;
|
|
|
|
FORM_BROWSER_STATEMENT *Statement;
|
|
|
|
|
|
|
|
FormList = GetFirstNode (&FormSet->FormListHead);
|
|
|
|
|
|
|
|
while (!IsNull (&FormSet->FormListHead, FormList)) {
|
|
|
|
Form = FORM_BROWSER_FORM_FROM_LINK (FormList);
|
|
|
|
|
|
|
|
StatementList = GetFirstNode (&Form->StatementListHead);
|
|
|
|
|
|
|
|
while (!IsNull (&Form->StatementListHead, StatementList)) {
|
|
|
|
Statement = FORM_BROWSER_STATEMENT_FROM_LINK (StatementList);
|
|
|
|
if ((QuestionId == Statement->QuestionId) && (Statement->Storage != NULL)) {
|
|
|
|
//
|
|
|
|
// UEFI Question ID is unique in a FormSet.
|
|
|
|
//
|
|
|
|
ASSERT (Statement->Storage->Type == EFI_HII_VARSTORE_BUFFER);
|
2009-07-23 11:27:17 +02:00
|
|
|
return Statement;
|
2008-11-10 13:40:07 +01:00
|
|
|
}
|
|
|
|
StatementList = GetNextNode (&Form->StatementListHead, StatementList);
|
|
|
|
}
|
2008-04-16 09:36:51 +02:00
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
FormList = GetNextNode (&FormSet->FormListHead, FormList);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-04-16 09:36:51 +02:00
|
|
|
|
2008-05-15 11:14:36 +02:00
|
|
|
/**
|
2008-11-10 13:40:07 +01:00
|
|
|
Get the EFI_IFR_VARSTORE based the <ConfigHdr> string in a <ConfigRequest>
|
|
|
|
or a <ConfigResp> string.
|
|
|
|
|
|
|
|
@param FormSet The Form Set.
|
|
|
|
@param ConfigString The Configuration String which is defined by UEFI HII.
|
2008-05-15 11:14:36 +02:00
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
@retval FORMSET_STORAGE * The EFI_IFR_VARSTORE where the Question's value is stored.
|
|
|
|
@retval NULL If the Form Set does not have EFI_IFR_VARSTORE with such ID.
|
2008-05-15 11:14:36 +02:00
|
|
|
**/
|
2008-11-10 13:40:07 +01:00
|
|
|
FORMSET_STORAGE *
|
|
|
|
GetStorageFromConfigString (
|
|
|
|
IN CONST FORM_BROWSER_FORMSET *FormSet,
|
|
|
|
IN CONST EFI_STRING ConfigString
|
2008-04-16 09:36:51 +02:00
|
|
|
)
|
|
|
|
{
|
2008-11-10 13:40:07 +01:00
|
|
|
LIST_ENTRY *StorageList;
|
|
|
|
FORMSET_STORAGE *Storage;
|
2008-12-16 14:09:12 +01:00
|
|
|
CHAR16 *Name;
|
2008-04-16 09:36:51 +02:00
|
|
|
|
2010-03-04 07:48:52 +01:00
|
|
|
if (ConfigString == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
StorageList = GetFirstNode (&FormSet->StorageListHead);
|
2008-04-16 09:36:51 +02:00
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
while (!IsNull (&FormSet->StorageListHead, StorageList)) {
|
|
|
|
Storage = FORMSET_STORAGE_FROM_LINK (StorageList);
|
2012-05-10 10:00:22 +02:00
|
|
|
StorageList = GetNextNode (&FormSet->StorageListHead, StorageList);
|
|
|
|
if (Storage->Type != EFI_HII_VARSTORE_BUFFER) {
|
|
|
|
continue;
|
|
|
|
}
|
2008-04-16 09:36:51 +02:00
|
|
|
|
2008-12-16 14:09:12 +01:00
|
|
|
if ((Storage->VarStoreId == FormSet->DefaultVarStoreId) && (FormSet->OriginalDefaultVarStoreName != NULL)) {
|
|
|
|
Name = FormSet->OriginalDefaultVarStoreName;
|
|
|
|
} else {
|
|
|
|
Name = Storage->Name;
|
|
|
|
}
|
|
|
|
|
2009-04-20 10:14:08 +02:00
|
|
|
if (HiiIsConfigHdrMatch (ConfigString, &Storage->Guid, Name)) {
|
2008-11-10 13:40:07 +01:00
|
|
|
return Storage;
|
2008-04-16 09:36:51 +02:00
|
|
|
}
|
|
|
|
}
|
2008-05-15 11:14:36 +02:00
|
|
|
|
2010-03-04 07:48:52 +01:00
|
|
|
return NULL;
|
2008-04-16 09:36:51 +02:00
|
|
|
}
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2008-05-15 11:14:36 +02:00
|
|
|
/**
|
|
|
|
This function installs a EFI_CONFIG_ACCESS_PROTOCOL instance for a form package registered
|
|
|
|
by a module using Framework HII Protocol Interfaces.
|
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
UEFI HII require EFI_HII_CONFIG_ACCESS_PROTOCOL to be installed on a EFI_HANDLE, so
|
|
|
|
that Setup Utility can load the Buffer Storage using this protocol.
|
2008-05-15 11:14:36 +02:00
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
@param Packages The Package List.
|
|
|
|
@param ThunkContext The Thunk Context.
|
2008-05-15 11:14:36 +02:00
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
@retval EFI_SUCCESS The Config Access Protocol is installed successfully.
|
|
|
|
@retval EFI_OUT_RESOURCE There is not enough memory.
|
2008-05-15 11:14:36 +02:00
|
|
|
|
|
|
|
**/
|
2008-04-16 09:36:51 +02:00
|
|
|
EFI_STATUS
|
2008-08-18 07:56:23 +02:00
|
|
|
InstallDefaultConfigAccessProtocol (
|
|
|
|
IN CONST EFI_HII_PACKAGES *Packages,
|
|
|
|
IN OUT HII_THUNK_CONTEXT *ThunkContext
|
2008-04-16 09:36:51 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
2008-08-18 07:56:23 +02:00
|
|
|
CONFIG_ACCESS_PRIVATE *ConfigAccessInstance;
|
2009-04-09 07:03:21 +02:00
|
|
|
HII_VENDOR_DEVICE_PATH *HiiVendorPath;
|
2008-04-16 09:36:51 +02:00
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
ASSERT (ThunkContext->IfrPackageCount != 0);
|
|
|
|
|
2008-04-16 09:36:51 +02:00
|
|
|
ConfigAccessInstance = AllocateCopyPool (
|
2008-08-18 07:56:23 +02:00
|
|
|
sizeof (CONFIG_ACCESS_PRIVATE),
|
|
|
|
&gConfigAccessPrivateTempate
|
2008-04-16 09:36:51 +02:00
|
|
|
);
|
2008-05-15 11:14:36 +02:00
|
|
|
ASSERT (ConfigAccessInstance != NULL);
|
2009-04-09 07:03:21 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Use memory address as unique ID to distinguish from different device paths
|
|
|
|
// This function may be called multi times by the framework HII driver.
|
|
|
|
//
|
|
|
|
HiiVendorPath = AllocateCopyPool (
|
|
|
|
sizeof (HII_VENDOR_DEVICE_PATH),
|
|
|
|
&mUefiHiiVendorDevicePath
|
|
|
|
);
|
|
|
|
ASSERT (HiiVendorPath != NULL);
|
|
|
|
|
|
|
|
HiiVendorPath->Node.UniqueId = (UINT64) ((UINTN) HiiVendorPath);
|
|
|
|
|
2008-04-16 09:36:51 +02:00
|
|
|
Status = gBS->InstallMultipleProtocolInterfaces (
|
2008-08-18 07:56:23 +02:00
|
|
|
&ThunkContext->UefiHiiDriverHandle,
|
2009-04-02 10:48:03 +02:00
|
|
|
&gEfiDevicePathProtocolGuid,
|
2009-04-09 07:03:21 +02:00
|
|
|
HiiVendorPath,
|
2008-04-16 09:36:51 +02:00
|
|
|
&gEfiHiiConfigAccessProtocolGuid,
|
|
|
|
&ConfigAccessInstance->ConfigAccessProtocol,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
2008-08-18 07:56:23 +02:00
|
|
|
|
|
|
|
ConfigAccessInstance->ThunkContext = ThunkContext;
|
2008-04-16 09:36:51 +02:00
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
/**
|
|
|
|
This function un-installs the EFI_CONFIG_ACCESS_PROTOCOL instance for a form package registered
|
|
|
|
by a module using Framework HII Protocol Interfaces.
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
ASSERT if no Config Access is found for such pakcage list or failed to uninstall the protocol.
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
@param ThunkContext The Thunk Context.
|
|
|
|
|
|
|
|
**/
|
2008-08-18 07:56:23 +02:00
|
|
|
VOID
|
|
|
|
UninstallDefaultConfigAccessProtocol (
|
|
|
|
IN HII_THUNK_CONTEXT *ThunkContext
|
2008-04-16 09:36:51 +02:00
|
|
|
)
|
|
|
|
{
|
2008-08-18 07:56:23 +02:00
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
|
2009-04-09 09:23:22 +02:00
|
|
|
HII_VENDOR_DEVICE_PATH *HiiVendorPath;
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
Status = gBS->HandleProtocol (
|
|
|
|
ThunkContext->UefiHiiDriverHandle,
|
|
|
|
&gEfiHiiConfigAccessProtocolGuid,
|
|
|
|
(VOID **) &ConfigAccess
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
2009-04-09 09:23:22 +02:00
|
|
|
Status = gBS->HandleProtocol (
|
|
|
|
ThunkContext->UefiHiiDriverHandle,
|
|
|
|
&gEfiDevicePathProtocolGuid,
|
|
|
|
(VOID **) &HiiVendorPath
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
2009-04-02 10:48:03 +02:00
|
|
|
Status = gBS->UninstallMultipleProtocolInterfaces (
|
2008-08-18 07:56:23 +02:00
|
|
|
ThunkContext->UefiHiiDriverHandle,
|
2009-04-02 10:48:03 +02:00
|
|
|
&gEfiDevicePathProtocolGuid,
|
2009-04-09 09:23:22 +02:00
|
|
|
HiiVendorPath,
|
2008-08-18 07:56:23 +02:00
|
|
|
&gEfiHiiConfigAccessProtocolGuid,
|
2009-04-02 10:48:03 +02:00
|
|
|
ConfigAccess,
|
|
|
|
NULL
|
2008-08-18 07:56:23 +02:00
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
2008-04-16 09:36:51 +02:00
|
|
|
}
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2008-04-16 09:36:51 +02:00
|
|
|
|
2008-05-15 11:14:36 +02:00
|
|
|
/**
|
|
|
|
Wrap the EFI_HII_CONFIG_ACCESS_PROTOCOL.ExtractConfig to a call to EFI_FORM_CALLBACK_PROTOCOL.NvRead.
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
@param BufferStorage The key with all attributes needed to call EFI_FORM_CALLBACK_PROTOCOL.NvRead.
|
|
|
|
@param FwFormCallBack The EFI_FORM_CALLBACK_PROTOCOL registered by Framework HII module.
|
|
|
|
@param Data The data read.
|
|
|
|
@param DataSize The size of data.
|
2008-05-15 11:14:36 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
@retval EFI_STATUS The status returned by the EFI_FORM_CALLBACK_PROTOCOL.NvWrite.
|
2008-05-15 11:14:36 +02:00
|
|
|
@retval EFI_INVALID_PARAMETER If the EFI_FORM_CALLBACK_PROTOCOL.NvRead return the size information of the data
|
2008-08-18 07:56:23 +02:00
|
|
|
does not match what has been recorded early in he BUFFER_STORAGE_ENTRY.
|
2008-05-15 11:14:36 +02:00
|
|
|
**/
|
2008-04-16 09:36:51 +02:00
|
|
|
EFI_STATUS
|
2008-08-18 07:56:23 +02:00
|
|
|
CallFormCallBack (
|
2008-11-10 13:40:07 +01:00
|
|
|
IN FORMSET_STORAGE *BufferStorage,
|
2008-08-18 07:56:23 +02:00
|
|
|
IN EFI_FORM_CALLBACK_PROTOCOL *FwFormCallBack,
|
2008-04-16 09:36:51 +02:00
|
|
|
OUT VOID **Data,
|
|
|
|
OUT UINTN *DataSize
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
|
|
|
|
*DataSize = 0;
|
|
|
|
*Data = NULL;
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
Status = FwFormCallBack->NvRead (
|
|
|
|
FwFormCallBack,
|
|
|
|
BufferStorage->Name,
|
|
|
|
&BufferStorage->Guid,
|
2008-04-16 09:36:51 +02:00
|
|
|
NULL,
|
|
|
|
DataSize,
|
|
|
|
*Data
|
|
|
|
);
|
|
|
|
if (Status == EFI_BUFFER_TOO_SMALL) {
|
2008-08-18 07:56:23 +02:00
|
|
|
if (BufferStorage->Size != *DataSize) {
|
2008-04-16 09:36:51 +02:00
|
|
|
ASSERT (FALSE);
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
*Data = AllocateZeroPool (*DataSize);
|
2009-07-15 08:57:39 +02:00
|
|
|
if (*Data == NULL) {
|
2008-04-16 09:36:51 +02:00
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
|
2009-07-15 08:57:39 +02:00
|
|
|
Status = FwFormCallBack->NvRead (
|
2008-08-18 07:56:23 +02:00
|
|
|
FwFormCallBack,
|
|
|
|
BufferStorage->Name,
|
|
|
|
&BufferStorage->Guid,
|
2008-04-16 09:36:51 +02:00
|
|
|
NULL,
|
|
|
|
DataSize,
|
|
|
|
*Data
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2008-05-15 11:14:36 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Wrap the EFI_HII_CONFIG_ACCESS_PROTOCOL.ExtractConfig to a call to UEFI Variable Get Service.
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
@param BufferStorage The key with all attributes needed to call a UEFI Variable Get Service.
|
|
|
|
@param Data The data read.
|
|
|
|
@param DataSize The size of data.
|
2008-05-15 11:14:36 +02:00
|
|
|
|
|
|
|
If the UEFI Variable Get Service return the size information of the data
|
2008-08-18 07:56:23 +02:00
|
|
|
does not match what has been recorded early in he BUFFER_STORAGE_ENTRY.
|
2008-05-15 11:14:36 +02:00
|
|
|
then ASSERT.
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
@retval EFI_STATUS The status returned by the UEFI Variable Get Service.
|
2008-05-15 11:14:36 +02:00
|
|
|
@retval EFI_INVALID_PARAMETER If the UEFI Variable Get Service return the size information of the data
|
2008-08-18 07:56:23 +02:00
|
|
|
does not match what has been recorded early in he BUFFER_STORAGE_ENTRY.
|
2008-05-15 11:14:36 +02:00
|
|
|
**/
|
2008-04-16 09:36:51 +02:00
|
|
|
EFI_STATUS
|
2008-08-18 07:56:23 +02:00
|
|
|
GetUefiVariable (
|
2008-11-10 13:40:07 +01:00
|
|
|
IN FORMSET_STORAGE *BufferStorage,
|
2008-04-16 09:36:51 +02:00
|
|
|
OUT VOID **Data,
|
|
|
|
OUT UINTN *DataSize
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
|
|
|
|
*DataSize = 0;
|
|
|
|
*Data = NULL;
|
|
|
|
Status = gRT->GetVariable (
|
2008-08-18 07:56:23 +02:00
|
|
|
BufferStorage->Name,
|
|
|
|
&BufferStorage->Guid,
|
2008-04-16 09:36:51 +02:00
|
|
|
NULL,
|
|
|
|
DataSize,
|
|
|
|
*Data
|
|
|
|
);
|
|
|
|
if (Status == EFI_BUFFER_TOO_SMALL) {
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
if (BufferStorage->Size != *DataSize) {
|
2008-04-16 09:36:51 +02:00
|
|
|
ASSERT (FALSE);
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
*Data = AllocateZeroPool (*DataSize);
|
2009-07-15 08:57:39 +02:00
|
|
|
if (*Data == NULL) {
|
2008-04-16 09:36:51 +02:00
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = gRT->GetVariable (
|
2008-08-18 07:56:23 +02:00
|
|
|
BufferStorage->Name,
|
|
|
|
&BufferStorage->Guid,
|
2008-04-16 09:36:51 +02:00
|
|
|
NULL,
|
|
|
|
DataSize,
|
|
|
|
*Data
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2008-05-15 11:14:36 +02:00
|
|
|
/**
|
|
|
|
|
|
|
|
This function implement the EFI_HII_CONFIG_ACCESS_PROTOCOL.ExtractConfig
|
|
|
|
so that data can be read from the data storage such as UEFI Variable or module's
|
|
|
|
customized storage exposed by EFI_FRAMEWORK_CALLBACK.
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL
|
2008-05-15 11:14:36 +02:00
|
|
|
@param Request A null-terminated Unicode string in <ConfigRequest> format. Note that this
|
2008-08-18 07:56:23 +02:00
|
|
|
includes the routing information as well as the configurable name / value pairs. It is
|
|
|
|
invalid for this string to be in <MultiConfigRequest> format.
|
2008-05-15 11:14:36 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
@param Progress On return, points to a character in the Request string. Points to the string's null
|
|
|
|
terminator if request was successful. Points to the most recent '&' before the first
|
|
|
|
failing name / value pair (or the beginning of the string if the failure is in the first
|
|
|
|
name / value pair) if the request was not successful
|
2008-05-15 11:14:36 +02:00
|
|
|
@param Results A null-terminated Unicode string in <ConfigAltResp> format which has all
|
2008-08-18 07:56:23 +02:00
|
|
|
values filled in for the names in the Request string. String to be allocated by the called
|
|
|
|
function.
|
2008-05-15 11:14:36 +02:00
|
|
|
|
|
|
|
@retval EFI_INVALID_PARAMETER If there is no Buffer Storage for this Config Access instance.
|
2008-08-18 07:56:23 +02:00
|
|
|
@retval EFI_SUCCESS The setting is retrived successfully.
|
|
|
|
@retval !EFI_SUCCESS The error returned by UEFI Get Variable or Framework Form Callback Nvread.
|
2008-05-15 11:14:36 +02:00
|
|
|
**/
|
2008-04-16 09:36:51 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ThunkExtractConfig (
|
|
|
|
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
|
|
|
|
IN CONST EFI_STRING Request,
|
|
|
|
OUT EFI_STRING *Progress,
|
|
|
|
OUT EFI_STRING *Results
|
|
|
|
)
|
|
|
|
{
|
2010-03-04 07:48:52 +01:00
|
|
|
EFI_STATUS Status;
|
|
|
|
CONFIG_ACCESS_PRIVATE *ConfigAccess;
|
|
|
|
FORMSET_STORAGE *BufferStorage;
|
|
|
|
VOID *Data;
|
|
|
|
UINTN DataSize;
|
|
|
|
FORM_BROWSER_FORMSET *FormSetContext;
|
|
|
|
CHAR16 *VarStoreName;
|
|
|
|
EFI_STRING ConfigRequestHdr;
|
|
|
|
EFI_STRING ConfigRequest;
|
|
|
|
UINTN Size;
|
|
|
|
BOOLEAN AllocatedRequest;
|
|
|
|
LIST_ENTRY *StorageList;
|
|
|
|
EFI_STRING SingleResult;
|
|
|
|
EFI_STRING FinalResults;
|
|
|
|
EFI_STRING StrPointer;
|
|
|
|
|
|
|
|
if (Progress == NULL || Results == NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
*Progress = Request;
|
|
|
|
|
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
Data = NULL;
|
|
|
|
StrPointer = NULL;
|
|
|
|
SingleResult = NULL;
|
|
|
|
FinalResults = NULL;
|
|
|
|
ConfigAccess = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This);
|
|
|
|
FormSetContext = ConfigAccess->ThunkContext->FormSet;
|
|
|
|
if (IsListEmpty (&FormSetContext->StorageListHead)) {
|
|
|
|
//
|
|
|
|
// No VarStorage does exist in this form.
|
|
|
|
//
|
2008-11-17 15:30:47 +01:00
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
2010-03-04 07:48:52 +01:00
|
|
|
StorageList = GetFirstNode (&FormSetContext->StorageListHead);
|
2008-11-17 15:30:47 +01:00
|
|
|
|
2010-03-04 07:48:52 +01:00
|
|
|
do {
|
|
|
|
if (Request != NULL) {
|
|
|
|
BufferStorage = GetStorageFromConfigString (ConfigAccess->ThunkContext->FormSet, Request);
|
|
|
|
if (BufferStorage == NULL) {
|
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (IsNull (&FormSetContext->StorageListHead, StorageList)) {
|
|
|
|
//
|
|
|
|
// No Storage to be extracted into the results.
|
|
|
|
//
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
BufferStorage = FORMSET_STORAGE_FROM_LINK (StorageList);
|
|
|
|
StorageList = GetNextNode (&FormSetContext->StorageListHead, StorageList);
|
2012-05-10 10:00:22 +02:00
|
|
|
if (BufferStorage->Type != EFI_HII_VARSTORE_BUFFER) {
|
|
|
|
//
|
|
|
|
// BufferStorage type should be EFI_HII_VARSTORE_BUFFER
|
|
|
|
//
|
|
|
|
continue;
|
|
|
|
}
|
2010-03-04 07:48:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VarStoreName = NULL;
|
|
|
|
ConfigRequestHdr = NULL;
|
|
|
|
ConfigRequest = NULL;
|
|
|
|
Size = 0;
|
|
|
|
AllocatedRequest = FALSE;
|
|
|
|
|
|
|
|
if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {
|
|
|
|
//
|
|
|
|
// NvMapOverride is not used. Get the Storage data from EFI Variable or Framework Form Callback.
|
|
|
|
//
|
|
|
|
if (ConfigAccess->FormCallbackProtocol == NULL ||
|
|
|
|
ConfigAccess->FormCallbackProtocol->NvRead == NULL) {
|
|
|
|
Status = GetUefiVariable (
|
|
|
|
BufferStorage,
|
|
|
|
&Data,
|
|
|
|
&DataSize
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
Status = CallFormCallBack (
|
|
|
|
BufferStorage,
|
|
|
|
ConfigAccess->FormCallbackProtocol,
|
|
|
|
&Data,
|
|
|
|
&DataSize
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//
|
|
|
|
// Use the NvMapOverride.
|
|
|
|
//
|
|
|
|
DataSize = BufferStorage->Size;
|
|
|
|
Data = AllocateCopyPool (DataSize, ConfigAccess->ThunkContext->NvMapOverride);
|
|
|
|
|
|
|
|
if (Data != NULL) {
|
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
} else {
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
ConfigRequest = Request;
|
|
|
|
if (Request == NULL || (StrStr (Request, L"OFFSET") == NULL)) {
|
|
|
|
//
|
|
|
|
// Request is without any request element, construct full request string.
|
|
|
|
//
|
2008-04-16 09:36:51 +02:00
|
|
|
|
2010-03-04 07:48:52 +01:00
|
|
|
if ((BufferStorage->VarStoreId == FormSetContext->DefaultVarStoreId) && (FormSetContext->OriginalDefaultVarStoreName != NULL)) {
|
|
|
|
VarStoreName = FormSetContext->OriginalDefaultVarStoreName;
|
|
|
|
} else {
|
|
|
|
VarStoreName = BufferStorage->Name;
|
|
|
|
}
|
2008-04-16 09:36:51 +02:00
|
|
|
|
2010-03-04 07:48:52 +01:00
|
|
|
//
|
|
|
|
// First Set ConfigRequestHdr string.
|
|
|
|
//
|
|
|
|
ConfigRequestHdr = HiiConstructConfigHdr (&BufferStorage->Guid, VarStoreName, ConfigAccess->ThunkContext->UefiHiiDriverHandle);
|
|
|
|
ASSERT (ConfigRequestHdr != NULL);
|
2008-11-17 15:30:47 +01:00
|
|
|
|
2010-03-04 07:48:52 +01:00
|
|
|
//
|
|
|
|
// Allocate and fill a buffer large enough to hold the <ConfigHdr> template
|
|
|
|
// followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
|
|
|
|
//
|
|
|
|
Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
|
|
|
|
ConfigRequest = AllocateZeroPool (Size);
|
|
|
|
ASSERT (ConfigRequest != NULL);
|
|
|
|
AllocatedRequest = TRUE;
|
|
|
|
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)DataSize);
|
|
|
|
FreePool (ConfigRequestHdr);
|
|
|
|
}
|
|
|
|
Status = mHiiConfigRoutingProtocol->BlockToConfig (
|
|
|
|
mHiiConfigRoutingProtocol,
|
|
|
|
ConfigRequest,
|
|
|
|
Data,
|
|
|
|
DataSize,
|
|
|
|
&SingleResult,
|
|
|
|
Progress
|
|
|
|
);
|
|
|
|
//
|
|
|
|
// Free the allocated config request string.
|
|
|
|
//
|
|
|
|
if (AllocatedRequest) {
|
|
|
|
FreePool (ConfigRequest);
|
|
|
|
ConfigRequest = NULL;
|
|
|
|
}
|
|
|
|
}
|
2008-11-10 13:40:07 +01:00
|
|
|
//
|
2010-03-04 07:48:52 +01:00
|
|
|
// Free the allocated Data
|
2008-11-10 13:40:07 +01:00
|
|
|
//
|
2010-03-04 07:48:52 +01:00
|
|
|
if (Data != NULL) {
|
|
|
|
FreePool (Data);
|
2008-08-19 12:44:50 +02:00
|
|
|
}
|
2008-11-10 13:40:07 +01:00
|
|
|
//
|
2010-03-04 07:48:52 +01:00
|
|
|
// Directly return when meet with error
|
2008-11-10 13:40:07 +01:00
|
|
|
//
|
2010-03-04 07:48:52 +01:00
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Merge result into the final results.
|
|
|
|
//
|
|
|
|
if (FinalResults == NULL) {
|
|
|
|
FinalResults = SingleResult;
|
|
|
|
SingleResult = NULL;
|
2008-08-19 12:44:50 +02:00
|
|
|
} else {
|
2010-03-04 07:48:52 +01:00
|
|
|
Size = StrLen (FinalResults);
|
|
|
|
Size = Size + 1;
|
|
|
|
Size = Size + StrLen (SingleResult) + 1;
|
|
|
|
StrPointer = AllocateZeroPool (Size * sizeof (CHAR16));
|
|
|
|
ASSERT (StrPointer != NULL);
|
|
|
|
StrCpy (StrPointer, FinalResults);
|
|
|
|
FreePool (FinalResults);
|
|
|
|
FinalResults = StrPointer;
|
|
|
|
StrPointer = StrPointer + StrLen (StrPointer);
|
|
|
|
*StrPointer = L'&';
|
|
|
|
StrCpy (StrPointer + 1, SingleResult);
|
|
|
|
FreePool (SingleResult);
|
2008-08-19 12:44:50 +02:00
|
|
|
}
|
2010-03-04 07:48:52 +01:00
|
|
|
} while (Request == NULL);
|
|
|
|
|
2008-04-16 09:36:51 +02:00
|
|
|
if (!EFI_ERROR (Status)) {
|
2010-03-04 07:48:52 +01:00
|
|
|
*Results = FinalResults;
|
|
|
|
} else {
|
|
|
|
if (FinalResults != NULL) {
|
|
|
|
FreePool (FinalResults);
|
|
|
|
}
|
2008-04-16 09:36:51 +02:00
|
|
|
}
|
2010-03-04 07:48:52 +01:00
|
|
|
//
|
|
|
|
// Set Progress string to the original request string.
|
|
|
|
//
|
|
|
|
if (Request == NULL) {
|
|
|
|
*Progress = NULL;
|
|
|
|
} else if (StrStr (Request, L"OFFSET") == NULL) {
|
|
|
|
*Progress = Request + StrLen (Request);
|
2008-10-30 09:00:56 +01:00
|
|
|
}
|
2010-03-04 07:48:52 +01:00
|
|
|
|
2008-04-16 09:36:51 +02:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2008-05-15 11:14:36 +02:00
|
|
|
/**
|
|
|
|
This function implement the EFI_HII_CONFIG_ACCESS_PROTOCOL.RouteConfig
|
|
|
|
so that data can be written to the data storage such as UEFI Variable or module's
|
|
|
|
customized storage exposed by EFI_FRAMEWORK_CALLBACK.
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL
|
|
|
|
@param Configuration A null-terminated Unicode string in <ConfigResp> format.
|
2008-06-19 13:15:44 +02:00
|
|
|
@param Progress A pointer to a string filled in with the offset of the most recent '&' before the first
|
2008-08-18 07:56:23 +02:00
|
|
|
failing name / value pair (or the beginning of the string if the failure is in the first
|
|
|
|
name / value pair) or the terminating NULL if all was successful.
|
2008-05-15 11:14:36 +02:00
|
|
|
|
|
|
|
@retval EFI_INVALID_PARAMETER If there is no Buffer Storage for this Config Access instance.
|
2008-08-18 07:56:23 +02:00
|
|
|
@retval EFI_SUCCESS The setting is saved successfully.
|
|
|
|
@retval !EFI_SUCCESS The error returned by UEFI Set Variable or Framework Form Callback Nvwrite.
|
2008-05-15 11:14:36 +02:00
|
|
|
**/
|
2008-04-16 09:36:51 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ThunkRouteConfig (
|
|
|
|
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
|
|
|
|
IN CONST EFI_STRING Configuration,
|
|
|
|
OUT EFI_STRING *Progress
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
2008-08-18 07:56:23 +02:00
|
|
|
CONFIG_ACCESS_PRIVATE *ConfigAccess;
|
2008-11-10 13:40:07 +01:00
|
|
|
FORMSET_STORAGE *BufferStorage;
|
2008-11-10 14:27:09 +01:00
|
|
|
VOID *Data;
|
2008-04-16 09:36:51 +02:00
|
|
|
UINTN DataSize;
|
2008-08-18 07:56:23 +02:00
|
|
|
UINTN DataSize2;
|
|
|
|
BOOLEAN ResetRequired;
|
|
|
|
BOOLEAN DataAllocated;
|
2008-04-16 09:36:51 +02:00
|
|
|
|
2008-11-17 15:30:47 +01:00
|
|
|
if (Configuration == NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2008-04-16 09:36:51 +02:00
|
|
|
Data = NULL;
|
2008-08-18 07:56:23 +02:00
|
|
|
ConfigAccess = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This);
|
2008-04-16 09:36:51 +02:00
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
BufferStorage = GetStorageFromConfigString (ConfigAccess->ThunkContext->FormSet, Configuration);
|
2008-04-16 09:36:51 +02:00
|
|
|
|
2008-11-17 15:30:47 +01:00
|
|
|
if (BufferStorage == NULL) {
|
|
|
|
*Progress = Configuration;
|
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
DataSize2 = BufferStorage->Size;
|
|
|
|
if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {
|
2008-08-19 12:44:50 +02:00
|
|
|
DataAllocated = TRUE;
|
2008-08-18 07:56:23 +02:00
|
|
|
if (ConfigAccess->FormCallbackProtocol == NULL ||
|
|
|
|
ConfigAccess->FormCallbackProtocol->NvRead == NULL) {
|
|
|
|
Status = GetUefiVariable (
|
|
|
|
BufferStorage,
|
|
|
|
&Data,
|
|
|
|
&DataSize
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
Status = CallFormCallBack (
|
|
|
|
BufferStorage,
|
|
|
|
ConfigAccess->FormCallbackProtocol,
|
|
|
|
&Data,
|
|
|
|
&DataSize
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else {
|
2008-08-19 12:44:50 +02:00
|
|
|
//
|
|
|
|
// ConfigToBlock will convert the Config String and update the NvMapOverride accordingly.
|
|
|
|
//
|
2008-08-18 07:56:23 +02:00
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
Data = ConfigAccess->ThunkContext->NvMapOverride;
|
|
|
|
DataSize = DataSize2;
|
|
|
|
DataAllocated = FALSE;
|
|
|
|
}
|
2008-08-19 12:44:50 +02:00
|
|
|
if (EFI_ERROR (Status) || (DataSize2 != DataSize)) {
|
|
|
|
if (Data == NULL) {
|
|
|
|
Data = AllocateZeroPool (DataSize2);
|
|
|
|
}
|
2008-04-16 09:36:51 +02:00
|
|
|
}
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2010-02-09 07:29:37 +01:00
|
|
|
DataSize = DataSize2;
|
2008-04-24 09:08:46 +02:00
|
|
|
Status = mHiiConfigRoutingProtocol->ConfigToBlock (
|
|
|
|
mHiiConfigRoutingProtocol,
|
2008-04-16 09:36:51 +02:00
|
|
|
Configuration,
|
|
|
|
Data,
|
2010-02-09 07:29:37 +01:00
|
|
|
&DataSize,
|
2008-04-16 09:36:51 +02:00
|
|
|
Progress
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
goto Done;
|
|
|
|
}
|
2009-07-15 08:57:39 +02:00
|
|
|
|
2008-08-19 12:44:50 +02:00
|
|
|
if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {
|
|
|
|
if (ConfigAccess->FormCallbackProtocol == NULL ||
|
|
|
|
ConfigAccess->FormCallbackProtocol->NvWrite == NULL) {
|
|
|
|
Status = gRT->SetVariable (
|
|
|
|
BufferStorage->Name,
|
|
|
|
&BufferStorage->Guid,
|
|
|
|
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
|
|
|
DataSize2,
|
|
|
|
Data
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
Status = ConfigAccess->FormCallbackProtocol->NvWrite (
|
|
|
|
ConfigAccess->FormCallbackProtocol,
|
|
|
|
BufferStorage->Name,
|
|
|
|
&BufferStorage->Guid,
|
|
|
|
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
|
|
|
DataSize2,
|
|
|
|
Data,
|
|
|
|
&ResetRequired
|
|
|
|
);
|
|
|
|
}
|
2008-04-16 09:36:51 +02:00
|
|
|
}
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
Done:
|
|
|
|
if (DataAllocated && (Data != NULL)) {
|
|
|
|
FreePool (Data);
|
|
|
|
}
|
|
|
|
|
2008-04-16 09:36:51 +02:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
/**
|
2009-07-13 11:28:09 +02:00
|
|
|
Build the EFI_IFR_DATA_ARRAY which will be used to pass to
|
|
|
|
EFI_FORM_CALLBACK_PROTOCOL.Callback. Check definition of EFI_IFR_DATA_ARRAY
|
2008-11-10 13:40:07 +01:00
|
|
|
for details.
|
|
|
|
|
|
|
|
ASSERT if the Question Type is not EFI_IFR_TYPE_NUM_SIZE_* or EFI_IFR_TYPE_STRING.
|
|
|
|
|
2010-03-01 04:26:19 +01:00
|
|
|
@param ConfigAccess Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL
|
2008-11-10 13:40:07 +01:00
|
|
|
@param QuestionId The Question ID.
|
|
|
|
@param Type The Question Type.
|
|
|
|
@param Value The Question Value.
|
|
|
|
@param NvMapAllocated On output indicates if a buffer is allocated for NvMap.
|
|
|
|
|
2009-07-13 11:28:09 +02:00
|
|
|
@return A pointer to EFI_IFR_DATA_ARRAY. The caller must free this buffer allocated.
|
2008-11-10 13:40:07 +01:00
|
|
|
**/
|
2009-07-13 11:28:09 +02:00
|
|
|
EFI_IFR_DATA_ARRAY *
|
2008-08-18 07:56:23 +02:00
|
|
|
CreateIfrDataArray (
|
|
|
|
IN CONFIG_ACCESS_PRIVATE *ConfigAccess,
|
|
|
|
IN EFI_QUESTION_ID QuestionId,
|
|
|
|
IN UINT8 Type,
|
|
|
|
IN EFI_IFR_TYPE_VALUE *Value,
|
|
|
|
OUT BOOLEAN *NvMapAllocated
|
|
|
|
)
|
|
|
|
{
|
2009-07-13 11:28:09 +02:00
|
|
|
EFI_IFR_DATA_ARRAY *IfrDataArray;
|
|
|
|
EFI_IFR_DATA_ENTRY *IfrDataEntry;
|
2008-08-18 07:56:23 +02:00
|
|
|
UINTN BrowserDataSize;
|
2009-04-20 10:14:08 +02:00
|
|
|
FORMSET_STORAGE *BufferStorage;
|
2008-09-01 08:15:02 +02:00
|
|
|
UINTN Size;
|
|
|
|
EFI_STRING String;
|
2009-07-23 11:27:17 +02:00
|
|
|
FORM_BROWSER_STATEMENT *Statement;
|
2008-09-01 08:15:02 +02:00
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
*NvMapAllocated = FALSE;
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
String = NULL;
|
2008-09-01 08:15:02 +02:00
|
|
|
|
|
|
|
switch (Type) {
|
|
|
|
case EFI_IFR_TYPE_NUM_SIZE_8:
|
|
|
|
case EFI_IFR_TYPE_NUM_SIZE_16:
|
|
|
|
case EFI_IFR_TYPE_NUM_SIZE_32:
|
|
|
|
case EFI_IFR_TYPE_NUM_SIZE_64:
|
|
|
|
case EFI_IFR_TYPE_BOOLEAN:
|
|
|
|
Size = sizeof (*Value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EFI_IFR_TYPE_STRING:
|
2009-04-16 09:02:42 +02:00
|
|
|
if (Value->string == 0) {
|
|
|
|
Size = 0;
|
|
|
|
} else {
|
|
|
|
String = HiiGetString (ConfigAccess->ThunkContext->UefiHiiHandle, Value->string, NULL);
|
|
|
|
ASSERT (String != NULL);
|
2008-09-01 08:15:02 +02:00
|
|
|
|
2009-04-16 09:02:42 +02:00
|
|
|
Size = StrSize (String);
|
|
|
|
}
|
2008-09-01 08:15:02 +02:00
|
|
|
break;
|
2010-02-01 05:06:24 +01:00
|
|
|
|
|
|
|
case EFI_IFR_TYPE_ACTION:
|
2010-03-14 08:09:37 +01:00
|
|
|
case EFI_IFR_TYPE_UNDEFINED:
|
2010-02-01 05:06:24 +01:00
|
|
|
Size = 0;
|
|
|
|
break;
|
2008-09-01 08:15:02 +02:00
|
|
|
|
|
|
|
default:
|
|
|
|
ASSERT (FALSE);
|
|
|
|
Size = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-07-13 11:28:09 +02:00
|
|
|
IfrDataArray = AllocateZeroPool (sizeof (EFI_IFR_DATA_ARRAY) + sizeof (EFI_IFR_DATA_ENTRY) + Size);
|
2008-08-18 07:56:23 +02:00
|
|
|
ASSERT (IfrDataArray != NULL);
|
2009-07-23 11:27:17 +02:00
|
|
|
IfrDataArray->EntryCount = 1;
|
|
|
|
IfrDataEntry = (EFI_IFR_DATA_ENTRY *) (IfrDataArray + 1);
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2009-07-23 11:27:17 +02:00
|
|
|
Statement = GetStorageFromQuestionId (ConfigAccess->ThunkContext->FormSet, QuestionId);
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2009-07-23 11:27:17 +02:00
|
|
|
if (Statement == NULL || Statement->Storage == NULL) {
|
2008-11-10 13:40:07 +01:00
|
|
|
//
|
|
|
|
// The QuestionId is not associated with a Buffer Storage.
|
|
|
|
// Try to get the first Buffer Storage then.
|
|
|
|
//
|
|
|
|
BufferStorage = GetFirstStorageOfFormSet (ConfigAccess->ThunkContext->FormSet);
|
2009-07-23 11:27:17 +02:00
|
|
|
} else {
|
|
|
|
BufferStorage = Statement->Storage;
|
|
|
|
IfrDataEntry->OpCode = Statement->Operand;
|
2008-08-18 07:56:23 +02:00
|
|
|
}
|
2008-08-19 12:44:50 +02:00
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
if (BufferStorage != NULL) {
|
2009-07-23 11:27:17 +02:00
|
|
|
BrowserDataSize = BufferStorage->Size;
|
|
|
|
IfrDataEntry->Length = (UINT8) (sizeof (EFI_IFR_DATA_ENTRY) + Size);
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {
|
|
|
|
*NvMapAllocated = TRUE;
|
|
|
|
IfrDataArray->NvRamMap = AllocateZeroPool (BrowserDataSize);
|
|
|
|
} else {
|
|
|
|
*NvMapAllocated = FALSE;
|
|
|
|
IfrDataArray->NvRamMap = ConfigAccess->ThunkContext->NvMapOverride;
|
|
|
|
}
|
|
|
|
|
2009-04-27 07:55:16 +02:00
|
|
|
ASSERT (HiiGetBrowserData (&BufferStorage->Guid, BufferStorage->Name, BrowserDataSize, (UINT8 *) IfrDataArray->NvRamMap));
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
switch (Type) {
|
|
|
|
case EFI_IFR_TYPE_NUM_SIZE_8:
|
|
|
|
case EFI_IFR_TYPE_NUM_SIZE_16:
|
|
|
|
case EFI_IFR_TYPE_NUM_SIZE_32:
|
|
|
|
case EFI_IFR_TYPE_NUM_SIZE_64:
|
|
|
|
case EFI_IFR_TYPE_BOOLEAN:
|
|
|
|
CopyMem (&IfrDataEntry->Data, &(Value->u8), sizeof (*Value));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EFI_IFR_TYPE_STRING:
|
2009-04-16 09:02:42 +02:00
|
|
|
if (Size != 0) {
|
|
|
|
ASSERT (String != NULL);
|
|
|
|
StrCpy ((CHAR16 *) &IfrDataEntry->Data, String);
|
|
|
|
FreePool (String);
|
|
|
|
}
|
2008-11-10 13:40:07 +01:00
|
|
|
break;
|
2010-02-01 05:06:24 +01:00
|
|
|
|
|
|
|
case EFI_IFR_TYPE_ACTION:
|
2010-03-14 08:09:37 +01:00
|
|
|
case EFI_IFR_TYPE_UNDEFINED:
|
2010-02-01 05:06:24 +01:00
|
|
|
break;
|
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
default:
|
|
|
|
ASSERT (FALSE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2009-07-13 11:28:09 +02:00
|
|
|
// Need to fiil in the information for the rest of field for EFI_IFR_DATA_ENTRY.
|
2008-11-10 13:40:07 +01:00
|
|
|
// It seems that no implementation is found to use other fields. Leave them uninitialized for now.
|
|
|
|
//
|
|
|
|
//UINT8 OpCode; // Likely a string, numeric, or one-of
|
2009-07-13 11:28:09 +02:00
|
|
|
//UINT8 Length; // Length of the EFI_IFR_DATA_ENTRY packet
|
2008-11-10 13:40:07 +01:00
|
|
|
//UINT16 Flags; // Flags settings to determine what behavior is desired from the browser after the callback
|
|
|
|
//VOID *Data; // The data in the form based on the op-code type - this is not a pointer to the data, the data follows immediately
|
|
|
|
// If the OpCode is a OneOf or Numeric type - Data is a UINT16 value
|
|
|
|
// If the OpCode is a String type - Data is a CHAR16[x] type
|
|
|
|
// If the OpCode is a Checkbox type - Data is a UINT8 value
|
|
|
|
// If the OpCode is a NV Access type - Data is a FRAMEWORK_EFI_IFR_NV_DATA structure
|
2008-08-18 07:56:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return IfrDataArray;
|
|
|
|
}
|
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
/**
|
|
|
|
If a NvMapOverride is passed in to EFI_FORM_BROWSER_PROTOCOL.SendForm, the Form Browser
|
|
|
|
needs to be informed when data changed in NvMapOverride. This function will invoke
|
|
|
|
SetBrowserData () to set internal data of Form Browser.
|
|
|
|
|
|
|
|
@param ConfigAccess The Config Access Private Context.
|
|
|
|
@param QuestionId The Question Id that invokes the callback.
|
|
|
|
|
|
|
|
|
|
|
|
**/
|
2008-08-19 12:44:50 +02:00
|
|
|
VOID
|
|
|
|
SyncBrowserDataForNvMapOverride (
|
2008-11-10 13:40:07 +01:00
|
|
|
IN CONST CONFIG_ACCESS_PRIVATE *ConfigAccess,
|
|
|
|
IN EFI_QUESTION_ID QuestionId
|
2008-08-19 12:44:50 +02:00
|
|
|
)
|
|
|
|
{
|
2009-04-20 10:14:08 +02:00
|
|
|
FORMSET_STORAGE *BufferStorage;
|
|
|
|
BOOLEAN CheckFlag;
|
|
|
|
UINTN BrowserDataSize;
|
2009-07-23 11:27:17 +02:00
|
|
|
FORM_BROWSER_STATEMENT *Statement;
|
2008-08-19 12:44:50 +02:00
|
|
|
|
|
|
|
if (ConfigAccess->ThunkContext->NvMapOverride != NULL) {
|
2008-11-10 13:40:07 +01:00
|
|
|
|
2009-07-23 11:27:17 +02:00
|
|
|
Statement = GetStorageFromQuestionId (ConfigAccess->ThunkContext->FormSet, QuestionId);
|
2008-11-10 13:40:07 +01:00
|
|
|
|
2009-07-23 11:27:17 +02:00
|
|
|
if (Statement == NULL || Statement->Storage == NULL) {
|
2008-11-10 13:40:07 +01:00
|
|
|
//
|
|
|
|
// QuestionId is a statement without Storage.
|
|
|
|
// 1) It is a Goto.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
BufferStorage = GetFirstStorageOfFormSet (ConfigAccess->ThunkContext->FormSet);
|
2009-07-23 11:27:17 +02:00
|
|
|
} else {
|
|
|
|
BufferStorage = Statement->Storage;
|
2008-11-10 13:40:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// If NvMapOverride is not NULL, this Form must have at least one Buffer Type Variable Storage.
|
|
|
|
//
|
|
|
|
ASSERT (BufferStorage != NULL);
|
2008-08-19 12:44:50 +02:00
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
BrowserDataSize = BufferStorage->Size;
|
2008-08-19 12:44:50 +02:00
|
|
|
|
2009-04-20 10:14:08 +02:00
|
|
|
CheckFlag = HiiSetBrowserData (&BufferStorage->Guid, BufferStorage->Name, BrowserDataSize, ConfigAccess->ThunkContext->NvMapOverride, NULL);
|
|
|
|
ASSERT (CheckFlag);
|
2008-08-19 12:44:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
/**
|
2009-07-13 11:28:09 +02:00
|
|
|
Free up resource allocated for a EFI_IFR_DATA_ARRAY by CreateIfrDataArray ().
|
2008-11-10 13:40:07 +01:00
|
|
|
|
2009-07-13 11:28:09 +02:00
|
|
|
@param Array The EFI_IFR_DATA_ARRAY allocated.
|
|
|
|
@param NvMapAllocated If the NvRamMap is allocated for EFI_IFR_DATA_ARRAY.
|
2008-11-10 13:40:07 +01:00
|
|
|
|
|
|
|
**/
|
2008-08-18 07:56:23 +02:00
|
|
|
VOID
|
|
|
|
DestroyIfrDataArray (
|
2009-07-13 11:28:09 +02:00
|
|
|
IN EFI_IFR_DATA_ARRAY *Array,
|
2008-08-18 07:56:23 +02:00
|
|
|
IN BOOLEAN NvMapAllocated
|
|
|
|
)
|
|
|
|
{
|
2008-08-20 16:17:24 +02:00
|
|
|
if (Array != NULL) {
|
|
|
|
if (NvMapAllocated) {
|
|
|
|
FreePool (Array->NvRamMap);
|
|
|
|
}
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2008-08-20 16:17:24 +02:00
|
|
|
FreePool (Array);
|
|
|
|
}
|
2008-08-18 07:56:23 +02:00
|
|
|
}
|
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
/**
|
|
|
|
Get the ONE_OF_OPTION_MAP_ENTRY for a QuestionId that invokes the
|
|
|
|
EFI_FORM_CALLBACK_PROTOCOL.Callback. The information is needed as
|
|
|
|
the callback mechanism for EFI_IFR_ONE_OF_OPTION is changed from
|
|
|
|
EFI_IFR_ONE_OF_OPTION in Framework IFR. Check EFI_IFR_GUID_OPTIONKEY
|
|
|
|
for detailed information.
|
|
|
|
|
|
|
|
@param ThunkContext The Thunk Context.
|
|
|
|
@param QuestionId The Question Id.
|
|
|
|
@param Type The Question Type.
|
|
|
|
@param Value The One Of Option's value.
|
|
|
|
|
|
|
|
@return The ONE_OF_OPTION_MAP_ENTRY found.
|
|
|
|
@retval NULL If no entry is found.
|
|
|
|
**/
|
2008-08-18 07:56:23 +02:00
|
|
|
ONE_OF_OPTION_MAP_ENTRY *
|
|
|
|
GetOneOfOptionMapEntry (
|
|
|
|
IN HII_THUNK_CONTEXT *ThunkContext,
|
|
|
|
IN EFI_QUESTION_ID QuestionId,
|
|
|
|
IN UINT8 Type,
|
|
|
|
IN EFI_IFR_TYPE_VALUE *Value
|
|
|
|
)
|
|
|
|
{
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
LIST_ENTRY *Link2;
|
|
|
|
ONE_OF_OPTION_MAP_ENTRY *OneOfOptionMapEntry;
|
|
|
|
ONE_OF_OPTION_MAP *OneOfOptionMap;
|
2008-11-10 13:40:07 +01:00
|
|
|
FORM_BROWSER_FORMSET *FormSet;
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
FormSet = ThunkContext->FormSet;
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
Link = GetFirstNode (&FormSet->OneOfOptionMapListHead);
|
|
|
|
|
|
|
|
while (!IsNull (&FormSet->OneOfOptionMapListHead, Link)) {
|
2008-08-18 07:56:23 +02:00
|
|
|
OneOfOptionMap = ONE_OF_OPTION_MAP_FROM_LINK(Link);
|
|
|
|
if (OneOfOptionMap->QuestionId == QuestionId) {
|
|
|
|
ASSERT (OneOfOptionMap->ValueType == Type);
|
|
|
|
|
|
|
|
Link2 = GetFirstNode (&OneOfOptionMap->OneOfOptionMapEntryListHead);
|
|
|
|
|
|
|
|
while (!IsNull (&OneOfOptionMap->OneOfOptionMapEntryListHead, Link2)) {
|
|
|
|
OneOfOptionMapEntry = ONE_OF_OPTION_MAP_ENTRY_FROM_LINK (Link2);
|
|
|
|
|
|
|
|
if (CompareMem (Value, &OneOfOptionMapEntry->Value, sizeof (EFI_IFR_TYPE_VALUE)) == 0) {
|
|
|
|
return OneOfOptionMapEntry;
|
|
|
|
}
|
|
|
|
|
|
|
|
Link2 = GetNextNode (&OneOfOptionMap->OneOfOptionMapEntryListHead, Link2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
Link = GetNextNode (&FormSet->OneOfOptionMapListHead, Link);
|
2008-08-18 07:56:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Functions which are registered to receive notification of
|
|
|
|
database events have this prototype. The actual event is encoded
|
|
|
|
in NotifyType. The following table describes how PackageType,
|
|
|
|
PackageGuid, Handle, and Package are used for each of the
|
|
|
|
notification types.
|
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
If any Pakcage List in database is updated, mHiiPackageListUpdated
|
|
|
|
will be set. If mHiiPackageListUpdated is set, Framework ThunkCallback()
|
|
|
|
will force the UEFI Setup Browser to save the uncommitted data. This
|
|
|
|
is needed as Framework's Callback function may dynamically update
|
|
|
|
opcode in a Package List. UEFI Setup Browser will quit itself and reparse
|
|
|
|
the Package List's IFR and display it. UEFI Config Access's implementation
|
|
|
|
is required to save the modified (SetBrowserData or directly save the data
|
|
|
|
to NV storage). But Framework HII Modules is not aware of this rule. Therefore,
|
|
|
|
we will enforce the rule in ThunkCallback (). The side effect of force saving
|
|
|
|
of NV data is the NV flag in browser may not flag a update as data has already
|
|
|
|
been saved to NV storage.
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
@param PackageType Package type of the notification.
|
|
|
|
|
|
|
|
@param PackageGuid If PackageType is
|
|
|
|
EFI_HII_PACKAGE_TYPE_GUID, then this is
|
|
|
|
the pointer to the GUID from the Guid
|
|
|
|
field of EFI_HII_PACKAGE_GUID_HEADER.
|
|
|
|
Otherwise, it must be NULL.
|
|
|
|
|
|
|
|
@param Package Points to the package referred to by the
|
|
|
|
notification Handle The handle of the package
|
|
|
|
list which contains the specified package.
|
|
|
|
|
|
|
|
@param Handle The HII handle.
|
|
|
|
|
|
|
|
@param NotifyType The type of change concerning the
|
|
|
|
database. See
|
|
|
|
EFI_HII_DATABASE_NOTIFY_TYPE.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
FormUpdateNotify (
|
|
|
|
IN UINT8 PackageType,
|
|
|
|
IN CONST EFI_GUID *PackageGuid,
|
|
|
|
IN CONST EFI_HII_PACKAGE_HEADER *Package,
|
|
|
|
IN EFI_HII_HANDLE Handle,
|
|
|
|
IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
|
|
|
|
)
|
|
|
|
{
|
|
|
|
mHiiPackageListUpdated = TRUE;
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-05-15 11:14:36 +02:00
|
|
|
/**
|
|
|
|
Wrap the EFI_HII_CONFIG_ACCESS_PROTOCOL.CallBack to EFI_FORM_CALLBACK_PROTOCOL.Callback. Therefor,
|
2008-11-10 13:40:07 +01:00
|
|
|
the framework HII module willl do no porting and work with a UEFI HII SetupBrowser.
|
2008-05-15 11:14:36 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
|
|
|
|
@param Action Specifies the type of action taken by the browser. See EFI_BROWSER_ACTION_x.
|
2008-05-15 11:14:36 +02:00
|
|
|
@param QuestionId A unique value which is sent to the original exporting driver so that it can identify the
|
2008-08-18 07:56:23 +02:00
|
|
|
type of data to expect. The format of the data tends to vary based on the opcode that
|
|
|
|
generated the callback.
|
|
|
|
@param Type The type of value for the question. See EFI_IFR_TYPE_x in
|
|
|
|
EFI_IFR_ONE_OF_OPTION.
|
|
|
|
@param Value A pointer to the data being sent to the original exporting driver. The type is specified
|
|
|
|
by Type. Type EFI_IFR_TYPE_VALUE is defined in
|
|
|
|
EFI_IFR_ONE_OF_OPTION.
|
2008-05-15 11:14:36 +02:00
|
|
|
@param ActionRequest On return, points to the action requested by the callback function. Type
|
2008-08-18 07:56:23 +02:00
|
|
|
EFI_BROWSER_ACTION_REQUEST is specified in SendForm() in the Form
|
|
|
|
Browser Protocol.
|
2008-05-15 11:14:36 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
@retval EFI_UNSUPPORTED If the Framework HII module does not register Callback although it specify the opcode under
|
|
|
|
focuse to be INTERRACTIVE.
|
2008-05-15 11:14:36 +02:00
|
|
|
@retval EFI_SUCCESS The callback complete successfully.
|
|
|
|
@retval !EFI_SUCCESS The error code returned by EFI_FORM_CALLBACK_PROTOCOL.Callback.
|
|
|
|
|
|
|
|
**/
|
2008-04-16 09:36:51 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ThunkCallback (
|
|
|
|
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
|
|
|
|
IN EFI_BROWSER_ACTION Action,
|
|
|
|
IN EFI_QUESTION_ID QuestionId,
|
|
|
|
IN UINT8 Type,
|
|
|
|
IN EFI_IFR_TYPE_VALUE *Value,
|
|
|
|
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
2008-08-18 07:56:23 +02:00
|
|
|
CONFIG_ACCESS_PRIVATE *ConfigAccess;
|
|
|
|
EFI_FORM_CALLBACK_PROTOCOL *FormCallbackProtocol;
|
2008-04-16 09:36:51 +02:00
|
|
|
EFI_HII_CALLBACK_PACKET *Packet;
|
2009-07-13 11:28:09 +02:00
|
|
|
EFI_IFR_DATA_ARRAY *Data;
|
|
|
|
EFI_IFR_DATA_ENTRY *DataEntry;
|
2008-08-18 07:56:23 +02:00
|
|
|
UINT16 KeyValue;
|
|
|
|
ONE_OF_OPTION_MAP_ENTRY *OneOfOptionMapEntry;
|
|
|
|
EFI_HANDLE NotifyHandle;
|
|
|
|
EFI_INPUT_KEY Key;
|
|
|
|
BOOLEAN NvMapAllocated;
|
2008-04-16 09:36:51 +02:00
|
|
|
|
2011-05-20 03:28:17 +02:00
|
|
|
if (Action == EFI_BROWSER_ACTION_CHANGING) {
|
|
|
|
ASSERT (This != NULL);
|
|
|
|
ASSERT (Value != NULL);
|
|
|
|
ASSERT (ActionRequest != NULL);
|
2009-11-13 11:05:52 +01:00
|
|
|
|
2011-05-20 03:28:17 +02:00
|
|
|
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;
|
2008-04-16 09:36:51 +02:00
|
|
|
|
2011-05-20 03:28:17 +02:00
|
|
|
ConfigAccess = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This);
|
2008-04-16 09:36:51 +02:00
|
|
|
|
2011-05-20 03:28:17 +02:00
|
|
|
FormCallbackProtocol = ConfigAccess->FormCallbackProtocol;
|
|
|
|
if (FormCallbackProtocol == NULL) {
|
|
|
|
ASSERT (FALSE);
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
2008-04-16 09:36:51 +02:00
|
|
|
|
2011-05-20 03:28:17 +02:00
|
|
|
//
|
|
|
|
// Check if the QuestionId match a OneOfOption.
|
|
|
|
//
|
|
|
|
OneOfOptionMapEntry = GetOneOfOptionMapEntry (ConfigAccess->ThunkContext, QuestionId, Type, Value);
|
2008-04-16 09:36:51 +02:00
|
|
|
|
2011-05-20 03:28:17 +02:00
|
|
|
if (OneOfOptionMapEntry == NULL) {
|
|
|
|
//
|
|
|
|
// This is not a One-Of-Option opcode. QuestionId is the KeyValue
|
|
|
|
//
|
|
|
|
KeyValue = QuestionId;
|
|
|
|
} else {
|
|
|
|
//
|
|
|
|
// Otherwise, use the original Key specified in One Of Option in the Framework VFR syntax.
|
|
|
|
//
|
|
|
|
KeyValue = OneOfOptionMapEntry->FwKey;
|
|
|
|
}
|
2008-08-18 07:56:23 +02:00
|
|
|
|
|
|
|
//
|
2011-05-20 03:28:17 +02:00
|
|
|
// Build the EFI_IFR_DATA_ARRAY
|
2008-08-18 07:56:23 +02:00
|
|
|
//
|
2011-05-20 03:28:17 +02:00
|
|
|
Data = CreateIfrDataArray (ConfigAccess, QuestionId, Type, Value, &NvMapAllocated);
|
|
|
|
|
|
|
|
Status = mHiiDatabase->RegisterPackageNotify (
|
|
|
|
mHiiDatabase,
|
|
|
|
EFI_HII_PACKAGE_FORMS,
|
|
|
|
NULL,
|
|
|
|
FormUpdateNotify,
|
|
|
|
EFI_HII_DATABASE_NOTIFY_REMOVE_PACK,
|
|
|
|
&NotifyHandle
|
|
|
|
);
|
2008-11-10 13:40:07 +01:00
|
|
|
//
|
2011-05-20 03:28:17 +02:00
|
|
|
//Call the Framework Callback function.
|
2008-11-10 13:40:07 +01:00
|
|
|
//
|
2011-05-20 03:28:17 +02:00
|
|
|
Packet = NULL;
|
|
|
|
Status = FormCallbackProtocol->Callback (
|
|
|
|
FormCallbackProtocol,
|
|
|
|
KeyValue,
|
|
|
|
Data,
|
|
|
|
&Packet
|
|
|
|
);
|
|
|
|
SyncBrowserDataForNvMapOverride (ConfigAccess, QuestionId);
|
2008-04-16 09:36:51 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
//
|
2011-05-20 03:28:17 +02:00
|
|
|
// Callback require browser to perform action
|
2008-08-18 07:56:23 +02:00
|
|
|
//
|
2011-05-20 03:28:17 +02:00
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
if (Packet != NULL) {
|
|
|
|
do {
|
|
|
|
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, Packet->String, NULL);
|
|
|
|
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Error Code in Status is discarded.
|
|
|
|
//
|
|
|
|
} else {
|
|
|
|
if (Packet != NULL) {
|
|
|
|
if (Packet->DataArray.EntryCount == 1 && Packet->DataArray.NvRamMap == NULL) {
|
|
|
|
DataEntry = (EFI_IFR_DATA_ENTRY *) ((UINT8 *) Packet + sizeof (EFI_IFR_DATA_ARRAY));
|
|
|
|
if ((DataEntry->Flags & EXIT_REQUIRED) == EXIT_REQUIRED) {
|
|
|
|
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((DataEntry->Flags & SAVE_REQUIRED) == SAVE_REQUIRED) {
|
|
|
|
Status = ConfigAccess->ConfigAccessProtocol.RouteConfig (
|
|
|
|
&ConfigAccess->ConfigAccessProtocol,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
}
|
2008-08-18 07:56:23 +02:00
|
|
|
}
|
2011-05-20 03:28:17 +02:00
|
|
|
FreePool (Packet);
|
|
|
|
}
|
2008-08-18 07:56:23 +02:00
|
|
|
}
|
|
|
|
|
2011-05-20 03:28:17 +02:00
|
|
|
//
|
|
|
|
// Unregister notify for Form package update
|
|
|
|
//
|
|
|
|
Status = mHiiDatabase->UnregisterPackageNotify (
|
|
|
|
mHiiDatabase,
|
|
|
|
NotifyHandle
|
|
|
|
);
|
|
|
|
//
|
|
|
|
// UEFI SetupBrowser behaves differently with Framework SetupBrowser when call back function
|
|
|
|
// update any forms in HII database. UEFI SetupBrowser will re-parse the displaying form package and load
|
|
|
|
// the values from variable storages. Framework SetupBrowser will only re-parse the displaying form packages.
|
|
|
|
// To make sure customer's previous changes is saved and the changing question behaves as expected, we
|
|
|
|
// issue a EFI_BROWSER_ACTION_REQUEST_SUBMIT to ask UEFI SetupBrowser to save the changes proceed to re-parse
|
|
|
|
// the form and load all the variable storages.
|
|
|
|
//
|
|
|
|
if (*ActionRequest == EFI_BROWSER_ACTION_REQUEST_NONE && mHiiPackageListUpdated) {
|
|
|
|
mHiiPackageListUpdated= FALSE;
|
|
|
|
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;
|
|
|
|
} else {
|
|
|
|
if (ConfigAccess->ThunkContext->FormSet->SubClass == EFI_FRONT_PAGE_SUBCLASS ||
|
|
|
|
ConfigAccess->ThunkContext->FormSet->SubClass == EFI_SINGLE_USE_SUBCLASS) {
|
|
|
|
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;
|
|
|
|
}
|
2008-09-05 03:19:01 +02:00
|
|
|
}
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2011-05-20 03:28:17 +02:00
|
|
|
//
|
|
|
|
// Clean up.
|
|
|
|
//
|
|
|
|
DestroyIfrDataArray (Data, NvMapAllocated);
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
2008-08-20 16:17:24 +02:00
|
|
|
|
2008-11-10 13:40:07 +01:00
|
|
|
//
|
2011-05-20 03:28:17 +02:00
|
|
|
// All other action return unsupported.
|
2008-11-10 13:40:07 +01:00
|
|
|
//
|
2011-05-20 03:28:17 +02:00
|
|
|
return EFI_UNSUPPORTED;
|
2008-04-16 09:36:51 +02:00
|
|
|
}
|
|
|
|
|