Per UEFI spec, FORM_OPEN/FORM_CLOSE Callback function should be called for each question in the form when this form opens or closes.

Update SetupBrowser driver to call Callback function (FORM_OPEN/FORM_CLOSE) based on UEFI spec, and update all EDKII HII drivers to correctly handle FORM_OPEN and FORM_CLOSE call back. 


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10560 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lgao4
2010-06-02 02:05:47 +00:00
parent 2bd78c92c6
commit 5adb8db71e
8 changed files with 306 additions and 140 deletions

View File

@ -842,61 +842,67 @@ DriverCallback (
UINTN MyVarSize;
if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {
//
// On FORM_OPEN event, update the form on-the-fly
//
PrivateData = DRIVER_SAMPLE_PRIVATE_FROM_THIS (This);
if (QuestionId == 0x1234) {
//
// Sample CallBack for UEFI FORM_OPEN action:
// Add Save action into Form 3 when Form 1 is opened.
// This will be done only in FORM_OPEN CallBack of question with ID 0x1234 from Form 1.
//
PrivateData = DRIVER_SAMPLE_PRIVATE_FROM_THIS (This);
//
// Initialize the container for dynamic opcodes
//
StartOpCodeHandle = HiiAllocateOpCodeHandle ();
ASSERT (StartOpCodeHandle != NULL);
//
// Initialize the container for dynamic opcodes
//
StartOpCodeHandle = HiiAllocateOpCodeHandle ();
ASSERT (StartOpCodeHandle != NULL);
//
// Create Hii Extend Label OpCode as the start opcode
//
StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
StartLabel->Number = LABEL_UPDATE2;
//
// Create Hii Extend Label OpCode as the start opcode
//
StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
StartLabel->Number = LABEL_UPDATE2;
HiiCreateActionOpCode (
StartOpCodeHandle, // Container for dynamic created opcodes
0x1238, // Question ID
STRING_TOKEN(STR_SAVE_TEXT), // Prompt text
STRING_TOKEN(STR_SAVE_TEXT), // Help text
EFI_IFR_FLAG_CALLBACK, // Question flag
0 // Action String ID
);
HiiUpdateForm (
PrivateData->HiiHandle[0], // HII handle
&mFormSetGuid, // Formset GUID
0x3, // Form ID
StartOpCodeHandle, // Label for where to insert opcodes
NULL // Insert data
HiiCreateActionOpCode (
StartOpCodeHandle, // Container for dynamic created opcodes
0x1238, // Question ID
STRING_TOKEN(STR_SAVE_TEXT), // Prompt text
STRING_TOKEN(STR_SAVE_TEXT), // Help text
EFI_IFR_FLAG_CALLBACK, // Question flag
0 // Action String ID
);
HiiFreeOpCodeHandle (StartOpCodeHandle);
HiiUpdateForm (
PrivateData->HiiHandle[0], // HII handle
&mFormSetGuid, // Formset GUID
0x3, // Form ID
StartOpCodeHandle, // Label for where to insert opcodes
NULL // Insert data
);
HiiFreeOpCodeHandle (StartOpCodeHandle);
}
return EFI_SUCCESS;
}
if (Action == EFI_BROWSER_ACTION_FORM_CLOSE) {
//
// On FORM_CLOSE event, show up a pop-up
//
do {
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
&Key,
L"",
L"You are going to leave the Form!",
L"Press ESC or ENTER to continue ...",
L"",
NULL
);
} while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));
if (QuestionId == 0x5678) {
//
// Sample CallBack for UEFI FORM_CLOSE action:
// Show up a pop-up to specify Form 3 will be closed when exit Form 3.
//
do {
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
&Key,
L"",
L"You are going to leave third Form!",
L"Press ESC or ENTER to continue ...",
L"",
NULL
);
} while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));
}
return EFI_SUCCESS;
}
@ -1028,6 +1034,37 @@ DriverCallback (
NULL // Default Opcode is NULl
);
HiiCreateTextOpCode (
StartOpCodeHandle,
STRING_TOKEN(STR_TEXT_SAMPLE_HELP),
STRING_TOKEN(STR_TEXT_SAMPLE_HELP),
STRING_TOKEN(STR_TEXT_SAMPLE_STRING)
);
HiiCreateDateOpCode (
StartOpCodeHandle,
0x8004,
0x0,
0x0,
STRING_TOKEN(STR_DATE_SAMPLE_HELP),
STRING_TOKEN(STR_DATE_SAMPLE_HELP),
0,
QF_DATE_STORAGE_TIME,
NULL
);
HiiCreateTimeOpCode (
StartOpCodeHandle,
0x8005,
0x0,
0x0,
STRING_TOKEN(STR_TIME_SAMPLE_HELP),
STRING_TOKEN(STR_TIME_SAMPLE_HELP),
0,
QF_TIME_STORAGE_TIME,
NULL
);
HiiCreateGotoOpCode (
StartOpCodeHandle, // Container for dynamic created opcodes
1, // Target Form ID