aboutsummaryrefslogtreecommitdiff
path: root/debug_rom
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@cs.berkeley.edu>2016-06-22 23:29:16 -0700
committerAndrew Waterman <waterman@cs.berkeley.edu>2016-06-22 23:29:16 -0700
commit8861244f8d6ff65a6c1b69f937b2c9d9af5527b9 (patch)
tree9b7401f5333f655bf7b2394901e4942742804d98 /debug_rom
parent965571945c16d691962211b3602168a17be859ee (diff)
downloadriscv-isa-sim-8861244f8d6ff65a6c1b69f937b2c9d9af5527b9.zip
riscv-isa-sim-8861244f8d6ff65a6c1b69f937b2c9d9af5527b9.tar.gz
riscv-isa-sim-8861244f8d6ff65a6c1b69f937b2c9d9af5527b9.tar.bz2
Parameterize debug ROM contents on XLEN
Diffstat (limited to 'debug_rom')
-rw-r--r--debug_rom/.gitignore5
-rw-r--r--debug_rom/Makefile26
-rwxr-xr-xdebug_rom/debug_rom.S53
-rw-r--r--debug_rom/debug_rom.h25
4 files changed, 81 insertions, 28 deletions
diff --git a/debug_rom/.gitignore b/debug_rom/.gitignore
index 7c986a1..98bd13e 100644
--- a/debug_rom/.gitignore
+++ b/debug_rom/.gitignore
@@ -1,2 +1,5 @@
/debug_rom
-/debug_rom.raw
+/debug_rom32
+/debug_rom64
+/debug_rom32.h
+/debug_rom64.h
diff --git a/debug_rom/Makefile b/debug_rom/Makefile
index ed4cb93..b72f37d 100644
--- a/debug_rom/Makefile
+++ b/debug_rom/Makefile
@@ -4,17 +4,27 @@
CC = $(RISCV)/bin/riscv64-unknown-elf-gcc
OBJCOPY = $(RISCV)/bin/riscv64-unknown-elf-objcopy
-%.o: %.S
- $(CC) -I.. -c $<
+COMPILE = $(CC) -nostdlib -nostartfiles -I.. -Tlink.ld
-debug_rom.h: debug_rom.raw
+ELFS = debug_rom debug_rom32 debug_rom64
+DEPS = debug_rom.S link.ld
+
+all: $(patsubst %,%.h,$(ELFS))
+
+%.h: %.raw
xxd -i $^ | sed "s/^unsigned/static const unsigned/" > $@
-debug_rom.raw: debug_rom
- $(OBJCOPY) -O binary --only-section .text debug_rom debug_rom.raw
+%.raw: %
+ $(OBJCOPY) -O binary --only-section .text $^ $@
+
+debug_rom: $(DEPS)
+ $(COMPILE) -DRV32 -DRV64 -o $@ $^
+
+debug_rom32: $(DEPS)
+ $(COMPILE) -DRV32 -DDEBUG_RAM_SIZE=28 -o $@ $^
-debug_rom: debug_rom.o link.ld
- $(CC) -nostdlib -nostartfiles -Tlink.ld -o $@ $^
+debug_rom64: $(DEPS)
+ $(COMPILE) -DRV64 -o $@ $^
clean:
- rm -f debug_rom debug_rom.o debug_rom.raw debug_rom.h
+ rm -f $(ELFS) debug_rom*.raw debug_rom*.h
diff --git a/debug_rom/debug_rom.S b/debug_rom/debug_rom.S
index 2219bff..74a934b 100755
--- a/debug_rom/debug_rom.S
+++ b/debug_rom/debug_rom.S
@@ -6,11 +6,19 @@
# TODO: Update these constants once they're finalized in the doc.
#define DEBUG_RAM 0x400
-#define DEBUG_RAM_SIZE 64
+#ifndef DEBUG_RAM_SIZE
+# define DEBUG_RAM_SIZE 64
+#endif
#define CLEARDEBINT 0x100
#define SETHALTNOT 0x10c
+#if (defined(RV32) + defined(RV64) + defined(RV128)) > 1
+# define MULTI_XLEN
+#elif (defined(RV32) + defined(RV64) + defined(RV128)) == 0
+# error define one or more of RV32, RV64, RV128
+#endif
+
.global entry
.global resume
.global exception
@@ -33,19 +41,39 @@ _resume2:
fence
# Restore s1.
+#ifdef MULTI_XLEN
csrr s1, CSR_MISA
+#endif
+
+#ifdef RV32
+# ifdef MULTI_XLEN
bltz s1, restore_not_32
+# endif
+
restore_32:
lw s1, (DEBUG_RAM + DEBUG_RAM_SIZE - 4)(zero)
+# if defined(RV64) || defined(RV128)
j finish_restore
+# endif
+#endif
+
restore_not_32:
+#if defined(RV64) && defined(RV128)
slli s1, s1, 1
bltz s1, restore_128
+#endif
+
+#ifdef RV64
restore_64:
ld s1, (DEBUG_RAM + DEBUG_RAM_SIZE - 8)(zero)
+#endif
+#if defined(RV64) && defined(RV128)
j finish_restore
+#endif
+#ifdef RV128
restore_128:
- nop #lq s1, (DEBUG_RAM + DEBUG_RAM_SIZE - 16)(zero)
+ lq s1, (DEBUG_RAM + DEBUG_RAM_SIZE - 16)(zero)
+#endif
finish_restore:
# s0 contains ~0 if we got here through an exception, and 0 otherwise.
@@ -60,8 +88,7 @@ finish_restore:
check_halt:
csrr s0, CSR_DCSR
andi s0, s0, DCSR_HALT
- beqz s0, exit
- j wait_for_interrupt
+ bnez s0, wait_for_interrupt
exit:
# Restore s0.
@@ -81,20 +108,36 @@ _entry:
jdebugram:
# Save s1 so that the debug program can use two registers.
+#ifdef MULTI_XLEN
csrr s0, CSR_MISA
+#endif
+
+#ifdef RV32
+# ifdef MULTI_XLEN
bltz s0, save_not_32
+# endif
save_32:
sw s1, (DEBUG_RAM + DEBUG_RAM_SIZE - 4)(zero)
jr zero, DEBUG_RAM
+#endif
+
save_not_32:
+#if defined(RV64) && defined(RV128)
slli s0, s0, 1
bltz s0, save_128
+#endif
+
+#ifdef RV64
save_64:
sd s1, (DEBUG_RAM + DEBUG_RAM_SIZE - 8)(zero)
jr zero, DEBUG_RAM
+#endif
+
+#ifdef RV128
save_128:
- nop #sq s1, (DEBUG_RAM + DEBUG_RAM_SIZE - 16)(zero)
+ sq s1, (DEBUG_RAM + DEBUG_RAM_SIZE - 16)(zero)
jr zero, DEBUG_RAM
+#endif
spontaneous_halt:
csrr s0, CSR_MHARTID
diff --git a/debug_rom/debug_rom.h b/debug_rom/debug_rom.h
index b4ee2dd..b93a98f 100644
--- a/debug_rom/debug_rom.h
+++ b/debug_rom/debug_rom.h
@@ -1,19 +1,16 @@
static const unsigned char debug_rom_raw[] = {
- 0x6f, 0x00, 0x00, 0x06, 0x6f, 0x00, 0xc0, 0x00, 0x13, 0x04, 0xf0, 0xff,
+ 0x6f, 0x00, 0xc0, 0x04, 0x6f, 0x00, 0xc0, 0x00, 0x13, 0x04, 0xf0, 0xff,
0x6f, 0x00, 0x80, 0x00, 0x13, 0x04, 0x00, 0x00, 0x0f, 0x00, 0xf0, 0x0f,
0xf3, 0x24, 0x00, 0xf1, 0x63, 0xc6, 0x04, 0x00, 0x83, 0x24, 0xc0, 0x43,
- 0x6f, 0x00, 0x80, 0x01, 0x93, 0x94, 0x14, 0x00, 0x63, 0xc6, 0x04, 0x00,
- 0x83, 0x34, 0x80, 0x43, 0x6f, 0x00, 0x80, 0x00, 0x13, 0x00, 0x00, 0x00,
- 0x23, 0x2e, 0x80, 0x42, 0x73, 0x24, 0x40, 0xf1, 0x23, 0x20, 0x80, 0x10,
- 0x73, 0x24, 0x00, 0x7b, 0x13, 0x74, 0x84, 0x00, 0x63, 0x04, 0x04, 0x00,
- 0x6f, 0x00, 0x80, 0x05, 0x73, 0x24, 0x20, 0x7b, 0x73, 0x00, 0x20, 0x7b,
- 0x73, 0x10, 0x24, 0x7b, 0x73, 0x24, 0x00, 0x7b, 0x13, 0x74, 0x04, 0x1c,
- 0x13, 0x04, 0x04, 0xf4, 0x63, 0x18, 0x04, 0x02, 0x0f, 0x10, 0x00, 0x00,
+ 0x6f, 0x00, 0x80, 0x00, 0x83, 0x34, 0x80, 0x43, 0x23, 0x2e, 0x80, 0x42,
+ 0x73, 0x24, 0x40, 0xf1, 0x23, 0x20, 0x80, 0x10, 0x73, 0x24, 0x00, 0x7b,
+ 0x13, 0x74, 0x84, 0x00, 0x63, 0x12, 0x04, 0x04, 0x73, 0x24, 0x20, 0x7b,
+ 0x73, 0x00, 0x20, 0x7b, 0x73, 0x10, 0x24, 0x7b, 0x73, 0x24, 0x00, 0x7b,
+ 0x13, 0x74, 0x04, 0x1c, 0x13, 0x04, 0x04, 0xf4, 0x63, 0x1e, 0x04, 0x00,
0x73, 0x24, 0x00, 0xf1, 0x63, 0x46, 0x04, 0x00, 0x23, 0x2e, 0x90, 0x42,
- 0x67, 0x00, 0x00, 0x40, 0x13, 0x14, 0x14, 0x00, 0x63, 0x46, 0x04, 0x00,
- 0x23, 0x3c, 0x90, 0x42, 0x67, 0x00, 0x00, 0x40, 0x13, 0x00, 0x00, 0x00,
- 0x67, 0x00, 0x00, 0x40, 0x73, 0x24, 0x40, 0xf1, 0x23, 0x26, 0x80, 0x10,
- 0x73, 0x60, 0x04, 0x7b, 0x73, 0x24, 0x00, 0x7b, 0x13, 0x74, 0x04, 0x02,
- 0xe3, 0x0c, 0x04, 0xfe, 0x6f, 0xf0, 0xdf, 0xfb
+ 0x67, 0x00, 0x00, 0x40, 0x23, 0x3c, 0x90, 0x42, 0x67, 0x00, 0x00, 0x40,
+ 0x73, 0x24, 0x40, 0xf1, 0x23, 0x26, 0x80, 0x10, 0x73, 0x60, 0x04, 0x7b,
+ 0x73, 0x24, 0x00, 0x7b, 0x13, 0x74, 0x04, 0x02, 0xe3, 0x0c, 0x04, 0xfe,
+ 0x6f, 0xf0, 0x1f, 0xfd
};
-static const unsigned int debug_rom_raw_len = 188;
+static const unsigned int debug_rom_raw_len = 148;