]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/EbcDxe/EbcDebugger/EbcDebuggerConfig.c
MdeModulePkg/EbcDxe: Add comments for functions
[mirror_edk2.git] / MdeModulePkg / Universal / EbcDxe / EbcDebugger / EbcDebuggerConfig.c
1 /** @file
2 Configuration application for the EBC Debugger.
3
4 Copyright (c) 2007 - 2016, 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 <Uefi.h>
16 #include <Protocol/ShellParameters.h>
17
18 #include "EdbCommon.h"
19 #include "EdbSupport.h"
20
21 /**
22
23 The function that displays the utility usage message.
24
25 **/
26 VOID
27 PrintUsage (
28 VOID
29 )
30 {
31 Print (
32 L"EbcDebuggerConfig Version 1.0\n"
33 L"Copyright (C) Intel Corp 2007-2016. All rights reserved.\n"
34 L"\n"
35 L"Configure EbcDebugger in EFI Shell Environment.\n"
36 L"\n"
37 L"usage: EdbCfg <Command>\n"
38 L" CommandList:\n"
39 L" BO[C|CX|R|E|T|K] <ON|OFF> - Enable/Disable BOC/BOCX/BOR/BOE/BOT/BOK.\n"
40 // L" SHOWINFO - Show Debugger Information.\n"
41 L"\n"
42 );
43 return;
44 }
45
46 /**
47
48 The function is to show some information.
49
50 @param DebuggerConfiguration Point to the EFI_DEBUGGER_CONFIGURATION_PROTOCOL.
51
52 **/
53 VOID
54 EdbShowInfo (
55 EFI_DEBUGGER_CONFIGURATION_PROTOCOL *DebuggerConfiguration
56 )
57 {
58 Print (L"Not supported!\n");
59 return ;
60 }
61
62 /**
63
64 EdbConfigBreak function.
65
66 @param DebuggerConfiguration Point to the EFI_DEBUGGER_CONFIGURATION_PROTOCOL.
67 @param Command Point to the command.
68 @param CommandArg The argument for this command.
69
70 **/
71 VOID
72 EdbConfigBreak (
73 EFI_DEBUGGER_CONFIGURATION_PROTOCOL *DebuggerConfiguration,
74 CHAR16 *Command,
75 CHAR16 *CommandArg
76 )
77 {
78 EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate;
79
80 DebuggerPrivate = (EFI_DEBUGGER_PRIVATE_DATA *)DebuggerConfiguration->DebuggerPrivateData;
81
82 if (StriCmp (Command, L"BOC") == 0) {
83 if (CommandArg == NULL) {
84 if ((DebuggerPrivate->FeatureFlags & EFI_DEBUG_FLAG_EBC_BOC) == EFI_DEBUG_FLAG_EBC_BOC) {
85 Print (L"BOC on\n");
86 } else {
87 Print (L"BOC off\n");
88 }
89 } else if (StriCmp (CommandArg, L"ON") == 0) {
90 DebuggerPrivate->FeatureFlags |= EFI_DEBUG_FLAG_EBC_BOC;
91 } else if (StriCmp (CommandArg, L"OFF") == 0) {
92 DebuggerPrivate->FeatureFlags &= ~EFI_DEBUG_FLAG_EBC_B_BOC;
93 } else {
94 Print (L"Invalid parameter\n");
95 }
96 } else if (StriCmp (Command, L"BOCX") == 0) {
97 if (CommandArg == NULL) {
98 if ((DebuggerPrivate->FeatureFlags & EFI_DEBUG_FLAG_EBC_BOCX) == EFI_DEBUG_FLAG_EBC_BOCX) {
99 Print (L"BOCX on\n");
100 } else {
101 Print (L"BOCX off\n");
102 }
103 } else if (StriCmp (CommandArg, L"ON") == 0) {
104 DebuggerPrivate->FeatureFlags |= EFI_DEBUG_FLAG_EBC_BOCX;
105 } else if (StriCmp (CommandArg, L"OFF") == 0) {
106 DebuggerPrivate->FeatureFlags &= ~EFI_DEBUG_FLAG_EBC_B_BOCX;
107 } else {
108 Print (L"Invalid parameter\n");
109 }
110 } else if (StriCmp (Command, L"BOR") == 0) {
111 if (CommandArg == NULL) {
112 if ((DebuggerPrivate->FeatureFlags & EFI_DEBUG_FLAG_EBC_BOR) == EFI_DEBUG_FLAG_EBC_BOR) {
113 Print (L"BOR on\n");
114 } else {
115 Print (L"BOR off\n");
116 }
117 } else if (StriCmp (CommandArg, L"ON") == 0) {
118 DebuggerPrivate->FeatureFlags |= EFI_DEBUG_FLAG_EBC_BOR;
119 } else if (StriCmp (CommandArg, L"OFF") == 0) {
120 DebuggerPrivate->FeatureFlags &= ~EFI_DEBUG_FLAG_EBC_B_BOR;
121 } else {
122 Print (L"Invalid parameter\n");
123 }
124 } else if (StriCmp (Command, L"BOE") == 0) {
125 if (CommandArg == NULL) {
126 if ((DebuggerPrivate->FeatureFlags & EFI_DEBUG_FLAG_EBC_BOE) == EFI_DEBUG_FLAG_EBC_BOE) {
127 Print (L"BOE on\n");
128 } else {
129 Print (L"BOE off\n");
130 }
131 } else if (StriCmp (CommandArg, L"ON") == 0) {
132 DebuggerPrivate->FeatureFlags |= EFI_DEBUG_FLAG_EBC_BOE;
133 } else if (StriCmp (CommandArg, L"OFF") == 0) {
134 DebuggerPrivate->FeatureFlags &= ~EFI_DEBUG_FLAG_EBC_B_BOE;
135 } else {
136 Print (L"Invalid parameter\n");
137 }
138 } else if (StriCmp (Command, L"BOT") == 0) {
139 if (CommandArg == NULL) {
140 if ((DebuggerPrivate->FeatureFlags & EFI_DEBUG_FLAG_EBC_BOT) == EFI_DEBUG_FLAG_EBC_BOT) {
141 Print (L"BOT on\n");
142 } else {
143 Print (L"BOT off\n");
144 }
145 } else if (StriCmp (CommandArg, L"ON") == 0) {
146 DebuggerPrivate->FeatureFlags |= EFI_DEBUG_FLAG_EBC_BOT;
147 } else if (StriCmp (CommandArg, L"OFF") == 0) {
148 DebuggerPrivate->FeatureFlags &= ~EFI_DEBUG_FLAG_EBC_B_BOT;
149 } else {
150 Print (L"Invalid parameter\n");
151 }
152 } else if (StriCmp (Command, L"BOK") == 0) {
153 if (CommandArg == NULL) {
154 if ((DebuggerPrivate->FeatureFlags & EFI_DEBUG_FLAG_EBC_BOK) == EFI_DEBUG_FLAG_EBC_BOK) {
155 Print (L"BOK on\n");
156 } else {
157 Print (L"BOK off\n");
158 }
159 } else if (StriCmp (CommandArg, L"ON") == 0) {
160 DebuggerPrivate->FeatureFlags |= EFI_DEBUG_FLAG_EBC_BOK;
161 } else if (StriCmp (CommandArg, L"OFF") == 0) {
162 DebuggerPrivate->FeatureFlags &= ~EFI_DEBUG_FLAG_EBC_B_BOK;
163 } else {
164 Print (L"Invalid parameter\n");
165 }
166 }
167 return ;
168 }
169
170 /**
171 Alter the EBC Debugger configuration.
172
173 @param[in] ImageHandle The image handle.
174 @param[in] SystemTable The system table.
175
176 @retval EFI_SUCCESS Operation completed successfully.
177 @retval EFI_INVALID_PARAMETER Usage error.
178 @retval EFI_NOT_FOUND A running debugger cannot be located.
179 **/
180 EFI_STATUS
181 EFIAPI
182 InitializeEbcDebuggerConfig (
183 IN EFI_HANDLE ImageHandle,
184 IN EFI_SYSTEM_TABLE *SystemTable
185 )
186 {
187 UINTN Argc;
188 CHAR16 **Argv;
189 EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters;
190 EFI_DEBUGGER_CONFIGURATION_PROTOCOL *DebuggerConfiguration;
191 EFI_STATUS Status;
192
193 Status = gBS->HandleProtocol (
194 gImageHandle,
195 &gEfiShellParametersProtocolGuid,
196 (VOID**)&ShellParameters
197 );
198 if (EFI_ERROR(Status)) {
199 Print (L"Please use UEFI Shell to run this application.\n");
200 return EFI_INVALID_PARAMETER;
201 }
202
203 Argc = ShellParameters->Argc;
204 Argv = ShellParameters->Argv;
205
206 if (Argc < 2) {
207 PrintUsage ();
208 return EFI_INVALID_PARAMETER;
209 }
210
211 if (Argc == 2) {
212 if ((StrCmp (Argv[1], L"/?") == 0) ||
213 (StrCmp (Argv[1], L"-?") == 0) ||
214 (StrCmp (Argv[1], L"-h") == 0) ||
215 (StrCmp (Argv[1], L"-H") == 0) ) {
216 PrintUsage ();
217 return EFI_SUCCESS;
218 }
219 }
220
221 Status = gBS->LocateProtocol (
222 &gEfiDebuggerConfigurationProtocolGuid,
223 NULL,
224 (VOID**)&DebuggerConfiguration
225 );
226 if (EFI_ERROR(Status)) {
227 Print (L"Error: DebuggerConfiguration protocol not found.\n");
228 return EFI_NOT_FOUND;
229 }
230
231 if (StriCmp (Argv[1], L"SHOWINFO") == 0) {
232 EdbShowInfo (DebuggerConfiguration);
233 return EFI_SUCCESS;
234 }
235
236 if (((Argc == 2) || (Argc == 3)) &&
237 ((StriCmp (Argv[1], L"BOC") == 0) ||
238 (StriCmp (Argv[1], L"BOCX") == 0) ||
239 (StriCmp (Argv[1], L"BOR") == 0) ||
240 (StriCmp (Argv[1], L"BOE") == 0) ||
241 (StriCmp (Argv[1], L"BOT") == 0) ||
242 (StriCmp (Argv[1], L"BOK") == 0))) {
243 if (Argc == 3) {
244 EdbConfigBreak (DebuggerConfiguration, Argv[1], Argv[2]);
245 } else {
246 EdbConfigBreak (DebuggerConfiguration, Argv[1], NULL);
247 }
248 return EFI_SUCCESS;
249 }
250
251 Print (L"Error: Invalid Command.\n");
252 return EFI_INVALID_PARAMETER;
253 }