]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/SetupBrowser.c
1) Add in support for Framework VFR file which specify all VAR Store correctly. This...
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / FrameworkHiiToUefiHiiThunk / SetupBrowser.c
1 /**@file
2 Framework to UEFI 2.1 Setup Browser Thunk. The file consume EFI_FORM_BROWSER2_PROTOCOL
3 to produce a EFI_FORM_BROWSER_PROTOCOL.
4
5 Copyright (c) 2008, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #include "HiiDatabase.h"
17
18 /**
19 This is the Framework Setup Browser interface which displays a FormSet.
20
21 @param This The EFI_FORM_BROWSER_PROTOCOL context.
22 @param UseDatabase TRUE if the FormSet is from HII database. The Thunk implementation
23 only support UseDatabase is TRUE.
24 @param Handle The Handle buffer.
25 @param HandleCount The number of Handle in the Handle Buffer. It must be 1 for this implementation.
26 @param Packet The pointer to data buffer containing IFR and String package. Not supported.
27 @param CallbackHandle Not supported.
28 @param NvMapOverride The buffer is used only when there is no NV variable to define the
29 current settings and the caller needs to provide to the browser the
30 current settings for the the "fake" NV variable. If used, no saving of
31 an NV variable is possbile. This parameter is also ignored if Handle is NULL.
32
33 @retval EFI_SUCCESS If the Formset is displayed correctly.
34 @retval EFI_UNSUPPORTED If UseDatabase is FALSE or HandleCount is not 1.
35 @retval EFI_INVALID_PARAMETER If the *Handle passed in is not found in the database.
36 **/
37
38 EFI_STATUS
39 EFIAPI
40 ThunkSendForm (
41 IN EFI_FORM_BROWSER_PROTOCOL *This,
42 IN BOOLEAN UseDatabase,
43 IN FRAMEWORK_EFI_HII_HANDLE *Handle,
44 IN UINTN HandleCount,
45 IN FRAMEWORK_EFI_IFR_PACKET *Packet, OPTIONAL
46 IN EFI_HANDLE CallbackHandle, OPTIONAL
47 IN UINT8 *NvMapOverride, OPTIONAL
48 IN FRAMEWORK_EFI_SCREEN_DESCRIPTOR *ScreenDimensions, OPTIONAL
49 OUT BOOLEAN *ResetRequired OPTIONAL
50 )
51 {
52 EFI_STATUS Status;
53 EFI_BROWSER_ACTION_REQUEST ActionRequest;
54 HII_THUNK_CONTEXT *ThunkContext;
55 HII_THUNK_PRIVATE_DATA *Private;
56 EFI_FORMBROWSER_THUNK_PRIVATE_DATA *BrowserPrivate;
57
58 if (!UseDatabase) {
59 //
60 // ThunkSendForm only support displays forms registered into the HII database.
61 //
62 return EFI_UNSUPPORTED;
63 }
64
65 if (HandleCount != 1 ) {
66 return EFI_UNSUPPORTED;
67 }
68
69 BrowserPrivate = EFI_FORMBROWSER_THUNK_PRIVATE_DATA_FROM_THIS (This);
70 Private = BrowserPrivate->ThunkPrivate;
71
72 ThunkContext = FwHiiHandleToThunkContext (Private, *Handle);
73 if (ThunkContext == NULL) {
74 return EFI_INVALID_PARAMETER;
75 }
76
77 if (NvMapOverride != NULL) {
78 ThunkContext->NvMapOverride = NvMapOverride;
79 }
80
81 Status = mFormBrowser2Protocol->SendForm (
82 mFormBrowser2Protocol,
83 &ThunkContext->UefiHiiHandle,
84 1,
85 NULL,
86 0,
87 (EFI_SCREEN_DESCRIPTOR *) ScreenDimensions,
88 &ActionRequest
89 );
90
91 if (ActionRequest == EFI_BROWSER_ACTION_REQUEST_RESET) {
92 *ResetRequired = TRUE;
93 }
94
95 return Status;
96 }
97
98 /**
99
100 Rountine used to display a generic dialog interface and return
101 the Key or Input from user input.
102
103 @param NumberOfLines The number of lines for the dialog box.
104 @param HotKey Defines if a single character is parsed (TRUE) and returned in KeyValue
105 or if a string is returned in StringBuffer.
106 @param MaximumStringSize The maximum size in bytes of a typed-in string.
107 @param StringBuffer On return contains the typed-in string if HotKey
108 is FALSE.
109 @param KeyValue The EFI_INPUT_KEY value returned if HotKey is TRUE.
110 @param String The pointer to the first string in the list of strings
111 that comprise the dialog box.
112 @param ... A series of NumberOfLines text strings that will be used
113 to construct the dialog box.
114 @retval EFI_SUCCESS The dialog is created successfully and user interaction was received.
115 @retval EFI_DEVICE_ERROR The user typed in an ESC.
116 @retval EFI_INVALID_PARAMETER One of the parameters was invalid.(StringBuffer == NULL && HotKey == FALSE).
117 **/
118 EFI_STATUS
119 EFIAPI
120 ThunkCreatePopUp (
121 IN UINTN NumberOfLines,
122 IN BOOLEAN HotKey,
123 IN UINTN MaximumStringSize,
124 OUT CHAR16 *StringBuffer,
125 OUT EFI_INPUT_KEY *KeyValue,
126 IN CHAR16 *String,
127 ...
128 )
129 {
130 EFI_STATUS Status;
131 VA_LIST Marker;
132
133 if (HotKey != TRUE) {
134 return EFI_UNSUPPORTED;
135 }
136
137 VA_START (Marker, KeyValue);
138
139 Status = IfrLibCreatePopUp2 (NumberOfLines, KeyValue, Marker);
140
141 VA_END (Marker);
142
143 return Status;
144 }
145