Update contrib.
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Helper functions for HCR debug
21 #include <kernel/kernel.h>
24 #include "hcr_debug.h"
28 Make a classic hexadecimal dump of the content of an memory region. Do not
29 call directly but used the macros: HCR_HEX_DUMP_ABS(), HCR_HEX_DUMP_REL()
31 @param aStartAddress Pointer of the first byte of the region
32 aLength Size of the region
33 aAbsolute If it is TRUE then it displays absolute address where the aStartAddress points
34 If it is FALSE then it displays reltive address from aStartAddress
36 @pre Call from thread context (neither NULL, DFC0, DFC1 threads)
39 void HexDump(TUint8* aStartAddress, TUint32 aLength, TBool aAbsolute)
42 TBuf<128> printBuf; // Buffer for address and values
43 TBuf<32> printBuf2; // Buffer for character representation
45 TUint32 extLength = ((aLength & 0xf) == 0 ? aLength :(aLength & 0xfffffff0)+0x10);
47 for(nIndex = 0; nIndex != extLength ; ++nIndex )
51 // A line is ready compose two buffers and print the line out
52 printBuf.Append(_L(" "));
53 printBuf.Append(printBuf2);
54 Kern::Printf("%S", &printBuf);
58 printBuf.Append(_L("0x"));
61 printBuf.AppendNumFixedWidth((TUint)(aStartAddress + nIndex), EHex,8);
65 printBuf.AppendNumFixedWidth((TUint)(nIndex), EHex,8);
68 printBuf.Append(_L(": "));
72 if( nIndex < aLength )
75 // Put the value into buffer
76 printBuf.AppendNumFixedWidth(*(aStartAddress + nIndex), EHex,2 );
77 printBuf.Append(TChar(' '));
79 // Put the chracter representation into a second buffer
80 if( *(aStartAddress + nIndex) < ' ' )
82 printBuf2.Append(TChar('.')); // Control character
86 printBuf2.Append(TChar(*(aStartAddress + nIndex)));
92 printBuf.Append(_L(" ")); // Fill value place with spaces
93 printBuf2.Append(TChar(' ')); // Fill char representation place with space
96 // Print out the rest of the buffer
97 printBuf.Append(_L(" "));
98 printBuf.Append(printBuf2);
99 Kern::Printf("%S\n", &printBuf);