3 Copyright (c) 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
24 EdbDisplayMemoryUnit (
26 IN EDB_DATA_WIDTH Width
36 Address - Memory Address
41 Length of the memory unit
51 // Print accroding to width
55 CopyMem (&Data8
, (VOID
*)Address
, sizeof(UINT8
));
56 EDBPrint (L
"%02x ", Data8
);
59 CopyMem (&Data16
, (VOID
*)Address
, sizeof(UINT16
));
60 EDBPrint (L
"%04x ", Data16
);
61 return sizeof(UINT16
);
63 CopyMem (&Data32
, (VOID
*)Address
, sizeof(UINT32
));
64 EDBPrint (L
"%08x ", Data32
);
65 return sizeof(UINT32
);
67 CopyMem (&Data64
, (VOID
*)Address
, sizeof(UINT64
));
68 EDBPrint (L
"%016lx ", Data64
);
69 return sizeof(UINT64
);
85 IN EDB_DATA_WIDTH Width
95 Address - Memory Address
116 // Get line number and byte number
135 LineNumber
= Count
/ NumberInLine
;
136 ByteNumber
= Count
% NumberInLine
;
137 if (ByteNumber
== 0) {
139 ByteNumber
= NumberInLine
;
145 for (LineIndex
= 0; LineIndex
< LineNumber
; LineIndex
++) {
150 if (((LineIndex
% EFI_DEBUGGER_LINE_NUMBER_IN_PAGE
) == 0) &&
152 if (SetPageBreak ()) {
157 EDBPrint (EDB_PRINT_ADDRESS_FORMAT
, (UINTN
)Address
);
158 for (ByteIndex
= 0; ByteIndex
< NumberInLine
; ByteIndex
++) {
159 Address
+= EdbDisplayMemoryUnit (Address
, Width
);
167 if (((LineIndex
% EFI_DEBUGGER_LINE_NUMBER_IN_PAGE
) == 0) &&
169 if (SetPageBreak ()) {
177 EDBPrint (EDB_PRINT_ADDRESS_FORMAT
, (UINTN
)Address
);
178 for (ByteIndex
= 0; ByteIndex
< ByteNumber
; ByteIndex
++) {
179 Address
+= EdbDisplayMemoryUnit (Address
, Width
);
189 IN EDB_DATA_WIDTH Width
199 Address - Memory Address
211 CopyMem ((VOID
*)Address
, Value
, sizeof(UINT8
));
214 CopyMem ((VOID
*)Address
, Value
, sizeof(UINT16
));
217 CopyMem ((VOID
*)Address
, Value
, sizeof(UINT32
));
220 CopyMem ((VOID
*)Address
, Value
, sizeof(UINT64
));
230 EdbGetMemoryAddressCount (
231 IN CHAR16
*CommandArg
,
239 Get memory address and count
243 CommandArg - The argument for this command
244 Address - Memory Address
249 EFI_SUCCESS - memory address and count are got
250 EFI_INVALID_PARAMETER - something wrong
261 CommandStr
= CommandArg
;
262 if (CommandStr
== NULL
) {
263 EDBPrint (L
"Memory: Address error!\n");
264 return EFI_INVALID_PARAMETER
;
266 Status
= Symboltoi (CommandStr
, &MemAddress
);
267 if (EFI_ERROR (Status
)) {
268 if (Status
== EFI_NOT_FOUND
) {
269 MemAddress
= Xtoi(CommandStr
);
272 // Something wrong, let Symboltoi print error info.
274 EDBPrint (L
"Command Argument error!\n");
275 return EFI_INVALID_PARAMETER
;
278 *Address
= MemAddress
;
283 CommandStr
= StrGetNextTokenLine (L
" ");
284 if (CommandStr
== NULL
) {
287 *Count
= Xtoi(CommandStr
);
297 EdbGetMemoryAddressValue (
298 IN CHAR16
*CommandArg
,
306 Get memory address and value
310 CommandArg - The argument for this command
311 Address - Memory Address
316 EFI_SUCCESS - memory address and value are got
317 EFI_INVALID_PARAMETER - something wrong
328 CommandStr
= CommandArg
;
329 if (CommandStr
== NULL
) {
330 EDBPrint (L
"Memory: Address error!\n");
331 return EFI_INVALID_PARAMETER
;
333 Status
= Symboltoi (CommandStr
, &MemAddress
);
334 if (EFI_ERROR (Status
)) {
335 if (Status
== EFI_NOT_FOUND
) {
336 MemAddress
= Xtoi(CommandStr
);
339 // Something wrong, let Symboltoi print error info.
341 EDBPrint (L
"Command Argument error!\n");
342 return EFI_INVALID_PARAMETER
;
345 *Address
= MemAddress
;
350 CommandStr
= StrGetNextTokenLine (L
" ");
351 if (CommandStr
== NULL
) {
352 EDBPrint (L
"Memory: Value error!\n");
353 return EFI_INVALID_PARAMETER
;
355 *Value
= LXtoi(CommandStr
);
364 DebuggerMemoryDisplay (
365 IN CHAR16
*CommandArg
,
366 IN EDB_DATA_WIDTH Width
376 CommandArg - The argument for this command
381 EFI_DEBUG_RETURN - formal return value
390 // Get memory address and count
392 Status
= EdbGetMemoryAddressCount (CommandArg
, &Address
, &Count
);
393 if (EFI_ERROR(Status
)) {
394 return EFI_DEBUG_CONTINUE
;
400 EdbDisplayMemory (Address
, Count
, Width
);
405 return EFI_DEBUG_CONTINUE
;
409 DebuggerMemoryEnter (
410 IN CHAR16
*CommandArg
,
411 IN EDB_DATA_WIDTH Width
421 CommandArg - The argument for this command
426 EFI_DEBUG_RETURN - formal return value
435 // Get memory address and value
437 Status
= EdbGetMemoryAddressValue (CommandArg
, &Address
, &Value
);
438 if (EFI_ERROR(Status
)) {
439 return EFI_DEBUG_CONTINUE
;
445 EdbEnterMemory (Address
, &Value
, Width
);
450 return EFI_DEBUG_CONTINUE
;
455 IN CHAR16
*CommandArg
,
456 IN EFI_DEBUGGER_PRIVATE_DATA
*DebuggerPrivate
,
457 IN EFI_EXCEPTION_TYPE ExceptionType
,
458 IN OUT EFI_SYSTEM_CONTEXT SystemContext
468 CommandArg - The argument for this command
469 DebuggerPrivate - EBC Debugger private data structure
470 InterruptType - Interrupt type.
471 SystemContext - EBC system context.
475 EFI_DEBUG_RETURN - formal return value
479 return DebuggerMemoryDisplay (CommandArg
, EdbWidthUint8
);
484 IN CHAR16
*CommandArg
,
485 IN EFI_DEBUGGER_PRIVATE_DATA
*DebuggerPrivate
,
486 IN EFI_EXCEPTION_TYPE ExceptionType
,
487 IN OUT EFI_SYSTEM_CONTEXT SystemContext
497 CommandArg - The argument for this command
498 DebuggerPrivate - EBC Debugger private data structure
499 InterruptType - Interrupt type.
500 SystemContext - EBC system context.
504 EFI_DEBUG_RETURN - formal return value
508 return DebuggerMemoryDisplay (CommandArg
, EdbWidthUint16
);
513 IN CHAR16
*CommandArg
,
514 IN EFI_DEBUGGER_PRIVATE_DATA
*DebuggerPrivate
,
515 IN EFI_EXCEPTION_TYPE ExceptionType
,
516 IN OUT EFI_SYSTEM_CONTEXT SystemContext
526 CommandArg - The argument for this command
527 DebuggerPrivate - EBC Debugger private data structure
528 InterruptType - Interrupt type.
529 SystemContext - EBC system context.
533 EFI_DEBUG_RETURN - formal return value
537 return DebuggerMemoryDisplay (CommandArg
, EdbWidthUint32
);
542 IN CHAR16
*CommandArg
,
543 IN EFI_DEBUGGER_PRIVATE_DATA
*DebuggerPrivate
,
544 IN EFI_EXCEPTION_TYPE ExceptionType
,
545 IN OUT EFI_SYSTEM_CONTEXT SystemContext
555 CommandArg - The argument for this command
556 DebuggerPrivate - EBC Debugger private data structure
557 InterruptType - Interrupt type.
558 SystemContext - EBC system context.
562 EFI_DEBUG_RETURN - formal return value
566 return DebuggerMemoryDisplay (CommandArg
, EdbWidthUint64
);
571 IN CHAR16
*CommandArg
,
572 IN EFI_DEBUGGER_PRIVATE_DATA
*DebuggerPrivate
,
573 IN EFI_EXCEPTION_TYPE ExceptionType
,
574 IN OUT EFI_SYSTEM_CONTEXT SystemContext
584 CommandArg - The argument for this command
585 DebuggerPrivate - EBC Debugger private data structure
586 InterruptType - Interrupt type.
587 SystemContext - EBC system context.
591 EFI_DEBUG_RETURN - formal return value
595 return DebuggerMemoryEnter (CommandArg
, EdbWidthUint8
);
600 IN CHAR16
*CommandArg
,
601 IN EFI_DEBUGGER_PRIVATE_DATA
*DebuggerPrivate
,
602 IN EFI_EXCEPTION_TYPE ExceptionType
,
603 IN OUT EFI_SYSTEM_CONTEXT SystemContext
613 CommandArg - The argument for this command
614 DebuggerPrivate - EBC Debugger private data structure
615 InterruptType - Interrupt type.
616 SystemContext - EBC system context.
620 EFI_DEBUG_RETURN - formal return value
624 return DebuggerMemoryEnter (CommandArg
, EdbWidthUint16
);
629 IN CHAR16
*CommandArg
,
630 IN EFI_DEBUGGER_PRIVATE_DATA
*DebuggerPrivate
,
631 IN EFI_EXCEPTION_TYPE ExceptionType
,
632 IN OUT EFI_SYSTEM_CONTEXT SystemContext
642 CommandArg - The argument for this command
643 DebuggerPrivate - EBC Debugger private data structure
644 InterruptType - Interrupt type.
645 SystemContext - EBC system context.
649 EFI_DEBUG_RETURN - formal return value
653 return DebuggerMemoryEnter (CommandArg
, EdbWidthUint32
);
658 IN CHAR16
*CommandArg
,
659 IN EFI_DEBUGGER_PRIVATE_DATA
*DebuggerPrivate
,
660 IN EFI_EXCEPTION_TYPE ExceptionType
,
661 IN OUT EFI_SYSTEM_CONTEXT SystemContext
671 CommandArg - The argument for this command
672 DebuggerPrivate - EBC Debugger private data structure
673 InterruptType - Interrupt type.
674 SystemContext - EBC system context.
678 EFI_DEBUG_RETURN - formal return value
682 return DebuggerMemoryEnter (CommandArg
, EdbWidthUint64
);