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