summaryrefslogtreecommitdiff
path: root/sys/stand
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2019-11-28 00:17:14 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2019-11-28 00:17:14 +0000
commitca53f2e86f998d94cd315ce272f8678030128ea3 (patch)
tree50ec25d2e5d1306ac3b844c89e0f2ca6b03134ba /sys/stand
parent5e22f15993801e613c6031b049bafc2c64a175ec (diff)
Implement a hexdump command in the boot loader. This helps to
inspect the memory layout that the firmware has created. It is especially useful for UEFI debugging. OK deraadt@ kettenis@
Diffstat (limited to 'sys/stand')
-rw-r--r--sys/stand/boot/cmd.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/sys/stand/boot/cmd.c b/sys/stand/boot/cmd.c
index a03b7d662aa..d9e7ba76e28 100644
--- a/sys/stand/boot/cmd.c
+++ b/sys/stand/boot/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.65 2019/08/03 15:22:19 deraadt Exp $ */
+/* $OpenBSD: cmd.c,v 1.66 2019/11/28 00:17:13 bluhm Exp $ */
/*
* Copyright (c) 1997-1999 Michael Shalayeff
@@ -39,6 +39,7 @@
static int Xboot(void);
static int Xecho(void);
static int Xhelp(void);
+static int Xhexdump(void);
static int Xls(void);
static int Xnop(void);
static int Xreboot(void);
@@ -62,6 +63,7 @@ const struct cmd_table cmd_table[] = {
{"echo", CMDT_CMD, Xecho},
{"env", CMDT_CMD, Xenv},
{"help", CMDT_CMD, Xhelp},
+ {"hexdump",CMDT_CMD, Xhexdump},
{"ls", CMDT_CMD, Xls},
#ifdef MACHINE_CMD
{"machine",CMDT_MDC, Xmachine},
@@ -347,6 +349,29 @@ Xhelp(void)
#endif
}
+static int
+Xhexdump(void)
+{
+ long long val[2];
+ char *ep;
+ int i;
+
+ if (cmd.argc != 3) {
+ printf("hexdump addr size\n");
+ return 0;
+ }
+
+ for (i = 1; i < cmd.argc; i++) {
+ val[i-1] = strtoll(cmd.argv[i], &ep, 0);
+ if (cmd.argv[i][0] == '\0' || *ep != '\0') {
+ printf("bad '%c' in \"%s\"\n", *ep, cmd.argv[i]);
+ return 0;
+ }
+ }
+ hexdump((void *)val[0], val[1]);
+ return 0;
+}
+
#ifdef MACHINE_CMD
static int
Xmachine(void)