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