3 Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
4 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.
22 @param Address - Memory Address
23 @param Width - Memory Width
25 @return Length of the memory unit
29 EdbDisplayMemoryUnit (
31 IN EDB_DATA_WIDTH Width
40 // Print according to width
44 CopyMem (&Data8
, (VOID
*)Address
, sizeof(UINT8
));
45 EDBPrint (L
"%02x ", Data8
);
48 CopyMem (&Data16
, (VOID
*)Address
, sizeof(UINT16
));
49 EDBPrint (L
"%04x ", Data16
);
50 return sizeof(UINT16
);
52 CopyMem (&Data32
, (VOID
*)Address
, sizeof(UINT32
));
53 EDBPrint (L
"%08x ", Data32
);
54 return sizeof(UINT32
);
56 CopyMem (&Data64
, (VOID
*)Address
, sizeof(UINT64
));
57 EDBPrint (L
"%016lx ", Data64
);
58 return sizeof(UINT64
);
74 @param Address - Memory Address
75 @param Count - Memory Count
76 @param Width - Memory Width
83 IN EDB_DATA_WIDTH Width
97 // Get line number and byte number
116 LineNumber
= Count
/ NumberInLine
;
117 ByteNumber
= Count
% NumberInLine
;
118 if (ByteNumber
== 0) {
120 ByteNumber
= NumberInLine
;
126 for (LineIndex
= 0; LineIndex
< LineNumber
; LineIndex
++) {
131 if (((LineIndex
% EFI_DEBUGGER_LINE_NUMBER_IN_PAGE
) == 0) &&
133 if (SetPageBreak ()) {
138 EDBPrint (EDB_PRINT_ADDRESS_FORMAT
, (UINTN
)Address
);
139 for (ByteIndex
= 0; ByteIndex
< NumberInLine
; ByteIndex
++) {
140 Address
+= EdbDisplayMemoryUnit (Address
, Width
);
148 if (((LineIndex
% EFI_DEBUGGER_LINE_NUMBER_IN_PAGE
) == 0) &&
150 if (SetPageBreak ()) {
158 EDBPrint (EDB_PRINT_ADDRESS_FORMAT
, (UINTN
)Address
);
159 for (ByteIndex
= 0; ByteIndex
< ByteNumber
; ByteIndex
++) {
160 Address
+= EdbDisplayMemoryUnit (Address
, Width
);
170 @param Address - Memory Address
171 @param Value - Memory Value
172 @param Width - Memory Width
179 IN EDB_DATA_WIDTH Width
184 CopyMem ((VOID
*)Address
, Value
, sizeof(UINT8
));
187 CopyMem ((VOID
*)Address
, Value
, sizeof(UINT16
));
190 CopyMem ((VOID
*)Address
, Value
, sizeof(UINT32
));
193 CopyMem ((VOID
*)Address
, Value
, sizeof(UINT64
));
204 Get memory address and count.
206 @param CommandArg - The argument for this command
207 @param Address - Memory Address
208 @param Count - Memory Count
210 @retval EFI_SUCCESS - memory address and count are got
211 @retval EFI_INVALID_PARAMETER - something wrong
215 EdbGetMemoryAddressCount (
216 IN CHAR16
*CommandArg
,
228 CommandStr
= CommandArg
;
229 if (CommandStr
== NULL
) {
230 EDBPrint (L
"Memory: Address error!\n");
231 return EFI_INVALID_PARAMETER
;
233 Status
= Symboltoi (CommandStr
, &MemAddress
);
234 if (EFI_ERROR (Status
)) {
235 if (Status
== EFI_NOT_FOUND
) {
236 MemAddress
= Xtoi(CommandStr
);
239 // Something wrong, let Symboltoi print error info.
241 EDBPrint (L
"Command Argument error!\n");
242 return EFI_INVALID_PARAMETER
;
245 *Address
= MemAddress
;
250 CommandStr
= StrGetNextTokenLine (L
" ");
251 if (CommandStr
== NULL
) {
254 *Count
= Xtoi(CommandStr
);
265 Get memory address and value.
267 @param CommandArg - The argument for this command
268 @param Address - Memory Address
269 @param Value - Memory Value
271 @retval EFI_SUCCESS - memory address and value are got
272 @retval EFI_INVALID_PARAMETER - something wrong
276 EdbGetMemoryAddressValue (
277 IN CHAR16
*CommandArg
,
289 CommandStr
= CommandArg
;
290 if (CommandStr
== NULL
) {
291 EDBPrint (L
"Memory: Address error!\n");
292 return EFI_INVALID_PARAMETER
;
294 Status
= Symboltoi (CommandStr
, &MemAddress
);
295 if (EFI_ERROR (Status
)) {
296 if (Status
== EFI_NOT_FOUND
) {
297 MemAddress
= Xtoi(CommandStr
);
300 // Something wrong, let Symboltoi print error info.
302 EDBPrint (L
"Command Argument error!\n");
303 return EFI_INVALID_PARAMETER
;
306 *Address
= MemAddress
;
311 CommandStr
= StrGetNextTokenLine (L
" ");
312 if (CommandStr
== NULL
) {
313 EDBPrint (L
"Memory: Value error!\n");
314 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
);