]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c
OvmfPkg: Add QemuVideoDxe driver
[mirror_edk2.git] / ShellPkg / Library / UefiShellDebug1CommandsLib / Bcfg.c
CommitLineData
5d73d92f 1/** @file\r
3737ac2b 2 Main file for bcfg shell Debug1 function.\r
5d73d92f 3\r
3737ac2b 4 Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
5d73d92f 5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include "UefiShellDebug1CommandsLib.h"\r
16#include <Guid/GlobalVariable.h>\r
17#include <Library/PrintLib.h>\r
18#include <Library/HandleParsingLib.h>\r
19#include <Library/DevicePathLib.h>\r
20\r
21typedef enum {\r
3737ac2b 22 BcfgTargetBootOrder = 0,\r
23 BcfgTargetDriverOrder = 1,\r
24 BcfgTargetMax = 2\r
5d73d92f 25} BCFG_OPERATION_TARGET;\r
26\r
27typedef enum {\r
3737ac2b 28 BcfgTypeDump = 0,\r
29 BcfgTypeAdd = 1,\r
30 BcfgTypeAddp = 2,\r
31 BcfgTypeAddh = 3,\r
32 BcfgTypeRm = 4,\r
33 BcfgTypeMv = 5,\r
34 BcfgTypeOpt = 6,\r
35 BcfgTypeMax = 7\r
5d73d92f 36} BCFG_OPERATION_TYPE;\r
37\r
38typedef struct {\r
39 BCFG_OPERATION_TARGET Target;\r
40 BCFG_OPERATION_TYPE Type;\r
41 UINT16 Number1;\r
42 UINT16 Number2;\r
43 UINTN HandleIndex;\r
44 CHAR16 *FileName;\r
45 CHAR16 *Description;\r
46 UINT16 *Order;\r
47 CONST CHAR16 *OptData;\r
48} BGFG_OPERATION;\r
49\r
3737ac2b 50/**\r
51 Function to add a option.\r
52\r
53 @param[in] Position The position to add Target at.\r
54 @param[in] File The file to make the target.\r
55 @param[in] Desc The description text.\r
56 @param[in] CurrentOrder The pointer to the current order of items.\r
57 @param[in] OrderCount The number if items in CurrentOrder.\r
58 @param[in] Target The info on the option to add.\r
59 @param[in] UseHandle TRUE to use HandleNumber, FALSE to use File and Desc.\r
60 @param[in] UsePath TRUE to convert to devicepath.\r
61 @param[in] HandleNumber The handle number to add.\r
62\r
63 @retval SHELL_SUCCESS The operation was successful.\r
64 @retval SHELL_INVALID_PARAMETER A parameter was invalid.\r
65**/\r
5d73d92f 66SHELL_STATUS\r
67EFIAPI\r
3737ac2b 68BcfgAddDebug1(\r
5d73d92f 69 IN UINTN Position,\r
70 IN CONST CHAR16 *File,\r
71 IN CONST CHAR16 *Desc,\r
72 IN CONST UINT16 *CurrentOrder,\r
73 IN CONST UINTN OrderCount,\r
74 IN CONST BCFG_OPERATION_TARGET Target,\r
75 IN CONST BOOLEAN UseHandle,\r
76 IN CONST BOOLEAN UsePath,\r
77 IN CONST UINTN HandleNumber\r
78 )\r
79{\r
80 EFI_STATUS Status;\r
3737ac2b 81 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
82 EFI_DEVICE_PATH_PROTOCOL *FilePath;\r
83 EFI_DEVICE_PATH_PROTOCOL *FileNode;\r
84 EFI_DEVICE_PATH_PROTOCOL *DevPath;\r
5d73d92f 85 CHAR16 *Str;\r
3737ac2b 86 CONST CHAR16 *StringWalker;\r
87 UINT8 *TempByteBuffer;\r
88 UINT8 *TempByteStart;\r
5d73d92f 89 EFI_SHELL_FILE_INFO *Arg;\r
90 EFI_SHELL_FILE_INFO *FileList;\r
91 CHAR16 OptionStr[40];\r
92 UINTN DescSize, FilePathSize;\r
93 BOOLEAN Found;\r
94 UINTN TargetLocation;\r
95 UINTN Index;\r
96 EFI_HANDLE *Handles;\r
97 EFI_HANDLE CurHandle;\r
98 UINTN DriverBindingHandleCount;\r
99 UINTN ParentControllerHandleCount;\r
100 UINTN ChildControllerHandleCount;\r
101 SHELL_STATUS ShellStatus;\r
102 UINT16 *NewOrder;\r
3737ac2b 103 UINT64 Intermediate;\r
5d73d92f 104\r
105 if (!UseHandle) {\r
3737ac2b 106 if (File == NULL || Desc == NULL) {\r
107 return (SHELL_INVALID_PARAMETER);\r
108 }\r
5d73d92f 109 } else {\r
3737ac2b 110 if (HandleNumber == 0) {\r
111 return (SHELL_INVALID_PARAMETER);\r
112 }\r
5d73d92f 113 }\r
114\r
3737ac2b 115 if (Position > OrderCount) {\r
116 Position = OrderCount;\r
117 }\r
5d73d92f 118\r
119 Str = NULL;\r
120 FilePath = NULL;\r
121 FileNode = NULL;\r
122 FileList = NULL;\r
123 Handles = NULL;\r
124 ShellStatus = SHELL_SUCCESS;\r
125 TargetLocation = 0xFFFF;\r
126\r
5d73d92f 127 if (UseHandle) {\r
3737ac2b 128 Status = ShellConvertStringToUint64(File, &Intermediate, TRUE, FALSE);\r
129 CurHandle = ConvertHandleIndexToHandle((UINTN)Intermediate);\r
130 if (CurHandle == NULL || EFI_ERROR(Status)) {\r
5d73d92f 131 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, File);\r
132 ShellStatus = SHELL_INVALID_PARAMETER;\r
133 } else {\r
134 //\r
135 //Make sure that the handle should point to a real controller\r
136 //\r
137 Status = PARSE_HANDLE_DATABASE_UEFI_DRIVERS (\r
138 CurHandle,\r
139 &DriverBindingHandleCount,\r
140 NULL);\r
141\r
142 Status = PARSE_HANDLE_DATABASE_PARENTS (\r
143 CurHandle,\r
144 &ParentControllerHandleCount,\r
145 NULL);\r
146\r
147 Status = ParseHandleDatabaseForChildControllers (\r
148 CurHandle,\r
149 &ChildControllerHandleCount,\r
150 NULL);\r
151\r
152 if (DriverBindingHandleCount > 0\r
153 || ParentControllerHandleCount > 0\r
154 || ChildControllerHandleCount > 0) {\r
155 FilePath = NULL;\r
156 Status = gBS->HandleProtocol (\r
157 CurHandle,\r
158 &gEfiDevicePathProtocolGuid,\r
159 (VOID**)&FilePath);\r
160 }\r
161 if (EFI_ERROR (Status)) {\r
3737ac2b 162 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_HANDLE), gShellDebug1HiiHandle, Intermediate);\r
5d73d92f 163 ShellStatus = SHELL_INVALID_PARAMETER;\r
164 }\r
165 }\r
166 } else {\r
167 //\r
168 // Get file info\r
169 //\r
170 ShellOpenFileMetaArg ((CHAR16*)File, EFI_FILE_MODE_READ, &FileList);\r
171\r
3737ac2b 172 if (FileList == NULL) {\r
173 //\r
174 // If filename matched nothing fail\r
175 //\r
176 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, File);\r
177 ShellStatus = SHELL_INVALID_PARAMETER;\r
178 } else if (FileList->Link.ForwardLink != FileList->Link.BackLink) {\r
179 //\r
180 // If filename expanded to multiple names, fail\r
181 //\r
5d73d92f 182 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_FILE), gShellDebug1HiiHandle, File);\r
183 ShellStatus = SHELL_INVALID_PARAMETER;\r
184 } else {\r
185 Arg = (EFI_SHELL_FILE_INFO*)GetFirstNode(&FileList->Link);\r
186 if (EFI_ERROR(Arg->Status)) {\r
187 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_FILE_OPEN), gShellDebug1HiiHandle, File, Arg->Status);\r
188 ShellStatus = SHELL_INVALID_PARAMETER;\r
189 } else {\r
190 //\r
191 // Build FilePath to the filename\r
192 //\r
193\r
194 //\r
195 // get the device path\r
196 //\r
197 DevicePath = mEfiShellProtocol->GetDevicePathFromFilePath(Arg->FullName);\r
3737ac2b 198 if (DevicePath == NULL) {\r
5d73d92f 199 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_FILE_DP), gShellDebug1HiiHandle, Arg->FullName);\r
200 ShellStatus = SHELL_UNSUPPORTED;\r
201 } else {\r
202 if (UsePath) {\r
203 DevPath = DevicePath;\r
204 while (!IsDevicePathEnd(DevPath)) {\r
205 if ((DevicePathType(DevPath) == MEDIA_DEVICE_PATH) &&\r
206 (DevicePathSubType(DevPath) == MEDIA_HARDDRIVE_DP)) {\r
207\r
208 //\r
209 // If we find it use it instead\r
210 //\r
211 DevicePath = DevPath;\r
212 break;\r
213 }\r
214 DevPath = NextDevicePathNode(DevPath);\r
215 }\r
216 //\r
217 // append the file\r
218 //\r
3737ac2b 219 for(StringWalker=Arg->FullName; *StringWalker != CHAR_NULL && *StringWalker != ':'; StringWalker++);\r
220 FileNode = FileDevicePath(NULL, StringWalker+1);\r
5d73d92f 221 FilePath = AppendDevicePath(DevicePath, FileNode);\r
222 FreePool(FileNode);\r
223 } else {\r
224 FilePath = DuplicateDevicePath(DevicePath);\r
225 }\r
226\r
227 FreePool(DevicePath);\r
228 }\r
229 }\r
230 }\r
231 }\r
232\r
233\r
234 if (ShellStatus == SHELL_SUCCESS) {\r
235 //\r
236 // Find a free target ,a brute force implementation\r
237 //\r
238 Found = FALSE;\r
3737ac2b 239 for (TargetLocation=0; TargetLocation < 0xFFFF; TargetLocation++) {\r
5d73d92f 240 Found = TRUE;\r
241 for (Index=0; Index < OrderCount; Index++) {\r
242 if (CurrentOrder[Index] == TargetLocation) {\r
243 Found = FALSE;\r
244 break;\r
245 }\r
246 }\r
247\r
248 if (Found) {\r
249 break;\r
250 }\r
251 }\r
252\r
253 if (TargetLocation == 0xFFFF) {\r
254 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_TARGET_NF), gShellDebug1HiiHandle);\r
255 } else {\r
256 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_TARGET), gShellDebug1HiiHandle, TargetLocation);\r
257 }\r
258 }\r
259\r
260 if (ShellStatus == SHELL_SUCCESS) {\r
261 //\r
262 // Add the option\r
263 //\r
264 DescSize = StrSize(Desc);\r
265 FilePathSize = GetDevicePathSize (FilePath);\r
266\r
3737ac2b 267 TempByteBuffer = AllocateZeroPool(sizeof(UINT32) + sizeof(UINT16) + DescSize + FilePathSize);\r
33c031ee 268 if (TempByteBuffer != NULL) {\r
269 TempByteStart = TempByteBuffer;\r
270 *((UINT32 *) TempByteBuffer) = LOAD_OPTION_ACTIVE; // Attributes\r
271 TempByteBuffer += sizeof (UINT32);\r
5d73d92f 272\r
33c031ee 273 *((UINT16 *) TempByteBuffer) = (UINT16)FilePathSize; // FilePathListLength\r
274 TempByteBuffer += sizeof (UINT16);\r
5d73d92f 275\r
33c031ee 276 CopyMem (TempByteBuffer, Desc, DescSize);\r
277 TempByteBuffer += DescSize;\r
278 CopyMem (TempByteBuffer, FilePath, FilePathSize);\r
5d73d92f 279\r
33c031ee 280 UnicodeSPrint (OptionStr, sizeof(OptionStr), L"%s%04x", Target == BcfgTargetBootOrder?L"Boot":L"Driver", TargetLocation);\r
281 Status = gRT->SetVariable (\r
282 OptionStr,\r
283 &gEfiGlobalVariableGuid,\r
284 EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,\r
285 sizeof(UINT32) + sizeof(UINT16) + DescSize + FilePathSize,\r
286 TempByteStart\r
287 );\r
288\r
289 FreePool(TempByteStart);\r
290 } else {\r
291 Status = EFI_OUT_OF_RESOURCES;\r
292 }\r
5d73d92f 293\r
294 if (EFI_ERROR(Status)) {\r
295 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_SET_VAR_FAIL), gShellDebug1HiiHandle, OptionStr, Status);\r
296 } else {\r
3737ac2b 297 NewOrder = AllocateZeroPool((OrderCount+1)*sizeof(NewOrder[0]));\r
5d73d92f 298 ASSERT(NewOrder != NULL);\r
299 CopyMem(NewOrder, CurrentOrder, (OrderCount)*sizeof(NewOrder[0]));\r
300\r
301 //\r
302 // Insert target into order list\r
303 //\r
304 for (Index=OrderCount; Index > Position; Index--) {\r
305 NewOrder[Index] = NewOrder[Index-1];\r
306 }\r
307\r
308 NewOrder[Position] = (UINT16) TargetLocation;\r
309 Status = gRT->SetVariable (\r
3737ac2b 310 Target == BcfgTargetBootOrder?L"BootOrder":L"DriverOrder",\r
5d73d92f 311 &gEfiGlobalVariableGuid,\r
312 EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,\r
313 (OrderCount+1) * sizeof(UINT16),\r
314 NewOrder\r
315 );\r
316\r
317 FreePool(NewOrder);\r
318\r
319 if (EFI_ERROR(Status)) {\r
3737ac2b 320 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_WRITE_FAIL), gShellDebug1HiiHandle, Target == BcfgTargetBootOrder?L"BootOrder":L"DriverOrder", Status);\r
5d73d92f 321 ShellStatus = SHELL_INVALID_PARAMETER;\r
322 } else {\r
323 Print (L"bcfg: Add %s as %x\n", OptionStr, Position);\r
324 }\r
325 }\r
326 }\r
5d73d92f 327\r
328//\r
329//If always Free FilePath, will free devicepath in system when use "addh"\r
330//\r
5d73d92f 331 if (FilePath!=NULL && !UseHandle) {\r
332 FreePool (FilePath);\r
333 }\r
334\r
335 if (Str != NULL) {\r
336 FreePool(Str);\r
337 }\r
338\r
339 if (Handles != NULL) {\r
340 FreePool (Handles);\r
341 }\r
342\r
343 if (FileList != NULL) {\r
344 ShellCloseFileMetaArg (&FileList);\r
345 }\r
346\r
347 return (ShellStatus);\r
348}\r
349\r
3737ac2b 350/**\r
351 Funciton to remove an item.\r
352\r
353 @param[in] Target The target item to move.\r
354 @param[in] CurrentOrder The pointer to the current order of items.\r
355 @param[in] OrderCount The number if items in CurrentOrder.\r
356 @param[in] Location The current location of the Target.\r
357\r
358 @retval SHELL_SUCCESS The operation was successful.\r
359 @retval SHELL_INVALID_PARAMETER A parameter was invalid.\r
360**/\r
5d73d92f 361SHELL_STATUS\r
362EFIAPI\r
3737ac2b 363BcfgRemoveDebug1(\r
5d73d92f 364 IN CONST BCFG_OPERATION_TARGET Target,\r
365 IN CONST UINT16 *CurrentOrder,\r
366 IN CONST UINTN OrderCount,\r
367 IN CONST UINT16 Location\r
368 )\r
369{\r
370 CHAR16 VariableName[12];\r
371 UINT16 *NewOrder;\r
372 EFI_STATUS Status;\r
373 UINTN LoopVar;\r
374 UINTN NewCount;\r
375\r
3737ac2b 376 UnicodeSPrint(VariableName, sizeof(VariableName), L"%s%04x", Target == BcfgTargetBootOrder?L"Boot":L"Driver", Location);\r
5d73d92f 377 Status = gRT->SetVariable(\r
378 VariableName,\r
379 (EFI_GUID*)&gEfiGlobalVariableGuid,\r
380 EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,\r
381 0,\r
382 NULL);\r
383 if (EFI_ERROR(Status)) {\r
384 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_WRITE_FAIL), gShellDebug1HiiHandle, VariableName, Status);\r
385 return (SHELL_INVALID_PARAMETER);\r
386 }\r
3737ac2b 387 NewOrder = AllocateZeroPool(OrderCount*sizeof(CurrentOrder[0]));\r
33c031ee 388 if (NewOrder != NULL) {\r
389 NewCount = OrderCount;\r
390 CopyMem(NewOrder, CurrentOrder, OrderCount*sizeof(CurrentOrder[0]));\r
391 for (LoopVar = 0 ; LoopVar < OrderCount ; LoopVar++){\r
392 if (NewOrder[LoopVar] == Location) {\r
393 CopyMem(NewOrder+LoopVar, NewOrder+LoopVar+1, (OrderCount - LoopVar - 1)*sizeof(CurrentOrder[0]));\r
394 NewCount--;\r
395 }\r
5d73d92f 396 }\r
33c031ee 397 Status = gRT->SetVariable(\r
398 Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder",\r
399 (EFI_GUID*)&gEfiGlobalVariableGuid,\r
400 EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,\r
401 NewCount*sizeof(NewOrder[0]),\r
402 NewOrder);\r
403 FreePool(NewOrder);\r
404 } else {\r
405 Status = EFI_OUT_OF_RESOURCES;\r
5d73d92f 406 }\r
5d73d92f 407 if (EFI_ERROR(Status)) {\r
3737ac2b 408 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_WRITE_FAIL), gShellDebug1HiiHandle, Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder", Status);\r
5d73d92f 409 return (SHELL_INVALID_PARAMETER);\r
410 }\r
411 return (SHELL_SUCCESS);\r
412}\r
413\r
3737ac2b 414/**\r
415 Funciton to move a item to another location.\r
416\r
417 @param[in] Target The target item to move.\r
418 @param[in] CurrentOrder The pointer to the current order of items.\r
419 @param[in] OrderCount The number if items in CurrentOrder.\r
420 @param[in] OldLocation The current location of the Target.\r
421 @param[in] NewLocation The desired location of the Target.\r
422\r
423 @retval SHELL_SUCCESS The operation was successful.\r
424 @retval SHELL_INVALID_PARAMETER A parameter was invalid.\r
425**/\r
5d73d92f 426SHELL_STATUS\r
427EFIAPI\r
3737ac2b 428BcfgMoveDebug1(\r
5d73d92f 429 IN CONST BCFG_OPERATION_TARGET Target,\r
430 IN CONST UINT16 *CurrentOrder,\r
431 IN CONST UINTN OrderCount,\r
432 IN CONST UINT16 OldLocation,\r
433 IN CONST UINT16 NewLocation\r
434 )\r
435{\r
436 UINT16 *NewOrder;\r
437 EFI_STATUS Status;\r
438 UINT16 Temp;\r
439\r
3737ac2b 440 NewOrder = AllocateZeroPool(OrderCount*sizeof(CurrentOrder[0]));\r
5d73d92f 441 ASSERT(NewOrder != NULL);\r
442\r
443 Temp = CurrentOrder[OldLocation];\r
444 CopyMem(NewOrder, CurrentOrder, OrderCount*sizeof(CurrentOrder[0]));\r
445 CopyMem(NewOrder+OldLocation, NewOrder+OldLocation+1, (OrderCount - OldLocation - 1)*sizeof(CurrentOrder[0]));\r
446 CopyMem(NewOrder+NewLocation+1, NewOrder+NewLocation, (OrderCount - NewLocation - 1)*sizeof(CurrentOrder[0]));\r
447 NewOrder[NewLocation] = Temp;\r
448\r
449\r
450 Status = gRT->SetVariable(\r
3737ac2b 451 Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder",\r
5d73d92f 452 (EFI_GUID*)&gEfiGlobalVariableGuid,\r
453 EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,\r
454 OrderCount*sizeof(CurrentOrder[0]),\r
455 NewOrder);\r
456\r
457 FreePool(NewOrder);\r
458\r
459 if (EFI_ERROR(Status)) {\r
3737ac2b 460 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_WRITE_FAIL), gShellDebug1HiiHandle, Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder", Status);\r
5d73d92f 461 return (SHELL_INVALID_PARAMETER);\r
462 }\r
463 return (SHELL_SUCCESS);\r
464}\r
465\r
f2ad804f 466/**\r
467 Function to add optional data to an option.\r
468\r
469 @param[in] OptData The optional data to add.\r
470 @param[in] Target The target of the operation.\r
471\r
472 @retval SHELL_SUCCESS The operation was succesful.\r
473**/\r
5d73d92f 474SHELL_STATUS\r
475EFIAPI\r
3737ac2b 476BcfgAddOptDebug1(\r
477 IN CONST CHAR16 *OptData,\r
478 IN CONST BCFG_OPERATION_TARGET Target\r
479 )\r
480{\r
481 ASSERT(OptData != NULL);\r
482 return SHELL_SUCCESS;\r
483}\r
484\r
485/**\r
486 Function to dump the Bcfg information.\r
487\r
488 @param[in] Op The operation.\r
489 @param[in] OrderCount How many to dump.\r
490 @param[in] CurrentOrder The pointer to the current order of items.\r
491 @param[in] VerboseOutput TRUE for extra output. FALSE otherwise.\r
492\r
493 @retval SHELL_SUCCESS The dump was successful.\r
494 @retval SHELL_INVALID_PARAMETER A parameter was invalid.\r
495**/\r
496SHELL_STATUS\r
497EFIAPI\r
498BcfgDisplayDumpDebug1(\r
5d73d92f 499 IN CONST CHAR16 *Op,\r
3737ac2b 500 IN CONST UINTN OrderCount,\r
501 IN CONST UINT16 *CurrentOrder,\r
5d73d92f 502 IN CONST BOOLEAN VerboseOutput\r
503 )\r
504{\r
505 EFI_STATUS Status;\r
506 UINT8 *Buffer;\r
507 UINTN BufferSize;\r
508 CHAR16 VariableName[12];\r
509 UINTN LoopVar;\r
510 UINTN LoopVar2;\r
511 CHAR16 *DevPathString;\r
512 VOID *DevPath;\r
513\r
3737ac2b 514 if (OrderCount == 0) {\r
515 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_BCFG_NONE), gShellDebug1HiiHandle);\r
516 return (SHELL_SUCCESS);\r
517 }\r
518\r
5d73d92f 519 for (LoopVar = 0 ; LoopVar < OrderCount ; LoopVar++) {\r
520 Buffer = NULL;\r
521 BufferSize = 0;\r
3737ac2b 522 UnicodeSPrint(VariableName, sizeof(VariableName), L"%s%04x", Op, CurrentOrder[LoopVar]);\r
5d73d92f 523\r
524 Status = gRT->GetVariable(\r
525 VariableName,\r
526 (EFI_GUID*)&gEfiGlobalVariableGuid,\r
527 NULL,\r
528 &BufferSize,\r
529 Buffer);\r
530 if (Status == EFI_BUFFER_TOO_SMALL) {\r
3737ac2b 531 Buffer = AllocateZeroPool(BufferSize);\r
5d73d92f 532 Status = gRT->GetVariable(\r
533 VariableName,\r
534 (EFI_GUID*)&gEfiGlobalVariableGuid,\r
535 NULL,\r
536 &BufferSize,\r
537 Buffer);\r
538 }\r
539\r
540 if (EFI_ERROR(Status) || Buffer == NULL) {\r
541 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_READ_FAIL), gShellDebug1HiiHandle, VariableName, Status);\r
542 return (SHELL_INVALID_PARAMETER);\r
543 }\r
544\r
3737ac2b 545 DevPath = AllocateZeroPool(*(UINT16*)(Buffer+4));\r
5d73d92f 546 CopyMem(DevPath, Buffer+6+StrSize((CHAR16*)(Buffer+6)), *(UINT16*)(Buffer+4));\r
547 DevPathString = gDevPathToText->ConvertDevicePathToText(DevPath, TRUE, FALSE);\r
548 ShellPrintHiiEx(\r
549 -1,\r
550 -1,\r
551 NULL,\r
552 STRING_TOKEN(STR_BCFG_LOAD_OPTIONS),\r
553 gShellDebug1HiiHandle,\r
3737ac2b 554 LoopVar,\r
5d73d92f 555 VariableName,\r
556 (CHAR16*)(Buffer+6),\r
557 DevPathString,\r
558 (StrSize((CHAR16*)(Buffer+6)) + *(UINT16*)(Buffer+4) + 6) <= BufferSize?L'N':L'Y');\r
559 if (VerboseOutput) {\r
560 for (LoopVar2 = (StrSize((CHAR16*)(Buffer+6)) + *(UINT16*)(Buffer+4) + 6);LoopVar2<BufferSize;LoopVar2++){\r
561 ShellPrintEx(\r
562 -1,\r
563 -1,\r
564 NULL,\r
565 L"%02x",\r
566 Buffer[LoopVar2]);\r
567 }\r
568 ShellPrintEx(\r
569 -1,\r
570 -1,\r
571 NULL,\r
572 L"\r\n");\r
573 }\r
574\r
575 if (Buffer != NULL) {\r
576 FreePool(Buffer);\r
577 }\r
578 if (DevPath != NULL) {\r
579 FreePool(DevPath);\r
580 }\r
581 if (DevPathString != NULL) {\r
582 FreePool(DevPathString);\r
583 }\r
584 }\r
585 return (SHELL_SUCCESS);\r
586}\r
587\r
3737ac2b 588/**\r
589 Function to initialize the BCFG operation structure.\r
590\r
591 @param[in] Struct The stuct to initialize.\r
592**/\r
5d73d92f 593VOID\r
594EFIAPI\r
3737ac2b 595InitBcfgStructDebug1(\r
5d73d92f 596 IN BGFG_OPERATION *Struct\r
597 )\r
598{\r
599 ASSERT(Struct != NULL);\r
3737ac2b 600 Struct->Target = BcfgTargetMax;\r
601 Struct->Type = BcfgTypeMax;\r
5d73d92f 602 Struct->Number1 = 0;\r
603 Struct->Number2 = 0;\r
604 Struct->HandleIndex = 0;\r
605 Struct->FileName = NULL;\r
606 Struct->Description = NULL;\r
607 Struct->Order = NULL;\r
608 Struct->OptData = NULL;\r
609}\r
610\r
611\r
612STATIC CONST SHELL_PARAM_ITEM ParamList[] = {\r
613 {L"-v", TypeFlag},\r
614 {L"-opt", TypeMaxValue},\r
615 {NULL, TypeMax}\r
616 };\r
617\r
618/**\r
619 Function for 'bcfg' command.\r
620\r
621 @param[in] ImageHandle Handle to the Image (NULL if Internal).\r
622 @param[in] SystemTable Pointer to the System Table (NULL if Internal).\r
623**/\r
624SHELL_STATUS\r
625EFIAPI\r
626ShellCommandRunBcfg (\r
627 IN EFI_HANDLE ImageHandle,\r
628 IN EFI_SYSTEM_TABLE *SystemTable\r
629 )\r
630{\r
631 EFI_STATUS Status;\r
632 LIST_ENTRY *Package;\r
633 CHAR16 *ProblemParam;\r
634 SHELL_STATUS ShellStatus;\r
635 UINTN ParamNumber;\r
636 CONST CHAR16 *CurrentParam;\r
637 BGFG_OPERATION CurrentOperation;\r
638 UINTN Length;\r
3737ac2b 639 UINT64 Intermediate;\r
5d73d92f 640\r
641 Length = 0;\r
642 ProblemParam = NULL;\r
643 Package = NULL;\r
644 ShellStatus = SHELL_SUCCESS;\r
645\r
3737ac2b 646 InitBcfgStructDebug1(&CurrentOperation);\r
5d73d92f 647\r
648 //\r
649 // initialize the shell lib (we must be in non-auto-init...)\r
650 //\r
651 Status = ShellInitialize();\r
652 ASSERT_EFI_ERROR(Status);\r
653\r
654 Status = CommandInit();\r
655 ASSERT_EFI_ERROR(Status);\r
656\r
657 //\r
658 // parse the command line\r
659 //\r
660 Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);\r
661 if (EFI_ERROR(Status)) {\r
662 if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
663 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam);\r
664 FreePool(ProblemParam);\r
665 ShellStatus = SHELL_INVALID_PARAMETER;\r
666 } else {\r
667 ASSERT(FALSE);\r
668 }\r
669 } else {\r
3737ac2b 670 //\r
671 // Read in if we are doing -OPT\r
672 //\r
673 if (ShellCommandLineGetFlag(Package, L"-opt")) {\r
674 CurrentOperation.OptData = ShellCommandLineGetValue(Package, L"-opt");\r
675 if (CurrentOperation.OptData == NULL) {\r
676 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellDebug1HiiHandle, L"-opt");\r
677 ShellStatus = SHELL_INVALID_PARAMETER;\r
678 }\r
679 CurrentOperation.Type = BcfgTypeOpt;\r
680 }\r
681\r
5d73d92f 682 //\r
683 // small block to read the target of the operation\r
684 //\r
3737ac2b 685 if ((ShellCommandLineGetCount(Package) < 3 && CurrentOperation.Type != BcfgTypeOpt) ||\r
686 (ShellCommandLineGetCount(Package) < 2 && CurrentOperation.Type == BcfgTypeOpt)\r
687 ){\r
5d73d92f 688 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle);\r
689 ShellStatus = SHELL_INVALID_PARAMETER;\r
690 } else if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)ShellCommandLineGetRawValue(Package, 1), L"driver") == 0) {\r
3737ac2b 691 CurrentOperation.Target = BcfgTargetDriverOrder;\r
5d73d92f 692 } else if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)ShellCommandLineGetRawValue(Package, 1), L"boot") == 0) {\r
3737ac2b 693 CurrentOperation.Target = BcfgTargetBootOrder;\r
5d73d92f 694 } else {\r
695 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_DRIVER_BOOT), gShellDebug1HiiHandle);\r
696 ShellStatus = SHELL_INVALID_PARAMETER;\r
697 }\r
698\r
5d73d92f 699\r
700 //\r
701 // Read in the boot or driver order environment variable (not needed for opt)\r
702 //\r
3737ac2b 703 if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target < BcfgTargetMax && CurrentOperation.Type != BcfgTypeOpt) {\r
5d73d92f 704 Length = 0;\r
705 Status = gRT->GetVariable(\r
3737ac2b 706 CurrentOperation.Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder",\r
5d73d92f 707 (EFI_GUID*)&gEfiGlobalVariableGuid,\r
708 NULL,\r
709 &Length,\r
710 CurrentOperation.Order);\r
711 if (Status == EFI_BUFFER_TOO_SMALL) {\r
3737ac2b 712 CurrentOperation.Order = AllocateZeroPool(Length+(4*sizeof(CurrentOperation.Order[0])));\r
5d73d92f 713 Status = gRT->GetVariable(\r
3737ac2b 714 CurrentOperation.Target == BcfgTargetBootOrder?(CHAR16*)L"BootOrder":(CHAR16*)L"DriverOrder",\r
5d73d92f 715 (EFI_GUID*)&gEfiGlobalVariableGuid,\r
716 NULL,\r
717 &Length,\r
718 CurrentOperation.Order);\r
719 }\r
720 }\r
721\r
722 //\r
723 // large block to read the type of operation and verify parameter types for the info.\r
724 //\r
3737ac2b 725 if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target < BcfgTargetMax) {\r
5d73d92f 726 for (ParamNumber = 2 ; ParamNumber < ShellCommandLineGetCount(Package) && ShellStatus == SHELL_SUCCESS; ParamNumber++) {\r
727 CurrentParam = ShellCommandLineGetRawValue(Package, ParamNumber);\r
728 if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)CurrentParam, L"dump") == 0) {\r
3737ac2b 729 CurrentOperation.Type = BcfgTypeDump;\r
5d73d92f 730 } else if (ShellCommandLineGetFlag(Package, L"-v")) {\r
731 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"-v (without dump)");\r
732 ShellStatus = SHELL_INVALID_PARAMETER;\r
733 } else if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)CurrentParam, L"add") == 0) {\r
734 if ((ParamNumber + 3) >= ShellCommandLineGetCount(Package)) {\r
735 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle);\r
736 ShellStatus = SHELL_INVALID_PARAMETER;\r
737 }\r
3737ac2b 738 CurrentOperation.Type = BcfgTypeAdd;\r
5d73d92f 739 CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber);\r
740 if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) {\r
741 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, CurrentParam);\r
742 ShellStatus = SHELL_INVALID_PARAMETER;\r
743 } else {\r
3737ac2b 744 Status = ShellConvertStringToUint64(CurrentParam, &Intermediate, TRUE, FALSE);\r
745 CurrentOperation.Number1 = (UINT16)Intermediate;\r
5d73d92f 746 ASSERT(CurrentOperation.FileName == NULL);\r
747 CurrentOperation.FileName = StrnCatGrow(&CurrentOperation.FileName , NULL, ShellCommandLineGetRawValue(Package, ++ParamNumber), 0);\r
748 ASSERT(CurrentOperation.Description == NULL);\r
749 CurrentOperation.Description = StrnCatGrow(&CurrentOperation.Description, NULL, ShellCommandLineGetRawValue(Package, ++ParamNumber), 0);\r
750 }\r
751 } else if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)CurrentParam, L"addp") == 0) {\r
752 if ((ParamNumber + 3) >= ShellCommandLineGetCount(Package)) {\r
753 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle);\r
754 ShellStatus = SHELL_INVALID_PARAMETER;\r
755 }\r
3737ac2b 756 CurrentOperation.Type = BcfgTypeAddp;\r
5d73d92f 757 CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber);\r
758 if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) {\r
759 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, CurrentParam);\r
760 ShellStatus = SHELL_INVALID_PARAMETER;\r
761 } else {\r
3737ac2b 762 Status = ShellConvertStringToUint64(CurrentParam, &Intermediate, TRUE, FALSE);\r
763 CurrentOperation.Number1 = (UINT16)Intermediate;\r
5d73d92f 764 ASSERT(CurrentOperation.FileName == NULL);\r
765 CurrentOperation.FileName = StrnCatGrow(&CurrentOperation.FileName , NULL, ShellCommandLineGetRawValue(Package, ++ParamNumber), 0);\r
766 ASSERT(CurrentOperation.Description == NULL);\r
767 CurrentOperation.Description = StrnCatGrow(&CurrentOperation.Description, NULL, ShellCommandLineGetRawValue(Package, ++ParamNumber), 0);\r
768 }\r
769 } else if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)CurrentParam, L"addh") == 0) {\r
770 if ((ParamNumber + 3) >= ShellCommandLineGetCount(Package)) {\r
771 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle);\r
772 ShellStatus = SHELL_INVALID_PARAMETER;\r
773 }\r
3737ac2b 774 CurrentOperation.Type = BcfgTypeAddh;\r
5d73d92f 775 CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber);\r
776 if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) {\r
777 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, CurrentParam);\r
778 ShellStatus = SHELL_INVALID_PARAMETER;\r
779 } else {\r
3737ac2b 780 Status = ShellConvertStringToUint64(CurrentParam, &Intermediate, TRUE, FALSE);\r
781 CurrentOperation.Number1 = (UINT16)Intermediate;\r
5d73d92f 782 CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber);\r
783 if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) {\r
784 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, CurrentParam);\r
785 ShellStatus = SHELL_INVALID_PARAMETER;\r
786 } else {\r
3737ac2b 787 Status = ShellConvertStringToUint64(CurrentParam, &Intermediate, TRUE, FALSE);\r
788 CurrentOperation.HandleIndex = (UINT16)Intermediate;\r
5d73d92f 789 ASSERT(CurrentOperation.Description == NULL);\r
790 CurrentOperation.Description = StrnCatGrow(&CurrentOperation.Description, NULL, ShellCommandLineGetRawValue(Package, ++ParamNumber), 0);\r
791 }\r
792 }\r
793 } else if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)CurrentParam, L"rm") == 0) {\r
794 if ((ParamNumber + 1) >= ShellCommandLineGetCount(Package)) {\r
795 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle);\r
796 ShellStatus = SHELL_INVALID_PARAMETER;\r
797 }\r
3737ac2b 798 CurrentOperation.Type = BcfgTypeRm;\r
5d73d92f 799 CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber);\r
800 if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) {\r
801 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, CurrentParam);\r
802 ShellStatus = SHELL_INVALID_PARAMETER;\r
803 } else {\r
3737ac2b 804 Status = ShellConvertStringToUint64(CurrentParam, &Intermediate, TRUE, FALSE);\r
805 CurrentOperation.Number1 = (UINT16)Intermediate;\r
5d73d92f 806 if (CurrentOperation.Number1 > (Length / sizeof(CurrentOperation.Order[0]))){\r
807 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_NUMB_RANGE), gShellDebug1HiiHandle, Length / sizeof(CurrentOperation.Order[0]));\r
808 ShellStatus = SHELL_INVALID_PARAMETER;\r
809 }\r
810 }\r
811 } else if (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)CurrentParam, L"mv") == 0) {\r
812 if ((ParamNumber + 2) >= ShellCommandLineGetCount(Package)) {\r
813 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle);\r
814 ShellStatus = SHELL_INVALID_PARAMETER;\r
815 }\r
3737ac2b 816 CurrentOperation.Type = BcfgTypeMv;\r
5d73d92f 817 CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber);\r
818 if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) {\r
819 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, CurrentParam);\r
820 ShellStatus = SHELL_INVALID_PARAMETER;\r
821 } else {\r
3737ac2b 822 Status = ShellConvertStringToUint64(CurrentParam, &Intermediate, TRUE, FALSE);\r
823 CurrentOperation.Number1 = (UINT16)Intermediate;\r
5d73d92f 824 if (CurrentOperation.Number1 > (Length / sizeof(CurrentOperation.Order[0]))){\r
825 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_NUMB_RANGE), gShellDebug1HiiHandle, Length / sizeof(CurrentOperation.Order[0]));\r
826 ShellStatus = SHELL_INVALID_PARAMETER;\r
827 }\r
828 CurrentParam = ShellCommandLineGetRawValue(Package, ++ParamNumber);\r
829 if (CurrentParam == NULL || !ShellIsHexOrDecimalNumber(CurrentParam, TRUE, FALSE)) {\r
830 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, CurrentParam);\r
831 ShellStatus = SHELL_INVALID_PARAMETER;\r
832 } else {\r
3737ac2b 833 Status = ShellConvertStringToUint64(CurrentParam, &Intermediate, TRUE, FALSE);\r
834 CurrentOperation.Number2 = (UINT16)Intermediate;\r
5d73d92f 835 }\r
836 if (CurrentOperation.Number2 == CurrentOperation.Number1\r
837 ||CurrentOperation.Number1 > (Length / sizeof(CurrentOperation.Order[0]))\r
838 ||CurrentOperation.Number2 > (Length / sizeof(CurrentOperation.Order[0]))\r
839 ){\r
840 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_NUMB_RANGE), gShellDebug1HiiHandle, Length / sizeof(CurrentOperation.Order[0]));\r
841 ShellStatus = SHELL_INVALID_PARAMETER;\r
842 }\r
843 }\r
844 } else {\r
845 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, CurrentParam);\r
846 ShellStatus = SHELL_INVALID_PARAMETER;\r
847 }\r
848 }\r
849 }\r
3737ac2b 850 if (ShellStatus == SHELL_SUCCESS && CurrentOperation.Target < BcfgTargetMax && CurrentOperation.Type < BcfgTypeMax) {\r
5d73d92f 851 //\r
852 // we have all the info. Do the work\r
853 //\r
854 switch (CurrentOperation.Type) {\r
3737ac2b 855 case BcfgTypeDump:\r
856 ShellStatus = BcfgDisplayDumpDebug1(\r
857 CurrentOperation.Target == BcfgTargetBootOrder?L"Boot":L"Driver",\r
5d73d92f 858 Length / sizeof(CurrentOperation.Order[0]),\r
3737ac2b 859 CurrentOperation.Order,\r
5d73d92f 860 ShellCommandLineGetFlag(Package, L"-v"));\r
861 break;\r
3737ac2b 862 case BcfgTypeMv:\r
863 ShellStatus = BcfgMoveDebug1(\r
5d73d92f 864 CurrentOperation.Target,\r
865 CurrentOperation.Order,\r
866 Length / sizeof(CurrentOperation.Order[0]),\r
867 CurrentOperation.Number1,\r
868 CurrentOperation.Number2);\r
869 break;\r
3737ac2b 870 case BcfgTypeRm:\r
871 ShellStatus = BcfgRemoveDebug1(\r
5d73d92f 872 CurrentOperation.Target,\r
873 CurrentOperation.Order,\r
874 Length / sizeof(CurrentOperation.Order[0]),\r
875 CurrentOperation.Number1);\r
876 break;\r
3737ac2b 877 case BcfgTypeAdd:\r
878 case BcfgTypeAddp:\r
879 case BcfgTypeAddh:\r
880 ShellStatus = BcfgAddDebug1(\r
5d73d92f 881 CurrentOperation.Number1,\r
882 CurrentOperation.FileName,\r
883 CurrentOperation.Description,\r
884 CurrentOperation.Order,\r
3737ac2b 885 Length / sizeof(CurrentOperation.Order[0]),\r
5d73d92f 886 CurrentOperation.Target,\r
3737ac2b 887 (BOOLEAN)(CurrentOperation.Type == BcfgTypeAddh),\r
888 (BOOLEAN)(CurrentOperation.Type == BcfgTypeAddp),\r
5d73d92f 889 CurrentOperation.HandleIndex);\r
890 break;\r
3737ac2b 891 case BcfgTypeOpt:\r
892 ShellStatus = BcfgAddOptDebug1(\r
893 CurrentOperation.OptData,\r
894 CurrentOperation.Target);\r
895 break;\r
5d73d92f 896 default:\r
897 ASSERT(FALSE);\r
898 }\r
899 }\r
900 }\r
901\r
902 if (Package != NULL) {\r
903 ShellCommandLineFreeVarList (Package);\r
904 }\r
905 if (CurrentOperation.FileName != NULL) {\r
906 FreePool(CurrentOperation.FileName);\r
907 }\r
908 if (CurrentOperation.Description != NULL) {\r
909 FreePool(CurrentOperation.Description);\r
910 }\r
911 if (CurrentOperation.Order != NULL) {\r
912 FreePool(CurrentOperation.Order);\r
913 }\r
914\r
915 return (ShellStatus);\r
916}\r