6 printf ( "\nPress a key" );
12 printf ( "---more---" );
17 /* Produce a paged hex dump of the specified data and length */
18 void hex_dump ( const unsigned char *data, const unsigned int len ) {
20 for ( index = 0; index < len; index++ ) {
21 if ( ( index % 16 ) == 0 ) {
24 if ( ( index % 368 ) == 352 ) {
27 if ( ( index % 16 ) == 0 ) {
28 printf ( "%p [%lx] : %04x :", data + index,
29 virt_to_phys ( data + index ), index );
31 printf ( " %02x", data[index] );
36 #define GUARD_SYMBOL ( ( 'M' << 24 ) | ( 'I' << 16 ) | ( 'N' << 8 ) | 'E' )
37 /* Fill a region with guard markers. We use a 4-byte pattern to make
38 * it less likely that check_region will find spurious 1-byte regions
41 void guard_region ( void *region, size_t len ) {
45 for ( offset = 0; offset < len ; offset += 4 ) {
46 *((uint32_t *)(region + offset)) = GUARD_SYMBOL;
50 /* Check a region that has been guarded with guard_region() for
53 int check_region ( void *region, size_t len ) {
54 uint8_t corrupted = 0;
55 uint8_t in_corruption = 0;
60 for ( offset = 0; offset < len ; offset += 4 ) {
61 test = *((uint32_t *)(region + offset)) = GUARD_SYMBOL;
62 if ( ( in_corruption == 0 ) &&
63 ( test != GUARD_SYMBOL ) ) {
64 /* Start of corruption */
65 if ( corrupted == 0 ) {
67 printf ( "Region %p-%p (physical %#lx-%#lx) "
70 virt_to_phys ( region ),
71 virt_to_phys ( region + len ) );
74 printf ( "--- offset %#lx ", offset );
75 } else if ( ( in_corruption != 0 ) &&
76 ( test == GUARD_SYMBOL ) ) {
77 /* End of corruption */
79 printf ( "to offset %#lx", offset );
83 if ( in_corruption != 0 ) {
84 printf ( "to offset %#x (end of region)\n", len-1 );