2 Main file for devices shell Driver1 function.
4 Copyright (c) 2010, 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
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.
15 #include "UefiShellDriver1CommandsLib.h"
20 IN EFI_HANDLE TheHandle
,
28 IN CONST CHAR8
*Language
32 gEfiShellProtocol
->GetDeviceName(TheHandle
, EFI_DEVICE_NAME_USE_COMPONENT_NAME
|EFI_DEVICE_NAME_USE_DEVICE_PATH
, (CHAR8
*)Language
, Name
);
49 STATIC CONST SHELL_PARAM_ITEM ParamList
[] = {
56 ShellCommandRunDevices (
62 SHELL_STATUS ShellStatus
;
64 EFI_HANDLE
*HandleList
;
65 EFI_HANDLE
*HandleListWalker
;
74 ShellStatus
= SHELL_SUCCESS
;
78 // initialize the shell lib (we must be in non-auto-init...)
80 Status
= ShellInitialize();
81 ASSERT_EFI_ERROR(Status
);
83 Status
= CommandInit();
84 ASSERT_EFI_ERROR(Status
);
87 // parse the command line
89 Status
= ShellCommandLineParse (ParamList
, &Package
, &ProblemParam
, TRUE
);
90 if EFI_ERROR(Status
) {
91 if (Status
== EFI_VOLUME_CORRUPTED
&& ProblemParam
!= NULL
) {
92 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellDriver1HiiHandle
, ProblemParam
);
93 FreePool(ProblemParam
);
94 ShellStatus
= SHELL_INVALID_PARAMETER
;
100 // if more than 0 'value' parameters we have too many parameters
102 if (ShellCommandLineGetRawValue(Package
, 1) != NULL
){
104 // error for too many parameters
106 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
), gShellDriver1HiiHandle
);
107 ShellStatus
= SHELL_INVALID_PARAMETER
;
110 // get the language if necessary
112 if (ShellCommandLineGetFlag(Package
, L
"-l") != FALSE
) {
113 Language
= AllocateZeroPool(StrSize(ShellCommandLineGetValue(Package
, L
"-l")));
114 AsciiSPrint(Language
, StrSize(ShellCommandLineGetValue(Package
, L
"-l")), "%S", ShellCommandLineGetValue(Package
, L
"-l"));
120 ShellPrintHiiEx(-1, -1, Language
, STRING_TOKEN (STR_DEVICES_HEADER_LINES
), gShellDriver1HiiHandle
);
123 // loop through each handle
125 HandleList
= GetHandleListByPotocol(NULL
);
126 ASSERT(HandleList
!= NULL
);
127 for (HandleListWalker
= HandleList
128 ; HandleListWalker
!= NULL
&& *HandleListWalker
!= NULL
&& !EFI_ERROR(Status
)
132 // get all the info on each handle
134 Status
= GetDeviceHandleInfo(*HandleListWalker
, &Type
, &Cfg
, &Diag
, &Parents
, &Devices
, &Children
, &Name
, Language
);
135 if (Parents
!= 0 || Devices
!= 0 || Children
!= 0) {
140 STRING_TOKEN (STR_DEVICES_ITEM_LINE
),
141 gShellDriver1HiiHandle
,
144 Cfg
!=FALSE
?L
'X':L
'-',
145 Diag
!=FALSE
?L
'X':L
'-',
156 if (HandleList
!= NULL
) {
157 FreePool(HandleList
);
160 ShellCommandLineFreeVarList (Package
);
162 return (ShellStatus
);