]>
Commit | Line | Data |
---|---|---|
779ae357 | 1 | /** @file\r |
2 | HII Config Access protocol implementation of VLAN configuration module.\r | |
3 | \r | |
083f7c69 | 4 | Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r |
e5eed7d3 | 5 | This program and the accompanying materials\r |
779ae357 | 6 | are licensed and made available under the terms and conditions\r |
7 | of the BSD License which accompanies this distribution. The full\r | |
8 | text of the license may be found at<BR>\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #include "VlanConfigImpl.h"\r | |
17 | \r | |
18 | EFI_GUID mVlanFormSetGuid = VLAN_CONFIG_PRIVATE_GUID;\r | |
19 | CHAR16 mVlanStorageName[] = L"VlanNvData";\r | |
20 | EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRouting = NULL;\r | |
21 | \r | |
22 | VLAN_CONFIG_PRIVATE_DATA mVlanConfigPrivateDateTemplate = {\r | |
23 | VLAN_CONFIG_PRIVATE_DATA_SIGNATURE,\r | |
24 | {\r | |
25 | VlanExtractConfig,\r | |
26 | VlanRouteConfig,\r | |
27 | VlanCallback\r | |
28 | }\r | |
29 | };\r | |
30 | \r | |
31 | VENDOR_DEVICE_PATH mHiiVendorDevicePathNode = {\r | |
32 | {\r | |
33 | HARDWARE_DEVICE_PATH,\r | |
34 | HW_VENDOR_DP,\r | |
35 | {\r | |
36 | (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r | |
37 | (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r | |
38 | }\r | |
39 | },\r | |
40 | VLAN_CONFIG_PRIVATE_GUID\r | |
41 | };\r | |
42 | \r | |
43 | /**\r | |
44 | This function allows a caller to extract the current configuration for one\r | |
45 | or more named elements from the target driver.\r | |
46 | \r | |
47 | @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r | |
48 | @param[in] Request A null-terminated Unicode string in\r | |
49 | <ConfigRequest> format.\r | |
50 | @param[out] Progress On return, points to a character in the Request\r | |
51 | string. Points to the string's null terminator if\r | |
52 | request was successful. Points to the most recent\r | |
53 | '&' before the first failing name/value pair (or\r | |
54 | the beginning of the string if the failure is in\r | |
55 | the first name/value pair) if the request was not\r | |
56 | successful.\r | |
57 | @param[out] Results A null-terminated Unicode string in\r | |
58 | <ConfigAltResp> format which has all values filled\r | |
59 | in for the names in the Request string. String to\r | |
60 | be allocated by the called function.\r | |
61 | \r | |
62 | @retval EFI_SUCCESS The Results is filled with the requested values.\r | |
63 | @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.\r | |
5a157365 | 64 | @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.\r |
779ae357 | 65 | @retval EFI_NOT_FOUND Routing data doesn't match any storage in this\r |
66 | driver.\r | |
67 | \r | |
68 | **/\r | |
69 | EFI_STATUS\r | |
70 | EFIAPI\r | |
71 | VlanExtractConfig (\r | |
72 | IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r | |
73 | IN CONST EFI_STRING Request,\r | |
74 | OUT EFI_STRING *Progress,\r | |
75 | OUT EFI_STRING *Results\r | |
76 | )\r | |
77 | {\r | |
59aefb7e LG |
78 | EFI_STATUS Status;\r |
79 | UINTN BufferSize;\r | |
80 | VLAN_CONFIGURATION Configuration;\r | |
81 | VLAN_CONFIG_PRIVATE_DATA *PrivateData;\r | |
82 | EFI_STRING ConfigRequestHdr;\r | |
83 | EFI_STRING ConfigRequest;\r | |
84 | BOOLEAN AllocatedRequest;\r | |
85 | UINTN Size;\r | |
86 | \r | |
87 | if (Progress == NULL || Results == NULL) {\r | |
779ae357 | 88 | return EFI_INVALID_PARAMETER;\r |
89 | }\r | |
90 | \r | |
59aefb7e LG |
91 | *Progress = Request;\r |
92 | if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &mVlanFormSetGuid, mVlanStorageName)) {\r | |
93 | return EFI_NOT_FOUND;\r | |
94 | }\r | |
95 | \r | |
96 | ConfigRequestHdr = NULL;\r | |
97 | ConfigRequest = NULL;\r | |
98 | AllocatedRequest = FALSE;\r | |
99 | Size = 0;\r | |
100 | \r | |
779ae357 | 101 | //\r |
102 | // Retrieve the pointer to the UEFI HII Config Routing Protocol\r | |
103 | //\r | |
104 | if (mHiiConfigRouting == NULL) {\r | |
105 | gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **) &mHiiConfigRouting);\r | |
106 | }\r | |
107 | ASSERT (mHiiConfigRouting != NULL);\r | |
108 | \r | |
109 | //\r | |
110 | // Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r | |
111 | //\r | |
59aefb7e | 112 | PrivateData = VLAN_CONFIG_PRIVATE_DATA_FROM_THIS (This);\r |
779ae357 | 113 | ZeroMem (&Configuration, sizeof (VLAN_CONFIGURATION));\r |
5a157365 | 114 | BufferSize = sizeof (Configuration);\r |
59aefb7e LG |
115 | ConfigRequest = Request;\r |
116 | if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {\r | |
117 | //\r | |
118 | // Request has no request element, construct full request string.\r | |
119 | // Allocate and fill a buffer large enough to hold the <ConfigHdr> template\r | |
120 | // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator\r | |
121 | //\r | |
122 | ConfigRequestHdr = HiiConstructConfigHdr (&mVlanFormSetGuid, mVlanStorageName, PrivateData->DriverHandle);\r | |
123 | Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);\r | |
124 | ConfigRequest = AllocateZeroPool (Size);\r | |
125 | ASSERT (ConfigRequest != NULL);\r | |
126 | AllocatedRequest = TRUE;\r | |
127 | UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);\r | |
128 | FreePool (ConfigRequestHdr);\r | |
129 | }\r | |
130 | \r | |
779ae357 | 131 | Status = mHiiConfigRouting->BlockToConfig (\r |
132 | mHiiConfigRouting,\r | |
59aefb7e | 133 | ConfigRequest,\r |
779ae357 | 134 | (UINT8 *) &Configuration,\r |
135 | BufferSize,\r | |
136 | Results,\r | |
137 | Progress\r | |
138 | );\r | |
59aefb7e LG |
139 | //\r |
140 | // Free the allocated config request string.\r | |
141 | //\r | |
142 | if (AllocatedRequest) {\r | |
143 | FreePool (ConfigRequest);\r | |
144 | ConfigRequest = NULL;\r | |
145 | }\r | |
146 | //\r | |
147 | // Set Progress string to the original request string.\r | |
148 | //\r | |
149 | if (Request == NULL) {\r | |
150 | *Progress = NULL;\r | |
151 | } else if (StrStr (Request, L"OFFSET") == NULL) {\r | |
152 | *Progress = Request + StrLen (Request);\r | |
153 | }\r | |
154 | \r | |
779ae357 | 155 | return Status;\r |
156 | }\r | |
157 | \r | |
158 | \r | |
159 | /**\r | |
160 | This function processes the results of changes in configuration.\r | |
161 | \r | |
162 | @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r | |
163 | @param[in] Configuration A null-terminated Unicode string in <ConfigResp>\r | |
164 | format.\r | |
165 | @param[out] Progress A pointer to a string filled in with the offset of\r | |
166 | the most recent '&' before the first failing\r | |
167 | name/value pair (or the beginning of the string if\r | |
168 | the failure is in the first name/value pair) or\r | |
169 | the terminating NULL if all was successful.\r | |
170 | \r | |
171 | @retval EFI_SUCCESS The Results is processed successfully.\r | |
172 | @retval EFI_INVALID_PARAMETER Configuration is NULL.\r | |
173 | @retval EFI_NOT_FOUND Routing data doesn't match any storage in this\r | |
174 | driver.\r | |
175 | \r | |
176 | **/\r | |
177 | EFI_STATUS\r | |
178 | EFIAPI\r | |
179 | VlanRouteConfig (\r | |
180 | IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r | |
181 | IN CONST EFI_STRING Configuration,\r | |
182 | OUT EFI_STRING *Progress\r | |
183 | )\r | |
184 | {\r | |
185 | if (Configuration == NULL || Progress == NULL) {\r | |
186 | return EFI_INVALID_PARAMETER;\r | |
187 | }\r | |
188 | \r | |
189 | *Progress = Configuration;\r | |
190 | if (!HiiIsConfigHdrMatch (Configuration, &mVlanFormSetGuid, mVlanStorageName)) {\r | |
191 | return EFI_NOT_FOUND;\r | |
192 | }\r | |
193 | \r | |
194 | *Progress = Configuration + StrLen (Configuration);\r | |
195 | return EFI_SUCCESS;\r | |
196 | }\r | |
197 | \r | |
198 | /**\r | |
199 | This function processes the results of changes in configuration.\r | |
200 | \r | |
201 | @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r | |
202 | @param[in] Action Specifies the type of action taken by the browser.\r | |
203 | @param[in] QuestionId A unique value which is sent to the original\r | |
204 | exporting driver so that it can identify the type\r | |
205 | of data to expect.\r | |
206 | @param[in] Type The type of value for the question.\r | |
207 | @param[in] Value A pointer to the data being sent to the original\r | |
208 | exporting driver.\r | |
209 | @param[out] ActionRequest On return, points to the action requested by the\r | |
210 | callback function.\r | |
211 | \r | |
212 | @retval EFI_SUCCESS The callback successfully handled the action.\r | |
213 | @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the\r | |
214 | variable and its data.\r | |
215 | @retval EFI_DEVICE_ERROR The variable could not be saved.\r | |
216 | @retval EFI_UNSUPPORTED The specified Action is not supported by the\r | |
217 | callback.\r | |
218 | \r | |
219 | **/\r | |
220 | EFI_STATUS\r | |
221 | EFIAPI\r | |
222 | VlanCallback (\r | |
223 | IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r | |
224 | IN EFI_BROWSER_ACTION Action,\r | |
225 | IN EFI_QUESTION_ID QuestionId,\r | |
226 | IN UINT8 Type,\r | |
227 | IN EFI_IFR_TYPE_VALUE *Value,\r | |
228 | OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest\r | |
229 | )\r | |
230 | {\r | |
231 | VLAN_CONFIG_PRIVATE_DATA *PrivateData;\r | |
232 | VLAN_CONFIGURATION *Configuration;\r | |
233 | EFI_VLAN_CONFIG_PROTOCOL *VlanConfig;\r | |
234 | UINTN Index;\r | |
235 | EFI_HANDLE VlanHandle;\r | |
236 | \r | |
237 | PrivateData = VLAN_CONFIG_PRIVATE_DATA_FROM_THIS (This);\r | |
238 | \r | |
239 | if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {\r | |
5adb8db7 LG |
240 | if (QuestionId == VLAN_ADD_QUESTION_ID) {\r |
241 | //\r | |
242 | // Update current VLAN list into Form when Form is opened.\r | |
243 | // This will be done only in FORM_OPEN CallBack of question with VLAN_ADD_QUESTION_ID.\r | |
244 | //\r | |
245 | VlanUpdateForm (PrivateData);\r | |
246 | }\r | |
247 | return EFI_SUCCESS;\r | |
248 | }\r | |
249 | \r | |
250 | if (Action == EFI_BROWSER_ACTION_FORM_CLOSE) {\r | |
779ae357 | 251 | //\r |
5adb8db7 | 252 | // Do nothing for UEFI FORM_CLOSE action\r |
779ae357 | 253 | //\r |
779ae357 | 254 | return EFI_SUCCESS;\r |
255 | }\r | |
256 | \r | |
083f7c69 | 257 | if (Action == EFI_BROWSER_ACTION_CHANGING) {\r |
779ae357 | 258 | //\r |
083f7c69 | 259 | // Get Browser data\r |
779ae357 | 260 | //\r |
083f7c69 ED |
261 | Configuration = AllocateZeroPool (sizeof (VLAN_CONFIGURATION));\r |
262 | ASSERT (Configuration != NULL);\r | |
263 | HiiGetBrowserData (&mVlanFormSetGuid, mVlanStorageName, sizeof (VLAN_CONFIGURATION), (UINT8 *) Configuration);\r | |
779ae357 | 264 | \r |
083f7c69 ED |
265 | VlanConfig = PrivateData->VlanConfig;\r |
266 | \r | |
267 | switch (QuestionId) {\r | |
268 | case VLAN_ADD_QUESTION_ID:\r | |
779ae357 | 269 | //\r |
083f7c69 | 270 | // Add a VLAN\r |
779ae357 | 271 | //\r |
083f7c69 ED |
272 | VlanConfig->Set (VlanConfig, Configuration->VlanId, Configuration->Priority);\r |
273 | VlanUpdateForm (PrivateData);\r | |
779ae357 | 274 | \r |
083f7c69 ED |
275 | //\r |
276 | // Connect the newly created VLAN device\r | |
277 | //\r | |
278 | VlanHandle = NetLibGetVlanHandle (PrivateData->ControllerHandle, Configuration->VlanId);\r | |
279 | if (VlanHandle == NULL) {\r | |
779ae357 | 280 | //\r |
083f7c69 | 281 | // There may be no child handle created for VLAN ID 0, connect the parent handle\r |
779ae357 | 282 | //\r |
083f7c69 | 283 | VlanHandle = PrivateData->ControllerHandle;\r |
779ae357 | 284 | }\r |
083f7c69 | 285 | gBS->ConnectController (VlanHandle, NULL, NULL, TRUE);\r |
779ae357 | 286 | \r |
779ae357 | 287 | //\r |
083f7c69 | 288 | // Clear UI data\r |
779ae357 | 289 | //\r |
083f7c69 ED |
290 | *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;\r |
291 | Configuration->VlanId = 0;\r | |
292 | Configuration->Priority = 0;\r | |
293 | break;\r | |
779ae357 | 294 | \r |
083f7c69 ED |
295 | case VLAN_REMOVE_QUESTION_ID:\r |
296 | //\r | |
297 | // Remove VLAN\r | |
298 | //\r | |
299 | ASSERT (PrivateData->NumberOfVlan <= MAX_VLAN_NUMBER);\r | |
300 | for (Index = 0; Index < PrivateData->NumberOfVlan; Index++) {\r | |
301 | if (Configuration->VlanList[Index] != 0) {\r | |
302 | //\r | |
303 | // Checkbox is selected, need remove this VLAN\r | |
304 | //\r | |
305 | VlanConfig->Remove (VlanConfig, PrivateData->VlanId[Index]);\r | |
306 | }\r | |
307 | }\r | |
779ae357 | 308 | \r |
083f7c69 ED |
309 | VlanUpdateForm (PrivateData);\r |
310 | if (PrivateData->NumberOfVlan == 0) {\r | |
311 | //\r | |
312 | // No VLAN device now, connect the physical NIC handle.\r | |
313 | // Note: PrivateData->NumberOfVlan has been updated by VlanUpdateForm()\r | |
314 | //\r | |
315 | gBS->ConnectController (PrivateData->ControllerHandle, NULL, NULL, TRUE);\r | |
316 | }\r | |
317 | \r | |
318 | *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;\r | |
319 | ZeroMem (Configuration->VlanList, MAX_VLAN_NUMBER);\r | |
320 | break;\r | |
321 | \r | |
322 | default:\r | |
323 | break;\r | |
324 | }\r | |
325 | \r | |
326 | HiiSetBrowserData (&mVlanFormSetGuid, mVlanStorageName, sizeof (VLAN_CONFIGURATION), (UINT8 *) Configuration, NULL);\r | |
327 | FreePool (Configuration);\r | |
328 | return EFI_SUCCESS;\r | |
779ae357 | 329 | }\r |
330 | \r | |
083f7c69 ED |
331 | //\r |
332 | // All other action return unsupported.\r | |
333 | //\r | |
334 | return EFI_UNSUPPORTED;\r | |
779ae357 | 335 | }\r |
336 | \r | |
337 | \r | |
338 | /**\r | |
339 | This function update VLAN list in the VLAN configuration Form.\r | |
340 | \r | |
341 | @param[in, out] PrivateData Points to VLAN configuration private data.\r | |
342 | \r | |
343 | **/\r | |
344 | VOID\r | |
345 | VlanUpdateForm (\r | |
346 | IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData\r | |
347 | )\r | |
348 | {\r | |
349 | EFI_VLAN_CONFIG_PROTOCOL *VlanConfig;\r | |
350 | UINT16 NumberOfVlan;\r | |
351 | UINTN Index;\r | |
352 | EFI_VLAN_FIND_DATA *VlanData;\r | |
353 | VOID *StartOpCodeHandle;\r | |
354 | EFI_IFR_GUID_LABEL *StartLabel;\r | |
355 | VOID *EndOpCodeHandle;\r | |
356 | EFI_IFR_GUID_LABEL *EndLabel;\r | |
357 | CHAR16 *String;\r | |
358 | CHAR16 VlanStr[30];\r | |
359 | CHAR16 VlanIdStr[6];\r | |
360 | UINTN DigitalCount;\r | |
361 | EFI_STRING_ID StringId;\r | |
362 | \r | |
363 | //\r | |
364 | // Find current VLAN configuration\r | |
365 | //\r | |
366 | VlanData = NULL;\r | |
367 | NumberOfVlan = 0;\r | |
368 | VlanConfig = PrivateData->VlanConfig;\r | |
369 | VlanConfig->Find (VlanConfig, NULL, &NumberOfVlan, &VlanData);\r | |
370 | \r | |
371 | //\r | |
372 | // Update VLAN configuration in PrivateData\r | |
373 | //\r | |
374 | if (NumberOfVlan > MAX_VLAN_NUMBER) {\r | |
375 | NumberOfVlan = MAX_VLAN_NUMBER;\r | |
376 | }\r | |
377 | PrivateData->NumberOfVlan = NumberOfVlan;\r | |
378 | \r | |
379 | //\r | |
380 | // Init OpCode Handle\r | |
381 | //\r | |
382 | StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r | |
383 | ASSERT (StartOpCodeHandle != NULL);\r | |
384 | \r | |
385 | EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r | |
386 | ASSERT (EndOpCodeHandle != NULL);\r | |
387 | \r | |
388 | //\r | |
389 | // Create Hii Extend Label OpCode as the start opcode\r | |
390 | //\r | |
391 | StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r | |
392 | StartOpCodeHandle,\r | |
393 | &gEfiIfrTianoGuid,\r | |
394 | NULL,\r | |
395 | sizeof (EFI_IFR_GUID_LABEL)\r | |
396 | );\r | |
397 | StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r | |
398 | StartLabel->Number = LABEL_VLAN_LIST;\r | |
399 | \r | |
400 | //\r | |
401 | // Create Hii Extend Label OpCode as the end opcode\r | |
402 | //\r | |
403 | EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r | |
404 | EndOpCodeHandle,\r | |
405 | &gEfiIfrTianoGuid,\r | |
406 | NULL,\r | |
407 | sizeof (EFI_IFR_GUID_LABEL)\r | |
408 | );\r | |
409 | EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r | |
410 | EndLabel->Number = LABEL_END;\r | |
411 | \r | |
412 | ZeroMem (PrivateData->VlanId, MAX_VLAN_NUMBER);\r | |
413 | for (Index = 0; Index < NumberOfVlan; Index++) {\r | |
414 | String = VlanStr;\r | |
415 | \r | |
416 | StrCpy (String, L" VLAN ID:");\r | |
417 | String += 10;\r | |
418 | //\r | |
419 | // Pad VlanId string up to 4 characters with space\r | |
420 | //\r | |
421 | DigitalCount = UnicodeValueToString (VlanIdStr, 0, VlanData[Index].VlanId, 5);\r | |
422 | SetMem16 (String, (4 - DigitalCount) * sizeof (CHAR16), L' ');\r | |
423 | StrCpy (String + 4 - DigitalCount, VlanIdStr);\r | |
424 | String += 4;\r | |
425 | \r | |
426 | StrCpy (String, L", Priority:");\r | |
427 | String += 11;\r | |
428 | String += UnicodeValueToString (String, 0, VlanData[Index].Priority, 4);\r | |
429 | *String = 0;\r | |
430 | \r | |
431 | StringId = HiiSetString (PrivateData->HiiHandle, 0, VlanStr, NULL);\r | |
432 | ASSERT (StringId != 0);\r | |
433 | \r | |
434 | HiiCreateCheckBoxOpCode (\r | |
435 | StartOpCodeHandle,\r | |
436 | (EFI_QUESTION_ID) (VLAN_LIST_VAR_OFFSET + Index),\r | |
437 | VLAN_CONFIGURATION_VARSTORE_ID,\r | |
438 | (UINT16) (VLAN_LIST_VAR_OFFSET + Index),\r | |
439 | StringId,\r | |
440 | STRING_TOKEN (STR_VLAN_VLAN_LIST_HELP),\r | |
441 | 0,\r | |
442 | 0,\r | |
443 | NULL\r | |
444 | );\r | |
445 | \r | |
446 | //\r | |
447 | // Save VLAN id to private data\r | |
448 | //\r | |
449 | PrivateData->VlanId[Index] = VlanData[Index].VlanId;\r | |
450 | }\r | |
451 | \r | |
452 | HiiUpdateForm (\r | |
453 | PrivateData->HiiHandle, // HII handle\r | |
454 | &mVlanFormSetGuid, // Formset GUID\r | |
455 | VLAN_CONFIGURATION_FORM_ID, // Form ID\r | |
456 | StartOpCodeHandle, // Label for where to insert opcodes\r | |
457 | EndOpCodeHandle // Replace data\r | |
458 | );\r | |
459 | \r | |
460 | HiiFreeOpCodeHandle (StartOpCodeHandle);\r | |
461 | HiiFreeOpCodeHandle (EndOpCodeHandle);\r | |
462 | \r | |
463 | if (VlanData != NULL) {\r | |
464 | FreePool (VlanData);\r | |
465 | }\r | |
466 | }\r | |
467 | \r | |
468 | \r | |
469 | /**\r | |
470 | This function publish the VLAN configuration Form for a network device. The\r | |
471 | HII Config Access protocol will be installed on a child handle of the network\r | |
472 | device.\r | |
473 | \r | |
474 | @param[in, out] PrivateData Points to VLAN configuration private data.\r | |
475 | \r | |
476 | @retval EFI_SUCCESS HII Form is installed for this network device.\r | |
477 | @retval EFI_OUT_OF_RESOURCES Not enough resource for HII Form installation.\r | |
478 | @retval Others Other errors as indicated.\r | |
479 | \r | |
480 | **/\r | |
481 | EFI_STATUS\r | |
482 | InstallVlanConfigForm (\r | |
483 | IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData\r | |
484 | )\r | |
485 | {\r | |
486 | EFI_STATUS Status;\r | |
487 | EFI_HII_HANDLE HiiHandle;\r | |
488 | EFI_HANDLE DriverHandle;\r | |
e2851998 | 489 | CHAR16 Str[26 + sizeof (EFI_MAC_ADDRESS) * 2 + 1];\r |
779ae357 | 490 | CHAR16 *MacString;\r |
491 | EFI_DEVICE_PATH_PROTOCOL *ChildDevicePath;\r | |
492 | EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;\r | |
493 | \r | |
494 | //\r | |
495 | // Create child handle and install HII Config Access Protocol\r | |
496 | //\r | |
497 | ChildDevicePath = AppendDevicePathNode (\r | |
498 | PrivateData->ParentDevicePath,\r | |
499 | (CONST EFI_DEVICE_PATH_PROTOCOL *) &mHiiVendorDevicePathNode\r | |
500 | );\r | |
501 | if (ChildDevicePath == NULL) {\r | |
502 | return EFI_OUT_OF_RESOURCES;\r | |
503 | }\r | |
504 | PrivateData->ChildDevicePath = ChildDevicePath;\r | |
505 | \r | |
506 | DriverHandle = NULL;\r | |
507 | ConfigAccess = &PrivateData->ConfigAccess;\r | |
508 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
509 | &DriverHandle,\r | |
510 | &gEfiDevicePathProtocolGuid,\r | |
511 | ChildDevicePath,\r | |
512 | &gEfiHiiConfigAccessProtocolGuid,\r | |
513 | ConfigAccess,\r | |
514 | NULL\r | |
515 | );\r | |
516 | if (EFI_ERROR (Status)) {\r | |
517 | return Status;\r | |
518 | }\r | |
519 | PrivateData->DriverHandle = DriverHandle;\r | |
520 | \r | |
521 | //\r | |
522 | // Publish the HII package list\r | |
523 | //\r | |
524 | HiiHandle = HiiAddPackages (\r | |
525 | &mVlanFormSetGuid,\r | |
526 | DriverHandle,\r | |
527 | VlanConfigDxeStrings,\r | |
528 | VlanConfigBin,\r | |
529 | NULL\r | |
530 | );\r | |
531 | if (HiiHandle == NULL) {\r | |
532 | return EFI_OUT_OF_RESOURCES;\r | |
533 | }\r | |
534 | PrivateData->HiiHandle = HiiHandle;\r | |
535 | \r | |
536 | //\r | |
3ddc4cf2 | 537 | // Update formset title help string.\r |
779ae357 | 538 | //\r |
539 | MacString = NULL;\r | |
540 | Status = NetLibGetMacString (PrivateData->ControllerHandle, PrivateData->ImageHandle, &MacString);\r | |
541 | if (EFI_ERROR (Status)) {\r | |
542 | return Status;\r | |
543 | }\r | |
544 | PrivateData->MacString = MacString;\r | |
545 | \r | |
546 | StrCpy (Str, L"VLAN Configuration (MAC:");\r | |
1b2bf3ca | 547 | StrnCat (Str, MacString, sizeof (EFI_MAC_ADDRESS) * 2);\r |
779ae357 | 548 | StrCat (Str, L")");\r |
549 | HiiSetString (\r | |
550 | HiiHandle,\r | |
c7f204db | 551 | STRING_TOKEN (STR_VLAN_FORM_SET_TITLE_HELP),\r |
779ae357 | 552 | Str,\r |
553 | NULL\r | |
554 | );\r | |
555 | \r | |
556 | //\r | |
3ddc4cf2 | 557 | // Update form title help string.\r |
779ae357 | 558 | //\r |
559 | HiiSetString (\r | |
560 | HiiHandle,\r | |
c7f204db | 561 | STRING_TOKEN (STR_VLAN_FORM_HELP),\r |
779ae357 | 562 | Str,\r |
563 | NULL\r | |
564 | );\r | |
565 | \r | |
566 | return EFI_SUCCESS;\r | |
567 | }\r | |
568 | \r | |
569 | /**\r | |
570 | This function remove the VLAN configuration Form for a network device. The\r | |
571 | child handle for HII Config Access protocol will be destroyed.\r | |
572 | \r | |
573 | @param[in, out] PrivateData Points to VLAN configuration private data.\r | |
574 | \r | |
575 | **/\r | |
576 | VOID\r | |
577 | UninstallVlanConfigForm (\r | |
578 | IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData\r | |
579 | )\r | |
580 | {\r | |
581 | //\r | |
582 | // Free MAC string\r | |
583 | //\r | |
584 | if (PrivateData->MacString != NULL) {\r | |
585 | FreePool (PrivateData->MacString);\r | |
586 | PrivateData->MacString = NULL;\r | |
587 | }\r | |
588 | \r | |
589 | //\r | |
590 | // Uninstall HII package list\r | |
591 | //\r | |
592 | if (PrivateData->HiiHandle != NULL) {\r | |
593 | HiiRemovePackages (PrivateData->HiiHandle);\r | |
594 | PrivateData->HiiHandle = NULL;\r | |
595 | }\r | |
596 | \r | |
597 | //\r | |
598 | // Uninstall HII Config Access Protocol\r | |
599 | //\r | |
600 | if (PrivateData->DriverHandle != NULL) {\r | |
601 | gBS->UninstallMultipleProtocolInterfaces (\r | |
602 | PrivateData->DriverHandle,\r | |
603 | &gEfiDevicePathProtocolGuid,\r | |
604 | PrivateData->ChildDevicePath,\r | |
605 | &gEfiHiiConfigAccessProtocolGuid,\r | |
606 | &PrivateData->ConfigAccess,\r | |
607 | NULL\r | |
608 | );\r | |
609 | PrivateData->DriverHandle = NULL;\r | |
610 | \r | |
611 | if (PrivateData->ChildDevicePath != NULL) {\r | |
612 | FreePool (PrivateData->ChildDevicePath);\r | |
613 | PrivateData->ChildDevicePath = NULL;\r | |
614 | }\r | |
615 | }\r | |
616 | }\r |