mirror of https://github.com/acidanthera/audk.git
Add new "Refresh guid" opcode, also add sample code to use it.
Signed-off-by: ydong10 Reviewed-by: lgao4 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11767 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
5b127d7565
commit
211cc6e5cd
|
@ -20,10 +20,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
EFI_GUID mFormSetGuid = FORMSET_GUID;
|
EFI_GUID mFormSetGuid = FORMSET_GUID;
|
||||||
EFI_GUID mInventoryGuid = INVENTORY_GUID;
|
EFI_GUID mInventoryGuid = INVENTORY_GUID;
|
||||||
|
EFI_GUID MyEventGroupGuid = EFI_IFR_REFRESH_ID_OP_GUID;
|
||||||
|
|
||||||
CHAR16 VariableName[] = L"MyIfrNVData";
|
CHAR16 VariableName[] = L"MyIfrNVData";
|
||||||
EFI_HANDLE DriverHandle[2] = {NULL, NULL};
|
EFI_HANDLE DriverHandle[2] = {NULL, NULL};
|
||||||
DRIVER_SAMPLE_PRIVATE_DATA *PrivateData = NULL;
|
DRIVER_SAMPLE_PRIVATE_DATA *PrivateData = NULL;
|
||||||
|
EFI_EVENT mEvent;
|
||||||
|
|
||||||
HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath0 = {
|
HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath0 = {
|
||||||
{
|
{
|
||||||
|
@ -75,6 +77,158 @@ HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath1 = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Add empty function for event process function.
|
||||||
|
|
||||||
|
@param Event The Event need to be process
|
||||||
|
@param Context The context of the event.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
DriverSampleInternalEmptyFunction (
|
||||||
|
IN EFI_EVENT Event,
|
||||||
|
IN VOID *Context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Notification function for keystrokes.
|
||||||
|
|
||||||
|
@param[in] KeyData The key that was pressed.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The operation was successful.
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
NotificationFunction(
|
||||||
|
IN EFI_KEY_DATA *KeyData
|
||||||
|
)
|
||||||
|
{
|
||||||
|
gBS->SignalEvent (mEvent);
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Function to start monitoring for CTRL-C using SimpleTextInputEx.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The feature is enabled.
|
||||||
|
@retval EFI_OUT_OF_RESOURCES There is not enough mnemory available.
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
InternalStartMonitor(
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *SimpleEx;
|
||||||
|
EFI_KEY_DATA KeyData;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_HANDLE *Handles;
|
||||||
|
UINTN HandleCount;
|
||||||
|
UINTN HandleIndex;
|
||||||
|
EFI_HANDLE NotifyHandle;
|
||||||
|
|
||||||
|
Status = gBS->LocateHandleBuffer (
|
||||||
|
ByProtocol,
|
||||||
|
&gEfiSimpleTextInputExProtocolGuid,
|
||||||
|
NULL,
|
||||||
|
&HandleCount,
|
||||||
|
&Handles
|
||||||
|
);
|
||||||
|
for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
|
||||||
|
Status = gBS->HandleProtocol (Handles[HandleIndex], &gEfiSimpleTextInputExProtocolGuid, (VOID **) &SimpleEx);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
KeyData.KeyState.KeyToggleState = 0;
|
||||||
|
KeyData.Key.ScanCode = 0;
|
||||||
|
KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED;
|
||||||
|
KeyData.Key.UnicodeChar = L'c';
|
||||||
|
|
||||||
|
Status = SimpleEx->RegisterKeyNotify(
|
||||||
|
SimpleEx,
|
||||||
|
&KeyData,
|
||||||
|
NotificationFunction,
|
||||||
|
&NotifyHandle);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED;
|
||||||
|
Status = SimpleEx->RegisterKeyNotify(
|
||||||
|
SimpleEx,
|
||||||
|
&KeyData,
|
||||||
|
NotificationFunction,
|
||||||
|
&NotifyHandle);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Function to stop monitoring for CTRL-C using SimpleTextInputEx.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The feature is enabled.
|
||||||
|
@retval EFI_OUT_OF_RESOURCES There is not enough mnemory available.
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
InternalStopMonitor(
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *SimpleEx;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_HANDLE *Handles;
|
||||||
|
EFI_KEY_DATA KeyData;
|
||||||
|
UINTN HandleCount;
|
||||||
|
UINTN HandleIndex;
|
||||||
|
EFI_HANDLE NotifyHandle;
|
||||||
|
|
||||||
|
Status = gBS->LocateHandleBuffer (
|
||||||
|
ByProtocol,
|
||||||
|
&gEfiSimpleTextInputExProtocolGuid,
|
||||||
|
NULL,
|
||||||
|
&HandleCount,
|
||||||
|
&Handles
|
||||||
|
);
|
||||||
|
for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
|
||||||
|
Status = gBS->HandleProtocol (Handles[HandleIndex], &gEfiSimpleTextInputExProtocolGuid, (VOID **) &SimpleEx);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
KeyData.KeyState.KeyToggleState = 0;
|
||||||
|
KeyData.Key.ScanCode = 0;
|
||||||
|
KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED;
|
||||||
|
KeyData.Key.UnicodeChar = L'c';
|
||||||
|
|
||||||
|
Status = SimpleEx->RegisterKeyNotify(
|
||||||
|
SimpleEx,
|
||||||
|
&KeyData,
|
||||||
|
NotificationFunction,
|
||||||
|
&NotifyHandle);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
Status = SimpleEx->UnregisterKeyNotify (SimpleEx, NotifyHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED;
|
||||||
|
Status = SimpleEx->RegisterKeyNotify(
|
||||||
|
SimpleEx,
|
||||||
|
&KeyData,
|
||||||
|
NotificationFunction,
|
||||||
|
&NotifyHandle);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
Status = SimpleEx->UnregisterKeyNotify (SimpleEx, NotifyHandle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Encode the password using a simple algorithm.
|
Encode the password using a simple algorithm.
|
||||||
|
|
||||||
|
@ -1124,6 +1278,7 @@ DriverCallback (
|
||||||
EFI_INPUT_KEY Key;
|
EFI_INPUT_KEY Key;
|
||||||
DRIVER_SAMPLE_CONFIGURATION *Configuration;
|
DRIVER_SAMPLE_CONFIGURATION *Configuration;
|
||||||
UINTN MyVarSize;
|
UINTN MyVarSize;
|
||||||
|
EFI_FORM_ID FormId;
|
||||||
|
|
||||||
if (((Value == NULL) && (Action != EFI_BROWSER_ACTION_FORM_OPEN) && (Action != EFI_BROWSER_ACTION_FORM_CLOSE))||
|
if (((Value == NULL) && (Action != EFI_BROWSER_ACTION_FORM_OPEN) && (Action != EFI_BROWSER_ACTION_FORM_CLOSE))||
|
||||||
(ActionRequest == NULL)) {
|
(ActionRequest == NULL)) {
|
||||||
|
@ -1131,6 +1286,7 @@ DriverCallback (
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FormId = 0;
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
PrivateData = DRIVER_SAMPLE_PRIVATE_FROM_THIS (This);
|
PrivateData = DRIVER_SAMPLE_PRIVATE_FROM_THIS (This);
|
||||||
|
|
||||||
|
@ -1177,6 +1333,11 @@ DriverCallback (
|
||||||
|
|
||||||
HiiFreeOpCodeHandle (StartOpCodeHandle);
|
HiiFreeOpCodeHandle (StartOpCodeHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (QuestionId == 0x1247) {
|
||||||
|
Status = InternalStartMonitor ();
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1199,6 +1360,11 @@ DriverCallback (
|
||||||
);
|
);
|
||||||
} while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));
|
} while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (QuestionId == 0x1247) {
|
||||||
|
Status = InternalStopMonitor ();
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1424,6 +1590,7 @@ DriverCallback (
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x5678:
|
case 0x5678:
|
||||||
|
case 0x1247:
|
||||||
//
|
//
|
||||||
// We will reach here once the Question is refreshed
|
// We will reach here once the Question is refreshed
|
||||||
//
|
//
|
||||||
|
@ -1439,7 +1606,15 @@ DriverCallback (
|
||||||
//
|
//
|
||||||
StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
|
StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
|
||||||
StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
|
StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
|
||||||
StartLabel->Number = LABEL_UPDATE2;
|
if (QuestionId == 0x5678) {
|
||||||
|
StartLabel->Number = LABEL_UPDATE2;
|
||||||
|
FormId = 0x03;
|
||||||
|
PrivateData->Configuration.DynamicRefresh++;
|
||||||
|
} else if (QuestionId == 0x1247 ) {
|
||||||
|
StartLabel->Number = LABEL_UPDATE3;
|
||||||
|
FormId = 0x05;
|
||||||
|
PrivateData->Configuration.RefreshGuidCount++;
|
||||||
|
}
|
||||||
|
|
||||||
HiiCreateActionOpCode (
|
HiiCreateActionOpCode (
|
||||||
StartOpCodeHandle, // Container for dynamic created opcodes
|
StartOpCodeHandle, // Container for dynamic created opcodes
|
||||||
|
@ -1453,7 +1628,7 @@ DriverCallback (
|
||||||
HiiUpdateForm (
|
HiiUpdateForm (
|
||||||
PrivateData->HiiHandle[0], // HII handle
|
PrivateData->HiiHandle[0], // HII handle
|
||||||
&mFormSetGuid, // Formset GUID
|
&mFormSetGuid, // Formset GUID
|
||||||
0x3, // Form ID
|
FormId, // Form ID
|
||||||
StartOpCodeHandle, // Label for where to insert opcodes
|
StartOpCodeHandle, // Label for where to insert opcodes
|
||||||
NULL // Insert data
|
NULL // Insert data
|
||||||
);
|
);
|
||||||
|
@ -1463,7 +1638,6 @@ DriverCallback (
|
||||||
//
|
//
|
||||||
// Refresh the Question value
|
// Refresh the Question value
|
||||||
//
|
//
|
||||||
PrivateData->Configuration.DynamicRefresh++;
|
|
||||||
Status = gRT->SetVariable(
|
Status = gRT->SetVariable(
|
||||||
VariableName,
|
VariableName,
|
||||||
&mFormSetGuid,
|
&mFormSetGuid,
|
||||||
|
@ -1472,19 +1646,21 @@ DriverCallback (
|
||||||
&PrivateData->Configuration
|
&PrivateData->Configuration
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
if (QuestionId == 0x5678) {
|
||||||
// Change an EFI Variable storage (MyEfiVar) asynchronous, this will cause
|
//
|
||||||
// the first statement in Form 3 be suppressed
|
// Change an EFI Variable storage (MyEfiVar) asynchronous, this will cause
|
||||||
//
|
// the first statement in Form 3 be suppressed
|
||||||
MyVarSize = 1;
|
//
|
||||||
MyVar = 111;
|
MyVarSize = 1;
|
||||||
Status = gRT->SetVariable(
|
MyVar = 111;
|
||||||
L"MyVar",
|
Status = gRT->SetVariable(
|
||||||
&mFormSetGuid,
|
L"MyVar",
|
||||||
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
|
&mFormSetGuid,
|
||||||
MyVarSize,
|
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
|
||||||
&MyVar
|
MyVarSize,
|
||||||
);
|
&MyVar
|
||||||
|
);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x1237:
|
case 0x1237:
|
||||||
|
@ -1805,7 +1981,15 @@ DriverSampleInit (
|
||||||
|
|
||||||
FreePool (ConfigRequestHdr);
|
FreePool (ConfigRequestHdr);
|
||||||
|
|
||||||
|
Status = gBS->CreateEventEx (
|
||||||
|
EVT_NOTIFY_SIGNAL,
|
||||||
|
TPL_NOTIFY,
|
||||||
|
DriverSampleInternalEmptyFunction,
|
||||||
|
NULL,
|
||||||
|
&MyEventGroupGuid,
|
||||||
|
&mEvent
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
//
|
//
|
||||||
// In default, this driver is built into Flash device image,
|
// In default, this driver is built into Flash device image,
|
||||||
// the following code doesn't run.
|
// the following code doesn't run.
|
||||||
|
@ -1893,5 +2077,7 @@ DriverSampleUnload (
|
||||||
FreePool (PrivateData);
|
FreePool (PrivateData);
|
||||||
PrivateData = NULL;
|
PrivateData = NULL;
|
||||||
|
|
||||||
|
gBS->CloseEvent (mEvent);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,7 @@
|
||||||
gEfiHiiConfigAccessProtocolGuid ## PRODUCES
|
gEfiHiiConfigAccessProtocolGuid ## PRODUCES
|
||||||
gEfiFormBrowser2ProtocolGuid ## CONSUMES
|
gEfiFormBrowser2ProtocolGuid ## CONSUMES
|
||||||
gEfiHiiDatabaseProtocolGuid ## CONSUMES
|
gEfiHiiDatabaseProtocolGuid ## CONSUMES
|
||||||
|
gEfiSimpleTextInputExProtocolGuid ## CONSUMES
|
||||||
|
|
||||||
|
|
||||||
[Depex]
|
[Depex]
|
||||||
|
|
|
@ -41,6 +41,11 @@ Revision History:
|
||||||
#define EFI_USER_INFO_ACCESS_SETUP_ADMIN_GUID \
|
#define EFI_USER_INFO_ACCESS_SETUP_ADMIN_GUID \
|
||||||
{ 0x85b75607, 0xf7ce, 0x471e, { 0xb7, 0xe4, 0x2a, 0xea, 0x5f, 0x72, 0x32, 0xee } }
|
{ 0x85b75607, 0xf7ce, 0x471e, { 0xb7, 0xe4, 0x2a, 0xea, 0x5f, 0x72, 0x32, 0xee } }
|
||||||
|
|
||||||
|
#define EFI_IFR_REFRESH_ID_OP_GUID \
|
||||||
|
{ \
|
||||||
|
0xF5E655D9, 0x02A6, 0x46f2, {0x9E, 0x76, 0xB8, 0xBE, 0x8E, 0x60, 0xAB, 0x22} \
|
||||||
|
}
|
||||||
|
|
||||||
#define CONFIGURATION_VARSTORE_ID 0x1234
|
#define CONFIGURATION_VARSTORE_ID 0x1234
|
||||||
|
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
|
@ -77,6 +82,7 @@ typedef struct {
|
||||||
UINT8 GetDefaultValueFromCallBack;
|
UINT8 GetDefaultValueFromCallBack;
|
||||||
UINT8 GetDefaultValueFromAccess;
|
UINT8 GetDefaultValueFromAccess;
|
||||||
EFI_HII_TIME Time;
|
EFI_HII_TIME Time;
|
||||||
|
UINT8 RefreshGuidCount;
|
||||||
} DRIVER_SAMPLE_CONFIGURATION;
|
} DRIVER_SAMPLE_CONFIGURATION;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -93,6 +99,7 @@ typedef struct {
|
||||||
//
|
//
|
||||||
#define LABEL_UPDATE1 0x1234
|
#define LABEL_UPDATE1 0x1234
|
||||||
#define LABEL_UPDATE2 0x2234
|
#define LABEL_UPDATE2 0x2234
|
||||||
|
#define LABEL_UPDATE3 0x3234
|
||||||
#define LABEL_END 0x2223
|
#define LABEL_END 0x2223
|
||||||
|
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
Binary file not shown.
|
@ -2068,6 +2068,14 @@ ParseOpCodes (
|
||||||
CurrentStatement->RefreshInterval = ((EFI_IFR_REFRESH *) OpCodeData)->RefreshInterval;
|
CurrentStatement->RefreshInterval = ((EFI_IFR_REFRESH *) OpCodeData)->RefreshInterval;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Refresh guid.
|
||||||
|
//
|
||||||
|
case EFI_IFR_REFRESH_ID_OP:
|
||||||
|
ASSERT (CurrentStatement != NULL);
|
||||||
|
CopyMem (&CurrentStatement->RefreshGuid, &((EFI_IFR_REFRESH_ID *) OpCodeData)->RefreshEventGroupId, sizeof (EFI_GUID));
|
||||||
|
break;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Modal tag
|
// Modal tag
|
||||||
//
|
//
|
||||||
|
|
|
@ -376,6 +376,7 @@ typedef struct {
|
||||||
EFI_QUESTION_ID RefQuestionId; // for EFI_IFR_REF2
|
EFI_QUESTION_ID RefQuestionId; // for EFI_IFR_REF2
|
||||||
EFI_GUID RefFormSetId; // for EFI_IFR_REF3
|
EFI_GUID RefFormSetId; // for EFI_IFR_REF3
|
||||||
EFI_STRING_ID RefDevicePath; // for EFI_IFR_REF4
|
EFI_STRING_ID RefDevicePath; // for EFI_IFR_REF4
|
||||||
|
EFI_GUID RefreshGuid; // for EFI_IFR_REFRESH_ID
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get from IFR parsing
|
// Get from IFR parsing
|
||||||
|
|
|
@ -16,7 +16,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
LIST_ENTRY gMenuOption;
|
LIST_ENTRY gMenuOption;
|
||||||
LIST_ENTRY gMenuList = INITIALIZE_LIST_HEAD_VARIABLE (gMenuList);
|
LIST_ENTRY gMenuList = INITIALIZE_LIST_HEAD_VARIABLE (gMenuList);
|
||||||
MENU_REFRESH_ENTRY *gMenuRefreshHead;
|
MENU_REFRESH_ENTRY *gMenuRefreshHead; // Menu list used for refresh timer opcode.
|
||||||
|
MENU_REFRESH_ENTRY *gMenuEventGuidRefreshHead; // Menu list used for refresh event guid opcode.
|
||||||
|
|
||||||
//
|
//
|
||||||
// Search table for UiDisplayMenu()
|
// Search table for UiDisplayMenu()
|
||||||
|
@ -320,11 +321,116 @@ UiFreeRefreshList (
|
||||||
gMenuRefreshHead = OldMenuRefreshEntry;
|
gMenuRefreshHead = OldMenuRefreshEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
gMenuRefreshHead = NULL;
|
while (gMenuEventGuidRefreshHead != NULL) {
|
||||||
|
OldMenuRefreshEntry = gMenuEventGuidRefreshHead->Next;
|
||||||
|
if (gMenuEventGuidRefreshHead != NULL) {
|
||||||
|
gBS->CloseEvent(gMenuEventGuidRefreshHead->Event);
|
||||||
|
}
|
||||||
|
FreePool (gMenuEventGuidRefreshHead);
|
||||||
|
gMenuEventGuidRefreshHead = OldMenuRefreshEntry;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Refresh question.
|
||||||
|
|
||||||
|
@param MenuRefreshEntry Menu refresh structure which has info about the refresh question.
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
RefreshQuestion (
|
||||||
|
IN MENU_REFRESH_ENTRY *MenuRefreshEntry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
CHAR16 *OptionString;
|
||||||
|
UINTN Index;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
UI_MENU_SELECTION *Selection;
|
||||||
|
FORM_BROWSER_STATEMENT *Question;
|
||||||
|
|
||||||
|
Selection = MenuRefreshEntry->Selection;
|
||||||
|
Question = MenuRefreshEntry->MenuOption->ThisTag;
|
||||||
|
|
||||||
|
Status = GetQuestionValue (Selection->FormSet, Selection->Form, Question, FALSE);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
OptionString = NULL;
|
||||||
|
ProcessOptions (Selection, MenuRefreshEntry->MenuOption, FALSE, &OptionString);
|
||||||
|
|
||||||
|
if (OptionString != NULL) {
|
||||||
|
//
|
||||||
|
// If leading spaces on OptionString - remove the spaces
|
||||||
|
//
|
||||||
|
for (Index = 0; OptionString[Index] == L' '; Index++)
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
// If old Text is longer than new string, need to clean the old string before paint the newer.
|
||||||
|
// This option is no need for time/date opcode, because time/data opcode has fixed string length.
|
||||||
|
//
|
||||||
|
if ((MenuRefreshEntry->MenuOption->ThisTag->Operand != EFI_IFR_DATE_OP) &&
|
||||||
|
(MenuRefreshEntry->MenuOption->ThisTag->Operand != EFI_IFR_TIME_OP)) {
|
||||||
|
ClearLines (
|
||||||
|
MenuRefreshEntry->CurrentColumn,
|
||||||
|
MenuRefreshEntry->CurrentColumn + gOptionBlockWidth - 1,
|
||||||
|
MenuRefreshEntry->CurrentRow,
|
||||||
|
MenuRefreshEntry->CurrentRow,
|
||||||
|
PcdGet8 (PcdBrowserFieldTextColor) | FIELD_BACKGROUND
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
gST->ConOut->SetAttribute (gST->ConOut, MenuRefreshEntry->CurrentAttribute);
|
||||||
|
PrintStringAt (MenuRefreshEntry->CurrentColumn, MenuRefreshEntry->CurrentRow, &OptionString[Index]);
|
||||||
|
FreePool (OptionString);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Question value may be changed, need invoke its Callback()
|
||||||
|
//
|
||||||
|
Status = ProcessCallBackFunction (Selection, Question, EFI_BROWSER_ACTION_CHANGING, FALSE);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Refresh the question which has refresh guid event attribute.
|
||||||
|
|
||||||
|
@param Event The event which has this function related.
|
||||||
|
@param Context The input context info related to this event or the status code return to the caller.
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
RefreshQuestionNotify(
|
||||||
|
IN EFI_EVENT Event,
|
||||||
|
IN VOID *Context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
MENU_REFRESH_ENTRY *MenuRefreshEntry;
|
||||||
|
UI_MENU_SELECTION *Selection;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Reset FormPackage update flag
|
||||||
|
//
|
||||||
|
mHiiPackageListUpdated = FALSE;
|
||||||
|
|
||||||
|
MenuRefreshEntry = (MENU_REFRESH_ENTRY *)Context;
|
||||||
|
ASSERT (MenuRefreshEntry != NULL);
|
||||||
|
Selection = MenuRefreshEntry->Selection;
|
||||||
|
|
||||||
|
RefreshQuestion (MenuRefreshEntry);
|
||||||
|
|
||||||
|
if (mHiiPackageListUpdated) {
|
||||||
|
//
|
||||||
|
// Package list is updated, force to reparse IFR binary of target Formset
|
||||||
|
//
|
||||||
|
mHiiPackageListUpdated = FALSE;
|
||||||
|
Selection->Action = UI_ACTION_REFRESH_FORMSET;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Refresh screen.
|
Refresh screen.
|
||||||
|
|
||||||
|
@ -334,65 +440,23 @@ RefreshForm (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CHAR16 *OptionString;
|
|
||||||
MENU_REFRESH_ENTRY *MenuRefreshEntry;
|
MENU_REFRESH_ENTRY *MenuRefreshEntry;
|
||||||
UINTN Index;
|
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UI_MENU_SELECTION *Selection;
|
UI_MENU_SELECTION *Selection;
|
||||||
FORM_BROWSER_STATEMENT *Question;
|
|
||||||
|
|
||||||
if (gMenuRefreshHead != NULL) {
|
if (gMenuRefreshHead != NULL) {
|
||||||
|
//
|
||||||
|
// call from refresh interval process.
|
||||||
|
//
|
||||||
MenuRefreshEntry = gMenuRefreshHead;
|
MenuRefreshEntry = gMenuRefreshHead;
|
||||||
|
Selection = MenuRefreshEntry->Selection;
|
||||||
//
|
//
|
||||||
// Reset FormPackage update flag
|
// Reset FormPackage update flag
|
||||||
//
|
//
|
||||||
mHiiPackageListUpdated = FALSE;
|
mHiiPackageListUpdated = FALSE;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
Selection = MenuRefreshEntry->Selection;
|
Status = RefreshQuestion (MenuRefreshEntry);
|
||||||
Question = MenuRefreshEntry->MenuOption->ThisTag;
|
|
||||||
|
|
||||||
Status = GetQuestionValue (Selection->FormSet, Selection->Form, Question, FALSE);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
OptionString = NULL;
|
|
||||||
ProcessOptions (Selection, MenuRefreshEntry->MenuOption, FALSE, &OptionString);
|
|
||||||
|
|
||||||
if (OptionString != NULL) {
|
|
||||||
//
|
|
||||||
// If leading spaces on OptionString - remove the spaces
|
|
||||||
//
|
|
||||||
for (Index = 0; OptionString[Index] == L' '; Index++)
|
|
||||||
;
|
|
||||||
|
|
||||||
//
|
|
||||||
// If old Text is longer than new string, need to clean the old string before paint the newer.
|
|
||||||
// This option is no need for time/date opcode, because time/data opcode has fixed string length.
|
|
||||||
//
|
|
||||||
if ((MenuRefreshEntry->MenuOption->ThisTag->Operand != EFI_IFR_DATE_OP) &&
|
|
||||||
(MenuRefreshEntry->MenuOption->ThisTag->Operand != EFI_IFR_TIME_OP)) {
|
|
||||||
ClearLines (
|
|
||||||
MenuRefreshEntry->CurrentColumn,
|
|
||||||
MenuRefreshEntry->CurrentColumn + gOptionBlockWidth - 1,
|
|
||||||
MenuRefreshEntry->CurrentRow,
|
|
||||||
MenuRefreshEntry->CurrentRow,
|
|
||||||
PcdGet8 (PcdBrowserFieldTextColor) | FIELD_BACKGROUND
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
gST->ConOut->SetAttribute (gST->ConOut, MenuRefreshEntry->CurrentAttribute);
|
|
||||||
PrintStringAt (MenuRefreshEntry->CurrentColumn, MenuRefreshEntry->CurrentRow, &OptionString[Index]);
|
|
||||||
FreePool (OptionString);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Question value may be changed, need invoke its Callback()
|
|
||||||
//
|
|
||||||
Status = ProcessCallBackFunction(Selection, Question, EFI_BROWSER_ACTION_CHANGING, FALSE);
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@ -1636,6 +1700,7 @@ UiDisplayMenu (
|
||||||
UI_CONTROL_FLAG ControlFlag;
|
UI_CONTROL_FLAG ControlFlag;
|
||||||
EFI_SCREEN_DESCRIPTOR LocalScreen;
|
EFI_SCREEN_DESCRIPTOR LocalScreen;
|
||||||
MENU_REFRESH_ENTRY *MenuRefreshEntry;
|
MENU_REFRESH_ENTRY *MenuRefreshEntry;
|
||||||
|
MENU_REFRESH_ENTRY *MenuUpdateEntry;
|
||||||
UI_SCREEN_OPERATION ScreenOperation;
|
UI_SCREEN_OPERATION ScreenOperation;
|
||||||
UINT8 MinRefreshInterval;
|
UINT8 MinRefreshInterval;
|
||||||
UINTN BufferSize;
|
UINTN BufferSize;
|
||||||
|
@ -1872,6 +1937,34 @@ UiDisplayMenu (
|
||||||
OptionString[Count] = CHAR_NULL;
|
OptionString[Count] = CHAR_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// If Question has refresh guid, register the op-code.
|
||||||
|
//
|
||||||
|
if (!CompareGuid (&Statement->RefreshGuid, &gZeroGuid)) {
|
||||||
|
if (gMenuEventGuidRefreshHead == NULL) {
|
||||||
|
MenuUpdateEntry = AllocateZeroPool (sizeof (MENU_REFRESH_ENTRY));
|
||||||
|
gMenuEventGuidRefreshHead = MenuUpdateEntry;
|
||||||
|
} else {
|
||||||
|
MenuUpdateEntry = gMenuEventGuidRefreshHead;
|
||||||
|
while (MenuUpdateEntry->Next != NULL) {
|
||||||
|
MenuUpdateEntry = MenuUpdateEntry->Next;
|
||||||
|
}
|
||||||
|
MenuUpdateEntry->Next = AllocateZeroPool (sizeof (MENU_REFRESH_ENTRY));
|
||||||
|
}
|
||||||
|
ASSERT (MenuUpdateEntry != NULL);
|
||||||
|
Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY, RefreshQuestionNotify, MenuUpdateEntry, &Statement->RefreshGuid, &MenuUpdateEntry->Event);
|
||||||
|
ASSERT (!EFI_ERROR (Status));
|
||||||
|
MenuUpdateEntry->MenuOption = MenuOption;
|
||||||
|
MenuUpdateEntry->Selection = Selection;
|
||||||
|
MenuUpdateEntry->CurrentColumn = MenuOption->OptCol;
|
||||||
|
MenuUpdateEntry->CurrentRow = MenuOption->Row;
|
||||||
|
if (MenuOption->GrayOut) {
|
||||||
|
MenuUpdateEntry->CurrentAttribute = FIELD_TEXT_GRAYED | FIELD_BACKGROUND;
|
||||||
|
} else {
|
||||||
|
MenuUpdateEntry->CurrentAttribute = PcdGet8 (PcdBrowserFieldTextColor) | FIELD_BACKGROUND;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// If Question request refresh, register the op-code
|
// If Question request refresh, register the op-code
|
||||||
//
|
//
|
||||||
|
|
|
@ -178,6 +178,7 @@ struct _MENU_REFRESH_ENTRY {
|
||||||
UINTN CurrentColumn;
|
UINTN CurrentColumn;
|
||||||
UINTN CurrentRow;
|
UINTN CurrentRow;
|
||||||
UINTN CurrentAttribute;
|
UINTN CurrentAttribute;
|
||||||
|
EFI_EVENT Event;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
Loading…
Reference in New Issue