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