diff options
author | msmith <msmith@FreeBSD.org> | 1998-09-19 01:31:28 +0000 |
---|---|---|
committer | msmith <msmith@FreeBSD.org> | 1998-09-19 01:31:28 +0000 |
commit | c820301756f1a0e998ef6a618030c9c195207a32 (patch) | |
tree | 2e77cfab0494af5416a73c04240747f9f9613a7f /sys/boot/common | |
parent | fb53c69912b8cf3f11b3513f209c78221a194560 (diff) | |
download | FreeBSD-src-c820301756f1a0e998ef6a618030c9c195207a32.zip FreeBSD-src-c820301756f1a0e998ef6a618030c9c195207a32.tar.gz |
Add a generic hexdump tool for debugging purposes.
Diffstat (limited to 'sys/boot/common')
-rw-r--r-- | sys/boot/common/bootstrap.h | 3 | ||||
-rw-r--r-- | sys/boot/common/misc.c | 42 |
2 files changed, 43 insertions, 2 deletions
diff --git a/sys/boot/common/bootstrap.h b/sys/boot/common/bootstrap.h index f624c29..fe7d1c1 100644 --- a/sys/boot/common/bootstrap.h +++ b/sys/boot/common/bootstrap.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bootstrap.h,v 1.4 1998/09/04 02:43:26 msmith Exp $ + * $Id: bootstrap.h,v 1.5 1998/09/14 18:27:04 msmith Exp $ */ #include <sys/types.h> @@ -65,6 +65,7 @@ extern int autoboot(int delay, char *prompt); /* misc.c */ extern char *unargv(int argc, char *argv[]); +extern void hexdump(caddr_t region, size_t len); extern size_t strlenout(vm_offset_t str); extern char *strdupout(vm_offset_t str); diff --git a/sys/boot/common/misc.c b/sys/boot/common/misc.c index 2999da5..6333eaf 100644 --- a/sys/boot/common/misc.c +++ b/sys/boot/common/misc.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: misc.c,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $ + * $Id: misc.c,v 1.2 1998/09/03 02:10:07 msmith Exp $ */ #include <string.h> @@ -87,3 +87,43 @@ strdupout(vm_offset_t str) } return(result); } + +/* + * Display a region in traditional hexdump format. + */ +void +hexdump(caddr_t region, size_t len) +{ + caddr_t line; + int x, c; + char lbuf[80]; +#define emit(fmt, args...) {sprintf(lbuf, fmt , ## args); pager_output(lbuf);} + + pager_open(); + for (line = region; line < (region + len); line += 16) { + emit("%08x ", line); + + for (x = 0; x < 16; x++) { + if ((line + x) < (region + len)) { + emit("%02x ", *(u_int8_t *)(line + x)); + } else { + emit("-- "); + } + if (x == 7) + emit(" "); + } + emit(" |"); + for (x = 0; x < 16; x++) { + if ((line + x) < (region + len)) { + c = *(u_int8_t *)(line + x); + if ((c < ' ') || (c > '~')) /* !isprint(c) */ + c = '.'; + emit("%c", c); + } else { + emit(" "); + } + } + emit("|\n"); + } + pager_close(); +} |