int macdbg_dmphex_kernel(const char* buff_in, int len)
{
int retval = 0;
int x, y, tot, lineoff;
const char* curr;
char buff[128];
int index;
//Ser_Printf("buff %x.\r\n", buff );
lineoff = 0;
curr = buff_in;
tot = 0;
for( x = 0; x+16 < len; ){
index = 0x00;
memset( buff, 0x00, sizeof(buff) );
sprintf( &buff[index], "%x\t", lineoff );
index = strlen(buff);
//printk("index = %d\n", index);
for( y = 0; y < 16; y++ ){
sprintf( &buff[index], "%02x ", (unsigned char)*(curr + y) );
index = strlen(buff);
}
sprintf( &buff[index], "%s", " " );
index = strlen(buff);
for( y = 0; y < 16; y++ ){
char c;
c = *(curr + y);
if( c > 31 && c < 127 ){
sprintf( &buff[index], "%c", c );
}else{
sprintf( &buff[index], "%c", '.' );
}
index = strlen(buff);
tot++;
}
curr += 16;
x += 16;
lineoff+=16;
sprintf( &buff[index], "%s", "\r\n" );
printk("%s", buff);
}
//do last line
//Ser_Printf("tot %d.\r\n", tot );
//Ser_Printf("len %d.\r\n", len );
index = 0x00;
memset( buff, 0x00, sizeof(buff) );
if( tot < len ){
curr = (buff_in + tot);
sprintf( &buff[index], "%x\t", lineoff );
index = strlen(buff);
for( y = 0; y < (len - tot); y++ ){
sprintf( &buff[index], "%02x ", (unsigned char)*(curr + y) );
index = strlen(buff);
}
//padding with spaces
//printk("(len - tot) %d.\r\n", (len - tot) );
if( (len - tot) < 16 ){
for( y = 0; y<(16-(len-tot)); y++ ){
sprintf( &buff[index], "%s", " " );
index = index + 3;
}
}
sprintf( &buff[index], "%s", " " );
index = strlen(buff);
//Ser_Printf("(len - tot) %d.\r\n", (len - tot) );
for( y = 0; y < (len - tot); y++ ){
char c;
c = *(curr + y);
if( c > 31 && c < 127 ){
sprintf( &buff[index], "%c", c );
}else{
sprintf( &buff[index], "%c", '.' );
}
index = strlen(buff);
}
}
sprintf( &buff[index], "%s", "\r\n" );
printk("%s", buff);
return retval;
}
int macdbg_dmphex_kernel(const char* buff_in, int len)
{
int retval = 0;
int x, y, tot, lineoff;
const char* curr;
char buff[128];
int index;
//Ser_Printf("buff %x.\r\n", buff );
lineoff = 0;
curr = buff_in;
tot = 0;
for( x = 0; x+16 < len; ){
index = 0x00;
memset( buff, 0x00, sizeof(buff) );
sprintf( &buff[index], "%x\t", lineoff );
index = strlen(buff);
//printk("index = %d\n", index);
for( y = 0; y < 16; y++ ){
sprintf( &buff[index], "%02x ", (unsigned char)*(curr + y) );
index = strlen(buff);
}
sprintf( &buff[index], "%s", " " );
index = strlen(buff);
for( y = 0; y < 16; y++ ){
char c;
c = *(curr + y);
if( c > 31 && c < 127 ){
sprintf( &buff[index], "%c", c );
}else{
sprintf( &buff[index], "%c", '.' );
}
index = strlen(buff);
tot++;
}
curr += 16;
x += 16;
lineoff+=16;
sprintf( &buff[index], "%s", "\r\n" );
printk("%s", buff);
}
//do last line
//Ser_Printf("tot %d.\r\n", tot );
//Ser_Printf("len %d.\r\n", len );
index = 0x00;
memset( buff, 0x00, sizeof(buff) );
if( tot < len ){
curr = (buff_in + tot);
sprintf( &buff[index], "%x\t", lineoff );
index = strlen(buff);
for( y = 0; y < (len - tot); y++ ){
sprintf( &buff[index], "%02x ", (unsigned char)*(curr + y) );
index = strlen(buff);
}
//padding with spaces
//printk("(len - tot) %d.\r\n", (len - tot) );
if( (len - tot) < 16 ){
for( y = 0; y<(16-(len-tot)); y++ ){
sprintf( &buff[index], "%s", " " );
index = index + 3;
}
}
sprintf( &buff[index], "%s", " " );
index = strlen(buff);
//Ser_Printf("(len - tot) %d.\r\n", (len - tot) );
for( y = 0; y < (len - tot); y++ ){
char c;
c = *(curr + y);
if( c > 31 && c < 127 ){
sprintf( &buff[index], "%c", c );
}else{
sprintf( &buff[index], "%c", '.' );
}
index = strlen(buff);
}
}
sprintf( &buff[index], "%s", "\r\n" );
printk("%s", buff);
return retval;
}