]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel2CommandsLib / Map.c
1 /** @file
2 Main file for map shell level 2 command.
3
4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
5 (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
6 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
7
8 SPDX-License-Identifier: BSD-2-Clause-Patent
9
10 **/
11
12 #include "UefiShellLevel2CommandsLib.h"
13 #include <Protocol/SimpleFileSystem.h>
14 #include <Protocol/BlockIo.h>
15 #include <Library/DevicePathLib.h>
16 #include <Library/HandleParsingLib.h>
17 #include <Library/SortLib.h>
18
19 /**
20 Determine if a string has only numbers and letters.
21
22 This is useful for such things as Map names which can only be letters and numbers.
23
24 @param[in] String pointer to the string to analyze,
25 @param[in] Len Number of characters to analyze.
26
27 @retval TRUE String has only numbers and letters
28 @retval FALSE String has at least one other character.
29 **/
30 BOOLEAN
31 IsNumberLetterOnly (
32 IN CONST CHAR16 *String,
33 IN CONST UINTN Len
34 )
35 {
36 UINTN Count;
37
38 for (Count = 0; Count < Len && String != NULL && *String != CHAR_NULL; String++, Count++) {
39 if (!(((*String >= L'a') && (*String <= L'z')) ||
40 ((*String >= L'A') && (*String <= L'Z')) ||
41 ((*String >= L'0') && (*String <= L'9')))
42 )
43 {
44 return (FALSE);
45 }
46 }
47
48 return (TRUE);
49 }
50
51 /**
52 Do a search in the Target delimited list.
53
54 @param[in] List The list to seatch in.
55 @param[in] MetaTarget The item to search for. MetaMatching supported.
56 @param[out] FullName Optional pointer to an allocated buffer containing
57 the match.
58 @param[in] Meta TRUE to use MetaMatching.
59 @param[in] SkipTrailingNumbers TRUE to allow for numbers after the MetaTarget.
60 @param[in] Target The single character that delimits list
61 items (";" normally).
62 **/
63 BOOLEAN
64 SearchList (
65 IN CONST CHAR16 *List,
66 IN CONST CHAR16 *MetaTarget,
67 OUT CHAR16 **FullName OPTIONAL,
68 IN CONST BOOLEAN Meta,
69 IN CONST BOOLEAN SkipTrailingNumbers,
70 IN CONST CHAR16 *Target
71
72 )
73 {
74 CHAR16 *TempList;
75 CONST CHAR16 *ListWalker;
76 BOOLEAN Result;
77 CHAR16 *TempSpot;
78
79 for (ListWalker = List, TempList = NULL
80 ; ListWalker != NULL && *ListWalker != CHAR_NULL
81 ;
82 )
83 {
84 TempList = StrnCatGrow (&TempList, NULL, ListWalker, 0);
85 ASSERT (TempList != NULL);
86 TempSpot = StrStr (TempList, Target);
87 if (TempSpot != NULL) {
88 *TempSpot = CHAR_NULL;
89 }
90
91 while (SkipTrailingNumbers && (ShellIsDecimalDigitCharacter (TempList[StrLen (TempList)-1]) || TempList[StrLen (TempList)-1] == L':')) {
92 TempList[StrLen (TempList)-1] = CHAR_NULL;
93 }
94
95 ListWalker = StrStr (ListWalker, Target);
96 while (ListWalker != NULL && *ListWalker == *Target) {
97 ListWalker++;
98 }
99
100 if (Meta) {
101 Result = gUnicodeCollation->MetaiMatch (gUnicodeCollation, (CHAR16 *)TempList, (CHAR16 *)MetaTarget);
102 } else {
103 Result = (BOOLEAN)(StrCmp (TempList, MetaTarget) == 0);
104 }
105
106 if (Result) {
107 if (FullName != NULL) {
108 *FullName = TempList;
109 } else {
110 FreePool (TempList);
111 }
112
113 return (TRUE);
114 }
115
116 FreePool (TempList);
117 TempList = NULL;
118 }
119
120 return (FALSE);
121 }
122
123 /**
124 Determine what type of device is represented and return it's string. The
125 string is in allocated memory and must be callee freed. The HII is is listed below.
126 The actual string cannot be determined.
127
128 @param[in] DevicePath The device to analyze.
129
130 @retval STR_MAP_MEDIA_UNKNOWN The media type is unknown.
131 @retval STR_MAP_MEDIA_HARDDISK The media is a hard drive.
132 @retval STR_MAP_MEDIA_CDROM The media is a CD ROM.
133 @retval STR_MAP_MEDIA_FLOPPY The media is a floppy drive.
134 **/
135 CHAR16 *
136 GetDeviceMediaType (
137 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
138 )
139 {
140 ACPI_HID_DEVICE_PATH *Acpi;
141
142 //
143 // Parse the device path:
144 // Devicepath sub type mediatype
145 // MEDIA_HANRDDRIVE_DP -> Hard Disk
146 // MEDIA_CDROM_DP -> CD Rom
147 // Acpi.HID = 0X0604 -> Floppy
148 //
149 if (NULL == DevicePath) {
150 return HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_MAP_MEDIA_UNKNOWN), NULL);
151 }
152
153 for ( ; !IsDevicePathEndType (DevicePath); DevicePath = NextDevicePathNode (DevicePath)) {
154 if (DevicePathType (DevicePath) == MEDIA_DEVICE_PATH) {
155 switch (DevicePathSubType (DevicePath)) {
156 case MEDIA_HARDDRIVE_DP:
157 return HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_MAP_MEDIA_HARDDISK), NULL);
158 case MEDIA_CDROM_DP:
159 return HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_MAP_MEDIA_CDROM), NULL);
160 }
161 } else if (DevicePathType (DevicePath) == ACPI_DEVICE_PATH) {
162 Acpi = (ACPI_HID_DEVICE_PATH *)DevicePath;
163 if (EISA_ID_TO_NUM (Acpi->HID) == 0x0604) {
164 return HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_MAP_MEDIA_FLOPPY), NULL);
165 }
166 }
167 }
168
169 return HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_MAP_MEDIA_UNKNOWN), NULL);
170 }
171
172 /**
173 Function to detemine if a handle has removable storage.
174
175 @param[in] DevicePath DevicePath to test.
176
177 @retval TRUE The handle has removable storage.
178 @retval FALSE The handle does not have removable storage.
179 **/
180 BOOLEAN
181 IsRemoveableDevice (
182 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
183 )
184 {
185 if (NULL == DevicePath) {
186 return FALSE;
187 }
188
189 while (!IsDevicePathEndType (DevicePath)) {
190 if (DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) {
191 switch (DevicePathSubType (DevicePath)) {
192 case MSG_USB_DP:
193 case MSG_SCSI_DP:
194 return TRUE;
195 default:
196 return FALSE;
197 }
198 }
199
200 DevicePath = NextDevicePathNode (DevicePath);
201 }
202
203 return FALSE;
204 }
205
206 /**
207 Function to detemine if a something on the map list matches.
208
209 @param[in] MapList The pointer to the list to test.
210 @param[in] Specific The pointer to a specific name to test for.
211 @param[in] TypeString The pointer to the list of types.
212 @param[in] Normal Always show normal mappings.
213 @param[in] Consist Always show consistent mappings.
214
215 @retval TRUE The map should be displayed.
216 @retval FALSE The map should not be displayed.
217 **/
218 BOOLEAN
219 MappingListHasType (
220 IN CONST CHAR16 *MapList,
221 IN CONST CHAR16 *Specific,
222 IN CONST CHAR16 *TypeString,
223 IN CONST BOOLEAN Normal,
224 IN CONST BOOLEAN Consist
225 )
226 {
227 CHAR16 *NewSpecific;
228 RETURN_STATUS Status;
229 UINTN Length;
230
231 //
232 // specific has priority
233 //
234 if (Specific != NULL) {
235 Length = StrLen (Specific);
236 //
237 // Allocate enough buffer for Specific and potential ":"
238 //
239 NewSpecific = AllocatePool ((Length + 2) * sizeof (CHAR16));
240 if (NewSpecific == NULL) {
241 return FALSE;
242 }
243
244 StrCpyS (NewSpecific, Length + 2, Specific);
245 if (Specific[Length - 1] != L':') {
246 Status = StrnCatS (NewSpecific, Length + 2, L":", StrLen (L":"));
247 if (EFI_ERROR (Status)) {
248 FreePool (NewSpecific);
249 return FALSE;
250 }
251 }
252
253 if (SearchList (MapList, NewSpecific, NULL, TRUE, FALSE, L";")) {
254 FreePool (NewSpecific);
255 return (TRUE);
256 }
257
258 FreePool (NewSpecific);
259 }
260
261 if ( Consist
262 && (Specific == NULL)
263 && ( SearchList (MapList, L"HD*", NULL, TRUE, TRUE, L";")
264 || SearchList (MapList, L"CD*", NULL, TRUE, TRUE, L";")
265 || SearchList (MapList, L"F*", NULL, TRUE, TRUE, L";")
266 || SearchList (MapList, L"FP*", NULL, TRUE, TRUE, L";")))
267 {
268 return (TRUE);
269 }
270
271 if ( Normal
272 && (Specific == NULL)
273 && ( SearchList (MapList, L"FS", NULL, FALSE, TRUE, L";")
274 || SearchList (MapList, L"BLK", NULL, FALSE, TRUE, L";")))
275 {
276 return (TRUE);
277 }
278
279 if ((TypeString != NULL) && SearchList (MapList, TypeString, NULL, TRUE, TRUE, L";")) {
280 return (TRUE);
281 }
282
283 return (FALSE);
284 }
285
286 /**
287 Display a single map line for device Handle if conditions are met.
288
289 @param[in] Verbose TRUE to display (extra) verbose information.
290 @param[in] Consist TRUE to display consistent mappings.
291 @param[in] Normal TRUE to display normal (not consist) mappings.
292 @param[in] TypeString pointer to string of filter types.
293 @param[in] SFO TRUE to display output in Standard Output Format.
294 @param[in] Specific pointer to string for specific map to display.
295 @param[in] Handle The handle to display from.
296
297 @retval EFI_SUCCESS The mapping was displayed.
298 **/
299 EFI_STATUS
300 PerformSingleMappingDisplay (
301 IN CONST BOOLEAN Verbose,
302 IN CONST BOOLEAN Consist,
303 IN CONST BOOLEAN Normal,
304 IN CONST CHAR16 *TypeString,
305 IN CONST BOOLEAN SFO,
306 IN CONST CHAR16 *Specific OPTIONAL,
307 IN CONST EFI_HANDLE Handle
308 )
309 {
310 EFI_DEVICE_PATH_PROTOCOL *DevPath;
311 EFI_DEVICE_PATH_PROTOCOL *DevPathCopy;
312 CONST CHAR16 *MapList;
313 CHAR16 *CurrentName;
314 CHAR16 *MediaType;
315 CHAR16 *DevPathString;
316 CHAR16 *TempSpot;
317 CHAR16 *Alias;
318 UINTN TempLen;
319 BOOLEAN Removable;
320 CONST CHAR16 *TempSpot2;
321
322 Alias = NULL;
323 TempSpot2 = NULL;
324 CurrentName = NULL;
325 DevPath = DevicePathFromHandle (Handle);
326 DevPathCopy = DevPath;
327 MapList = gEfiShellProtocol->GetMapFromDevicePath (&DevPathCopy);
328 if (MapList == NULL) {
329 return EFI_NOT_FOUND;
330 }
331
332 if (!MappingListHasType (MapList, Specific, TypeString, Normal, Consist)) {
333 return EFI_NOT_FOUND;
334 }
335
336 if (Normal || !Consist) {
337 //
338 // need the Normal here since people can use both on command line. otherwise unused.
339 //
340
341 //
342 // Allocate a name
343 //
344 CurrentName = NULL;
345 CurrentName = StrnCatGrow (&CurrentName, 0, MapList, 0);
346 if (CurrentName == NULL) {
347 return (EFI_OUT_OF_RESOURCES);
348 }
349
350 //
351 // Chop off the other names that become "Alias(s)"
352 // leaving just the normal name
353 //
354 TempSpot = StrStr (CurrentName, L";");
355 if (TempSpot != NULL) {
356 *TempSpot = CHAR_NULL;
357 }
358 } else {
359 CurrentName = NULL;
360
361 //
362 // Skip the first name. This is the standard name.
363 //
364 TempSpot = StrStr (MapList, L";");
365 if (TempSpot != NULL) {
366 TempSpot++;
367 }
368
369 SearchList (TempSpot, L"HD*", &CurrentName, TRUE, FALSE, L";");
370 if (CurrentName == NULL) {
371 SearchList (TempSpot, L"CD*", &CurrentName, TRUE, FALSE, L";");
372 }
373
374 if (CurrentName == NULL) {
375 SearchList (TempSpot, L"FP*", &CurrentName, TRUE, FALSE, L";");
376 }
377
378 if (CurrentName == NULL) {
379 SearchList (TempSpot, L"F*", &CurrentName, TRUE, FALSE, L";");
380 }
381
382 if (CurrentName == NULL) {
383 //
384 // We didnt find anything, so just the first one in the list...
385 //
386 CurrentName = StrnCatGrow (&CurrentName, 0, MapList, 0);
387 if (CurrentName == NULL) {
388 return (EFI_OUT_OF_RESOURCES);
389 }
390
391 TempSpot = StrStr (CurrentName, L";");
392 if (TempSpot != NULL) {
393 *TempSpot = CHAR_NULL;
394 }
395 } else {
396 Alias = StrnCatGrow (&Alias, 0, MapList, 0);
397 if (Alias == NULL) {
398 return EFI_OUT_OF_RESOURCES;
399 }
400
401 TempSpot = StrStr (Alias, CurrentName);
402 if (TempSpot != NULL) {
403 TempSpot2 = StrStr (TempSpot, L";");
404 if (TempSpot2 != NULL) {
405 TempSpot2++; // Move past ";" from CurrentName
406 CopyMem (TempSpot, TempSpot2, StrSize (TempSpot2));
407 } else {
408 *TempSpot = CHAR_NULL;
409 }
410 }
411
412 if (Alias[StrLen (Alias)-1] == L';') {
413 Alias[StrLen (Alias)-1] = CHAR_NULL;
414 }
415 }
416 }
417
418 DevPathString = ConvertDevicePathToText (DevPath, TRUE, FALSE);
419 TempLen = StrLen (CurrentName);
420 if (!SFO) {
421 ShellPrintHiiEx (
422 -1,
423 -1,
424 NULL,
425 STRING_TOKEN (STR_MAP_ENTRY),
426 gShellLevel2HiiHandle,
427 CurrentName,
428 Alias != NULL ? Alias : (TempLen < StrLen (MapList) ? MapList + TempLen+1 : L""),
429 DevPathString
430 );
431 if (Verbose) {
432 //
433 // also print handle, media type, removable (y/n), and current directory
434 //
435 MediaType = GetDeviceMediaType (DevPath);
436 if (((TypeString != NULL) && (MediaType != NULL) && (StrStr (TypeString, MediaType) != NULL)) || (TypeString == NULL)) {
437 Removable = IsRemoveableDevice (DevPath);
438 TempSpot2 = ShellGetCurrentDir (CurrentName);
439 ShellPrintHiiEx (
440 -1,
441 -1,
442 NULL,
443 STRING_TOKEN (STR_MAP_ENTRY_VERBOSE),
444 gShellLevel2HiiHandle,
445 ConvertHandleToHandleIndex (Handle),
446 MediaType,
447 Removable ? L"Yes" : L"No",
448 TempSpot2
449 );
450 }
451
452 SHELL_FREE_NON_NULL (MediaType);
453 }
454 } else {
455 ShellPrintHiiEx (
456 -1,
457 -1,
458 NULL,
459 STRING_TOKEN (STR_MAP_SFO_MAPPINGS),
460 gShellLevel2HiiHandle,
461 CurrentName,
462 DevPathString,
463 Consist ? L"" : (TempLen < StrLen (MapList) ? MapList + TempLen+1 : L"")
464 );
465 }
466
467 SHELL_FREE_NON_NULL (DevPathString);
468 SHELL_FREE_NON_NULL (CurrentName);
469 SHELL_FREE_NON_NULL (Alias);
470 return EFI_SUCCESS;
471 }
472
473 /**
474 Delete Specific from the list of maps for device Handle.
475
476 @param[in] Specific The name to delete.
477 @param[in] Handle The device to look on.
478
479 @retval EFI_SUCCESS The delete was successful.
480 @retval EFI_NOT_FOUND Name was not a map on Handle.
481 **/
482 EFI_STATUS
483 PerformSingleMappingDelete (
484 IN CONST CHAR16 *Specific,
485 IN CONST EFI_HANDLE Handle
486 )
487 {
488 EFI_DEVICE_PATH_PROTOCOL *DevPath;
489 EFI_DEVICE_PATH_PROTOCOL *DevPathCopy;
490 CONST CHAR16 *MapList;
491 CHAR16 *CurrentName;
492
493 DevPath = DevicePathFromHandle (Handle);
494 DevPathCopy = DevPath;
495 MapList = gEfiShellProtocol->GetMapFromDevicePath (&DevPathCopy);
496 CurrentName = NULL;
497
498 if (MapList == NULL) {
499 return (EFI_NOT_FOUND);
500 }
501
502 //
503 // if there is a specific and its not on the list...
504 //
505 if (!SearchList (MapList, Specific, &CurrentName, TRUE, FALSE, L";")) {
506 return (EFI_NOT_FOUND);
507 }
508
509 return (gEfiShellProtocol->SetMap (NULL, CurrentName));
510 }
511
512 CONST CHAR16 Cd[] = L"cd*";
513 CONST CHAR16 Hd[] = L"hd*";
514 CONST CHAR16 Fp[] = L"fp*";
515 CONST CHAR16 AnyF[] = L"F*";
516
517 /**
518 Function to display mapping information to the user.
519
520 If Specific is specified then Consist and Normal will be ignored since information will
521 be printed for the specific item only.
522
523 @param[in] Verbose TRUE to display (extra) verbose information.
524 @param[in] Consist TRUE to display consistent mappings.
525 @param[in] Normal TRUE to display normal (not consist) mappings.
526 @param[in] TypeString Pointer to string of filter types.
527 @param[in] SFO TRUE to display output in Standard Output Format.
528 @param[in] Specific Pointer to string for specific map to display.
529 @param[in] Header TRUE to print the header block.
530
531 @retval SHELL_SUCCESS The display was printed.
532 @retval SHELL_INVALID_PARAMETER One of Consist or Normal must be TRUE if no Specific.
533
534 **/
535 SHELL_STATUS
536 PerformMappingDisplay (
537 IN CONST BOOLEAN Verbose,
538 IN CONST BOOLEAN Consist,
539 IN CONST BOOLEAN Normal,
540 IN CONST CHAR16 *TypeString,
541 IN CONST BOOLEAN SFO,
542 IN CONST CHAR16 *Specific OPTIONAL,
543 IN CONST BOOLEAN Header
544 )
545 {
546 EFI_STATUS Status;
547 EFI_HANDLE *HandleBuffer;
548 UINTN BufferSize;
549 UINTN LoopVar;
550 CHAR16 *Test;
551 BOOLEAN Found;
552
553 if (!Consist && !Normal && (Specific == NULL) && (TypeString == NULL)) {
554 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"map");
555 return (SHELL_INVALID_PARAMETER);
556 }
557
558 if (TypeString != NULL) {
559 Test = (CHAR16 *)Cd;
560 if (StrnCmp (TypeString, Test, StrLen (Test)-1) != 0) {
561 Test = (CHAR16 *)Hd;
562 if (StrnCmp (TypeString, Test, StrLen (Test)-1) != 0) {
563 Test = (CHAR16 *)Fp;
564 if (StrnCmp (TypeString, Test, StrLen (Test)-1) != 0) {
565 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", TypeString);
566 return (SHELL_INVALID_PARAMETER);
567 }
568 } else if (Test == NULL) {
569 Test = (CHAR16 *)AnyF;
570 }
571 }
572 } else {
573 Test = NULL;
574 }
575
576 if (Header) {
577 //
578 // Print the header
579 //
580 if (!SFO) {
581 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MAP_HEADER), gShellLevel2HiiHandle);
582 } else {
583 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_SFO_HEADER), gShellLevel2HiiHandle, L"map");
584 }
585 }
586
587 BufferSize = 0;
588 HandleBuffer = NULL;
589
590 //
591 // Look up all SimpleFileSystems in the platform
592 //
593 Status = gBS->LocateHandle (
594 ByProtocol,
595 &gEfiSimpleFileSystemProtocolGuid,
596 NULL,
597 &BufferSize,
598 HandleBuffer
599 );
600 if (Status == EFI_BUFFER_TOO_SMALL) {
601 HandleBuffer = AllocateZeroPool (BufferSize);
602 if (HandleBuffer == NULL) {
603 return (SHELL_OUT_OF_RESOURCES);
604 }
605
606 Status = gBS->LocateHandle (
607 ByProtocol,
608 &gEfiSimpleFileSystemProtocolGuid,
609 NULL,
610 &BufferSize,
611 HandleBuffer
612 );
613 }
614
615 //
616 // Get the map name(s) for each one.
617 //
618 for ( LoopVar = 0, Found = FALSE
619 ; LoopVar < (BufferSize / sizeof (EFI_HANDLE)) && HandleBuffer != NULL
620 ; LoopVar++
621 )
622 {
623 Status = PerformSingleMappingDisplay (
624 Verbose,
625 Consist,
626 Normal,
627 Test,
628 SFO,
629 Specific,
630 HandleBuffer[LoopVar]
631 );
632 if (!EFI_ERROR (Status)) {
633 Found = TRUE;
634 }
635 }
636
637 //
638 // Look up all BlockIo in the platform
639 //
640 Status = gBS->LocateHandle (
641 ByProtocol,
642 &gEfiBlockIoProtocolGuid,
643 NULL,
644 &BufferSize,
645 HandleBuffer
646 );
647 if (Status == EFI_BUFFER_TOO_SMALL) {
648 SHELL_FREE_NON_NULL (HandleBuffer);
649 HandleBuffer = AllocateZeroPool (BufferSize);
650 if (HandleBuffer == NULL) {
651 return (SHELL_OUT_OF_RESOURCES);
652 }
653
654 Status = gBS->LocateHandle (
655 ByProtocol,
656 &gEfiBlockIoProtocolGuid,
657 NULL,
658 &BufferSize,
659 HandleBuffer
660 );
661 }
662
663 if (!EFI_ERROR (Status) && (HandleBuffer != NULL)) {
664 //
665 // Get the map name(s) for each one.
666 //
667 for ( LoopVar = 0
668 ; LoopVar < BufferSize / sizeof (EFI_HANDLE)
669 ; LoopVar++
670 )
671 {
672 //
673 // Skip any that were already done...
674 //
675 if (gBS->OpenProtocol (
676 HandleBuffer[LoopVar],
677 &gEfiSimpleFileSystemProtocolGuid,
678 NULL,
679 gImageHandle,
680 NULL,
681 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
682 ) == EFI_SUCCESS)
683 {
684 continue;
685 }
686
687 Status = PerformSingleMappingDisplay (
688 Verbose,
689 Consist,
690 Normal,
691 Test,
692 SFO,
693 Specific,
694 HandleBuffer[LoopVar]
695 );
696 if (!EFI_ERROR (Status)) {
697 Found = TRUE;
698 }
699 }
700
701 FreePool (HandleBuffer);
702 }
703
704 if (!Found) {
705 if (Specific != NULL) {
706 ShellPrintHiiEx (gST->ConOut->Mode->CursorColumn, gST->ConOut->Mode->CursorRow-1, NULL, STRING_TOKEN (STR_MAP_NF), gShellLevel2HiiHandle, L"map", Specific);
707 } else {
708 ShellPrintHiiEx (gST->ConOut->Mode->CursorColumn, gST->ConOut->Mode->CursorRow-1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle, L"map");
709 }
710 }
711
712 return (SHELL_SUCCESS);
713 }
714
715 /**
716 Perform a mapping display and parse for multiple types in the TypeString.
717
718 @param[in] Verbose TRUE to use verbose output.
719 @param[in] Consist TRUE to display consistent names.
720 @param[in] Normal TRUE to display normal names.
721 @param[in] TypeString An optional comma-delimited list of types.
722 @param[in] SFO TRUE to display in SFO format. See Spec.
723 @param[in] Specific An optional specific map name to display alone.
724
725 @retval SHELL_INVALID_PARAMETER A parameter was invalid.
726 @retval SHELL_SUCCESS The display was successful.
727 @sa PerformMappingDisplay
728 **/
729 SHELL_STATUS
730 PerformMappingDisplay2 (
731 IN CONST BOOLEAN Verbose,
732 IN CONST BOOLEAN Consist,
733 IN CONST BOOLEAN Normal,
734 IN CONST CHAR16 *TypeString,
735 IN CONST BOOLEAN SFO,
736 IN CONST CHAR16 *Specific OPTIONAL
737 )
738 {
739 CONST CHAR16 *TypeWalker;
740 SHELL_STATUS ShellStatus;
741 CHAR16 *Comma;
742
743 if (TypeString == NULL) {
744 return (PerformMappingDisplay (Verbose, Consist, Normal, NULL, SFO, Specific, TRUE));
745 }
746
747 ShellStatus = SHELL_SUCCESS;
748 for (TypeWalker = TypeString; TypeWalker != NULL && *TypeWalker != CHAR_NULL;) {
749 Comma = StrStr (TypeWalker, L",");
750 if (Comma == NULL) {
751 if (ShellStatus == SHELL_SUCCESS) {
752 ShellStatus = PerformMappingDisplay (Verbose, Consist, Normal, TypeWalker, SFO, Specific, (BOOLEAN)(TypeWalker == TypeString));
753 } else {
754 PerformMappingDisplay (Verbose, Consist, Normal, TypeWalker, SFO, Specific, (BOOLEAN)(TypeWalker == TypeString));
755 }
756
757 break;
758 } else {
759 *Comma = CHAR_NULL;
760 if (ShellStatus == SHELL_SUCCESS) {
761 ShellStatus = PerformMappingDisplay (Verbose, Consist, Normal, TypeWalker, SFO, Specific, (BOOLEAN)(TypeWalker == TypeString));
762 } else {
763 PerformMappingDisplay (Verbose, Consist, Normal, TypeWalker, SFO, Specific, (BOOLEAN)(TypeWalker == TypeString));
764 }
765
766 *Comma = L',';
767 TypeWalker = Comma + 1;
768 }
769 }
770
771 return (ShellStatus);
772 }
773
774 /**
775 Delete a specific map.
776
777 @param[in] Specific The pointer to the name of the map to delete.
778
779 @retval EFI_INVALID_PARAMETER Specific was NULL.
780 @retval EFI_SUCCESS The operation was successful.
781 @retval EFI_NOT_FOUND Specific could not be found.
782 **/
783 EFI_STATUS
784 PerformMappingDelete (
785 IN CONST CHAR16 *Specific
786 )
787 {
788 EFI_STATUS Status;
789 EFI_HANDLE *HandleBuffer;
790 UINTN BufferSize;
791 UINTN LoopVar;
792 BOOLEAN Deleted;
793
794 if (Specific == NULL) {
795 return (EFI_INVALID_PARAMETER);
796 }
797
798 BufferSize = 0;
799 HandleBuffer = NULL;
800 Deleted = FALSE;
801
802 //
803 // Look up all SimpleFileSystems in the platform
804 //
805 Status = gBS->LocateHandle (
806 ByProtocol,
807 &gEfiDevicePathProtocolGuid,
808 NULL,
809 &BufferSize,
810 HandleBuffer
811 );
812 if (Status == EFI_BUFFER_TOO_SMALL) {
813 HandleBuffer = AllocateZeroPool (BufferSize);
814 if (HandleBuffer == NULL) {
815 return (EFI_OUT_OF_RESOURCES);
816 }
817
818 Status = gBS->LocateHandle (
819 ByProtocol,
820 &gEfiDevicePathProtocolGuid,
821 NULL,
822 &BufferSize,
823 HandleBuffer
824 );
825 }
826
827 if (EFI_ERROR (Status)) {
828 SHELL_FREE_NON_NULL (HandleBuffer);
829 return (Status);
830 }
831
832 if (HandleBuffer != NULL) {
833 //
834 // Get the map name(s) for each one.
835 //
836 for ( LoopVar = 0
837 ; LoopVar < BufferSize / sizeof (EFI_HANDLE)
838 ; LoopVar++
839 )
840 {
841 if (PerformSingleMappingDelete (Specific, HandleBuffer[LoopVar]) == SHELL_SUCCESS) {
842 Deleted = TRUE;
843 }
844 }
845 }
846
847 //
848 // Look up all BlockIo in the platform
849 //
850 Status = gBS->LocateHandle (
851 ByProtocol,
852 &gEfiBlockIoProtocolGuid,
853 NULL,
854 &BufferSize,
855 HandleBuffer
856 );
857 if (Status == EFI_BUFFER_TOO_SMALL) {
858 FreePool (HandleBuffer);
859 HandleBuffer = AllocateZeroPool (BufferSize);
860 if (HandleBuffer == NULL) {
861 return (EFI_OUT_OF_RESOURCES);
862 }
863
864 Status = gBS->LocateHandle (
865 ByProtocol,
866 &gEfiBlockIoProtocolGuid,
867 NULL,
868 &BufferSize,
869 HandleBuffer
870 );
871 }
872
873 if (EFI_ERROR (Status)) {
874 SHELL_FREE_NON_NULL (HandleBuffer);
875 return (Status);
876 }
877
878 if (HandleBuffer != NULL) {
879 //
880 // Get the map name(s) for each one.
881 //
882 for ( LoopVar = 0
883 ; LoopVar < BufferSize / sizeof (EFI_HANDLE)
884 ; LoopVar++
885 )
886 {
887 //
888 // Skip any that were already done...
889 //
890 if (gBS->OpenProtocol (
891 HandleBuffer[LoopVar],
892 &gEfiDevicePathProtocolGuid,
893 NULL,
894 gImageHandle,
895 NULL,
896 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
897 ) == EFI_SUCCESS)
898 {
899 continue;
900 }
901
902 if (PerformSingleMappingDelete (Specific, HandleBuffer[LoopVar]) == SHELL_SUCCESS) {
903 Deleted = TRUE;
904 }
905 }
906 }
907
908 SHELL_FREE_NON_NULL (HandleBuffer);
909 if (!Deleted) {
910 return (EFI_NOT_FOUND);
911 }
912
913 return (EFI_SUCCESS);
914 }
915
916 /**
917 function to add a mapping from mapping.
918
919 This function will get the device path associated with the mapping and call SetMap.
920
921 @param[in] Map The Map to add a mapping for
922 @param[in] SName The name of the new mapping
923
924 @retval SHELL_SUCCESS the mapping was added
925 @retval SHELL_INVALID_PARAMETER the device path for Map could not be retrieved.
926 @return Shell version of a return value from EfiShellProtocol->SetMap
927
928 **/
929 SHELL_STATUS
930 AddMappingFromMapping (
931 IN CONST CHAR16 *Map,
932 IN CONST CHAR16 *SName
933 )
934 {
935 CONST EFI_DEVICE_PATH_PROTOCOL *DevPath;
936 EFI_STATUS Status;
937 CHAR16 *NewSName;
938 RETURN_STATUS StrRetStatus;
939
940 NewSName = AllocateCopyPool (StrSize (SName) + sizeof (CHAR16), SName);
941 if (NewSName == NULL) {
942 return (SHELL_OUT_OF_RESOURCES);
943 }
944
945 if (NewSName[StrLen (NewSName)-1] != L':') {
946 StrRetStatus = StrnCatS (NewSName, (StrSize (SName) + sizeof (CHAR16))/sizeof (CHAR16), L":", StrLen (L":"));
947 if (EFI_ERROR (StrRetStatus)) {
948 FreePool (NewSName);
949 return ((SHELL_STATUS)(StrRetStatus & (~MAX_BIT)));
950 }
951 }
952
953 if (!IsNumberLetterOnly (NewSName, StrLen (NewSName)-1)) {
954 FreePool (NewSName);
955 return (SHELL_INVALID_PARAMETER);
956 }
957
958 DevPath = gEfiShellProtocol->GetDevicePathFromMap (Map);
959 if (DevPath == NULL) {
960 FreePool (NewSName);
961 return (SHELL_INVALID_PARAMETER);
962 }
963
964 Status = gEfiShellProtocol->SetMap (DevPath, NewSName);
965 FreePool (NewSName);
966 if (EFI_ERROR (Status)) {
967 return (SHELL_DEVICE_ERROR);
968 }
969
970 return (SHELL_SUCCESS);
971 }
972
973 /**
974 function to add a mapping from an EFI_HANDLE.
975
976 This function will get the device path associated with the Handle and call SetMap.
977
978 @param[in] Handle The handle to add a mapping for
979 @param[in] SName The name of the new mapping
980
981 @retval SHELL_SUCCESS the mapping was added
982 @retval SHELL_INVALID_PARAMETER SName was not valid for a map name.
983 @return Shell version of a return value from either
984 gBS->OpenProtocol or EfiShellProtocol->SetMap
985
986 **/
987 SHELL_STATUS
988 AddMappingFromHandle (
989 IN CONST EFI_HANDLE Handle,
990 IN CONST CHAR16 *SName
991 )
992 {
993 EFI_DEVICE_PATH_PROTOCOL *DevPath;
994 EFI_STATUS Status;
995 CHAR16 *NewSName;
996 RETURN_STATUS StrRetStatus;
997
998 NewSName = AllocateCopyPool (StrSize (SName) + sizeof (CHAR16), SName);
999 if (NewSName == NULL) {
1000 return (SHELL_OUT_OF_RESOURCES);
1001 }
1002
1003 if (NewSName[StrLen (NewSName)-1] != L':') {
1004 StrRetStatus = StrnCatS (NewSName, (StrSize (SName) + sizeof (CHAR16))/sizeof (CHAR16), L":", StrLen (L":"));
1005 if (EFI_ERROR (StrRetStatus)) {
1006 FreePool (NewSName);
1007 return ((SHELL_STATUS)(StrRetStatus & (~MAX_BIT)));
1008 }
1009 }
1010
1011 if (!IsNumberLetterOnly (NewSName, StrLen (NewSName)-1)) {
1012 FreePool (NewSName);
1013 return (SHELL_INVALID_PARAMETER);
1014 }
1015
1016 Status = gBS->OpenProtocol (
1017 Handle,
1018 &gEfiDevicePathProtocolGuid,
1019 (VOID **)&DevPath,
1020 gImageHandle,
1021 NULL,
1022 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1023 );
1024 if (EFI_ERROR (Status)) {
1025 FreePool (NewSName);
1026 return (SHELL_DEVICE_ERROR);
1027 }
1028
1029 Status = gEfiShellProtocol->SetMap (DevPath, NewSName);
1030 FreePool (NewSName);
1031 if (EFI_ERROR (Status)) {
1032 return (SHELL_DEVICE_ERROR);
1033 }
1034
1035 return (SHELL_SUCCESS);
1036 }
1037
1038 STATIC CONST SHELL_PARAM_ITEM MapParamList[] = {
1039 { L"-d", TypeValue },
1040 { L"-r", TypeFlag },
1041 { L"-v", TypeFlag },
1042 { L"-c", TypeFlag },
1043 { L"-f", TypeFlag },
1044 { L"-u", TypeFlag },
1045 { L"-t", TypeValue },
1046 { L"-sfo", TypeValue },
1047 { NULL, TypeMax }
1048 };
1049
1050 /**
1051 The routine issues dummy read for every physical block device to cause
1052 the BlockIo re-installed if media change happened.
1053 **/
1054 VOID
1055 ProbeForMediaChange (
1056 VOID
1057 )
1058 {
1059 EFI_STATUS Status;
1060 UINTN HandleCount;
1061 EFI_HANDLE *Handles;
1062 EFI_BLOCK_IO_PROTOCOL *BlockIo;
1063 UINTN Index;
1064
1065 gBS->LocateHandleBuffer (
1066 ByProtocol,
1067 &gEfiBlockIoProtocolGuid,
1068 NULL,
1069 &HandleCount,
1070 &Handles
1071 );
1072 //
1073 // Probe for media change for every physical block io
1074 //
1075 for (Index = 0; Index < HandleCount; Index++) {
1076 Status = gBS->HandleProtocol (
1077 Handles[Index],
1078 &gEfiBlockIoProtocolGuid,
1079 (VOID **)&BlockIo
1080 );
1081 if (!EFI_ERROR (Status)) {
1082 if (!BlockIo->Media->LogicalPartition) {
1083 //
1084 // Per spec:
1085 // The function (ReadBlocks) must return EFI_NO_MEDIA or
1086 // EFI_MEDIA_CHANGED even if LBA, BufferSize, or Buffer are invalid so the caller can probe
1087 // for changes in media state.
1088 //
1089 BlockIo->ReadBlocks (
1090 BlockIo,
1091 BlockIo->Media->MediaId,
1092 0,
1093 0,
1094 NULL
1095 );
1096 }
1097 }
1098 }
1099 }
1100
1101 /**
1102 Function for 'map' command.
1103
1104 @param[in] ImageHandle Handle to the Image (NULL if Internal).
1105 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
1106 **/
1107 SHELL_STATUS
1108 EFIAPI
1109 ShellCommandRunMap (
1110 IN EFI_HANDLE ImageHandle,
1111 IN EFI_SYSTEM_TABLE *SystemTable
1112 )
1113 {
1114 EFI_STATUS Status;
1115 LIST_ENTRY *Package;
1116 CHAR16 *ProblemParam;
1117 CONST CHAR16 *SName;
1118 CONST CHAR16 *Mapping;
1119 EFI_HANDLE MapAsHandle;
1120 SHELL_STATUS ShellStatus;
1121 BOOLEAN SfoMode;
1122 BOOLEAN ConstMode;
1123 BOOLEAN NormlMode;
1124 CONST CHAR16 *Param1;
1125 CONST CHAR16 *TypeString;
1126 UINTN TempStringLength;
1127
1128 ProblemParam = NULL;
1129 Mapping = NULL;
1130 SName = NULL;
1131 ShellStatus = SHELL_SUCCESS;
1132 MapAsHandle = NULL;
1133
1134 //
1135 // initialize the shell lib (we must be in non-auto-init...)
1136 //
1137 Status = ShellInitialize ();
1138 ASSERT_EFI_ERROR (Status);
1139
1140 Status = CommandInit ();
1141 ASSERT_EFI_ERROR (Status);
1142
1143 //
1144 // parse the command line
1145 //
1146 Status = ShellCommandLineParse (MapParamList, &Package, &ProblemParam, TRUE);
1147 if (EFI_ERROR (Status)) {
1148 if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
1149 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"map", ProblemParam);
1150 FreePool (ProblemParam);
1151 ShellStatus = SHELL_INVALID_PARAMETER;
1152 } else {
1153 ASSERT (FALSE);
1154 }
1155 } else {
1156 //
1157 // check for "-?"
1158 //
1159 SfoMode = ShellCommandLineGetFlag (Package, L"-sfo");
1160 ConstMode = ShellCommandLineGetFlag (Package, L"-c");
1161 NormlMode = ShellCommandLineGetFlag (Package, L"-f");
1162 if (ShellCommandLineGetFlag (Package, L"-?")) {
1163 ASSERT (FALSE);
1164 } else if (ShellCommandLineGetRawValue (Package, 3) != NULL) {
1165 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"map");
1166 ShellStatus = SHELL_INVALID_PARAMETER;
1167 } else {
1168 //
1169 // Deleting a map name...
1170 //
1171 if (ShellCommandLineGetFlag (Package, L"-d")) {
1172 if ( ShellCommandLineGetFlag (Package, L"-r")
1173 || ShellCommandLineGetFlag (Package, L"-v")
1174 || ConstMode
1175 || NormlMode
1176 || ShellCommandLineGetFlag (Package, L"-u")
1177 || ShellCommandLineGetFlag (Package, L"-t")
1178 )
1179 {
1180 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CON), gShellLevel2HiiHandle, L"map");
1181 ShellStatus = SHELL_INVALID_PARAMETER;
1182 } else {
1183 SName = ShellCommandLineGetValue (Package, L"-d");
1184 if (SName != NULL) {
1185 Status = PerformMappingDelete (SName);
1186 if (EFI_ERROR (Status)) {
1187 if (Status == EFI_ACCESS_DENIED) {
1188 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_AD), gShellLevel2HiiHandle, L"map");
1189 ShellStatus = SHELL_ACCESS_DENIED;
1190 } else if (Status == EFI_NOT_FOUND) {
1191 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MAP_NF), gShellLevel2HiiHandle, L"map", SName);
1192 ShellStatus = SHELL_INVALID_PARAMETER;
1193 } else {
1194 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"map", Status);
1195 ShellStatus = SHELL_UNSUPPORTED;
1196 }
1197 }
1198 } else {
1199 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"map");
1200 ShellStatus = SHELL_INVALID_PARAMETER;
1201 }
1202 }
1203 } else if ( ShellCommandLineGetFlag (Package, L"-r")
1204 // || ShellCommandLineGetFlag(Package, L"-v")
1205 || ConstMode
1206 || NormlMode
1207 || ShellCommandLineGetFlag (Package, L"-u")
1208 || ShellCommandLineGetFlag (Package, L"-t")
1209 )
1210 {
1211 ProbeForMediaChange ();
1212 if ( ShellCommandLineGetFlag (Package, L"-r")) {
1213 //
1214 // Do the reset
1215 //
1216 Status = ShellCommandCreateInitialMappingsAndPaths ();
1217 if (EFI_ERROR (Status)) {
1218 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"map", Status);
1219 ShellStatus = SHELL_UNSUPPORTED;
1220 }
1221 }
1222
1223 if ((ShellStatus == SHELL_SUCCESS) && ShellCommandLineGetFlag (Package, L"-u")) {
1224 //
1225 // Do the Update
1226 //
1227 Status = ShellCommandUpdateMapping ();
1228 if (EFI_ERROR (Status)) {
1229 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"map", Status);
1230 ShellStatus = SHELL_UNSUPPORTED;
1231 }
1232 }
1233
1234 if (ShellStatus == SHELL_SUCCESS) {
1235 Param1 = ShellCommandLineGetRawValue (Package, 1);
1236 TypeString = ShellCommandLineGetValue (Package, L"-t");
1237 if ( !ConstMode
1238 && !NormlMode
1239 && (TypeString == NULL)
1240 )
1241 {
1242 //
1243 // now do the display...
1244 //
1245 ShellStatus = PerformMappingDisplay (
1246 ShellCommandLineGetFlag (Package, L"-v"),
1247 TRUE,
1248 TRUE,
1249 NULL,
1250 SfoMode,
1251 Param1,
1252 TRUE
1253 );
1254 } else {
1255 //
1256 // now do the display...
1257 //
1258 ShellStatus = PerformMappingDisplay2 (
1259 ShellCommandLineGetFlag (Package, L"-v"),
1260 ConstMode,
1261 NormlMode,
1262 TypeString,
1263 SfoMode,
1264 Param1
1265 );
1266 }
1267 }
1268 } else {
1269 //
1270 // adding or displaying (there were no flags)
1271 //
1272 SName = ShellCommandLineGetRawValue (Package, 1);
1273 Mapping = ShellCommandLineGetRawValue (Package, 2);
1274 if ( (SName == NULL)
1275 && (Mapping == NULL)
1276 )
1277 {
1278 //
1279 // display only since no flags
1280 //
1281 ShellStatus = PerformMappingDisplay (
1282 ShellCommandLineGetFlag (Package, L"-v"),
1283 TRUE,
1284 TRUE,
1285 NULL,
1286 SfoMode,
1287 NULL,
1288 TRUE
1289 );
1290 } else if ( (SName == NULL)
1291 || (Mapping == NULL)
1292 )
1293 {
1294 //
1295 // Display only the one specified
1296 //
1297 ShellStatus = PerformMappingDisplay (
1298 FALSE,
1299 FALSE,
1300 FALSE,
1301 NULL,
1302 SfoMode,
1303 SName, // note the variable here...
1304 TRUE
1305 );
1306 } else {
1307 if (ShellIsHexOrDecimalNumber (Mapping, TRUE, FALSE)) {
1308 MapAsHandle = ConvertHandleIndexToHandle (ShellStrToUintn (Mapping));
1309 } else {
1310 MapAsHandle = NULL;
1311 }
1312
1313 if ((MapAsHandle == NULL) && (Mapping[StrLen (Mapping)-1] != L':')) {
1314 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", Mapping);
1315 ShellStatus = SHELL_INVALID_PARAMETER;
1316 } else {
1317 TempStringLength = StrLen (SName);
1318 if (!IsNumberLetterOnly (SName, TempStringLength-((SName[TempStringLength-1] == L':') ? 1 : 0))) {
1319 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", SName);
1320 ShellStatus = SHELL_INVALID_PARAMETER;
1321 }
1322
1323 if (ShellStatus == SHELL_SUCCESS) {
1324 if (MapAsHandle != NULL) {
1325 ShellStatus = AddMappingFromHandle (MapAsHandle, SName);
1326 } else {
1327 ShellStatus = AddMappingFromMapping (Mapping, SName);
1328 }
1329
1330 if (ShellStatus != SHELL_SUCCESS) {
1331 switch (ShellStatus) {
1332 case SHELL_ACCESS_DENIED:
1333 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_AD), gShellLevel2HiiHandle, L"map");
1334 break;
1335 case SHELL_INVALID_PARAMETER:
1336 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"map", Mapping);
1337 break;
1338 case SHELL_DEVICE_ERROR:
1339 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MAP_NOF), gShellLevel2HiiHandle, L"map", Mapping);
1340 break;
1341 default:
1342 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"map", ShellStatus|MAX_BIT);
1343 }
1344 } else {
1345 //
1346 // now do the display...
1347 //
1348 ShellStatus = PerformMappingDisplay (
1349 FALSE,
1350 FALSE,
1351 FALSE,
1352 NULL,
1353 SfoMode,
1354 SName,
1355 TRUE
1356 );
1357 } // we were sucessful so do an output
1358 }
1359 } // got a valid map target
1360 } // got 2 variables
1361 } // we are adding a mapping
1362 } // got valid parameters
1363 }
1364
1365 //
1366 // free the command line package
1367 //
1368 ShellCommandLineFreeVarList (Package);
1369
1370 return (ShellStatus);
1371 }