From 0f7ea52f9be2c42fce893acf8f1c9acc7074fb49 Mon Sep 17 00:00:00 2001 From: David Harris Date: Sat, 4 Feb 2023 08:18:55 -0800 Subject: [PATCH] Started making debug testcase --- tests/custom/debug/Makefile | 27 ++++++++++++++++++++++++ tests/custom/debug/debug.S | 42 +++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 tests/custom/debug/Makefile create mode 100644 tests/custom/debug/debug.S diff --git a/tests/custom/debug/Makefile b/tests/custom/debug/Makefile new file mode 100644 index 00000000..a63fb3b1 --- /dev/null +++ b/tests/custom/debug/Makefile @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 + +TARGET = debug + +%.elf.memfile: %.elf %.elf.objdump.adr + riscv64-unknown-elf-elf2hex --bit-width $(if $(findstring rv64,$*),64,32) --input $< --output $@ + +%.elf.objdump.addr: %.elf.objdump + extractFunctionRadix.sh $< + +$(TARGET).objdump: $(TARGET).elf + riscv64-unknown-elf-objdump -D $(TARGET).elf > $(TARGET).objdump + +$(TARGET): $(TARGET).S Makefile + riscv64-unknown-elf-gcc -g -o $(TARGET).elf -march=rv64gc -mabi=lp64 -mcmodel=medany \ + -nostartfiles -T../../link/link.ld $(TARGET).S + +sim: + spike +signature=$(TARGET).signature.output +signature-granularity=8 $(TARGET) + diff --ignore-case $(TARGET).signature.output $(TARGET).reference_output || exit + echo "Signature matches! Success!" + +clean: + rm -f $(TARGET).elf $(TARGET).objdump $(TARGET).objdump.adr %(TARGET).elf.memfile $(TARGET).signature.output + + + diff --git a/tests/custom/debug/debug.S b/tests/custom/debug/debug.S new file mode 100644 index 00000000..aadbcac6 --- /dev/null +++ b/tests/custom/debug/debug.S @@ -0,0 +1,42 @@ +// debug.S +// David_Harris@hmc.edu 4 February 2023 +// Small code snippets for the purpose of debugging issues +// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 + +# openhwgroup/cvw Issue #55 +li x1, 0x7ff0000000000001 +fmv.w.x f4, x1 +li x1, 7ff8000000000000 +fmv.w.x f9, x1 +fsgnjx.s f12,f9,f4 # expected f 0xffffffff7fc00000 + + +######################### +# HTIF and signature +######################### + +write_tohost: + la t1, tohost + li t0, 1 # 1 for success, 3 for failure + sd t0, 0(t1) # send success code + +self_loop: + j self_loop # wait + +.section .tohost +tohost: # write to HTIF + .dword 0 +fromhost: + .dword 0 + +.data + +.EQU XLEN,64 +begin_signature: + .fill 2*(XLEN/32),4,0xdeadbeef # +end_signature: + +# Initialize stack with room for 512 bytes +.bss + .space 512 +topofstack: \ No newline at end of file