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