aboutsummaryrefslogtreecommitdiff
path: root/sw/devmem3.c
diff options
context:
space:
mode:
Diffstat (limited to 'sw/devmem3.c')
-rw-r--r--sw/devmem3.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/sw/devmem3.c b/sw/devmem3.c
new file mode 100644
index 0000000..3c3fa16
--- /dev/null
+++ b/sw/devmem3.c
@@ -0,0 +1,40 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "novena-eim.h"
+
+int
+main(int argc, char *argv[])
+{
+ off_t offset;
+ uint32_t value, result;
+
+ if (argc < 3 || argc > 4) {
+ usage:
+ fprintf(stderr, "usage: %s offset r\n", argv[0]);
+ fprintf(stderr, "usage: %s offset w value\n", argv[0]);
+ exit(EXIT_FAILURE);
+ }
+
+ if (eim_setup() != 0) {
+ fprintf(stderr, "EIM setup failed\n");
+ exit(EXIT_FAILURE);
+ }
+
+ offset = (off_t)strtoul(argv[1], NULL, 0);
+ if (argv[2][0] == 'r') {
+ eim_read_32(offset, &result);
+ printf("%08x\n", result);
+ }
+ else if (argv[2][0] == 'w') {
+ value = strtoul(argv[3], NULL, 0);
+ eim_write_32(offset, &value);
+ }
+ else {
+ fprintf(stderr, "unknown command '%s'\n", argv[2]);
+ goto usage;
+ }
+
+ exit(EXIT_SUCCESS);
+}
+