1 | /** @file
|
---|
2 | Main file for DrvCfg shell Driver1 function.
|
---|
3 |
|
---|
4 | Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
|
---|
5 | 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 | #include "UefiShellDriver1CommandsLib.h"
|
---|
16 | #include <Protocol/HiiConfigAccess.h>
|
---|
17 | #include <Protocol/HiiDatabase.h>
|
---|
18 |
|
---|
19 | STATIC CONST EFI_GUID *CfgGuidList[] = {&gEfiDriverConfigurationProtocolGuid, &gEfiDriverConfiguration2ProtocolGuid, NULL};
|
---|
20 |
|
---|
21 | /**
|
---|
22 | Find the EFI_HII_HANDLE by device path.
|
---|
23 |
|
---|
24 | @param[in] DevPath1 The Device Path to match.
|
---|
25 | @param[out] HiiHandle The EFI_HII_HANDLE after the converstion.
|
---|
26 | @param[in] HiiDb The Hii database protocol
|
---|
27 |
|
---|
28 | @retval EFI_SUCCESS The operation was successful.
|
---|
29 | @retval EFI_NOT_FOUND There was no EFI_HII_HANDLE found for that deviec path.
|
---|
30 | **/
|
---|
31 | EFI_STATUS
|
---|
32 | EFIAPI
|
---|
33 | FindHiiHandleViaDevPath(
|
---|
34 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevPath1,
|
---|
35 | OUT EFI_HII_HANDLE *HiiHandle,
|
---|
36 | IN EFI_HII_DATABASE_PROTOCOL *HiiDb
|
---|
37 | )
|
---|
38 | {
|
---|
39 | EFI_HII_HANDLE *HandleBuffer;
|
---|
40 | UINTN HandleBufferSize;
|
---|
41 | VOID *MainBuffer;
|
---|
42 | UINTN MainBufferSize;
|
---|
43 | EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
|
---|
44 | EFI_HII_PACKAGE_HEADER *PackageHeader;
|
---|
45 | UINTN LoopVariable;
|
---|
46 | EFI_DEVICE_PATH_PROTOCOL *DevPath2;
|
---|
47 | EFI_STATUS Status;
|
---|
48 |
|
---|
49 | ASSERT(DevPath1 != NULL);
|
---|
50 | ASSERT(HiiHandle != NULL);
|
---|
51 | ASSERT(*HiiHandle == NULL);
|
---|
52 | ASSERT(HiiDb != NULL);
|
---|
53 |
|
---|
54 | HandleBufferSize = 0;
|
---|
55 | HandleBuffer = NULL;
|
---|
56 | Status = HiiDb->ListPackageLists(HiiDb, EFI_HII_PACKAGE_DEVICE_PATH, NULL, &HandleBufferSize, HandleBuffer);
|
---|
57 | if (Status == EFI_BUFFER_TOO_SMALL) {
|
---|
58 | HandleBuffer = AllocateZeroPool(HandleBufferSize);
|
---|
59 | ASSERT (HandleBuffer != NULL);
|
---|
60 | Status = HiiDb->ListPackageLists(HiiDb, EFI_HII_PACKAGE_DEVICE_PATH, NULL, &HandleBufferSize, HandleBuffer);
|
---|
61 | }
|
---|
62 | if (EFI_ERROR(Status)) {
|
---|
63 | SHELL_FREE_NON_NULL(HandleBuffer);
|
---|
64 | return (Status);
|
---|
65 | }
|
---|
66 |
|
---|
67 | if (HandleBuffer == NULL) {
|
---|
68 | return EFI_NOT_FOUND;
|
---|
69 | }
|
---|
70 |
|
---|
71 | for (LoopVariable = 0 ; LoopVariable < (HandleBufferSize/sizeof(HandleBuffer[0])) && *HiiHandle == NULL ; LoopVariable++) {
|
---|
72 | MainBufferSize = 0;
|
---|
73 | MainBuffer = NULL;
|
---|
74 | Status = HiiDb->ExportPackageLists(HiiDb, HandleBuffer[LoopVariable], &MainBufferSize, MainBuffer);
|
---|
75 | if (Status == EFI_BUFFER_TOO_SMALL) {
|
---|
76 | MainBuffer = AllocateZeroPool(MainBufferSize);
|
---|
77 | ASSERT (MainBuffer != NULL);
|
---|
78 | Status = HiiDb->ExportPackageLists(HiiDb, HandleBuffer[LoopVariable], &MainBufferSize, MainBuffer);
|
---|
79 | }
|
---|
80 | //
|
---|
81 | // Enumerate through the block of returned memory.
|
---|
82 | // This should actually be a small block, but we need to be sure.
|
---|
83 | //
|
---|
84 | for (PackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER*)MainBuffer
|
---|
85 | ; PackageListHeader != NULL && ((CHAR8*)PackageListHeader) < (((CHAR8*)MainBuffer)+MainBufferSize) && *HiiHandle == NULL
|
---|
86 | ; PackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER*)(((CHAR8*)(PackageListHeader)) + PackageListHeader->PackageLength )) {
|
---|
87 | for (PackageHeader = (EFI_HII_PACKAGE_HEADER*)(((CHAR8*)(PackageListHeader))+sizeof(EFI_HII_PACKAGE_LIST_HEADER))
|
---|
88 | ; PackageHeader != NULL && ((CHAR8*)PackageHeader) < (((CHAR8*)MainBuffer)+MainBufferSize) && PackageHeader->Type != EFI_HII_PACKAGE_END && *HiiHandle == NULL
|
---|
89 | ; PackageHeader = (EFI_HII_PACKAGE_HEADER*)(((CHAR8*)(PackageHeader))+PackageHeader->Length)) {
|
---|
90 | if (PackageHeader->Type == EFI_HII_PACKAGE_DEVICE_PATH) {
|
---|
91 | DevPath2 = (EFI_DEVICE_PATH_PROTOCOL*)(((CHAR8*)PackageHeader) + sizeof(EFI_HII_PACKAGE_HEADER));
|
---|
92 | if (DevicePathCompare(&DevPath1, &DevPath2) == 0) {
|
---|
93 | *HiiHandle = HandleBuffer[LoopVariable];
|
---|
94 | break;
|
---|
95 | }
|
---|
96 | }
|
---|
97 | }
|
---|
98 | }
|
---|
99 | SHELL_FREE_NON_NULL(MainBuffer);
|
---|
100 | }
|
---|
101 | SHELL_FREE_NON_NULL(HandleBuffer);
|
---|
102 |
|
---|
103 | if (*HiiHandle == NULL) {
|
---|
104 | return (EFI_NOT_FOUND);
|
---|
105 | }
|
---|
106 | return (EFI_SUCCESS);
|
---|
107 | }
|
---|
108 |
|
---|
109 | /**
|
---|
110 | Convert a EFI_HANDLE to a EFI_HII_HANDLE.
|
---|
111 |
|
---|
112 | @param[in] Handle The EFI_HANDLE to convert.
|
---|
113 | @param[out] HiiHandle The EFI_HII_HANDLE after the converstion.
|
---|
114 | @param[in] HiiDb The Hii database protocol
|
---|
115 |
|
---|
116 | @retval EFI_SUCCESS The operation was successful.
|
---|
117 | **/
|
---|
118 | EFI_STATUS
|
---|
119 | EFIAPI
|
---|
120 | ConvertHandleToHiiHandle(
|
---|
121 | IN CONST EFI_HANDLE Handle,
|
---|
122 | OUT EFI_HII_HANDLE *HiiHandle,
|
---|
123 | IN EFI_HII_DATABASE_PROTOCOL *HiiDb
|
---|
124 | )
|
---|
125 | {
|
---|
126 | EFI_STATUS Status;
|
---|
127 | EFI_DEVICE_PATH_PROTOCOL *DevPath1;
|
---|
128 |
|
---|
129 | if (HiiHandle == NULL || HiiDb == NULL) {
|
---|
130 | return (EFI_INVALID_PARAMETER);
|
---|
131 | }
|
---|
132 | *HiiHandle = NULL;
|
---|
133 |
|
---|
134 | if (Handle == NULL) {
|
---|
135 | return (EFI_SUCCESS);
|
---|
136 | }
|
---|
137 |
|
---|
138 | DevPath1 = NULL;
|
---|
139 | Status = gBS->OpenProtocol(Handle, &gEfiDevicePathProtocolGuid, (VOID**)&DevPath1, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
|
---|
140 | if (EFI_ERROR(Status) || DevPath1 == NULL) {
|
---|
141 | return (EFI_NOT_FOUND);
|
---|
142 | }
|
---|
143 |
|
---|
144 | return (FindHiiHandleViaDevPath(DevPath1, HiiHandle, HiiDb));
|
---|
145 | }
|
---|
146 |
|
---|
147 | /**
|
---|
148 | Function to print out all HII configuration information to a file.
|
---|
149 |
|
---|
150 | @param[in] Handle The handle to get info on. NULL to do all handles.
|
---|
151 | @param[in] FileName The filename to rwite the info to.
|
---|
152 | **/
|
---|
153 | SHELL_STATUS
|
---|
154 | EFIAPI
|
---|
155 | ConfigToFile(
|
---|
156 | IN CONST EFI_HANDLE Handle,
|
---|
157 | IN CONST CHAR16 *FileName
|
---|
158 | )
|
---|
159 | {
|
---|
160 | EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
|
---|
161 | EFI_STATUS Status;
|
---|
162 | VOID *MainBuffer;
|
---|
163 | UINTN MainBufferSize;
|
---|
164 | EFI_HII_HANDLE HiiHandle;
|
---|
165 | SHELL_FILE_HANDLE FileHandle;
|
---|
166 |
|
---|
167 | HiiDatabase = NULL;
|
---|
168 | MainBufferSize = 0;
|
---|
169 | MainBuffer = NULL;
|
---|
170 | FileHandle = NULL;
|
---|
171 |
|
---|
172 | Status = ShellOpenFileByName(FileName, &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
|
---|
173 | if (EFI_ERROR(Status)) {
|
---|
174 | ShellPrintHiiEx(
|
---|
175 | -1,
|
---|
176 | -1,
|
---|
177 | NULL,
|
---|
178 | STRING_TOKEN(STR_GEN_FILE_OPEN),
|
---|
179 | gShellDriver1HiiHandle,
|
---|
180 | FileName,
|
---|
181 | Status);
|
---|
182 | return (SHELL_DEVICE_ERROR);
|
---|
183 | }
|
---|
184 |
|
---|
185 | //
|
---|
186 | // Locate HII Database protocol
|
---|
187 | //
|
---|
188 | Status = gBS->LocateProtocol (
|
---|
189 | &gEfiHiiDatabaseProtocolGuid,
|
---|
190 | NULL,
|
---|
191 | (VOID **) &HiiDatabase
|
---|
192 | );
|
---|
193 |
|
---|
194 | if (EFI_ERROR(Status) || HiiDatabase == NULL) {
|
---|
195 | ShellPrintHiiEx(
|
---|
196 | -1,
|
---|
197 | -1,
|
---|
198 | NULL,
|
---|
199 | STRING_TOKEN(STR_GEN_PROTOCOL_NF),
|
---|
200 | gShellDriver1HiiHandle,
|
---|
201 | L"EfiHiiDatabaseProtocol",
|
---|
202 | &gEfiHiiDatabaseProtocolGuid);
|
---|
203 | ShellCloseFile(&FileHandle);
|
---|
204 | return (SHELL_NOT_FOUND);
|
---|
205 | }
|
---|
206 |
|
---|
207 | Status = ConvertHandleToHiiHandle(Handle, &HiiHandle, HiiDatabase);
|
---|
208 | if (EFI_ERROR(Status)) {
|
---|
209 | ShellPrintHiiEx(
|
---|
210 | -1,
|
---|
211 | -1,
|
---|
212 | NULL,
|
---|
213 | STRING_TOKEN(STR_GEN_HANDLE_NOT),
|
---|
214 | gShellDriver1HiiHandle,
|
---|
215 | ConvertHandleToHandleIndex(Handle),
|
---|
216 | L"Device");
|
---|
217 | ShellCloseFile(&FileHandle);
|
---|
218 | return (SHELL_DEVICE_ERROR);
|
---|
219 | }
|
---|
220 |
|
---|
221 | Status = HiiDatabase->ExportPackageLists(HiiDatabase, HiiHandle, &MainBufferSize, MainBuffer);
|
---|
222 | if (Status == EFI_BUFFER_TOO_SMALL) {
|
---|
223 | MainBuffer = AllocateZeroPool(MainBufferSize);
|
---|
224 | Status = HiiDatabase->ExportPackageLists(HiiDatabase, HiiHandle, &MainBufferSize, MainBuffer);
|
---|
225 | }
|
---|
226 |
|
---|
227 | Status = ShellWriteFile(FileHandle, &MainBufferSize, MainBuffer);
|
---|
228 |
|
---|
229 | ShellCloseFile(&FileHandle);
|
---|
230 | SHELL_FREE_NON_NULL(MainBuffer);
|
---|
231 |
|
---|
232 | if (EFI_ERROR(Status)) {
|
---|
233 | ShellPrintHiiEx(
|
---|
234 | -1,
|
---|
235 | -1,
|
---|
236 | NULL,
|
---|
237 | STRING_TOKEN(STR_FILE_WRITE_FAIL),
|
---|
238 | gShellDriver1HiiHandle,
|
---|
239 | FileName,
|
---|
240 | Status);
|
---|
241 | return (SHELL_DEVICE_ERROR);
|
---|
242 | }
|
---|
243 | ShellPrintHiiEx(
|
---|
244 | -1,
|
---|
245 | -1,
|
---|
246 | NULL,
|
---|
247 | STRING_TOKEN(STR_DRVCFG_COMP),
|
---|
248 | gShellDriver1HiiHandle);
|
---|
249 |
|
---|
250 | return (SHELL_SUCCESS);
|
---|
251 | }
|
---|
252 |
|
---|
253 | /**
|
---|
254 | Function to read in HII configuration information from a file.
|
---|
255 |
|
---|
256 | @param[in] Handle The handle to get info for.
|
---|
257 | @param[in] FileName The filename to read the info from.
|
---|
258 | **/
|
---|
259 | SHELL_STATUS
|
---|
260 | EFIAPI
|
---|
261 | ConfigFromFile(
|
---|
262 | IN EFI_HANDLE Handle,
|
---|
263 | IN CONST CHAR16 *FileName
|
---|
264 | )
|
---|
265 | {
|
---|
266 | EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
|
---|
267 | EFI_STATUS Status;
|
---|
268 | VOID *MainBuffer;
|
---|
269 | UINT64 Temp;
|
---|
270 | UINTN MainBufferSize;
|
---|
271 | EFI_HII_HANDLE HiiHandle;
|
---|
272 | SHELL_FILE_HANDLE FileHandle;
|
---|
273 | CHAR16 *TempDevPathString;
|
---|
274 | EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
|
---|
275 | EFI_HII_PACKAGE_HEADER *PackageHeader;
|
---|
276 | EFI_DEVICE_PATH_PROTOCOL *DevPath;
|
---|
277 | UINTN HandleIndex;
|
---|
278 |
|
---|
279 | HiiDatabase = NULL;
|
---|
280 | MainBufferSize = 0;
|
---|
281 | MainBuffer = NULL;
|
---|
282 | FileHandle = NULL;
|
---|
283 |
|
---|
284 | Status = ShellOpenFileByName(FileName, &FileHandle, EFI_FILE_MODE_READ, 0);
|
---|
285 | if (EFI_ERROR(Status)) {
|
---|
286 | ShellPrintHiiEx(
|
---|
287 | -1,
|
---|
288 | -1,
|
---|
289 | NULL,
|
---|
290 | STRING_TOKEN(STR_GEN_FILE_OPEN),
|
---|
291 | gShellDriver1HiiHandle,
|
---|
292 | FileName,
|
---|
293 | Status);
|
---|
294 | return (SHELL_DEVICE_ERROR);
|
---|
295 | }
|
---|
296 |
|
---|
297 | //
|
---|
298 | // Locate HII Database protocol
|
---|
299 | //
|
---|
300 | Status = gBS->LocateProtocol (
|
---|
301 | &gEfiHiiDatabaseProtocolGuid,
|
---|
302 | NULL,
|
---|
303 | (VOID **) &HiiDatabase
|
---|
304 | );
|
---|
305 |
|
---|
306 | if (EFI_ERROR(Status) || HiiDatabase == NULL) {
|
---|
307 | ShellPrintHiiEx(
|
---|
308 | -1,
|
---|
309 | -1,
|
---|
310 | NULL,
|
---|
311 | STRING_TOKEN(STR_GEN_PROTOCOL_NF),
|
---|
312 | gShellDriver1HiiHandle,
|
---|
313 | L"EfiHiiDatabaseProtocol",
|
---|
314 | &gEfiHiiDatabaseProtocolGuid);
|
---|
315 | ShellCloseFile(&FileHandle);
|
---|
316 | return (SHELL_NOT_FOUND);
|
---|
317 | }
|
---|
318 |
|
---|
319 | Status = ShellGetFileSize(FileHandle, &Temp);
|
---|
320 | MainBufferSize = (UINTN)Temp;
|
---|
321 | if (EFI_ERROR(Status)) {
|
---|
322 | ShellPrintHiiEx(
|
---|
323 | -1,
|
---|
324 | -1,
|
---|
325 | NULL,
|
---|
326 | STRING_TOKEN(STR_FILE_READ_FAIL),
|
---|
327 | gShellDriver1HiiHandle,
|
---|
328 | FileName,
|
---|
329 | Status);
|
---|
330 | ShellCloseFile(&FileHandle);
|
---|
331 | return (SHELL_DEVICE_ERROR);
|
---|
332 | }
|
---|
333 | MainBuffer = AllocateZeroPool((UINTN)MainBufferSize);
|
---|
334 | if (EFI_ERROR(Status)) {
|
---|
335 | ShellPrintHiiEx(
|
---|
336 | -1,
|
---|
337 | -1,
|
---|
338 | NULL,
|
---|
339 | STRING_TOKEN(STR_GEN_OUT_MEM),
|
---|
340 | gShellDriver1HiiHandle);
|
---|
341 | ShellCloseFile(&FileHandle);
|
---|
342 | return (SHELL_DEVICE_ERROR);
|
---|
343 | }
|
---|
344 | Status = ShellReadFile(FileHandle, &MainBufferSize, MainBuffer);
|
---|
345 | if (EFI_ERROR(Status)) {
|
---|
346 | ShellPrintHiiEx(
|
---|
347 | -1,
|
---|
348 | -1,
|
---|
349 | NULL,
|
---|
350 | STRING_TOKEN(STR_FILE_READ_FAIL),
|
---|
351 | gShellDriver1HiiHandle,
|
---|
352 | FileName,
|
---|
353 | Status);
|
---|
354 | ShellCloseFile(&FileHandle);
|
---|
355 | SHELL_FREE_NON_NULL(MainBuffer);
|
---|
356 | return (SHELL_DEVICE_ERROR);
|
---|
357 | }
|
---|
358 |
|
---|
359 | ShellCloseFile(&FileHandle);
|
---|
360 |
|
---|
361 | if (Handle != NULL) {
|
---|
362 | //
|
---|
363 | // User override in place. Just do it.
|
---|
364 | //
|
---|
365 | HiiHandle = NULL;
|
---|
366 | Status = ConvertHandleToHiiHandle(Handle, &HiiHandle, HiiDatabase);
|
---|
367 | if (EFI_ERROR(Status)) {
|
---|
368 | ShellPrintHiiEx(
|
---|
369 | -1,
|
---|
370 | -1,
|
---|
371 | NULL,
|
---|
372 | STRING_TOKEN(STR_GEN_HANDLE_NOT),
|
---|
373 | gShellDriver1HiiHandle,
|
---|
374 | ConvertHandleToHandleIndex(Handle),
|
---|
375 | L"Device");
|
---|
376 | ShellCloseFile(&FileHandle);
|
---|
377 | return (SHELL_DEVICE_ERROR);
|
---|
378 | }
|
---|
379 | Status = HiiDatabase->UpdatePackageList(HiiDatabase, HiiHandle, MainBuffer);
|
---|
380 | if (EFI_ERROR(Status)) {
|
---|
381 | ShellPrintHiiEx(
|
---|
382 | -1,
|
---|
383 | -1,
|
---|
384 | NULL,
|
---|
385 | STRING_TOKEN(STR_GEN_UEFI_FUNC_ERROR),
|
---|
386 | gShellDriver1HiiHandle,
|
---|
387 | L"HiiDatabase->UpdatePackageList",
|
---|
388 | Status);
|
---|
389 | return (SHELL_DEVICE_ERROR);
|
---|
390 | }
|
---|
391 | } else {
|
---|
392 | //
|
---|
393 | // we need to parse the buffer and try to match the device paths for each item to try to find it's device path.
|
---|
394 | //
|
---|
395 |
|
---|
396 | for (PackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER*)MainBuffer
|
---|
397 | ; PackageListHeader != NULL && ((CHAR8*)PackageListHeader) < (((CHAR8*)MainBuffer)+MainBufferSize)
|
---|
398 | ; PackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER*)(((CHAR8*)(PackageListHeader)) + PackageListHeader->PackageLength )) {
|
---|
399 | for (PackageHeader = (EFI_HII_PACKAGE_HEADER*)(((CHAR8*)(PackageListHeader))+sizeof(EFI_HII_PACKAGE_LIST_HEADER))
|
---|
400 | ; PackageHeader != NULL && ((CHAR8*)PackageHeader) < (((CHAR8*)MainBuffer)+MainBufferSize) && PackageHeader->Type != EFI_HII_PACKAGE_END
|
---|
401 | ; PackageHeader = (EFI_HII_PACKAGE_HEADER*)(((CHAR8*)(PackageHeader))+PackageHeader->Length)) {
|
---|
402 | if (PackageHeader->Type == EFI_HII_PACKAGE_DEVICE_PATH) {
|
---|
403 | HiiHandle = NULL;
|
---|
404 | Status = FindHiiHandleViaDevPath((EFI_DEVICE_PATH_PROTOCOL*)(((CHAR8*)PackageHeader) + sizeof(EFI_HII_PACKAGE_HEADER)), &HiiHandle, HiiDatabase);
|
---|
405 | if (EFI_ERROR(Status)) {
|
---|
406 | //
|
---|
407 | // print out an error.
|
---|
408 | //
|
---|
409 | TempDevPathString = ConvertDevicePathToText((EFI_DEVICE_PATH_PROTOCOL*)(((CHAR8*)PackageHeader) + sizeof(EFI_HII_PACKAGE_HEADER)), TRUE, TRUE);
|
---|
410 | ShellPrintHiiEx(
|
---|
411 | -1,
|
---|
412 | -1,
|
---|
413 | NULL,
|
---|
414 | STRING_TOKEN(STR_DRVCFG_IN_FILE_NF),
|
---|
415 | gShellDriver1HiiHandle,
|
---|
416 | TempDevPathString);
|
---|
417 | SHELL_FREE_NON_NULL(TempDevPathString);
|
---|
418 | } else {
|
---|
419 | Status = HiiDatabase->UpdatePackageList(HiiDatabase, HiiHandle, PackageListHeader);
|
---|
420 | if (EFI_ERROR(Status)) {
|
---|
421 | ShellPrintHiiEx(
|
---|
422 | -1,
|
---|
423 | -1,
|
---|
424 | NULL,
|
---|
425 | STRING_TOKEN(STR_GEN_UEFI_FUNC_ERROR),
|
---|
426 | gShellDriver1HiiHandle,
|
---|
427 | L"HiiDatabase->UpdatePackageList",
|
---|
428 | Status);
|
---|
429 | return (SHELL_DEVICE_ERROR);
|
---|
430 | } else {
|
---|
431 | DevPath = (EFI_DEVICE_PATH_PROTOCOL*)(((CHAR8*)PackageHeader) + sizeof(EFI_HII_PACKAGE_HEADER));
|
---|
432 | gBS->LocateDevicePath(&gEfiHiiConfigAccessProtocolGuid, &DevPath, &Handle);
|
---|
433 | HandleIndex = ConvertHandleToHandleIndex(Handle);
|
---|
434 | ShellPrintHiiEx(
|
---|
435 | -1,
|
---|
436 | -1,
|
---|
437 | NULL,
|
---|
438 | STRING_TOKEN(STR_DRVCFG_DONE_HII),
|
---|
439 | gShellDriver1HiiHandle,
|
---|
440 | HandleIndex);
|
---|
441 | }
|
---|
442 | }
|
---|
443 | }
|
---|
444 | }
|
---|
445 | }
|
---|
446 | }
|
---|
447 |
|
---|
448 | SHELL_FREE_NON_NULL(MainBuffer);
|
---|
449 |
|
---|
450 |
|
---|
451 | ShellPrintHiiEx(
|
---|
452 | -1,
|
---|
453 | -1,
|
---|
454 | NULL,
|
---|
455 | STRING_TOKEN(STR_DRVCFG_COMP),
|
---|
456 | gShellDriver1HiiHandle);
|
---|
457 | return (SHELL_SUCCESS);
|
---|
458 | }
|
---|
459 |
|
---|
460 | /**
|
---|
461 | Present a requested action to the user.
|
---|
462 |
|
---|
463 | @param[in] DriverImageHandle The handle for the driver to configure.
|
---|
464 | @param[in] ControllerHandle The handle of the device being managed by the Driver specified.
|
---|
465 | @param[in] ChildHandle The handle of a child device of the specified device.
|
---|
466 | @param[in] ActionRequired The required HII action.
|
---|
467 |
|
---|
468 | @retval SHELL_INVALID_PARAMETER A parameter has a invalid value.
|
---|
469 | **/
|
---|
470 | EFI_STATUS
|
---|
471 | EFIAPI
|
---|
472 | ShellCmdDriverConfigurationProcessActionRequired (
|
---|
473 | EFI_HANDLE DriverImageHandle,
|
---|
474 | EFI_HANDLE ControllerHandle,
|
---|
475 | EFI_HANDLE ChildHandle,
|
---|
476 | EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED ActionRequired
|
---|
477 | )
|
---|
478 | {
|
---|
479 | EFI_HANDLE ConnectControllerContextOverride[2];
|
---|
480 |
|
---|
481 | switch (ActionRequired) {
|
---|
482 | case EfiDriverConfigurationActionNone:
|
---|
483 | ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_NONE), gShellDriver1HiiHandle);
|
---|
484 | break;
|
---|
485 |
|
---|
486 | case EfiDriverConfigurationActionStopController:
|
---|
487 | ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_STOP), gShellDriver1HiiHandle);
|
---|
488 | ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_ENTER_S), gShellDriver1HiiHandle, L"stop controller");
|
---|
489 | ShellPromptForResponse(ShellPromptResponseTypeEnterContinue, NULL, NULL);
|
---|
490 |
|
---|
491 | gBS->DisconnectController (ControllerHandle, DriverImageHandle, ChildHandle);
|
---|
492 | ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_CTLR_S), gShellDriver1HiiHandle, L"stopped");
|
---|
493 | break;
|
---|
494 |
|
---|
495 | case EfiDriverConfigurationActionRestartController:
|
---|
496 | ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_RESTART_S), gShellDriver1HiiHandle, L"controller");
|
---|
497 | ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_ENTER_S), gShellDriver1HiiHandle, L"restart controller");
|
---|
498 | ShellPromptForResponse(ShellPromptResponseTypeEnterContinue, NULL, NULL);
|
---|
499 |
|
---|
500 | gBS->DisconnectController (ControllerHandle, DriverImageHandle, ChildHandle);
|
---|
501 | ConnectControllerContextOverride[0] = DriverImageHandle;
|
---|
502 | ConnectControllerContextOverride[1] = NULL;
|
---|
503 | gBS->ConnectController (ControllerHandle, ConnectControllerContextOverride, NULL, TRUE);
|
---|
504 | ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_CTLR_S), gShellDriver1HiiHandle, L"restarted");
|
---|
505 | break;
|
---|
506 |
|
---|
507 | case EfiDriverConfigurationActionRestartPlatform:
|
---|
508 | ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_RESTART_S), gShellDriver1HiiHandle, L"platform");
|
---|
509 | ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_DRVCFG_ENTER_S), gShellDriver1HiiHandle, L"restart platform");
|
---|
510 | ShellPromptForResponse(ShellPromptResponseTypeEnterContinue, NULL, NULL);
|
---|
511 |
|
---|
512 | gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
|
---|
513 | break;
|
---|
514 |
|
---|
515 | default:
|
---|
516 | return (EFI_INVALID_PARAMETER);
|
---|
517 | }
|
---|
518 |
|
---|
519 | return EFI_SUCCESS;
|
---|
520 | }
|
---|
521 |
|
---|
522 | /**
|
---|
523 | Do the configuration in an environment without HII.
|
---|
524 |
|
---|
525 | @param[in] Language The language code.
|
---|
526 | @param[in] ForceDefaults TRUE to force defaults, FALSE otherwise.
|
---|
527 | @param[in] DefaultType If ForceDefaults is TRUE, specifies the default type.
|
---|
528 | @param[in] AllChildren TRUE to configure all children, FALSE otherwise.
|
---|
529 | @param[in] ValidateOptions TRUE to validate existing options, FALSE otherwise.
|
---|
530 | @param[in] SetOptions TRUE to set options, FALSE otherwise.
|
---|
531 | @param[in] DriverImageHandle The handle for the driver to configure.
|
---|
532 | @param[in] DeviceHandle The handle of the device being managed by the Driver specified.
|
---|
533 | @param[in] ChildHandle The handle of a child device of the specified device.
|
---|
534 |
|
---|
535 | @retval SHELL_NOT_FOUND A specified handle could not be found.
|
---|
536 | @retval SHELL_INVALID_PARAMETER A parameter has a invalid value.
|
---|
537 | **/
|
---|
538 | SHELL_STATUS
|
---|
539 | EFIAPI
|
---|
540 | PreHiiDrvCfg (
|
---|
541 | IN CONST CHAR8 *Language,
|
---|
542 | IN BOOLEAN ForceDefaults,
|
---|
543 | IN UINT32 DefaultType,
|
---|
544 | IN BOOLEAN AllChildren,
|
---|
545 | IN BOOLEAN ValidateOptions,
|
---|
546 | IN BOOLEAN SetOptions,
|
---|
547 | IN EFI_HANDLE DriverImageHandle,
|
---|
548 | IN EFI_HANDLE DeviceHandle,
|
---|
549 | IN EFI_HANDLE ChildHandle
|
---|
550 | )
|
---|
551 | {
|
---|
552 | EFI_STATUS Status;
|
---|
553 | SHELL_STATUS ShellStatus;
|
---|
554 | UINTN OuterLoopCounter;
|
---|
555 | CHAR8 *BestLanguage;
|
---|
556 | UINTN DriverImageHandleCount;
|
---|
557 | EFI_HANDLE *DriverImageHandleBuffer;
|
---|
558 | UINTN HandleCount;
|
---|
559 | EFI_HANDLE *HandleBuffer;
|
---|
560 | UINTN *HandleType;
|
---|
561 | UINTN LoopCounter;
|
---|
562 | UINTN ChildIndex;
|
---|
563 | UINTN ChildHandleCount;
|
---|
564 | EFI_HANDLE *ChildHandleBuffer;
|
---|
565 | UINTN *ChildHandleType;
|
---|
566 | EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED ActionRequired;
|
---|
567 | EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration;
|
---|
568 | BOOLEAN Iso639Language;
|
---|
569 | UINTN HandleIndex1;
|
---|
570 | UINTN HandleIndex2;
|
---|
571 | UINTN HandleIndex3;
|
---|
572 |
|
---|
573 | ShellStatus = SHELL_SUCCESS;
|
---|
574 |
|
---|
575 | if (ChildHandle == NULL && AllChildren) {
|
---|
576 | SetOptions = FALSE;
|
---|
577 | }
|
---|
578 |
|
---|
579 | if (ForceDefaults) {
|
---|
580 | ShellPrintHiiEx(
|
---|
581 | -1,
|
---|
582 | -1,
|
---|
583 | NULL,
|
---|
584 | STRING_TOKEN (STR_DRVCFG_FORCE_D),
|
---|
585 | gShellDriver1HiiHandle,
|
---|
586 | DefaultType);
|
---|
587 | } else if (ValidateOptions) {
|
---|
588 | ShellPrintHiiEx(
|
---|
589 | -1,
|
---|
590 | -1,
|
---|
591 | NULL,
|
---|
592 | STRING_TOKEN (STR_DRVCFG_VALIDATE),
|
---|
593 | gShellDriver1HiiHandle);
|
---|
594 | } else if (SetOptions) {
|
---|
595 | ShellPrintHiiEx(
|
---|
596 | -1,
|
---|
597 | -1,
|
---|
598 | NULL,
|
---|
599 | STRING_TOKEN (STR_DRVCFG_SET),
|
---|
600 | gShellDriver1HiiHandle);
|
---|
601 | }
|
---|
602 |
|
---|
603 | if (DriverImageHandle == 0) {
|
---|
604 | DriverImageHandleBuffer = GetHandleListByProtocolList(CfgGuidList);
|
---|
605 | if (DriverImageHandleBuffer == NULL) {
|
---|
606 | ShellStatus = SHELL_NOT_FOUND;
|
---|
607 | goto Done;
|
---|
608 | }
|
---|
609 | for (
|
---|
610 | HandleBuffer = DriverImageHandleBuffer, DriverImageHandleCount = 0
|
---|
611 | ; HandleBuffer != NULL && *HandleBuffer != NULL
|
---|
612 | ; HandleBuffer++,DriverImageHandleCount++);
|
---|
613 | } else {
|
---|
614 | DriverImageHandleCount = 1;
|
---|
615 | //
|
---|
616 | // Allocate buffer to hold the image handle so as to
|
---|
617 | // keep consistent with the above clause
|
---|
618 | //
|
---|
619 | DriverImageHandleBuffer = AllocatePool (sizeof (EFI_HANDLE));
|
---|
620 | ASSERT (DriverImageHandleBuffer);
|
---|
621 | DriverImageHandleBuffer[0] = DriverImageHandle;
|
---|
622 | }
|
---|
623 |
|
---|
624 | for (OuterLoopCounter = 0; OuterLoopCounter < DriverImageHandleCount; OuterLoopCounter++) {
|
---|
625 | Iso639Language = FALSE;
|
---|
626 | Status = gBS->OpenProtocol (
|
---|
627 | DriverImageHandleBuffer[OuterLoopCounter],
|
---|
628 | &gEfiDriverConfiguration2ProtocolGuid,
|
---|
629 | (VOID **) &DriverConfiguration,
|
---|
630 | NULL,
|
---|
631 | NULL,
|
---|
632 | EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
---|
633 | );
|
---|
634 | if (EFI_ERROR (Status)) {
|
---|
635 | Iso639Language = TRUE;
|
---|
636 | Status = gBS->OpenProtocol (
|
---|
637 | DriverImageHandleBuffer[OuterLoopCounter],
|
---|
638 | &gEfiDriverConfigurationProtocolGuid,
|
---|
639 | (VOID **) &DriverConfiguration,
|
---|
640 | NULL,
|
---|
641 | NULL,
|
---|
642 | EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
---|
643 | );
|
---|
644 | }
|
---|
645 | if (EFI_ERROR (Status)) {
|
---|
646 | // ShellPrintHiiEx(
|
---|
647 | // -1,
|
---|
648 | // -1,
|
---|
649 | // NULL,
|
---|
650 | // STRING_TOKEN (STR_DRVCFG_NOT_SUPPORT),
|
---|
651 | // gShellDriver1HiiHandle,
|
---|
652 | // ConvertHandleToHandleIndex (DriverImageHandleBuffer[OuterLoopCounter])
|
---|
653 | // );
|
---|
654 | ShellStatus = SHELL_UNSUPPORTED;
|
---|
655 | continue;
|
---|
656 | }
|
---|
657 |
|
---|
658 | BestLanguage = GetBestLanguage (
|
---|
659 | DriverConfiguration->SupportedLanguages,
|
---|
660 | Iso639Language,
|
---|
661 | Language!=NULL?Language:"",
|
---|
662 | DriverConfiguration->SupportedLanguages,
|
---|
663 | NULL
|
---|
664 | );
|
---|
665 | if (BestLanguage == NULL) {
|
---|
666 | ShellPrintHiiEx(
|
---|
667 | -1,
|
---|
668 | -1,
|
---|
669 | NULL,
|
---|
670 | STRING_TOKEN (STR_GEN_PROBLEM_VAL),
|
---|
671 | gShellDriver1HiiHandle,
|
---|
672 | L"-l"
|
---|
673 | );
|
---|
674 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
675 | continue;
|
---|
676 | }
|
---|
677 |
|
---|
678 | Status = ParseHandleDatabaseByRelationshipWithType (
|
---|
679 | DriverImageHandleBuffer[OuterLoopCounter],
|
---|
680 | NULL,
|
---|
681 | &HandleCount,
|
---|
682 | &HandleBuffer,
|
---|
683 | &HandleType
|
---|
684 | );
|
---|
685 | if (EFI_ERROR (Status)) {
|
---|
686 | continue;
|
---|
687 | }
|
---|
688 |
|
---|
689 | if (SetOptions && DeviceHandle == NULL) {
|
---|
690 |
|
---|
691 | gST->ConOut->ClearScreen (gST->ConOut);
|
---|
692 | Status = DriverConfiguration->SetOptions (
|
---|
693 | DriverConfiguration,
|
---|
694 | NULL,
|
---|
695 | NULL,
|
---|
696 | BestLanguage,
|
---|
697 | &ActionRequired
|
---|
698 | );
|
---|
699 | gST->ConOut->ClearScreen (gST->ConOut);
|
---|
700 |
|
---|
701 | ShellPrintHiiEx(
|
---|
702 | -1,
|
---|
703 | -1,
|
---|
704 | NULL,
|
---|
705 | STRING_TOKEN (STR_DRVCFG_ALL_LANG),
|
---|
706 | gShellDriver1HiiHandle,
|
---|
707 | ConvertHandleToHandleIndex (DriverImageHandleBuffer[OuterLoopCounter]),
|
---|
708 | DriverConfiguration->SupportedLanguages
|
---|
709 | );
|
---|
710 | if (!EFI_ERROR (Status)) {
|
---|
711 | ShellPrintHiiEx(
|
---|
712 | -1,
|
---|
713 | -1,
|
---|
714 | NULL,
|
---|
715 | STRING_TOKEN (STR_DRVCFG_OPTIONS_SET),
|
---|
716 | gShellDriver1HiiHandle);
|
---|
717 | for (LoopCounter = 0; LoopCounter < HandleCount; LoopCounter++) {
|
---|
718 | if ((HandleType[LoopCounter] & HR_CONTROLLER_HANDLE) == HR_CONTROLLER_HANDLE) {
|
---|
719 | ShellCmdDriverConfigurationProcessActionRequired (
|
---|
720 | DriverImageHandleBuffer[OuterLoopCounter],
|
---|
721 | HandleBuffer[LoopCounter],
|
---|
722 | NULL,
|
---|
723 | ActionRequired
|
---|
724 | );
|
---|
725 | }
|
---|
726 | }
|
---|
727 | } else {
|
---|
728 | ShellPrintHiiEx(
|
---|
729 | -1,
|
---|
730 | -1,
|
---|
731 | NULL,
|
---|
732 | STRING_TOKEN (STR_DRVCFG_NOT_SET),
|
---|
733 | gShellDriver1HiiHandle,
|
---|
734 | Status);
|
---|
735 | }
|
---|
736 | continue;
|
---|
737 | }
|
---|
738 |
|
---|
739 | for (LoopCounter = 0; LoopCounter < HandleCount; LoopCounter++) {
|
---|
740 | if ((HandleType[LoopCounter] & HR_CONTROLLER_HANDLE) != HR_CONTROLLER_HANDLE) {
|
---|
741 | continue;
|
---|
742 | }
|
---|
743 | if (DeviceHandle != NULL && DeviceHandle != HandleBuffer[LoopCounter]) {
|
---|
744 | continue;
|
---|
745 | }
|
---|
746 | if (ChildHandle == NULL) {
|
---|
747 | HandleIndex1 = ConvertHandleToHandleIndex (DriverImageHandleBuffer[OuterLoopCounter]);
|
---|
748 | HandleIndex2 = ConvertHandleToHandleIndex (HandleBuffer[LoopCounter]);
|
---|
749 | ShellPrintHiiEx(
|
---|
750 | -1,
|
---|
751 | -1,
|
---|
752 | NULL,
|
---|
753 | STRING_TOKEN (STR_DRVCFG_CTRL_LANG),
|
---|
754 | gShellDriver1HiiHandle,
|
---|
755 | HandleIndex1,
|
---|
756 | HandleIndex2,
|
---|
757 | DriverConfiguration->SupportedLanguages
|
---|
758 | );
|
---|
759 |
|
---|
760 | if (ForceDefaults) {
|
---|
761 | Status = DriverConfiguration->ForceDefaults (
|
---|
762 | DriverConfiguration,
|
---|
763 | HandleBuffer[LoopCounter],
|
---|
764 | NULL,
|
---|
765 | DefaultType,
|
---|
766 | &ActionRequired
|
---|
767 | );
|
---|
768 |
|
---|
769 | if (!EFI_ERROR (Status)) {
|
---|
770 | ShellPrintHiiEx(
|
---|
771 | -1,
|
---|
772 | -1,
|
---|
773 | NULL,
|
---|
774 | STRING_TOKEN (STR_DRVCFG_DEF_FORCED),
|
---|
775 | gShellDriver1HiiHandle);
|
---|
776 | ShellCmdDriverConfigurationProcessActionRequired (
|
---|
777 | DriverImageHandleBuffer[OuterLoopCounter],
|
---|
778 | HandleBuffer[LoopCounter],
|
---|
779 | NULL,
|
---|
780 | ActionRequired
|
---|
781 | );
|
---|
782 | } else {
|
---|
783 | ShellPrintHiiEx(
|
---|
784 | -1,
|
---|
785 | -1,
|
---|
786 | NULL,
|
---|
787 | STRING_TOKEN (STR_DRVCFG_FORCE_FAILED),
|
---|
788 | gShellDriver1HiiHandle,
|
---|
789 | Status);
|
---|
790 | ShellStatus = SHELL_DEVICE_ERROR;
|
---|
791 | }
|
---|
792 | } else if (ValidateOptions) {
|
---|
793 | Status = DriverConfiguration->OptionsValid (
|
---|
794 | DriverConfiguration,
|
---|
795 | HandleBuffer[LoopCounter],
|
---|
796 | NULL
|
---|
797 | );
|
---|
798 |
|
---|
799 | if (!EFI_ERROR (Status)) {
|
---|
800 | ShellPrintHiiEx(
|
---|
801 | -1,
|
---|
802 | -1,
|
---|
803 | NULL,
|
---|
804 | STRING_TOKEN (STR_DRVCFG_OPTIONS_VALID),
|
---|
805 | gShellDriver1HiiHandle);
|
---|
806 | } else {
|
---|
807 | ShellPrintHiiEx(
|
---|
808 | -1,
|
---|
809 | -1,
|
---|
810 | NULL,
|
---|
811 | STRING_TOKEN (STR_DRVCFG_OPTIONS_INV),
|
---|
812 | gShellDriver1HiiHandle,
|
---|
813 | Status);
|
---|
814 | ShellStatus = SHELL_DEVICE_ERROR;
|
---|
815 | }
|
---|
816 | } else if (SetOptions) {
|
---|
817 | gST->ConOut->ClearScreen (gST->ConOut);
|
---|
818 | Status = DriverConfiguration->SetOptions (
|
---|
819 | DriverConfiguration,
|
---|
820 | HandleBuffer[LoopCounter],
|
---|
821 | NULL,
|
---|
822 | BestLanguage,
|
---|
823 | &ActionRequired
|
---|
824 | );
|
---|
825 | gST->ConOut->ClearScreen (gST->ConOut);
|
---|
826 | HandleIndex1 = ConvertHandleToHandleIndex (DriverImageHandleBuffer[OuterLoopCounter]);
|
---|
827 | HandleIndex2 = ConvertHandleToHandleIndex (HandleBuffer[LoopCounter]);
|
---|
828 | ShellPrintHiiEx(
|
---|
829 | -1,
|
---|
830 | -1,
|
---|
831 | NULL,
|
---|
832 | STRING_TOKEN (STR_DRVCFG_CTRL_LANG),
|
---|
833 | gShellDriver1HiiHandle,
|
---|
834 | HandleIndex1,
|
---|
835 | HandleIndex2,
|
---|
836 | DriverConfiguration->SupportedLanguages
|
---|
837 | );
|
---|
838 | if (!EFI_ERROR (Status)) {
|
---|
839 | ShellPrintHiiEx(
|
---|
840 | -1,
|
---|
841 | -1,
|
---|
842 | NULL,
|
---|
843 | STRING_TOKEN (STR_DRVCFG_OPTIONS_SET),
|
---|
844 | gShellDriver1HiiHandle);
|
---|
845 |
|
---|
846 | ShellCmdDriverConfigurationProcessActionRequired (
|
---|
847 | DriverImageHandleBuffer[OuterLoopCounter],
|
---|
848 | HandleBuffer[LoopCounter],
|
---|
849 | NULL,
|
---|
850 | ActionRequired
|
---|
851 | );
|
---|
852 |
|
---|
853 | } else {
|
---|
854 | ShellPrintHiiEx(
|
---|
855 | -1,
|
---|
856 | -1,
|
---|
857 | NULL,
|
---|
858 | STRING_TOKEN (STR_DRVCFG_NOT_SET),
|
---|
859 | gShellDriver1HiiHandle,
|
---|
860 | Status);
|
---|
861 | ShellStatus = SHELL_DEVICE_ERROR;
|
---|
862 | }
|
---|
863 | } else {
|
---|
864 | Print (L"\n");
|
---|
865 | }
|
---|
866 | }
|
---|
867 |
|
---|
868 | if (ChildHandle == NULL && !AllChildren) {
|
---|
869 | continue;
|
---|
870 | }
|
---|
871 |
|
---|
872 | Status = ParseHandleDatabaseByRelationshipWithType (
|
---|
873 | DriverImageHandleBuffer[OuterLoopCounter],
|
---|
874 | HandleBuffer[LoopCounter],
|
---|
875 | &ChildHandleCount,
|
---|
876 | &ChildHandleBuffer,
|
---|
877 | &ChildHandleType
|
---|
878 | );
|
---|
879 | if (EFI_ERROR (Status)) {
|
---|
880 | continue;
|
---|
881 | }
|
---|
882 |
|
---|
883 | for (ChildIndex = 0; ChildIndex < ChildHandleCount; ChildIndex++) {
|
---|
884 |
|
---|
885 | if ((ChildHandleType[ChildIndex] & HR_CHILD_HANDLE) != HR_CHILD_HANDLE) {
|
---|
886 | continue;
|
---|
887 | }
|
---|
888 |
|
---|
889 | if (ChildHandle != NULL && ChildHandle != ChildHandleBuffer[ChildIndex]) {
|
---|
890 | continue;
|
---|
891 | }
|
---|
892 |
|
---|
893 | HandleIndex1 = ConvertHandleToHandleIndex (DriverImageHandleBuffer[OuterLoopCounter]);
|
---|
894 | HandleIndex2 = ConvertHandleToHandleIndex (HandleBuffer[LoopCounter]);
|
---|
895 | HandleIndex3 = ConvertHandleToHandleIndex (ChildHandleBuffer[ChildIndex]);
|
---|
896 | ShellPrintHiiEx(
|
---|
897 | -1,
|
---|
898 | -1,
|
---|
899 | NULL,
|
---|
900 | STRING_TOKEN (STR_DRVCFG_CHILD_LANG),
|
---|
901 | gShellDriver1HiiHandle,
|
---|
902 | HandleIndex1,
|
---|
903 | HandleIndex2,
|
---|
904 | HandleIndex3,
|
---|
905 | DriverConfiguration->SupportedLanguages);
|
---|
906 |
|
---|
907 | if (ForceDefaults) {
|
---|
908 | Status = DriverConfiguration->ForceDefaults (
|
---|
909 | DriverConfiguration,
|
---|
910 | HandleBuffer[LoopCounter],
|
---|
911 | ChildHandleBuffer[ChildIndex],
|
---|
912 | DefaultType,
|
---|
913 | &ActionRequired
|
---|
914 | );
|
---|
915 |
|
---|
916 | if (!EFI_ERROR (Status)) {
|
---|
917 | ShellPrintHiiEx(
|
---|
918 | -1,
|
---|
919 | -1,
|
---|
920 | NULL,
|
---|
921 | STRING_TOKEN (STR_DRVCFG_DEF_FORCED),
|
---|
922 | gShellDriver1HiiHandle);
|
---|
923 |
|
---|
924 | ShellCmdDriverConfigurationProcessActionRequired (
|
---|
925 | DriverImageHandleBuffer[OuterLoopCounter],
|
---|
926 | HandleBuffer[LoopCounter],
|
---|
927 | ChildHandleBuffer[ChildIndex],
|
---|
928 | ActionRequired
|
---|
929 | );
|
---|
930 |
|
---|
931 | } else {
|
---|
932 | ShellPrintHiiEx(
|
---|
933 | -1,
|
---|
934 | -1,
|
---|
935 | NULL,
|
---|
936 | STRING_TOKEN (STR_DRVCFG_FORCE_FAILED),
|
---|
937 | gShellDriver1HiiHandle,
|
---|
938 | Status);
|
---|
939 | ShellStatus = SHELL_DEVICE_ERROR;
|
---|
940 | }
|
---|
941 | } else if (ValidateOptions) {
|
---|
942 | Status = DriverConfiguration->OptionsValid (
|
---|
943 | DriverConfiguration,
|
---|
944 | HandleBuffer[LoopCounter],
|
---|
945 | ChildHandleBuffer[ChildIndex]
|
---|
946 | );
|
---|
947 |
|
---|
948 | if (!EFI_ERROR (Status)) {
|
---|
949 | ShellPrintHiiEx(
|
---|
950 | -1,
|
---|
951 | -1,
|
---|
952 | NULL,
|
---|
953 | STRING_TOKEN (STR_DRVCFG_OPTIONS_VALID),
|
---|
954 | gShellDriver1HiiHandle);
|
---|
955 | } else {
|
---|
956 | ShellPrintHiiEx(
|
---|
957 | -1,
|
---|
958 | -1,
|
---|
959 | NULL,
|
---|
960 | STRING_TOKEN (STR_DRVCFG_OPTIONS_INV),
|
---|
961 | gShellDriver1HiiHandle,
|
---|
962 | Status);
|
---|
963 | ShellStatus = SHELL_DEVICE_ERROR;
|
---|
964 | }
|
---|
965 | } else if (SetOptions) {
|
---|
966 | gST->ConOut->ClearScreen (gST->ConOut);
|
---|
967 | Status = DriverConfiguration->SetOptions (
|
---|
968 | DriverConfiguration,
|
---|
969 | HandleBuffer[LoopCounter],
|
---|
970 | ChildHandleBuffer[ChildIndex],
|
---|
971 | BestLanguage,
|
---|
972 | &ActionRequired
|
---|
973 | );
|
---|
974 | gST->ConOut->ClearScreen (gST->ConOut);
|
---|
975 | HandleIndex1 = ConvertHandleToHandleIndex (DriverImageHandleBuffer[OuterLoopCounter]);
|
---|
976 | HandleIndex2 = ConvertHandleToHandleIndex (HandleBuffer[LoopCounter]);
|
---|
977 | HandleIndex3 = ConvertHandleToHandleIndex (ChildHandleBuffer[ChildIndex]);
|
---|
978 | ShellPrintHiiEx(
|
---|
979 | -1,
|
---|
980 | -1,
|
---|
981 | NULL,
|
---|
982 | STRING_TOKEN (STR_DRVCFG_CHILD_LANG),
|
---|
983 | gShellDriver1HiiHandle,
|
---|
984 | HandleIndex1,
|
---|
985 | HandleIndex2,
|
---|
986 | HandleIndex3,
|
---|
987 | DriverConfiguration->SupportedLanguages
|
---|
988 | );
|
---|
989 | if (!EFI_ERROR (Status)) {
|
---|
990 | ShellPrintHiiEx(
|
---|
991 | -1,
|
---|
992 | -1,
|
---|
993 | NULL,
|
---|
994 | STRING_TOKEN (STR_DRVCFG_OPTIONS_SET),
|
---|
995 | gShellDriver1HiiHandle);
|
---|
996 |
|
---|
997 | ShellCmdDriverConfigurationProcessActionRequired (
|
---|
998 | DriverImageHandleBuffer[OuterLoopCounter],
|
---|
999 | HandleBuffer[LoopCounter],
|
---|
1000 | ChildHandleBuffer[ChildIndex],
|
---|
1001 | ActionRequired
|
---|
1002 | );
|
---|
1003 |
|
---|
1004 | } else {
|
---|
1005 | ShellPrintHiiEx(
|
---|
1006 | -1,
|
---|
1007 | -1,
|
---|
1008 | NULL,
|
---|
1009 | STRING_TOKEN (STR_DRVCFG_NOT_SET),
|
---|
1010 | gShellDriver1HiiHandle,
|
---|
1011 | Status);
|
---|
1012 | ShellStatus = SHELL_DEVICE_ERROR;
|
---|
1013 | }
|
---|
1014 | } else {
|
---|
1015 | Print (L"\n");
|
---|
1016 | }
|
---|
1017 | }
|
---|
1018 |
|
---|
1019 | FreePool (ChildHandleBuffer);
|
---|
1020 | FreePool (ChildHandleType);
|
---|
1021 | }
|
---|
1022 |
|
---|
1023 | FreePool (BestLanguage);
|
---|
1024 | FreePool (HandleBuffer);
|
---|
1025 | FreePool (HandleType);
|
---|
1026 | }
|
---|
1027 |
|
---|
1028 | if (DriverImageHandle != NULL && DriverImageHandleCount != 0) {
|
---|
1029 | FreePool (DriverImageHandleBuffer);
|
---|
1030 | }
|
---|
1031 |
|
---|
1032 | Done:
|
---|
1033 | return ShellStatus;
|
---|
1034 | }
|
---|
1035 |
|
---|
1036 | /**
|
---|
1037 | Function to print out configuration information on all configurable handles.
|
---|
1038 |
|
---|
1039 | @param[in] ChildrenToo TRUE to tewst for children.
|
---|
1040 | @param[in] Language ASCII string for language code.
|
---|
1041 | @param[in] UseHii TRUE to check for Hii and DPC, FALSE for DCP only.
|
---|
1042 |
|
---|
1043 | @retval SHELL_SUCCESS The operation was successful.
|
---|
1044 | **/
|
---|
1045 | SHELL_STATUS
|
---|
1046 | EFIAPI
|
---|
1047 | PrintConfigInfoOnAll(
|
---|
1048 | IN CONST BOOLEAN ChildrenToo,
|
---|
1049 | IN CONST CHAR8 *Language,
|
---|
1050 | IN CONST BOOLEAN UseHii
|
---|
1051 | )
|
---|
1052 | {
|
---|
1053 | EFI_HANDLE *HandleList;
|
---|
1054 | EFI_HANDLE *CurrentHandle;
|
---|
1055 | BOOLEAN Found;
|
---|
1056 | UINTN Index2;
|
---|
1057 |
|
---|
1058 |
|
---|
1059 | Found = FALSE;
|
---|
1060 | HandleList = NULL;
|
---|
1061 | CurrentHandle = NULL;
|
---|
1062 |
|
---|
1063 | if (UseHii) {
|
---|
1064 | //
|
---|
1065 | // HII method
|
---|
1066 | //
|
---|
1067 | HandleList = GetHandleListByProtocol(&gEfiHiiConfigAccessProtocolGuid);
|
---|
1068 | for (CurrentHandle = HandleList ; CurrentHandle != NULL && *CurrentHandle != NULL; CurrentHandle++){
|
---|
1069 | Found = TRUE;
|
---|
1070 | Index2 = *CurrentHandle == NULL ? 0 : ConvertHandleToHandleIndex(*CurrentHandle);
|
---|
1071 | ShellPrintHiiEx(
|
---|
1072 | -1,
|
---|
1073 | -1,
|
---|
1074 | NULL,
|
---|
1075 | STRING_TOKEN (STR_DRVCFG_LINE_HII),
|
---|
1076 | gShellDriver1HiiHandle,
|
---|
1077 | Index2
|
---|
1078 | );
|
---|
1079 | }
|
---|
1080 | SHELL_FREE_NON_NULL(HandleList);
|
---|
1081 | }
|
---|
1082 |
|
---|
1083 | if (PreHiiDrvCfg (
|
---|
1084 | Language,
|
---|
1085 | FALSE,
|
---|
1086 | 0,
|
---|
1087 | ChildrenToo,
|
---|
1088 | FALSE,
|
---|
1089 | FALSE,
|
---|
1090 | 0,
|
---|
1091 | 0,
|
---|
1092 | 0) == SHELL_SUCCESS) {
|
---|
1093 | Found = TRUE;
|
---|
1094 | }
|
---|
1095 |
|
---|
1096 | if (!Found) {
|
---|
1097 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DRVCFG_NONE_FOUND), gShellDriver1HiiHandle);
|
---|
1098 | return (SHELL_SUCCESS);
|
---|
1099 | }
|
---|
1100 |
|
---|
1101 | return (SHELL_SUCCESS);
|
---|
1102 | }
|
---|
1103 |
|
---|
1104 | STATIC CONST SHELL_PARAM_ITEM ParamListHii[] = {
|
---|
1105 | {L"-s", TypeFlag},
|
---|
1106 | {L"-l", TypeValue},
|
---|
1107 | {L"-f", TypeValue},
|
---|
1108 | {L"-o", TypeValue},
|
---|
1109 | {L"-i", TypeValue},
|
---|
1110 | {NULL, TypeMax}
|
---|
1111 | };
|
---|
1112 | STATIC CONST SHELL_PARAM_ITEM ParamListPreHii[] = {
|
---|
1113 | {L"-c", TypeFlag},
|
---|
1114 | {L"-s", TypeFlag},
|
---|
1115 | {L"-v", TypeFlag},
|
---|
1116 | {L"-l", TypeValue},
|
---|
1117 | {L"-f", TypeValue},
|
---|
1118 | {NULL, TypeMax}
|
---|
1119 | };
|
---|
1120 |
|
---|
1121 | /**
|
---|
1122 | Function for 'drvcfg' command.
|
---|
1123 |
|
---|
1124 | @param[in] ImageHandle Handle to the Image (NULL if Internal).
|
---|
1125 | @param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
---|
1126 | **/
|
---|
1127 | SHELL_STATUS
|
---|
1128 | EFIAPI
|
---|
1129 | ShellCommandRunDrvCfg (
|
---|
1130 | IN EFI_HANDLE ImageHandle,
|
---|
1131 | IN EFI_SYSTEM_TABLE *SystemTable
|
---|
1132 | )
|
---|
1133 | {
|
---|
1134 | EFI_STATUS Status;
|
---|
1135 | LIST_ENTRY *Package;
|
---|
1136 | CHAR16 *ProblemParam;
|
---|
1137 | SHELL_STATUS ShellStatus;
|
---|
1138 | CHAR8 *Language;
|
---|
1139 | CONST CHAR16 *Lang;
|
---|
1140 | CONST CHAR16 *HandleIndex1;
|
---|
1141 | CONST CHAR16 *HandleIndex2;
|
---|
1142 | CONST CHAR16 *HandleIndex3;
|
---|
1143 | CONST CHAR16 *ForceTypeString;
|
---|
1144 | BOOLEAN Force;
|
---|
1145 | BOOLEAN Set;
|
---|
1146 | BOOLEAN Validate;
|
---|
1147 | BOOLEAN InFromFile;
|
---|
1148 | BOOLEAN OutToFile;
|
---|
1149 | BOOLEAN AllChildren;
|
---|
1150 | BOOLEAN UseHii;
|
---|
1151 | UINT32 ForceType;
|
---|
1152 | UINT64 Intermediate;
|
---|
1153 | EFI_HANDLE Handle1;
|
---|
1154 | EFI_HANDLE Handle2;
|
---|
1155 | EFI_HANDLE Handle3;
|
---|
1156 | CONST CHAR16 *FileName;
|
---|
1157 |
|
---|
1158 | ShellStatus = SHELL_SUCCESS;
|
---|
1159 | Status = EFI_SUCCESS;
|
---|
1160 | Language = NULL;
|
---|
1161 | UseHii = TRUE;
|
---|
1162 |
|
---|
1163 | //
|
---|
1164 | // initialize the shell lib (we must be in non-auto-init...)
|
---|
1165 | //
|
---|
1166 | Status = ShellInitialize();
|
---|
1167 | ASSERT_EFI_ERROR(Status);
|
---|
1168 |
|
---|
1169 | Status = CommandInit();
|
---|
1170 | ASSERT_EFI_ERROR(Status);
|
---|
1171 |
|
---|
1172 | //
|
---|
1173 | // parse the command line
|
---|
1174 | //
|
---|
1175 | Status = ShellCommandLineParse (ParamListHii, &Package, &ProblemParam, TRUE);
|
---|
1176 | if (EFI_ERROR(Status) || ShellCommandLineGetCount(Package) > 2) {
|
---|
1177 | UseHii = FALSE;
|
---|
1178 | if (Package != NULL) {
|
---|
1179 | ShellCommandLineFreeVarList (Package);
|
---|
1180 | }
|
---|
1181 | SHELL_FREE_NON_NULL(ProblemParam);
|
---|
1182 | Status = ShellCommandLineParse (ParamListPreHii, &Package, &ProblemParam, TRUE);
|
---|
1183 | if (EFI_ERROR(Status)) {
|
---|
1184 | if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
|
---|
1185 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDriver1HiiHandle, ProblemParam);
|
---|
1186 | FreePool(ProblemParam);
|
---|
1187 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
1188 | goto Done;
|
---|
1189 | } else {
|
---|
1190 | ASSERT(FALSE);
|
---|
1191 | }
|
---|
1192 | }
|
---|
1193 | }
|
---|
1194 | if (ShellStatus == SHELL_SUCCESS) {
|
---|
1195 | Lang = ShellCommandLineGetValue(Package, L"-l");
|
---|
1196 | if (Lang != NULL) {
|
---|
1197 | Language = AllocateZeroPool(StrSize(Lang));
|
---|
1198 | AsciiSPrint(Language, StrSize(Lang), "%S", Lang);
|
---|
1199 | } else if (ShellCommandLineGetFlag(Package, L"-l")){
|
---|
1200 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"-l");
|
---|
1201 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
1202 | goto Done;
|
---|
1203 | }
|
---|
1204 | Set = ShellCommandLineGetFlag (Package, L"-s");
|
---|
1205 | Validate = ShellCommandLineGetFlag (Package, L"-v");
|
---|
1206 | InFromFile = ShellCommandLineGetFlag (Package, L"-i");
|
---|
1207 | OutToFile = ShellCommandLineGetFlag (Package, L"-o");
|
---|
1208 | AllChildren = ShellCommandLineGetFlag (Package, L"-c");
|
---|
1209 | Force = ShellCommandLineGetFlag (Package, L"-f");
|
---|
1210 | ForceTypeString = ShellCommandLineGetValue(Package, L"-f");
|
---|
1211 |
|
---|
1212 | if (OutToFile) {
|
---|
1213 | FileName = ShellCommandLineGetValue(Package, L"-o");
|
---|
1214 | } else if (InFromFile) {
|
---|
1215 | FileName = ShellCommandLineGetValue(Package, L"-i");
|
---|
1216 | } else {
|
---|
1217 | FileName = NULL;
|
---|
1218 | }
|
---|
1219 |
|
---|
1220 | if (InFromFile && EFI_ERROR(ShellFileExists(FileName))) {
|
---|
1221 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FIND_FAIL), gShellDriver1HiiHandle, FileName);
|
---|
1222 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
1223 | goto Done;
|
---|
1224 | }
|
---|
1225 | if (OutToFile && !EFI_ERROR(ShellFileExists(FileName))) {
|
---|
1226 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_EXIST), gShellDriver1HiiHandle, FileName);
|
---|
1227 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
1228 | goto Done;
|
---|
1229 | }
|
---|
1230 | if (Force && ForceTypeString == NULL) {
|
---|
1231 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"-f");
|
---|
1232 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
1233 | goto Done;
|
---|
1234 | }
|
---|
1235 | if (Force) {
|
---|
1236 | Status = ShellConvertStringToUint64(ForceTypeString, &Intermediate, FALSE, FALSE);
|
---|
1237 | if (EFI_ERROR(Status)) {
|
---|
1238 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellDriver1HiiHandle, L"-f");
|
---|
1239 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
1240 | goto Done;
|
---|
1241 | }
|
---|
1242 | ForceType = (UINT32)Intermediate;
|
---|
1243 | } else {
|
---|
1244 | ForceType = 0;
|
---|
1245 | }
|
---|
1246 | HandleIndex1 = ShellCommandLineGetRawValue(Package, 1);
|
---|
1247 | Handle1 = NULL;
|
---|
1248 | if (HandleIndex1 != NULL && !EFI_ERROR(ShellConvertStringToUint64(HandleIndex1, &Intermediate, TRUE, FALSE))) {
|
---|
1249 | Handle1 = ConvertHandleIndexToHandle((UINTN)Intermediate);
|
---|
1250 | if (Handle1 == NULL || (UINT64)(UINTN)Intermediate != Intermediate) {
|
---|
1251 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, HandleIndex1);
|
---|
1252 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
1253 | goto Done;
|
---|
1254 | }
|
---|
1255 | }
|
---|
1256 | HandleIndex2 = ShellCommandLineGetRawValue(Package, 2);
|
---|
1257 | Handle2 = NULL;
|
---|
1258 | if (HandleIndex2 != NULL && !EFI_ERROR(ShellConvertStringToUint64(HandleIndex2, &Intermediate, TRUE, FALSE))) {
|
---|
1259 | Handle2 = ConvertHandleIndexToHandle((UINTN)Intermediate);
|
---|
1260 | if (Handle2 == NULL || (UINT64)(UINTN)Intermediate != Intermediate) {
|
---|
1261 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, HandleIndex2);
|
---|
1262 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
1263 | goto Done;
|
---|
1264 | }
|
---|
1265 | }
|
---|
1266 | HandleIndex3 = ShellCommandLineGetRawValue(Package, 3);
|
---|
1267 | Handle3 = NULL;
|
---|
1268 | if (HandleIndex3 != NULL && !EFI_ERROR(ShellConvertStringToUint64(HandleIndex3, &Intermediate, TRUE, FALSE))) {
|
---|
1269 | Handle3 = ConvertHandleIndexToHandle((UINTN)Intermediate);
|
---|
1270 | if (Handle3 == NULL || (UINT64)(UINTN)Intermediate != Intermediate) {
|
---|
1271 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, HandleIndex3);
|
---|
1272 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
1273 | goto Done;
|
---|
1274 | }
|
---|
1275 | }
|
---|
1276 |
|
---|
1277 | if ((InFromFile || OutToFile) && (FileName == NULL)) {
|
---|
1278 | if (FileName == NULL) {
|
---|
1279 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, InFromFile?L"-i":L"-o");
|
---|
1280 | } else {
|
---|
1281 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_HANDLE_REQ), gShellDriver1HiiHandle);
|
---|
1282 | }
|
---|
1283 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
1284 | goto Done;
|
---|
1285 | }
|
---|
1286 | if (!UseHii && (InFromFile || OutToFile)) {
|
---|
1287 | if (InFromFile) {
|
---|
1288 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDriver1HiiHandle, L"-i");
|
---|
1289 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
1290 | goto Done;
|
---|
1291 | }
|
---|
1292 | if (OutToFile) {
|
---|
1293 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDriver1HiiHandle, L"-o");
|
---|
1294 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
1295 | goto Done;
|
---|
1296 | }
|
---|
1297 | }
|
---|
1298 | if (Validate && Force) {
|
---|
1299 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONF), gShellDriver1HiiHandle, L"-v", L"-f");
|
---|
1300 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
1301 | goto Done;
|
---|
1302 | }
|
---|
1303 | if (Validate && Set) {
|
---|
1304 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONF), gShellDriver1HiiHandle, L"-v", L"-s");
|
---|
1305 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
1306 | goto Done;
|
---|
1307 | }
|
---|
1308 | if (Set && Force) {
|
---|
1309 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONF), gShellDriver1HiiHandle, L"-s", L"-f");
|
---|
1310 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
1311 | goto Done;
|
---|
1312 | }
|
---|
1313 | if (OutToFile && InFromFile) {
|
---|
1314 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONF), gShellDriver1HiiHandle, L"-i", L"-o");
|
---|
1315 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
1316 | goto Done;
|
---|
1317 | }
|
---|
1318 |
|
---|
1319 | //
|
---|
1320 | // We do HII first.
|
---|
1321 | //
|
---|
1322 | if (UseHii) {
|
---|
1323 | if (Handle1 != NULL && EFI_ERROR(gBS->OpenProtocol(Handle1, &gEfiHiiConfigAccessProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
|
---|
1324 | //
|
---|
1325 | // no HII on this handle.
|
---|
1326 | //
|
---|
1327 | ShellStatus = SHELL_UNSUPPORTED;
|
---|
1328 | } else if (Validate) {
|
---|
1329 | } else if (Force) {
|
---|
1330 | } else if (Set) {
|
---|
1331 | } else if (InFromFile) {
|
---|
1332 | ShellStatus = ConfigFromFile(Handle1, FileName);
|
---|
1333 | if (Handle1 != NULL && ShellStatus == SHELL_SUCCESS) {
|
---|
1334 | goto Done;
|
---|
1335 | }
|
---|
1336 | } else if (OutToFile) {
|
---|
1337 | ShellStatus = ConfigToFile(Handle1, FileName);
|
---|
1338 | if (Handle1 != NULL && ShellStatus == SHELL_SUCCESS) {
|
---|
1339 | goto Done;
|
---|
1340 | }
|
---|
1341 | } else if (HandleIndex1 == NULL) {
|
---|
1342 | //
|
---|
1343 | // display all that are configurable
|
---|
1344 | //
|
---|
1345 | ShellStatus = PrintConfigInfoOnAll(AllChildren, Language, UseHii);
|
---|
1346 | goto Done;
|
---|
1347 | } else {
|
---|
1348 | if (!EFI_ERROR(gBS->OpenProtocol(Handle1, &gEfiHiiConfigAccessProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
|
---|
1349 | ShellPrintHiiEx(
|
---|
1350 | -1,
|
---|
1351 | -1,
|
---|
1352 | NULL,
|
---|
1353 | STRING_TOKEN (STR_DRVCFG_LINE_HII),
|
---|
1354 | gShellDriver1HiiHandle,
|
---|
1355 | ConvertHandleToHandleIndex(Handle1)
|
---|
1356 | );
|
---|
1357 | goto Done;
|
---|
1358 | }
|
---|
1359 | }
|
---|
1360 | }
|
---|
1361 |
|
---|
1362 | //
|
---|
1363 | // We allways need to do this one since it does both by default.
|
---|
1364 | //
|
---|
1365 | if (!InFromFile && !OutToFile) {
|
---|
1366 | ShellStatus = PreHiiDrvCfg (
|
---|
1367 | Language,
|
---|
1368 | Force,
|
---|
1369 | ForceType,
|
---|
1370 | AllChildren,
|
---|
1371 | Validate,
|
---|
1372 | Set,
|
---|
1373 | Handle1,
|
---|
1374 | Handle2,
|
---|
1375 | Handle3);
|
---|
1376 | }
|
---|
1377 |
|
---|
1378 | if (ShellStatus == SHELL_UNSUPPORTED) {
|
---|
1379 | ShellPrintHiiEx(
|
---|
1380 | -1,
|
---|
1381 | -1,
|
---|
1382 | NULL,
|
---|
1383 | STRING_TOKEN (STR_DRVCFG_NOT_SUPPORT),
|
---|
1384 | gShellDriver1HiiHandle,
|
---|
1385 | ConvertHandleToHandleIndex(Handle1)
|
---|
1386 | );
|
---|
1387 | }
|
---|
1388 | }
|
---|
1389 |
|
---|
1390 | Done:
|
---|
1391 | ShellCommandLineFreeVarList (Package);
|
---|
1392 | SHELL_FREE_NON_NULL(Language);
|
---|
1393 | return (ShellStatus);
|
---|
1394 | }
|
---|