From 0b1cd9b7b17b092c2eebbd0e772ee91162fcbc49 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Wed, 15 Apr 2009 14:01:08 +0000 Subject: [PATCH] - added PrintBuffer8() and memdump() Committed on the Free edition of March Hare Software CVSNT Server. Upgrade to CVS Suite for more features and support: http://march-hare.com/cvsnt/ git-svn-id: http://moon:8086/svn/vhdl/trunk@441 cc03376c-175c-47c8-b038-4cd826a8556b --- .../bsp/examples/bootloader/libsys_boot.c | 72 +++++++++++++++++++ .../bsp/examples/bootloader/libsys_boot.h | 2 + 2 files changed, 74 insertions(+) diff --git a/lib/CPUs/MIPS/bsp/examples/bootloader/libsys_boot.c b/lib/CPUs/MIPS/bsp/examples/bootloader/libsys_boot.c index 91a99ea..cf3ef5e 100644 --- a/lib/CPUs/MIPS/bsp/examples/bootloader/libsys_boot.c +++ b/lib/CPUs/MIPS/bsp/examples/bootloader/libsys_boot.c @@ -140,3 +140,75 @@ void print_word(int word) } } +// --------------------------------------------------------------------------------- +// PrintBuffer8() +// Prints byte buffer as hex and ascii interpretation +// --------------------------------------------------------------------------------- +// _Parameters : +// pBuf: : IN: Buffer to display +// nbpr : Number of bytes per row to display +// len : Length of input buffer +// _Return: none +// +// --------------------------------------------------------------------------- +void PrintBuffer8(UINT8 *pBuf, int nbpr, int len) +{ + memdump(pBuf, 1, nbpr, len); +} + +void memdump(UINT8 *pBuf, int print_offset_only, int num_bytes_per_row, int len) +{ + int i, j, cnt_hex, cnt_asc, base; + unsigned char c; + + i = j = 0; + cnt_hex = len; + cnt_asc = len; + base = 0; + if (!print_offset_only) + base = (int)pBuf; + + do + { + print_word(base + i); + sputs(": "); + for (j=0; j < num_bytes_per_row; j++) + { + if (cnt_hex) + { + print_byte(pBuf[i+j]); + sputs(" "); + cnt_hex--; + } + else + { + sputs(" "); + break; + } + + } + + sputs(" "); + for (j=0; j < num_bytes_per_row; j++) + { + if (cnt_asc) + { + c = pBuf[i+j]; + if((c < 0x20) || (c > 0x7F)) + c = '.'; + + _putchar(c); + cnt_asc--; + } + else + { + sputs(" "); + break; + } + } + sputs("\n"); + i += num_bytes_per_row; + + } while (cnt_hex); +} + diff --git a/lib/CPUs/MIPS/bsp/examples/bootloader/libsys_boot.h b/lib/CPUs/MIPS/bsp/examples/bootloader/libsys_boot.h index 31ab047..241103b 100644 --- a/lib/CPUs/MIPS/bsp/examples/bootloader/libsys_boot.h +++ b/lib/CPUs/MIPS/bsp/examples/bootloader/libsys_boot.h @@ -45,6 +45,8 @@ int write(int file, char *ptr, int len); int sputs(char *pStr); void print_byte(char byte); void print_word(int word); +void PrintBuffer8(UINT8 *pBuf, int nbpr, int len); +void memdump(UINT8 *pBuf, int print_offset_only, int num_bytes_per_row, int len); #endif // LIBSYS_H