From 7facb160390cbd6a1b19d62966fe5140425ee72a Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Sat, 23 Apr 2016 10:18:05 -0700 Subject: [PATCH] Clean up how Debug ROM is included. I'm not thrilled about including a static copy in so many cc files, and making the compiler throw it out. But without really grokking the Makefile this is the best it's going to be. --- {riscv/debug_rom => debug_rom}/Makefile | 6 +++--- {riscv/debug_rom => debug_rom}/debug_rom.S | 0 {riscv => debug_rom}/debug_rom.h | 4 ++-- {riscv/debug_rom => debug_rom}/link.ld | 0 riscv/debug_rom/debug_rom.h | 2 -- riscv/decode.h | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-) rename {riscv/debug_rom => debug_rom}/Makefile (73%) rename {riscv/debug_rom => debug_rom}/debug_rom.S (100%) rename {riscv => debug_rom}/debug_rom.h (91%) rename {riscv/debug_rom => debug_rom}/link.ld (100%) delete mode 100644 riscv/debug_rom/debug_rom.h diff --git a/riscv/debug_rom/Makefile b/debug_rom/Makefile similarity index 73% rename from riscv/debug_rom/Makefile rename to debug_rom/Makefile index ff37a29..d66b84f 100644 --- a/riscv/debug_rom/Makefile +++ b/debug_rom/Makefile @@ -7,8 +7,8 @@ OBJCOPY = $(RISCV)/bin/riscv64-unknown-elf-objcopy %.o: %.S $(CC) -c $< -debug_rom.cc: debug_rom.raw - xxd -i $^ > $@ +debug_rom.h: debug_rom.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 @@ -17,4 +17,4 @@ debug_rom: debug_rom.o $(CC) -nostdlib -nostartfiles -Tlink.ld -o $@ $^ clean: - rm -f debug_rom debug_rom.o debug_rom.raw debug_rom.c + rm -f debug_rom debug_rom.o debug_rom.raw debug_rom.h diff --git a/riscv/debug_rom/debug_rom.S b/debug_rom/debug_rom.S similarity index 100% rename from riscv/debug_rom/debug_rom.S rename to debug_rom/debug_rom.S diff --git a/riscv/debug_rom.h b/debug_rom/debug_rom.h similarity index 91% rename from riscv/debug_rom.h rename to debug_rom/debug_rom.h index d2837ac..1c53e11 100644 --- a/riscv/debug_rom.h +++ b/debug_rom/debug_rom.h @@ -1,4 +1,4 @@ -static unsigned char debug_rom_raw[] = { +static const unsigned char debug_rom_raw[] = { 0x6f, 0x00, 0x40, 0x05, 0xf3, 0x24, 0x00, 0xf1, 0x23, 0x24, 0x90, 0x10, 0xf3, 0x24, 0x00, 0x79, 0x93, 0xf4, 0x04, 0x40, 0x63, 0x94, 0x04, 0x08, 0xf3, 0x24, 0x00, 0xf0, 0x63, 0xc6, 0x04, 0x00, 0x83, 0x24, 0xc0, 0x43, @@ -15,4 +15,4 @@ static unsigned char debug_rom_raw[] = { 0x73, 0x24, 0x00, 0x79, 0x13, 0x74, 0x04, 0x40, 0xe3, 0x0c, 0x04, 0xfe, 0x6f, 0xf0, 0x1f, 0xfc }; -static unsigned int debug_rom_raw_len = 172; +static const unsigned int debug_rom_raw_len = 172; diff --git a/riscv/debug_rom/link.ld b/debug_rom/link.ld similarity index 100% rename from riscv/debug_rom/link.ld rename to debug_rom/link.ld diff --git a/riscv/debug_rom/debug_rom.h b/riscv/debug_rom/debug_rom.h deleted file mode 100644 index a99534e..0000000 --- a/riscv/debug_rom/debug_rom.h +++ /dev/null @@ -1,2 +0,0 @@ -extern unsigned char *debug_rom_raw; -extern unsigned int debug_rom_raw_len; diff --git a/riscv/decode.h b/riscv/decode.h index b59ee78..bf6a84c 100644 --- a/riscv/decode.h +++ b/riscv/decode.h @@ -14,7 +14,7 @@ #include "config.h" #include "common.h" #include -#include "debug_rom.h" +#include "debug_rom/debug_rom.h" typedef int64_t sreg_t; typedef uint64_t reg_t; -- 2.30.2