feat: scheduling, usermode, shell

This commit is contained in:
2026-02-17 19:17:01 +01:00
parent 20fa8a9be2
commit 605fbcbe42
46 changed files with 2622 additions and 98 deletions
+74
View File
@@ -0,0 +1,74 @@
# Nuke built-in rules and variables.
MAKEFLAGS += -rR
.SUFFIXES:
# Target architecture.
ARCH := x86_64
# Auto-detect cross compiler from toolchain/local/.
TOOLCHAIN_PREFIX := $(shell cd .. && pwd)/toolchain/local/bin/x86_64-elf-
ifneq ($(wildcard $(TOOLCHAIN_PREFIX)gcc),)
CXX := $(TOOLCHAIN_PREFIX)g++
else
CXX := g++
endif
# Compiler flags: freestanding, no stdlib, kernel-mode compatible.
override CXXFLAGS := \
-std=gnu++20 \
-g -O2 -pipe \
-Wall \
-Wextra \
-nostdinc \
-ffreestanding \
-fno-stack-protector \
-fno-stack-check \
-fno-PIC \
-fno-rtti \
-fno-exceptions \
-ffunction-sections \
-fdata-sections \
-m64 \
-march=x86-64 \
-mno-80387 \
-mno-mmx \
-mno-sse \
-mno-sse2 \
-mno-red-zone \
-mcmodel=small \
-I include \
-isystem ../kernel/freestnd-c-hdrs/x86_64/include \
-isystem ../kernel/freestnd-cxx-hdrs/x86_64/include
# Linker flags: freestanding static ELF.
override LDFLAGS := \
-nostdlib \
-static \
-Wl,--build-id=none \
-Wl,--gc-sections \
-Wl,-m,elf_x86_64 \
-z max-page-size=0x1000 \
-T link.ld
# Output directory.
BINDIR := bin
# Discover all programs (each subdirectory under src/ is a program).
PROGRAMS := $(notdir $(wildcard src/*))
# Build targets: one ELF per program.
TARGETS := $(addprefix $(BINDIR)/,$(addsuffix .elf,$(PROGRAMS)))
.PHONY: all clean
all: $(TARGETS)
# Build each program from its source files.
# For now each program is a single .cpp file compiled and linked directly.
$(BINDIR)/%.elf: src/%/main.cpp link.ld GNUmakefile
mkdir -p $(BINDIR) obj/$*
$(CXX) $(CXXFLAGS) -c src/$*/main.cpp -o obj/$*/main.o
$(CXX) $(CXXFLAGS) $(LDFLAGS) obj/$*/main.o -o $@
clean:
rm -rf $(BINDIR) obj