TianoCore EDK2 master
Loading...
Searching...
No Matches
EdbCmdMemory.c
Go to the documentation of this file.
1
9#include "Edb.h"
10
23 IN UINTN Address,
24 IN EDB_DATA_WIDTH Width
25 )
26{
27 UINT8 Data8;
28 UINT16 Data16;
29 UINT32 Data32;
30 UINT64 Data64;
31
32 //
33 // Print according to width
34 //
35 switch (Width) {
36 case EdbWidthUint8:
37 CopyMem (&Data8, (VOID *)Address, sizeof (UINT8));
38 EDBPrint (L"%02x ", Data8);
39 return sizeof (UINT8);
40 case EdbWidthUint16:
41 CopyMem (&Data16, (VOID *)Address, sizeof (UINT16));
42 EDBPrint (L"%04x ", Data16);
43 return sizeof (UINT16);
44 case EdbWidthUint32:
45 CopyMem (&Data32, (VOID *)Address, sizeof (UINT32));
46 EDBPrint (L"%08x ", Data32);
47 return sizeof (UINT32);
48 case EdbWidthUint64:
49 CopyMem (&Data64, (VOID *)Address, sizeof (UINT64));
50 EDBPrint (L"%016lx ", Data64);
51 return sizeof (UINT64);
52 default:
53 ASSERT (FALSE);
54 break;
55 }
56
57 //
58 // something wrong
59 //
60 return 0;
61}
62
72VOID
74 IN UINTN Address,
75 IN UINTN Count,
76 IN EDB_DATA_WIDTH Width
77 )
78{
79 UINTN LineNumber;
80 UINTN ByteNumber;
81 UINTN LineIndex;
82 UINTN ByteIndex;
83 UINTN NumberInLine;
84
85 if (Count == 0) {
86 return;
87 }
88
89 //
90 // Get line number and byte number
91 //
92 switch (Width) {
93 case EdbWidthUint8:
94 NumberInLine = 16;
95 break;
96 case EdbWidthUint16:
97 NumberInLine = 8;
98 break;
99 case EdbWidthUint32:
100 NumberInLine = 4;
101 break;
102 case EdbWidthUint64:
103 NumberInLine = 2;
104 break;
105 default:
106 return;
107 }
108
109 LineNumber = Count / NumberInLine;
110 ByteNumber = Count % NumberInLine;
111 if (ByteNumber == 0) {
112 LineNumber -= 1;
113 ByteNumber = NumberInLine;
114 }
115
116 //
117 // Print each line
118 //
119 for (LineIndex = 0; LineIndex < LineNumber; LineIndex++) {
120 //
121 // Break check
122 //
123 if (((LineIndex % EFI_DEBUGGER_LINE_NUMBER_IN_PAGE) == 0) &&
124 (LineIndex != 0))
125 {
126 if (SetPageBreak ()) {
127 break;
128 }
129 }
130
131 EDBPrint (EDB_PRINT_ADDRESS_FORMAT, (UINTN)Address);
132 for (ByteIndex = 0; ByteIndex < NumberInLine; ByteIndex++) {
133 Address += EdbDisplayMemoryUnit (Address, Width);
134 }
135
136 EDBPrint (L"\n");
137 }
138
139 //
140 // Break check
141 //
142 if (((LineIndex % EFI_DEBUGGER_LINE_NUMBER_IN_PAGE) == 0) &&
143 (LineIndex != 0))
144 {
145 if (SetPageBreak ()) {
146 return;
147 }
148 }
149
150 //
151 // Print last line
152 //
153 EDBPrint (EDB_PRINT_ADDRESS_FORMAT, (UINTN)Address);
154 for (ByteIndex = 0; ByteIndex < ByteNumber; ByteIndex++) {
155 Address += EdbDisplayMemoryUnit (Address, Width);
156 }
157
158 return;
159}
160
170VOID
172 IN UINTN Address,
173 IN VOID *Value,
174 IN EDB_DATA_WIDTH Width
175 )
176{
177 switch (Width) {
178 case EdbWidthUint8:
179 CopyMem ((VOID *)Address, Value, sizeof (UINT8));
180 break;
181 case EdbWidthUint16:
182 CopyMem ((VOID *)Address, Value, sizeof (UINT16));
183 break;
184 case EdbWidthUint32:
185 CopyMem ((VOID *)Address, Value, sizeof (UINT32));
186 break;
187 case EdbWidthUint64:
188 CopyMem ((VOID *)Address, Value, sizeof (UINT64));
189 break;
190 default:
191 break;
192 }
193
194 return;
195}
196
211 IN CHAR16 *CommandArg,
212 IN UINTN *Address,
213 IN UINTN *Count
214 )
215{
216 CHAR16 *CommandStr;
217 UINTN MemAddress;
218 EFI_STATUS Status;
219
220 //
221 // Get Address
222 //
223 CommandStr = CommandArg;
224 if (CommandStr == NULL) {
225 EDBPrint (L"Memory: Address error!\n");
226 return EFI_INVALID_PARAMETER;
227 }
228
229 Status = Symboltoi (CommandStr, &MemAddress);
230 if (EFI_ERROR (Status)) {
231 if (Status == EFI_NOT_FOUND) {
232 MemAddress = Xtoi (CommandStr);
233 } else {
234 //
235 // Something wrong, let Symboltoi print error info.
236 //
237 EDBPrint (L"Command Argument error!\n");
238 return EFI_INVALID_PARAMETER;
239 }
240 }
241
242 *Address = MemAddress;
243
244 //
245 // Get Count
246 //
247 CommandStr = StrGetNextTokenLine (L" ");
248 if (CommandStr == NULL) {
249 *Count = 1;
250 } else {
251 *Count = Xtoi (CommandStr);
252 }
253
254 //
255 // Done
256 //
257 return EFI_SUCCESS;
258}
259
274 IN CHAR16 *CommandArg,
275 IN UINTN *Address,
276 IN UINT64 *Value
277 )
278{
279 CHAR16 *CommandStr;
280 UINTN MemAddress;
281 EFI_STATUS Status;
282
283 //
284 // Get Address
285 //
286 CommandStr = CommandArg;
287 if (CommandStr == NULL) {
288 EDBPrint (L"Memory: Address error!\n");
289 return EFI_INVALID_PARAMETER;
290 }
291
292 Status = Symboltoi (CommandStr, &MemAddress);
293 if (EFI_ERROR (Status)) {
294 if (Status == EFI_NOT_FOUND) {
295 MemAddress = Xtoi (CommandStr);
296 } else {
297 //
298 // Something wrong, let Symboltoi print error info.
299 //
300 EDBPrint (L"Command Argument error!\n");
301 return EFI_INVALID_PARAMETER;
302 }
303 }
304
305 *Address = MemAddress;
306
307 //
308 // Get Value
309 //
310 CommandStr = StrGetNextTokenLine (L" ");
311 if (CommandStr == NULL) {
312 EDBPrint (L"Memory: Value error!\n");
313 return EFI_INVALID_PARAMETER;
314 }
315
316 *Value = LXtoi (CommandStr);
317
318 //
319 // Done
320 //
321 return EFI_SUCCESS;
322}
323
334EFI_DEBUG_STATUS
336 IN CHAR16 *CommandArg,
337 IN EDB_DATA_WIDTH Width
338 )
339{
340 EFI_STATUS Status;
341 UINTN Address;
342 UINTN Count;
343
344 //
345 // Get memory address and count
346 //
347 Status = EdbGetMemoryAddressCount (CommandArg, &Address, &Count);
348 if (EFI_ERROR (Status)) {
349 return EFI_DEBUG_CONTINUE;
350 }
351
352 //
353 // Display memory
354 //
355 EdbDisplayMemory (Address, Count, Width);
356
357 //
358 // Done
359 //
360 return EFI_DEBUG_CONTINUE;
361}
362
373EFI_DEBUG_STATUS
375 IN CHAR16 *CommandArg,
376 IN EDB_DATA_WIDTH Width
377 )
378{
379 EFI_STATUS Status;
380 UINTN Address;
381 UINT64 Value;
382
383 //
384 // Get memory address and value
385 //
386 Status = EdbGetMemoryAddressValue (CommandArg, &Address, &Value);
387 if (EFI_ERROR (Status)) {
388 return EFI_DEBUG_CONTINUE;
389 }
390
391 //
392 // Enter memory
393 //
394 EdbEnterMemory (Address, &Value, Width);
395
396 //
397 // Done
398 //
399 return EFI_DEBUG_CONTINUE;
400}
401
414EFI_DEBUG_STATUS
416 IN CHAR16 *CommandArg,
417 IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
418 IN EFI_EXCEPTION_TYPE ExceptionType,
419 IN OUT EFI_SYSTEM_CONTEXT SystemContext
420 )
421{
422 return DebuggerMemoryDisplay (CommandArg, EdbWidthUint8);
423}
424
437EFI_DEBUG_STATUS
439 IN CHAR16 *CommandArg,
440 IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
441 IN EFI_EXCEPTION_TYPE ExceptionType,
442 IN OUT EFI_SYSTEM_CONTEXT SystemContext
443 )
444{
445 return DebuggerMemoryDisplay (CommandArg, EdbWidthUint16);
446}
447
460EFI_DEBUG_STATUS
462 IN CHAR16 *CommandArg,
463 IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
464 IN EFI_EXCEPTION_TYPE ExceptionType,
465 IN OUT EFI_SYSTEM_CONTEXT SystemContext
466 )
467{
468 return DebuggerMemoryDisplay (CommandArg, EdbWidthUint32);
469}
470
483EFI_DEBUG_STATUS
485 IN CHAR16 *CommandArg,
486 IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
487 IN EFI_EXCEPTION_TYPE ExceptionType,
488 IN OUT EFI_SYSTEM_CONTEXT SystemContext
489 )
490{
491 return DebuggerMemoryDisplay (CommandArg, EdbWidthUint64);
492}
493
506EFI_DEBUG_STATUS
508 IN CHAR16 *CommandArg,
509 IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
510 IN EFI_EXCEPTION_TYPE ExceptionType,
511 IN OUT EFI_SYSTEM_CONTEXT SystemContext
512 )
513{
514 return DebuggerMemoryEnter (CommandArg, EdbWidthUint8);
515}
516
529EFI_DEBUG_STATUS
531 IN CHAR16 *CommandArg,
532 IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
533 IN EFI_EXCEPTION_TYPE ExceptionType,
534 IN OUT EFI_SYSTEM_CONTEXT SystemContext
535 )
536{
537 return DebuggerMemoryEnter (CommandArg, EdbWidthUint16);
538}
539
552EFI_DEBUG_STATUS
554 IN CHAR16 *CommandArg,
555 IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
556 IN EFI_EXCEPTION_TYPE ExceptionType,
557 IN OUT EFI_SYSTEM_CONTEXT SystemContext
558 )
559{
560 return DebuggerMemoryEnter (CommandArg, EdbWidthUint32);
561}
562
575EFI_DEBUG_STATUS
577 IN CHAR16 *CommandArg,
578 IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
579 IN EFI_EXCEPTION_TYPE ExceptionType,
580 IN OUT EFI_SYSTEM_CONTEXT SystemContext
581 )
582{
583 return DebuggerMemoryEnter (CommandArg, EdbWidthUint64);
584}
UINT64 UINTN
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
EFI_DEBUG_STATUS DebuggerMemoryDQ(IN CHAR16 *CommandArg, IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN EFI_EXCEPTION_TYPE ExceptionType, IN OUT EFI_SYSTEM_CONTEXT SystemContext)
Definition: EdbCmdMemory.c:484
EFI_DEBUG_STATUS DebuggerMemoryED(IN CHAR16 *CommandArg, IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN EFI_EXCEPTION_TYPE ExceptionType, IN OUT EFI_SYSTEM_CONTEXT SystemContext)
Definition: EdbCmdMemory.c:553
EFI_STATUS EdbGetMemoryAddressValue(IN CHAR16 *CommandArg, IN UINTN *Address, IN UINT64 *Value)
Definition: EdbCmdMemory.c:273
EFI_DEBUG_STATUS DebuggerMemoryEnter(IN CHAR16 *CommandArg, IN EDB_DATA_WIDTH Width)
Definition: EdbCmdMemory.c:374
EFI_DEBUG_STATUS DebuggerMemoryDW(IN CHAR16 *CommandArg, IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN EFI_EXCEPTION_TYPE ExceptionType, IN OUT EFI_SYSTEM_CONTEXT SystemContext)
Definition: EdbCmdMemory.c:438
EFI_DEBUG_STATUS DebuggerMemoryEW(IN CHAR16 *CommandArg, IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN EFI_EXCEPTION_TYPE ExceptionType, IN OUT EFI_SYSTEM_CONTEXT SystemContext)
Definition: EdbCmdMemory.c:530
VOID EdbDisplayMemory(IN UINTN Address, IN UINTN Count, IN EDB_DATA_WIDTH Width)
Definition: EdbCmdMemory.c:73
UINTN EdbDisplayMemoryUnit(IN UINTN Address, IN EDB_DATA_WIDTH Width)
Definition: EdbCmdMemory.c:22
EFI_DEBUG_STATUS DebuggerMemoryEQ(IN CHAR16 *CommandArg, IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN EFI_EXCEPTION_TYPE ExceptionType, IN OUT EFI_SYSTEM_CONTEXT SystemContext)
Definition: EdbCmdMemory.c:576
VOID EdbEnterMemory(IN UINTN Address, IN VOID *Value, IN EDB_DATA_WIDTH Width)
Definition: EdbCmdMemory.c:171
EFI_DEBUG_STATUS DebuggerMemoryDisplay(IN CHAR16 *CommandArg, IN EDB_DATA_WIDTH Width)
Definition: EdbCmdMemory.c:335
EFI_DEBUG_STATUS DebuggerMemoryEB(IN CHAR16 *CommandArg, IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN EFI_EXCEPTION_TYPE ExceptionType, IN OUT EFI_SYSTEM_CONTEXT SystemContext)
Definition: EdbCmdMemory.c:507
EFI_DEBUG_STATUS DebuggerMemoryDD(IN CHAR16 *CommandArg, IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN EFI_EXCEPTION_TYPE ExceptionType, IN OUT EFI_SYSTEM_CONTEXT SystemContext)
Definition: EdbCmdMemory.c:461
EFI_DEBUG_STATUS DebuggerMemoryDB(IN CHAR16 *CommandArg, IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate, IN EFI_EXCEPTION_TYPE ExceptionType, IN OUT EFI_SYSTEM_CONTEXT SystemContext)
Definition: EdbCmdMemory.c:415
EFI_STATUS EdbGetMemoryAddressCount(IN CHAR16 *CommandArg, IN UINTN *Address, IN UINTN *Count)
Definition: EdbCmdMemory.c:210
UINTN EFIAPI Xtoi(CHAR16 *Str)
BOOLEAN EFIAPI SetPageBreak(VOID)
Definition: EdbSupportUI.c:605
CHAR16 *EFIAPI StrGetNextTokenLine(IN CHAR16 *CharSet)
UINT64 EFIAPI LXtoi(CHAR16 *Str)
UINTN EFIAPI EDBPrint(IN CONST CHAR16 *Format,...)
Definition: EdbSupportUI.c:683
EFI_STATUS Symboltoi(IN CHAR16 *Symbol, OUT UINTN *Address)
Definition: EdbSymbol.c:2222
#define NULL
Definition: Base.h:319
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
INTN EFI_EXCEPTION_TYPE
Definition: DebugSupport.h:35
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112