3 Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
16 @param Address - Memory Address
17 @param Width - Memory Width
19 @return Length of the memory unit
23 EdbDisplayMemoryUnit (
25 IN EDB_DATA_WIDTH Width
34 // Print according to width
38 CopyMem (&Data8
, (VOID
*)Address
, sizeof(UINT8
));
39 EDBPrint (L
"%02x ", Data8
);
42 CopyMem (&Data16
, (VOID
*)Address
, sizeof(UINT16
));
43 EDBPrint (L
"%04x ", Data16
);
44 return sizeof(UINT16
);
46 CopyMem (&Data32
, (VOID
*)Address
, sizeof(UINT32
));
47 EDBPrint (L
"%08x ", Data32
);
48 return sizeof(UINT32
);
50 CopyMem (&Data64
, (VOID
*)Address
, sizeof(UINT64
));
51 EDBPrint (L
"%016lx ", Data64
);
52 return sizeof(UINT64
);
68 @param Address - Memory Address
69 @param Count - Memory Count
70 @param Width - Memory Width
77 IN EDB_DATA_WIDTH Width
91 // Get line number and byte number
110 LineNumber
= Count
/ NumberInLine
;
111 ByteNumber
= Count
% NumberInLine
;
112 if (ByteNumber
== 0) {
114 ByteNumber
= NumberInLine
;
120 for (LineIndex
= 0; LineIndex
< LineNumber
; LineIndex
++) {
125 if (((LineIndex
% EFI_DEBUGGER_LINE_NUMBER_IN_PAGE
) == 0) &&
127 if (SetPageBreak ()) {
132 EDBPrint (EDB_PRINT_ADDRESS_FORMAT
, (UINTN
)Address
);
133 for (ByteIndex
= 0; ByteIndex
< NumberInLine
; ByteIndex
++) {
134 Address
+= EdbDisplayMemoryUnit (Address
, Width
);
142 if (((LineIndex
% EFI_DEBUGGER_LINE_NUMBER_IN_PAGE
) == 0) &&
144 if (SetPageBreak ()) {
152 EDBPrint (EDB_PRINT_ADDRESS_FORMAT
, (UINTN
)Address
);
153 for (ByteIndex
= 0; ByteIndex
< ByteNumber
; ByteIndex
++) {
154 Address
+= EdbDisplayMemoryUnit (Address
, Width
);
164 @param Address - Memory Address
165 @param Value - Memory Value
166 @param Width - Memory Width
173 IN EDB_DATA_WIDTH Width
178 CopyMem ((VOID
*)Address
, Value
, sizeof(UINT8
));
181 CopyMem ((VOID
*)Address
, Value
, sizeof(UINT16
));
184 CopyMem ((VOID
*)Address
, Value
, sizeof(UINT32
));
187 CopyMem ((VOID
*)Address
, Value
, sizeof(UINT64
));
198 Get memory address and count.
200 @param CommandArg - The argument for this command
201 @param Address - Memory Address
202 @param Count - Memory Count
204 @retval EFI_SUCCESS - memory address and count are got
205 @retval EFI_INVALID_PARAMETER - something wrong
209 EdbGetMemoryAddressCount (
210 IN CHAR16
*CommandArg
,
222 CommandStr
= CommandArg
;
223 if (CommandStr
== NULL
) {
224 EDBPrint (L
"Memory: Address error!\n");
225 return EFI_INVALID_PARAMETER
;
227 Status
= Symboltoi (CommandStr
, &MemAddress
);
228 if (EFI_ERROR (Status
)) {
229 if (Status
== EFI_NOT_FOUND
) {
230 MemAddress
= Xtoi(CommandStr
);
233 // Something wrong, let Symboltoi print error info.
235 EDBPrint (L
"Command Argument error!\n");
236 return EFI_INVALID_PARAMETER
;
239 *Address
= MemAddress
;
244 CommandStr
= StrGetNextTokenLine (L
" ");
245 if (CommandStr
== NULL
) {
248 *Count
= Xtoi(CommandStr
);
259 Get memory address and value.
261 @param CommandArg - The argument for this command
262 @param Address - Memory Address
263 @param Value - Memory Value
265 @retval EFI_SUCCESS - memory address and value are got
266 @retval EFI_INVALID_PARAMETER - something wrong
270 EdbGetMemoryAddressValue (
271 IN CHAR16
*CommandArg
,
283 CommandStr
= CommandArg
;
284 if (CommandStr
== NULL
) {
285 EDBPrint (L
"Memory: Address error!\n");
286 return EFI_INVALID_PARAMETER
;
288 Status
= Symboltoi (CommandStr
, &MemAddress
);
289 if (EFI_ERROR (Status
)) {
290 if (Status
== EFI_NOT_FOUND
) {
291 MemAddress
= Xtoi(CommandStr
);
294 // Something wrong, let Symboltoi print error info.
296 EDBPrint (L
"Command Argument error!\n");
297 return EFI_INVALID_PARAMETER
;
300 *Address
= MemAddress
;
305 CommandStr
= StrGetNextTokenLine (L
" ");
306 if (CommandStr
== NULL
) {
307 EDBPrint (L
"Memory: Value error!\n");
308 return EFI_INVALID_PARAMETER
;
310 *Value
= LXtoi(CommandStr
);
322 @param CommandArg - The argument for this command
323 @param Width - Memory Width
325 @retval EFI_DEBUG_RETURN - formal return value
329 DebuggerMemoryDisplay (
330 IN CHAR16
*CommandArg
,
331 IN EDB_DATA_WIDTH Width
339 // Get memory address and count
341 Status
= EdbGetMemoryAddressCount (CommandArg
, &Address
, &Count
);
342 if (EFI_ERROR(Status
)) {
343 return EFI_DEBUG_CONTINUE
;
349 EdbDisplayMemory (Address
, Count
, Width
);
354 return EFI_DEBUG_CONTINUE
;
361 @param CommandArg - The argument for this command
362 @param Width - Memory Width
364 @retval EFI_DEBUG_RETURN - formal return value
368 DebuggerMemoryEnter (
369 IN CHAR16
*CommandArg
,
370 IN EDB_DATA_WIDTH Width
378 // Get memory address and value
380 Status
= EdbGetMemoryAddressValue (CommandArg
, &Address
, &Value
);
381 if (EFI_ERROR(Status
)) {
382 return EFI_DEBUG_CONTINUE
;
388 EdbEnterMemory (Address
, &Value
, Width
);
393 return EFI_DEBUG_CONTINUE
;
398 DebuggerCommand - DB.
400 @param CommandArg - The argument for this command
401 @param DebuggerPrivate - EBC Debugger private data structure
402 @param ExceptionType - Interrupt type.
403 @param SystemContext - EBC system context.
405 @retval EFI_DEBUG_RETURN - formal return value
410 IN CHAR16
*CommandArg
,
411 IN EFI_DEBUGGER_PRIVATE_DATA
*DebuggerPrivate
,
412 IN EFI_EXCEPTION_TYPE ExceptionType
,
413 IN OUT EFI_SYSTEM_CONTEXT SystemContext
416 return DebuggerMemoryDisplay (CommandArg
, EdbWidthUint8
);
421 DebuggerCommand - DW.
423 @param CommandArg - The argument for this command
424 @param DebuggerPrivate - EBC Debugger private data structure
425 @param ExceptionType - Interrupt type.
426 @param SystemContext - EBC system context.
428 @retval EFI_DEBUG_RETURN - formal return value
433 IN CHAR16
*CommandArg
,
434 IN EFI_DEBUGGER_PRIVATE_DATA
*DebuggerPrivate
,
435 IN EFI_EXCEPTION_TYPE ExceptionType
,
436 IN OUT EFI_SYSTEM_CONTEXT SystemContext
439 return DebuggerMemoryDisplay (CommandArg
, EdbWidthUint16
);
444 DebuggerCommand - DD.
446 @param CommandArg - The argument for this command
447 @param DebuggerPrivate - EBC Debugger private data structure
448 @param ExceptionType - Interrupt type.
449 @param SystemContext - EBC system context.
451 @retval EFI_DEBUG_RETURN - formal return value
456 IN CHAR16
*CommandArg
,
457 IN EFI_DEBUGGER_PRIVATE_DATA
*DebuggerPrivate
,
458 IN EFI_EXCEPTION_TYPE ExceptionType
,
459 IN OUT EFI_SYSTEM_CONTEXT SystemContext
462 return DebuggerMemoryDisplay (CommandArg
, EdbWidthUint32
);
467 DebuggerCommand - DQ.
469 @param CommandArg - The argument for this command
470 @param DebuggerPrivate - EBC Debugger private data structure
471 @param ExceptionType - Exception type.
472 @param SystemContext - EBC system context.
474 @retval EFI_DEBUG_RETURN - formal return value
479 IN CHAR16
*CommandArg
,
480 IN EFI_DEBUGGER_PRIVATE_DATA
*DebuggerPrivate
,
481 IN EFI_EXCEPTION_TYPE ExceptionType
,
482 IN OUT EFI_SYSTEM_CONTEXT SystemContext
485 return DebuggerMemoryDisplay (CommandArg
, EdbWidthUint64
);
490 DebuggerCommand - EB.
492 @param CommandArg - The argument for this command
493 @param DebuggerPrivate - EBC Debugger private data structure
494 @param ExceptionType - Exception type.
495 @param SystemContext - EBC system context.
497 @retval EFI_DEBUG_RETURN - formal return value
502 IN CHAR16
*CommandArg
,
503 IN EFI_DEBUGGER_PRIVATE_DATA
*DebuggerPrivate
,
504 IN EFI_EXCEPTION_TYPE ExceptionType
,
505 IN OUT EFI_SYSTEM_CONTEXT SystemContext
508 return DebuggerMemoryEnter (CommandArg
, EdbWidthUint8
);
513 DebuggerCommand - EW.
515 @param CommandArg - The argument for this command
516 @param DebuggerPrivate - EBC Debugger private data structure
517 @param ExceptionType - Interrupt type.
518 @param SystemContext - EBC system context.
520 @retval EFI_DEBUG_RETURN - formal return value
525 IN CHAR16
*CommandArg
,
526 IN EFI_DEBUGGER_PRIVATE_DATA
*DebuggerPrivate
,
527 IN EFI_EXCEPTION_TYPE ExceptionType
,
528 IN OUT EFI_SYSTEM_CONTEXT SystemContext
531 return DebuggerMemoryEnter (CommandArg
, EdbWidthUint16
);
536 DebuggerCommand - ED.
538 @param CommandArg - The argument for this command
539 @param DebuggerPrivate - EBC Debugger private data structure
540 @param ExceptionType - Exception type.
541 @param SystemContext - EBC system context.
543 @retval EFI_DEBUG_RETURN - formal return value
548 IN CHAR16
*CommandArg
,
549 IN EFI_DEBUGGER_PRIVATE_DATA
*DebuggerPrivate
,
550 IN EFI_EXCEPTION_TYPE ExceptionType
,
551 IN OUT EFI_SYSTEM_CONTEXT SystemContext
554 return DebuggerMemoryEnter (CommandArg
, EdbWidthUint32
);
559 DebuggerCommand - EQ.
561 @param CommandArg - The argument for this command
562 @param DebuggerPrivate - EBC Debugger private data structure
563 @param ExceptionType - Exception type.
564 @param SystemContext - EBC system context.
566 @retval EFI_DEBUG_RETURN - formal return value
571 IN CHAR16
*CommandArg
,
572 IN EFI_DEBUGGER_PRIVATE_DATA
*DebuggerPrivate
,
573 IN EFI_EXCEPTION_TYPE ExceptionType
,
574 IN OUT EFI_SYSTEM_CONTEXT SystemContext
577 return DebuggerMemoryEnter (CommandArg
, EdbWidthUint64
);