-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
15 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters