Add mmu regresion blank project
This commit is contained in:
parent
ccc3b63d7c
commit
3a38fe4130
|
@ -0,0 +1,73 @@
|
|||
PROJ_NAME=mmu
|
||||
|
||||
|
||||
RISCV_PATH?=/opt/riscv/
|
||||
CFLAGS += -march=rv32i -mabi=ilp32
|
||||
RISCV_NAME = riscv64-unknown-elf
|
||||
RISCV_OBJCOPY = $(RISCV_PATH)/bin/$(RISCV_NAME)-objcopy
|
||||
RISCV_OBJDUMP = $(RISCV_PATH)/bin/$(RISCV_NAME)-objdump
|
||||
RISCV_CLIB=$(RISCV_PATH)$(RISCV_NAME)/lib/
|
||||
RISCV_CC=$(RISCV_PATH)/bin/$(RISCV_NAME)-gcc
|
||||
LDSCRIPT=src/ld
|
||||
|
||||
|
||||
SRCS = $(wildcard src/*.c) \
|
||||
$(wildcard src/*.cpp) \
|
||||
$(wildcard src/*.S)
|
||||
|
||||
|
||||
CFLAGS += -static
|
||||
LDFLAGS += -e_start -T $(LDSCRIPT) -nostartfiles -Wl,-Map,$(OBJDIR)/$(PROJ_NAME).map -Wl,--print-memory-usage
|
||||
OBJDIR = build
|
||||
OBJS := $(SRCS)
|
||||
OBJS := $(OBJS:.c=.o)
|
||||
OBJS := $(OBJS:.cpp=.o)
|
||||
OBJS := $(OBJS:.S=.o)
|
||||
OBJS := $(addprefix $(OBJDIR)/,$(OBJS))
|
||||
|
||||
|
||||
|
||||
all: $(OBJDIR)/$(PROJ_NAME).elf $(OBJDIR)/$(PROJ_NAME).hex $(OBJDIR)/$(PROJ_NAME).asm $(OBJDIR)/$(PROJ_NAME).v
|
||||
@echo "done"
|
||||
|
||||
$(OBJDIR)/%.elf: $(OBJS) | $(OBJDIR)
|
||||
$(RISCV_CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
|
||||
|
||||
%.hex: %.elf
|
||||
$(RISCV_OBJCOPY) -O ihex $^ $@
|
||||
|
||||
%.bin: %.elf
|
||||
$(RISCV_OBJCOPY) -O binary $^ $@
|
||||
|
||||
%.v: %.elf
|
||||
$(RISCV_OBJCOPY) -O verilog $^ $@
|
||||
|
||||
%.asm: %.elf
|
||||
$(RISCV_OBJDUMP) -S -d $^ > $@
|
||||
|
||||
$(OBJDIR)/%.o: %.c
|
||||
mkdir -p $(dir $@)
|
||||
$(RISCV_CC) -c $(CFLAGS) $(INC) -o $@ $^
|
||||
|
||||
$(OBJDIR)/%.o: %.cpp
|
||||
mkdir -p $(dir $@)
|
||||
$(RISCV_CC) -c $(CFLAGS) $(INC) -o $@ $^
|
||||
|
||||
$(OBJDIR)/%.o: %.S
|
||||
mkdir -p $(dir $@)
|
||||
$(RISCV_CC) -c $(CFLAGS) -o $@ $^ -D__ASSEMBLY__=1
|
||||
|
||||
$(OBJDIR):
|
||||
mkdir -p $@
|
||||
|
||||
clean:
|
||||
rm -f $(OBJDIR)/$(PROJ_NAME).elf
|
||||
rm -f $(OBJDIR)/$(PROJ_NAME).hex
|
||||
rm -f $(OBJDIR)/$(PROJ_NAME).map
|
||||
rm -f $(OBJDIR)/$(PROJ_NAME).v
|
||||
rm -f $(OBJDIR)/$(PROJ_NAME).asm
|
||||
find $(OBJDIR) -type f -name '*.o' -print0 | xargs -0 -r rm
|
||||
|
||||
.SECONDARY: $(OBJS)
|
||||
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
|
||||
build/mmu.elf: file format elf32-littleriscv
|
||||
|
||||
|
||||
Disassembly of section .crt_section:
|
||||
|
||||
80000000 <trap_entry-0x20>:
|
||||
80000000: 0280006f j 80000028 <_start>
|
||||
80000004: 00000013 nop
|
||||
80000008: 00000013 nop
|
||||
8000000c: 00000013 nop
|
||||
80000010: 00000013 nop
|
||||
80000014: 00000013 nop
|
||||
80000018: 00000013 nop
|
||||
8000001c: 00000013 nop
|
||||
|
||||
80000020 <trap_entry>:
|
||||
80000020: 0200006f j 80000040 <fail>
|
||||
80000024: 30200073 mret
|
||||
|
||||
80000028 <_start>:
|
||||
80000028: 00000097 auipc ra,0x0
|
||||
8000002c: 01808093 addi ra,ra,24 # 80000040 <fail>
|
||||
80000030: 30509073 csrw mtvec,ra
|
||||
80000034: 10509073 csrw stvec,ra
|
||||
80000038: 00100e13 li t3,1
|
||||
8000003c: 0100006f j 8000004c <pass>
|
||||
|
||||
80000040 <fail>:
|
||||
80000040: f0100137 lui sp,0xf0100
|
||||
80000044: f2410113 addi sp,sp,-220 # f00fff24 <pass+0x700ffed8>
|
||||
80000048: 01c12023 sw t3,0(sp)
|
||||
|
||||
8000004c <pass>:
|
||||
8000004c: f0100137 lui sp,0xf0100
|
||||
80000050: f2010113 addi sp,sp,-224 # f00fff20 <pass+0x700ffed4>
|
||||
80000054: 00012023 sw zero,0(sp)
|
||||
80000058: 00000013 nop
|
||||
8000005c: 00000013 nop
|
||||
80000060: 00000013 nop
|
||||
80000064: 00000013 nop
|
||||
80000068: 00000013 nop
|
||||
8000006c: 00000013 nop
|
|
@ -0,0 +1,10 @@
|
|||
:0200000480007A
|
||||
:100000006F008002130000001300000013000000C6
|
||||
:100010001300000013000000130000001300000094
|
||||
:100020006F00000273002030970000009380800171
|
||||
:100030007390503073905010130E10006F00000139
|
||||
:10004000370110F0130141F22320C101370110F0F4
|
||||
:10005000130101F22320010013000000130000002F
|
||||
:100060001300000013000000130000001300000044
|
||||
:04000005800000284F
|
||||
:00000001FF
|
|
@ -0,0 +1,3 @@
|
|||
PROJ_NAME=mmu
|
||||
|
||||
include ../common/asm.mk
|
|
@ -0,0 +1,46 @@
|
|||
.globl _start
|
||||
|
||||
|
||||
j _start
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
.global trap_entry
|
||||
trap_entry:
|
||||
j fail
|
||||
mret
|
||||
|
||||
_start:
|
||||
la x1, fail
|
||||
csrw mtvec, x1
|
||||
csrw stvec, x1
|
||||
|
||||
//Test 1 SC on unreserved area should fail and not write memory
|
||||
li x28, 1
|
||||
|
||||
|
||||
|
||||
j pass
|
||||
|
||||
|
||||
fail: //x28 => error code
|
||||
li x2, 0xF00FFF24
|
||||
sw x28, 0(x2)
|
||||
|
||||
pass:
|
||||
li x2, 0xF00FFF20
|
||||
sw x0, 0(x2)
|
||||
|
||||
|
||||
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
|
@ -0,0 +1,16 @@
|
|||
OUTPUT_ARCH( "riscv" )
|
||||
|
||||
MEMORY {
|
||||
onChipRam (W!RX)/*(RX)*/ : ORIGIN = 0x80000000, LENGTH = 8K
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
|
||||
.crt_section :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*crt.o(.text)
|
||||
} > onChipRam
|
||||
|
||||
}
|
Loading…
Reference in New Issue