]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Forms.c
Add in some features for the thunk layer:
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / FrameworkHiiToUefiHiiThunk / Forms.c
CommitLineData
4259256b 1/**@file\r
2 This file contains the form processing code to the HII database.\r
3\r
4Copyright (c) 2006 - 2008 Intel Corporation. <BR>\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15\r
16#include "HiiDatabase.h"\r
17\r
18EFI_STATUS\r
19EFIAPI\r
20HiiExportDatabase (\r
21 IN EFI_HII_PROTOCOL *This,\r
22 IN FRAMEWORK_EFI_HII_HANDLE Handle,\r
23 IN OUT UINTN *BufferSize,\r
24 OUT VOID *Buffer\r
25 )\r
26/*++\r
27\r
28Routine Description:\r
29\r
30 This function allows a program to extract a form or form package that has\r
31 previously been registered with the EFI HII database.\r
32\r
33Arguments:\r
34\r
35Returns:\r
36\r
37--*/\r
38{\r
39 ASSERT (FALSE);\r
40 return EFI_UNSUPPORTED;\r
41}\r
42\r
43EFI_STATUS\r
44EFIAPI\r
45HiiGetForms (\r
46 IN EFI_HII_PROTOCOL *This,\r
47 IN FRAMEWORK_EFI_HII_HANDLE Handle,\r
48 IN EFI_FORM_ID FormId,\r
49 IN OUT UINTN *BufferLengthTemp,\r
50 OUT UINT8 *Buffer\r
51 )\r
52/*++\r
53\r
54Routine Description:\r
55\r
56 This function allows a program to extract a form or form package that has\r
57 previously been registered with the EFI HII database.\r
58\r
59Arguments:\r
60 This - A pointer to the EFI_HII_PROTOCOL instance.\r
61\r
62 Handle - Handle on which the form resides. Type FRAMEWORK_EFI_HII_HANDLE is defined in\r
63 EFI_HII_PROTOCOL.NewPack() in the Packages section.\r
64\r
65 FormId - The ID of the form to return. If the ID is zero, the entire form package is returned.\r
66 Type EFI_FORM_ID is defined in "Related Definitions" below.\r
67\r
68 BufferLength - On input, the length of the Buffer. On output, the length of the returned buffer, if\r
69 the length was sufficient and, if it was not, the length that is required to fit the\r
70 requested form(s).\r
71\r
72 Buffer - The buffer designed to receive the form(s).\r
73\r
74Returns:\r
75\r
76 EFI_SUCCESS - Buffer filled with the requested forms. BufferLength\r
77 was updated.\r
78\r
79 EFI_INVALID_PARAMETER - The handle is unknown.\r
80\r
81 EFI_NOT_FOUND - A form on the requested handle cannot be found with the\r
82 requested FormId.\r
83\r
84 EFI_BUFFER_TOO_SMALL - The buffer provided was not large enough to allow the form to be stored.\r
85\r
86--*/\r
87{\r
88 ASSERT (FALSE);\r
89 return EFI_UNSUPPORTED;\r
90}\r
91\r
92EFI_STATUS\r
93EFIAPI\r
94HiiGetDefaultImage (\r
95 IN EFI_HII_PROTOCOL *This,\r
96 IN FRAMEWORK_EFI_HII_HANDLE Handle,\r
97 IN UINTN DefaultMask,\r
98 OUT EFI_HII_VARIABLE_PACK_LIST **VariablePackList\r
99 )\r
100/*++\r
101\r
102 Routine Description:\r
103\r
104 This function allows a program to extract the NV Image\r
105 that represents the default storage image\r
106\r
107 Arguments:\r
108 This - A pointer to the EFI_HII_PROTOCOL instance.\r
109 Handle - The HII handle from which will have default data retrieved.\r
110 UINTN - Mask used to retrieve the default image.\r
111 VariablePackList - Callee allocated, tightly-packed, link list data\r
112 structure that contain all default varaible packs\r
113 from the Hii Database.\r
114\r
115 Returns:\r
116 EFI_NOT_FOUND - If Hii database does not contain any default images.\r
117 EFI_INVALID_PARAMETER - Invalid input parameter.\r
118 EFI_SUCCESS - Operation successful.\r
119\r
120--*/\r
121{\r
122 return EFI_SUCCESS;\r
123}\r
124\r
ebbd2793 125EFI_STATUS\r
126ThunkUpdateFormCallBack (\r
127 IN EFI_HANDLE CallbackHandle,\r
128 IN CONST HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry\r
129 )\r
130{\r
131 EFI_STATUS Status;\r
132 EFI_FORM_CALLBACK_PROTOCOL *FrameworkFormCallbackProtocol;\r
133 EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccessProtocol;\r
134 EFI_HANDLE UefiDriverHandle;\r
135 HII_TRHUNK_CONFIG_ACCESS_PROTOCOL_INSTANCE *ConfigAccessProtocolInstance;\r
136 \r
137 Status = gBS->HandleProtocol (\r
138 CallbackHandle,\r
139 &gEfiFormCallbackProtocolGuid,\r
140 (VOID **) &FrameworkFormCallbackProtocol\r
141 );\r
142 if (EFI_ERROR (Status)) {\r
143 return EFI_INVALID_PARAMETER;\r
144 }\r
145 \r
146 Status = mUefiHiiDatabaseProtocol->GetPackageListHandle (\r
147 mUefiHiiDatabaseProtocol,\r
148 HandleMapEntry->UefiHiiHandle,\r
149 &UefiDriverHandle\r
150 );\r
151 ASSERT_EFI_ERROR (Status);\r
152 Status = gBS->HandleProtocol (\r
153 UefiDriverHandle,\r
154 &gEfiHiiConfigAccessProtocolGuid,\r
155 (VOID **) &ConfigAccessProtocol\r
156 );\r
157 ASSERT_EFI_ERROR (Status);\r
158 \r
159 ConfigAccessProtocolInstance = HII_TRHUNK_CONFIG_ACCESS_PROTOCOL_INSTANCE_FROM_PROTOCOL (ConfigAccessProtocol);\r
160 \r
161 ConfigAccessProtocolInstance->FrameworkFormCallbackProtocol = FrameworkFormCallbackProtocol;\r
162\r
163 return EFI_SUCCESS;\r
164}\r
4259256b 165\r
166EFI_STATUS\r
167EFIAPI\r
168HiiUpdateForm (\r
169 IN EFI_HII_PROTOCOL *This,\r
170 IN FRAMEWORK_EFI_HII_HANDLE Handle,\r
171 IN EFI_FORM_LABEL Label,\r
172 IN BOOLEAN AddData,\r
173 IN EFI_HII_UPDATE_DATA *Data\r
174 )\r
175/*++\r
176\r
177Routine Description:\r
178 This function allows the caller to update a form that has\r
179 previously been registered with the EFI HII database.\r
180\r
181Arguments:\r
182 Handle - Hii Handle associated with the Formset to modify\r
183 Label - Update information starting immediately after this label in the IFR\r
184 AddData - If TRUE, add data. If FALSE, remove data\r
185 Data - If adding data, this is the pointer to the data to add\r
186\r
187Returns:\r
188 EFI_SUCCESS - Update success.\r
189 Other - Update fail.\r
190\r
191--*/\r
192{\r
ebbd2793 193 EFI_STATUS Status;\r
194 EFI_HII_THUNK_PRIVATE_DATA *Private;\r
195 HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;\r
196\r
197 Private = EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This);\r
198\r
199 HandleMapEntry = FrameworkHiiHandleToMapDatabaseEntry (Private, Handle);\r
200\r
201 if (HandleMapEntry == NULL) {\r
202 return EFI_NOT_FOUND;\r
203 }\r
204 \r
205 if (Data->FormSetUpdate) {\r
206 Status = ThunkUpdateFormCallBack ((EFI_HANDLE) (UINTN) Data->FormCallbackHandle, HandleMapEntry);\r
207 if (EFI_ERROR (Status)) {\r
208 return Status;\r
209 }\r
210 }\r
4259256b 211 return EFI_SUCCESS;\r
212}\r