Readme, makefile, clang-format

This commit is contained in:
Imbus 2025-06-26 01:07:04 +02:00
parent 88eeb60a09
commit d57ad4d9ee
3 changed files with 63 additions and 0 deletions

8
.clang-format Normal file
View file

@ -0,0 +1,8 @@
BasedOnStyle: LLVM
IndentWidth: 4
TabWidth: 4
UseTab: Never
ColumnLimit: 80
AllowShortLoopsOnASingleLine: true
AlwaysBreakTemplateDeclarations: true
BreakConstructorInitializers: BeforeComma

49
Makefile Normal file
View file

@ -0,0 +1,49 @@
# Makefile for the Fusion operating system.
# Make things fixable, not autocorrecting
# TODO: Toolchain installation should be documented in the README
# https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack
TOOLPREFIX = riscv-none-elf
CC = $(TOOLPREFIX)-gcc
AS = $(TOOLPREFIX)-gas
LD = $(TOOLPREFIX)-ld
OBJCOPY = $(TOOLPREFIX)-objcopy
OBJDUMP = $(TOOLPREFIX)-objdump
# TODO: Document these options with clear descriptions, it should be readable
# by people not intimately familiar with machine code and/or gcc tooling.
CFLAGS = -Wall -Werror -O -fno-omit-frame-pointer -ggdb -gdwarf-2
CFLAGS += -MD
CFLAGS += -mcmodel=medany
CFLAGS += -ffreestanding -fno-common -nostdlib -mno-relax
CFLAGS += -I.
CFLAGS += -fno-pie -no-pie
CFLAGS += -fno-stack-protector
CFLAGS += -march=rv64gc -mabi=lp64
LDFLAGS = -z max-page-size=4096
LDFLAGS += -m elf64lriscv
all: kernel.elf
%.o: %.c
@echo CC $@
@$(CC) $(CFLAGS) -nostdinc -I. -c $< -o $@
%.o: %.S
@echo CC-AS $@
@$(CC) $(CFLAGS) -c $< -o $@
kernel.elf: trap.o kernelvec.o entry.o start.o kernel.o spinlock.o
@echo LD $@
@$(LD) $(LDFLAGS) -T kernel.ld -o $@ $^
kernel.bin: kernel.elf
$(OBJCOPY) -O binary $< $@
clean:
rm -f *.o *.d *.elf *.bin
-include *.d

View file

@ -1,2 +1,8 @@
# fusion # fusion
For a quick reference on RISC-V assembly:
- https://risc-v.guru/instructions/
Toolchains:
- https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack
- https://github.com/xpack-dev-tools/qemu-riscv-xpack/