Skip to content

Commit

Permalink
Update imgfile to dummy
Browse files Browse the repository at this point in the history
  • Loading branch information
Emin017 committed May 11, 2024
1 parent 9ead2e1 commit 53b2545
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 28 deletions.
5 changes: 3 additions & 2 deletions src/imgfile/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
CSRCS = $(wildcard *.c)
EMU_CC ?= riscv64-linux-gnu-gcc
EMU_OBJCOPY ?= riscv64-linux-gnu-objcopy
OUT_BIN = dummy

compile:
@echo "Compiling..."
$(EMU_CC) -march=rv64g -ffreestanding -nostdlib -static -Wl,-Ttext=0 -O2 -o prog $(CSRCS)
$(EMU_OBJCOPY) -O binary --only-section=.text prog prog.bin
$(EMU_CC) -march=rv64g -ffreestanding -nostdlib -static -Wl,-Ttext=0x80000000 -O2 -o $(OUT_BIN) $(CSRCS)
$(EMU_OBJCOPY) -O binary --only-section=.text $(OUT_BIN) $(OUT_BIN).bin
@echo "Compilation complete."
10 changes: 10 additions & 0 deletions src/imgfile/dummy.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
static void ebreak(long arg0, long arg1) {
asm volatile("addi a0, x0, %0;"
"addi a1, x0, %1;"
"ebreak" : : "i"(arg0), "i"(arg1));
}
static void halt(int code) { ebreak(1, code); while (1); }
int main() {
halt(0);
return 0;
}
25 changes: 0 additions & 25 deletions src/imgfile/prog.c

This file was deleted.

3 changes: 2 additions & 1 deletion src/mem.zig
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub const MEM = struct {
pub var memory = std.mem.zeroes([size]u8);

pub fn paddr(addr: u64) u64 {
std.debug.print("addr:{x}\n", .{addr});
return addr - base;
}

Expand All @@ -35,7 +36,7 @@ pub const MEM = struct {
}
};

const filePath = "imgfile/dummy-riscv64-npc.bin";
const filePath = "imgfile/dummy.bin";

pub fn initMem() void {
const memSlice: []u8 = MEM.memory[0..];
Expand Down

0 comments on commit 53b2545

Please sign in to comment.