3 Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
15 @param Address - Memory Address
16 @param Width - Memory Width
18 @return Length of the memory unit
22 EdbDisplayMemoryUnit (
24 IN EDB_DATA_WIDTH Width
33 // Print according to width
37 CopyMem (&Data8
, (VOID
*)Address
, sizeof (UINT8
));
38 EDBPrint (L
"%02x ", Data8
);
39 return sizeof (UINT8
);
41 CopyMem (&Data16
, (VOID
*)Address
, sizeof (UINT16
));
42 EDBPrint (L
"%04x ", Data16
);
43 return sizeof (UINT16
);
45 CopyMem (&Data32
, (VOID
*)Address
, sizeof (UINT32
));
46 EDBPrint (L
"%08x ", Data32
);
47 return sizeof (UINT32
);
49 CopyMem (&Data64
, (VOID
*)Address
, sizeof (UINT64
));
50 EDBPrint (L
"%016lx ", Data64
);
51 return sizeof (UINT64
);
67 @param Address - Memory Address
68 @param Count - Memory Count
69 @param Width - Memory Width
76 IN EDB_DATA_WIDTH Width
90 // Get line number and byte number
109 LineNumber
= Count
/ NumberInLine
;
110 ByteNumber
= Count
% NumberInLine
;
111 if (ByteNumber
== 0) {
113 ByteNumber
= NumberInLine
;
119 for (LineIndex
= 0; LineIndex
< LineNumber
; LineIndex
++) {
123 if (((LineIndex
% EFI_DEBUGGER_LINE_NUMBER_IN_PAGE
) == 0) &&
126 if (SetPageBreak ()) {
131 EDBPrint (EDB_PRINT_ADDRESS_FORMAT
, (UINTN
)Address
);
132 for (ByteIndex
= 0; ByteIndex
< NumberInLine
; ByteIndex
++) {
133 Address
+= EdbDisplayMemoryUnit (Address
, Width
);
142 if (((LineIndex
% EFI_DEBUGGER_LINE_NUMBER_IN_PAGE
) == 0) &&
145 if (SetPageBreak ()) {
153 EDBPrint (EDB_PRINT_ADDRESS_FORMAT
, (UINTN
)Address
);
154 for (ByteIndex
= 0; ByteIndex
< ByteNumber
; ByteIndex
++) {
155 Address
+= EdbDisplayMemoryUnit (Address
, Width
);
165 @param Address - Memory Address
166 @param Value - Memory Value
167 @param Width - Memory Width
174 IN EDB_DATA_WIDTH Width
179 CopyMem ((VOID
*)Address
, Value
, sizeof (UINT8
));
182 CopyMem ((VOID
*)Address
, Value
, sizeof (UINT16
));
185 CopyMem ((VOID
*)Address
, Value
, sizeof (UINT32
));
188 CopyMem ((VOID
*)Address
, Value
, sizeof (UINT64
));
199 Get memory address and count.
201 @param CommandArg - The argument for this command
202 @param Address - Memory Address
203 @param Count - Memory Count
205 @retval EFI_SUCCESS - memory address and count are got
206 @retval EFI_INVALID_PARAMETER - something wrong
210 EdbGetMemoryAddressCount (
211 IN CHAR16
*CommandArg
,
223 CommandStr
= CommandArg
;
224 if (CommandStr
== NULL
) {
225 EDBPrint (L
"Memory: Address error!\n");
226 return EFI_INVALID_PARAMETER
;
229 Status
= Symboltoi (CommandStr
, &MemAddress
);
230 if (EFI_ERROR (Status
)) {
231 if (Status
== EFI_NOT_FOUND
) {
232 MemAddress
= Xtoi (CommandStr
);
235 // Something wrong, let Symboltoi print error info.
237 EDBPrint (L
"Command Argument error!\n");
238 return EFI_INVALID_PARAMETER
;
242 *Address
= MemAddress
;
247 CommandStr
= StrGetNextTokenLine (L
" ");
248 if (CommandStr
== NULL
) {
251 *Count
= Xtoi (CommandStr
);
262 Get memory address and value.
264 @param CommandArg - The argument for this command
265 @param Address - Memory Address
266 @param Value - Memory Value
268 @retval EFI_SUCCESS - memory address and value are got
269 @retval EFI_INVALID_PARAMETER - something wrong
273 EdbGetMemoryAddressValue (
274 IN CHAR16
*CommandArg
,
286 CommandStr
= CommandArg
;
287 if (CommandStr
== NULL
) {
288 EDBPrint (L
"Memory: Address error!\n");
289 return EFI_INVALID_PARAMETER
;
292 Status
= Symboltoi (CommandStr
, &MemAddress
);
293 if (EFI_ERROR (Status
)) {
294 if (Status
== EFI_NOT_FOUND
) {
295 MemAddress
= Xtoi (CommandStr
);
298 // Something wrong, let Symboltoi print error info.
300 EDBPrint (L
"Command Argument error!\n");
301 return EFI_INVALID_PARAMETER
;
305 *Address
= MemAddress
;
310 CommandStr
= StrGetNextTokenLine (L
" ");
311 if (CommandStr
== NULL
) {
312 EDBPrint (L
"Memory: Value error!\n");
313 return EFI_INVALID_PARAMETER
;
316 *Value
= LXtoi (CommandStr
);
328 @param CommandArg - The argument for this command
329 @param Width - Memory Width
331 @retval EFI_DEBUG_RETURN - formal return value
335 DebuggerMemoryDisplay (
336 IN CHAR16
*CommandArg
,
337 IN EDB_DATA_WIDTH Width
345 // Get memory address and count
347 Status
= EdbGetMemoryAddressCount (CommandArg
, &Address
, &Count
);
348 if (EFI_ERROR (Status
)) {
349 return EFI_DEBUG_CONTINUE
;
355 EdbDisplayMemory (Address
, Count
, Width
);
360 return EFI_DEBUG_CONTINUE
;
367 @param CommandArg - The argument for this command
368 @param Width - Memory Width
370 @retval EFI_DEBUG_RETURN - formal return value
374 DebuggerMemoryEnter (
375 IN CHAR16
*CommandArg
,
376 IN EDB_DATA_WIDTH Width
384 // Get memory address and value
386 Status
= EdbGetMemoryAddressValue (CommandArg
, &Address
, &Value
);
387 if (EFI_ERROR (Status
)) {
388 return EFI_DEBUG_CONTINUE
;
394 EdbEnterMemory (Address
, &Value
, Width
);
399 return EFI_DEBUG_CONTINUE
;
404 DebuggerCommand - DB.
406 @param CommandArg - The argument for this command
407 @param DebuggerPrivate - EBC Debugger private data structure
408 @param ExceptionType - Interrupt type.
409 @param SystemContext - EBC system context.
411 @retval EFI_DEBUG_RETURN - formal return value
416 IN CHAR16
*CommandArg
,
417 IN EFI_DEBUGGER_PRIVATE_DATA
*DebuggerPrivate
,
418 IN EFI_EXCEPTION_TYPE ExceptionType
,
419 IN OUT EFI_SYSTEM_CONTEXT SystemContext
422 return DebuggerMemoryDisplay (CommandArg
, EdbWidthUint8
);
427 DebuggerCommand - DW.
429 @param CommandArg - The argument for this command
430 @param DebuggerPrivate - EBC Debugger private data structure
431 @param ExceptionType - Interrupt type.
432 @param SystemContext - EBC system context.
434 @retval EFI_DEBUG_RETURN - formal return value
439 IN CHAR16
*CommandArg
,
440 IN EFI_DEBUGGER_PRIVATE_DATA
*DebuggerPrivate
,
441 IN EFI_EXCEPTION_TYPE ExceptionType
,
442 IN OUT EFI_SYSTEM_CONTEXT SystemContext
445 return DebuggerMemoryDisplay (CommandArg
, EdbWidthUint16
);
450 DebuggerCommand - DD.
452 @param CommandArg - The argument for this command
453 @param DebuggerPrivate - EBC Debugger private data structure
454 @param ExceptionType - Interrupt type.
455 @param SystemContext - EBC system context.
457 @retval EFI_DEBUG_RETURN - formal return value
462 IN CHAR16
*CommandArg
,
463 IN EFI_DEBUGGER_PRIVATE_DATA
*DebuggerPrivate
,
464 IN EFI_EXCEPTION_TYPE ExceptionType
,
465 IN OUT EFI_SYSTEM_CONTEXT SystemContext
468 return DebuggerMemoryDisplay (CommandArg
, EdbWidthUint32
);
473 DebuggerCommand - DQ.
475 @param CommandArg - The argument for this command
476 @param DebuggerPrivate - EBC Debugger private data structure
477 @param ExceptionType - Exception type.
478 @param SystemContext - EBC system context.
480 @retval EFI_DEBUG_RETURN - formal return value
485 IN CHAR16
*CommandArg
,
486 IN EFI_DEBUGGER_PRIVATE_DATA
*DebuggerPrivate
,
487 IN EFI_EXCEPTION_TYPE ExceptionType
,
488 IN OUT EFI_SYSTEM_CONTEXT SystemContext
491 return DebuggerMemoryDisplay (CommandArg
, EdbWidthUint64
);
496 DebuggerCommand - EB.
498 @param CommandArg - The argument for this command
499 @param DebuggerPrivate - EBC Debugger private data structure
500 @param ExceptionType - Exception type.
501 @param SystemContext - EBC system context.
503 @retval EFI_DEBUG_RETURN - formal return value
508 IN CHAR16
*CommandArg
,
509 IN EFI_DEBUGGER_PRIVATE_DATA
*DebuggerPrivate
,
510 IN EFI_EXCEPTION_TYPE ExceptionType
,
511 IN OUT EFI_SYSTEM_CONTEXT SystemContext
514 return DebuggerMemoryEnter (CommandArg
, EdbWidthUint8
);
519 DebuggerCommand - EW.
521 @param CommandArg - The argument for this command
522 @param DebuggerPrivate - EBC Debugger private data structure
523 @param ExceptionType - Interrupt type.
524 @param SystemContext - EBC system context.
526 @retval EFI_DEBUG_RETURN - formal return value
531 IN CHAR16
*CommandArg
,
532 IN EFI_DEBUGGER_PRIVATE_DATA
*DebuggerPrivate
,
533 IN EFI_EXCEPTION_TYPE ExceptionType
,
534 IN OUT EFI_SYSTEM_CONTEXT SystemContext
537 return DebuggerMemoryEnter (CommandArg
, EdbWidthUint16
);
542 DebuggerCommand - ED.
544 @param CommandArg - The argument for this command
545 @param DebuggerPrivate - EBC Debugger private data structure
546 @param ExceptionType - Exception type.
547 @param SystemContext - EBC system context.
549 @retval EFI_DEBUG_RETURN - formal return value
554 IN CHAR16
*CommandArg
,
555 IN EFI_DEBUGGER_PRIVATE_DATA
*DebuggerPrivate
,
556 IN EFI_EXCEPTION_TYPE ExceptionType
,
557 IN OUT EFI_SYSTEM_CONTEXT SystemContext
560 return DebuggerMemoryEnter (CommandArg
, EdbWidthUint32
);
565 DebuggerCommand - EQ.
567 @param CommandArg - The argument for this command
568 @param DebuggerPrivate - EBC Debugger private data structure
569 @param ExceptionType - Exception type.
570 @param SystemContext - EBC system context.
572 @retval EFI_DEBUG_RETURN - formal return value
577 IN CHAR16
*CommandArg
,
578 IN EFI_DEBUGGER_PRIVATE_DATA
*DebuggerPrivate
,
579 IN EFI_EXCEPTION_TYPE ExceptionType
,
580 IN OUT EFI_SYSTEM_CONTEXT SystemContext
583 return DebuggerMemoryEnter (CommandArg
, EdbWidthUint64
);