Add example usage of EFI_BROWSER_ACTION_FORM_OPEN and EFI_BROWSER_ACTION_FORM_CLOSE to DriverSample.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9365 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
xdu2 2009-10-26 05:27:28 +00:00
parent ce6d12cce0
commit a6973cff62
3 changed files with 119 additions and 33 deletions

View File

@ -2,7 +2,7 @@
This is an example of how a driver might export data to the HII protocol to be This is an example of how a driver might export data to the HII protocol to be
later utilized by the Setup Protocol later utilized by the Setup Protocol
Copyright (c) 2004 - 2008, Intel Corporation Copyright (c) 2004 - 2009, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -554,6 +554,67 @@ DriverCallback (
EFI_IFR_GUID_LABEL *StartLabel; EFI_IFR_GUID_LABEL *StartLabel;
VOID *EndOpCodeHandle; VOID *EndOpCodeHandle;
EFI_IFR_GUID_LABEL *EndLabel; EFI_IFR_GUID_LABEL *EndLabel;
EFI_INPUT_KEY Key;
DRIVER_SAMPLE_CONFIGURATION *Configuration;
if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {
//
// On FORM_OPEN event, update the form on-the-fly
//
PrivateData = DRIVER_SAMPLE_PRIVATE_FROM_THIS (This);
//
// 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;
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
);
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));
return EFI_SUCCESS;
}
if ((Value == NULL) || (ActionRequest == NULL)) { if ((Value == NULL) || (ActionRequest == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
@ -635,6 +696,28 @@ DriverCallback (
&PrivateData->Configuration &PrivateData->Configuration
); );
//
// Set initial vlaue of dynamic created oneof Question in Form Browser
//
Configuration = AllocateZeroPool (sizeof (DRIVER_SAMPLE_CONFIGURATION));
ASSERT (Configuration != NULL);
Status = HiiGetBrowserData (&mFormSetGuid, VariableName, sizeof (DRIVER_SAMPLE_CONFIGURATION), (UINT8 *) Configuration);
if (!EFI_ERROR (Status)) {
Configuration->DynamicOneof = 2;
//
// Update uncommitted data of Browser
//
HiiSetBrowserData (
&mFormSetGuid,
VariableName,
sizeof (DRIVER_SAMPLE_CONFIGURATION),
(UINT8 *) Configuration,
NULL
);
}
FreePool (Configuration);
HiiCreateOneOfOpCode ( HiiCreateOneOfOpCode (
StartOpCodeHandle, // Container for dynamic created opcodes StartOpCodeHandle, // Container for dynamic created opcodes
0x8001, // Question ID (or call it "key") 0x8001, // Question ID (or call it "key")
@ -682,6 +765,7 @@ DriverCallback (
HiiFreeOpCodeHandle (StartOpCodeHandle); HiiFreeOpCodeHandle (StartOpCodeHandle);
HiiFreeOpCodeHandle (OptionsOpCodeHandle); HiiFreeOpCodeHandle (OptionsOpCodeHandle);
HiiFreeOpCodeHandle (EndOpCodeHandle);
break; break;
case 0x5678: case 0x5678:

View File

@ -1,6 +1,6 @@
/** @file /** @file
Copyright (c) 2007, Intel Corporation Copyright (c) 2007 - 2009, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -43,6 +43,7 @@ Revision History
#include <Library/HiiLib.h> #include <Library/HiiLib.h>
#include <Library/DevicePathLib.h> #include <Library/DevicePathLib.h>
#include <Library/PrintLib.h> #include <Library/PrintLib.h>
#include <Library/UefiLib.h>
#include "NVDataStruc.h" #include "NVDataStruc.h"

View File

@ -2,7 +2,7 @@
# This is a sample driver which show how HII protocol, VFR and UNI files are used to # This is a sample driver which show how HII protocol, VFR and UNI files are used to
# create a driver which can be dipslayed and configured by a UEFI HII Form Browser. # create a driver which can be dipslayed and configured by a UEFI HII Form Browser.
# #
# Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved. # Copyright (c) 2007 - 2009, Intel Corporation. All rights reserved.
# #
# All rights reserved. This program and the accompanying materials # All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
@ -55,6 +55,7 @@
DebugLib DebugLib
HiiLib HiiLib
PrintLib PrintLib
UefiLib
[Guids] [Guids]
gEfiIfrTianoGuid ## CONSUMES ## Guid gEfiIfrTianoGuid ## CONSUMES ## Guid