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