feat: add support for aarch64 timer/interrupts, port MontaukOS userspace
This commit is contained in:
1 parent
8b6379fb7e
commit
8c09ccef66
101 files changed
+1720
-629
No files matched your search
+46
-31
@@ -2,20 +2,19 @@
|
||||
MAKEFLAGS += -rR
|
||||
.SUFFIXES:
|
||||
|
||||
# Target architecture.
|
||||
ARCH := x86_64
|
||||
# Target architecture (ARCH=x86_64 or aarch64) and the cross compiler
|
||||
# from toolchain/local/.
|
||||
include mk/arch.mk
|
||||
|
||||
# Auto-detect cross compiler from toolchain/local/.
|
||||
TOOLCHAIN_PREFIX := $(shell cd .. && pwd)/toolchain/local/bin/x86_64-montauk-
|
||||
ifeq ($(wildcard $(TOOLCHAIN_PREFIX)gcc),)
|
||||
CXX = $(error x86_64-montauk toolchain not found. Run ./toolchain/build-montauk-toolchain.sh first)
|
||||
CC = $(error x86_64-montauk toolchain not found. Run ./toolchain/build-montauk-toolchain.sh first)
|
||||
CXX = $(error $(TOOLCHAIN_MISSING))
|
||||
CC = $(error $(TOOLCHAIN_MISSING))
|
||||
else
|
||||
CXX := $(TOOLCHAIN_PREFIX)g++
|
||||
CC := $(TOOLCHAIN_PREFIX)gcc
|
||||
endif
|
||||
|
||||
# Compiler flags. The x86_64-montauk toolchain supplies the target ABI
|
||||
# Compiler flags. The <arch>-montauk toolchain supplies the target ABI
|
||||
# (static ET_EXEC, 4 KiB pages, no red zone) and header paths; system
|
||||
# programs additionally avoid FP/SIMD and their own runtime (-nostdlib).
|
||||
override CXXFLAGS := \
|
||||
@@ -30,10 +29,7 @@ override CXXFLAGS := \
|
||||
-fno-exceptions \
|
||||
-ffunction-sections \
|
||||
-fdata-sections \
|
||||
-mno-80387 \
|
||||
-mno-mmx \
|
||||
-mno-sse \
|
||||
-mno-sse2 \
|
||||
$(ARCH_NOFP_FLAGS) \
|
||||
-I include
|
||||
|
||||
# Linker flags: freestanding static ELF.
|
||||
@@ -43,7 +39,7 @@ override LDFLAGS := \
|
||||
-T link.ld
|
||||
|
||||
# Output directory.
|
||||
BINDIR := bin
|
||||
BINDIR := bin$(ARCH_SUFFIX)
|
||||
|
||||
# Discover all programs (each subdirectory under src/ is a program).
|
||||
PROGRAMS := $(notdir $(wildcard src/*))
|
||||
@@ -98,18 +94,34 @@ WPDST := $(patsubst $(WPDIR)/%,$(BINDIR)/os/wallpapers/%,$(WPSRC))
|
||||
|
||||
.PHONY: all clean 2048 files settings fetch wiki wikipedia weather imageviewer fontpreview spreadsheet wordprocessor pdfviewer disks devexplorer installer audio music video bluetooth network display capabilities keyboard sshserver sshd terminal syslog procmgr powermgr calculator charmap login desktop shell paint tcc lua screenshot texteditor mandelbrot printers timezone printd printctl dialogs icons fonts configs osdata bearssl libc tls libjpeg libjpegwrite install-apps libloader crashpad rtlsdr sdr check-syscalls gen-syscalls rust
|
||||
|
||||
all: bearssl libc libjpeg libjpegwrite tls libloader rtlsdr sdr devkit $(TARGETS) files settings fetch wiki wikipedia weather imageviewer fontpreview spreadsheet wordprocessor pdfviewer disks devexplorer installer audio music video bluetooth network display capabilities sshserver terminal syslog procmgr powermgr calculator charmap 2048 paint tcc lua screenshot texteditor mandelbrot printers timezone printd printctl dialogs login desktop shell sshd icons fonts install-apps crashpad rust $(MANDST) $(WWWDST) $(CA_CERTS) $(CONFIGDST) $(OSDATADST) $(FWDST) $(LICDST) $(WPDST)
|
||||
# The on-OS SDK, tcc (an x86 code generator) and the Rust programs exist
|
||||
# for x86_64 only.
|
||||
ifneq ($(ARCH),x86_64)
|
||||
ARCH_SKIP := devkit tcc rust
|
||||
endif
|
||||
|
||||
ALL_TARGETS := bearssl libc libjpeg libjpegwrite tls libloader rtlsdr sdr devkit $(TARGETS) files settings fetch wiki wikipedia weather imageviewer fontpreview spreadsheet wordprocessor pdfviewer disks devexplorer installer audio music video bluetooth network display capabilities sshserver terminal syslog procmgr powermgr calculator charmap 2048 paint tcc lua screenshot texteditor mandelbrot printers timezone printd printctl dialogs login desktop shell sshd icons fonts install-apps crashpad rust $(MANDST) $(WWWDST) $(CA_CERTS) $(CONFIGDST) $(OSDATADST) $(FWDST) $(LICDST) $(WPDST)
|
||||
|
||||
all: $(filter-out $(ARCH_SKIP),$(ALL_TARGETS))
|
||||
|
||||
# Build BearSSL static library (cross-compiled for freestanding x86_64).
|
||||
BEARSSL_INCLUDES := -isystem $(shell cd .. && pwd)/kernel/freestnd-c-hdrs/x86_64/include -isystem $(abspath include/libc)
|
||||
BEARSSL_INCLUDES := -isystem $(shell cd .. && pwd)/kernel/freestnd-c-hdrs/$(ARCH)/include -isystem $(abspath include/libc)
|
||||
ifeq ($(ARCH),x86_64)
|
||||
BEARSSL_ARCH_FLAGS := -m64 -march=x86-64 -mno-80387 -mno-mmx -mno-red-zone -mcmodel=small
|
||||
else
|
||||
BEARSSL_ARCH_FLAGS := $(ARCH_CFLAGS)
|
||||
endif
|
||||
BEARSSL_LIB := lib/bearssl/build$(ARCH_SUFFIX)/libbearssl.a
|
||||
|
||||
lib/bearssl/build/libbearssl.a:
|
||||
$(BEARSSL_LIB):
|
||||
$(MAKE) -C lib/bearssl CONF=MontaukOS \
|
||||
BEARSSL_CC="$(CC)" \
|
||||
BEARSSL_AR="$(TOOLCHAIN_PREFIX)ar" \
|
||||
BUILD=build$(ARCH_SUFFIX) \
|
||||
BEARSSL_ARCH_FLAGS="$(BEARSSL_ARCH_FLAGS)" \
|
||||
BEARSSL_INCLUDES="$(BEARSSL_INCLUDES)"
|
||||
|
||||
bearssl: lib/bearssl/build/libbearssl.a
|
||||
bearssl: $(BEARSSL_LIB)
|
||||
|
||||
# Build shared libc static library.
|
||||
#
|
||||
@@ -120,11 +132,12 @@ bearssl: lib/bearssl/build/libbearssl.a
|
||||
# under -j and silently leaves programs linked against a stale libc.
|
||||
# Grouped target (&:, GNU make 4.3+): one sub-make produces all of them.
|
||||
LIBC_DIR := lib/libc
|
||||
LIBC_LIB := $(LIBC_DIR)/liblibc.a
|
||||
LIBC_LIB := $(LIBC_DIR)/$(ARCH_OUT)liblibc.a
|
||||
LIBC_SRCS := $(wildcard $(LIBC_DIR)/*.c $(LIBC_DIR)/*.h $(LIBC_DIR)/*.S \
|
||||
$(LIBC_DIR)/crt/*.c) $(LIBC_DIR)/Makefile
|
||||
LIBC_OUTPUTS := $(LIBC_LIB) $(LIBC_DIR)/liblibc-full.a \
|
||||
$(LIBC_DIR)/crt1.o $(LIBC_DIR)/crti.o $(LIBC_DIR)/crtn.o
|
||||
LIBC_OUTPUTS := $(LIBC_LIB) $(LIBC_DIR)/$(ARCH_OUT)liblibc-full.a \
|
||||
$(LIBC_DIR)/$(ARCH_OUT)crt1.o $(LIBC_DIR)/$(ARCH_OUT)crti.o \
|
||||
$(LIBC_DIR)/$(ARCH_OUT)crtn.o
|
||||
|
||||
$(LIBC_OUTPUTS) &: $(LIBC_SRCS)
|
||||
$(MAKE) -C $(LIBC_DIR)
|
||||
@@ -282,7 +295,7 @@ login: bearssl libc
|
||||
$(MAKE) -C src/login
|
||||
|
||||
# Build shell via its own Makefile (multi-file build).
|
||||
shell:
|
||||
shell: libc
|
||||
$(MAKE) -C src/shell
|
||||
|
||||
# Build desktop via its own Makefile (depends on libc, libjpeg, bearssl for user.h, dialogs, and registry config files).
|
||||
@@ -291,11 +304,11 @@ desktop: libc libjpeg bearssl libloader dialogs configs
|
||||
|
||||
# Copy SVG icons for the desktop into bin/os/icons/.
|
||||
icons:
|
||||
../scripts/copy_icons.sh
|
||||
PROGRAMS_BIN=$(BINDIR) ../scripts/copy_icons.sh
|
||||
|
||||
# Copy TTF fonts for the desktop into bin/os/fonts/.
|
||||
fonts:
|
||||
../scripts/copy_fonts.sh
|
||||
PROGRAMS_BIN=$(BINDIR) ../scripts/copy_fonts.sh
|
||||
|
||||
# Copy default system config files into bin/config/.
|
||||
configs: $(CONFIGDST)
|
||||
@@ -400,7 +413,7 @@ crashpad: libc
|
||||
|
||||
# Install app bundles (manifests, icons, data files) into bin/apps/<name>/.
|
||||
install-apps: 2048 files settings paint spreadsheet wordprocessor weather wikipedia imageviewer fontpreview pdfviewer disks devexplorer installer audio music video bluetooth network display capabilities keyboard sshserver terminal syslog procmgr powermgr calculator charmap screenshot texteditor mandelbrot printers timezone crashpad
|
||||
../scripts/install_apps.sh
|
||||
PROGRAMS_BIN=$(BINDIR) ../scripts/install_apps.sh
|
||||
|
||||
# Copy man pages into bin/os/man/ so mkramdisk.sh picks them up.
|
||||
$(BINDIR)/os/man/%: $(MANDIR)/%
|
||||
@@ -446,14 +459,16 @@ $(BINDIR)/os/wallpapers/%: $(WPDIR)/%
|
||||
# (montauk/capabilities.h, Api/Syscall.hpp, ...) rebuilds every program that
|
||||
# uses it. A missing depfile matches the empty rule below, which forces a
|
||||
# rebuild; that is how programs built before this tracking existed catch up.
|
||||
$(BINDIR)/os/%.elf: src/%/main.cpp link.ld GNUmakefile $(LIBC_LIB) obj/%/main.elf.d
|
||||
mkdir -p $(BINDIR)/os obj/$*
|
||||
$(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF obj/$*/main.elf.d -c src/$*/main.cpp -o obj/$*/main.o
|
||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) obj/$*/main.o $(LIBC_LIB) -o $@
|
||||
OBJ := obj$(ARCH_SUFFIX)
|
||||
|
||||
obj/%/main.elf.d: ;
|
||||
.PRECIOUS: obj/%/main.elf.d
|
||||
-include $(wildcard obj/*/main.elf.d)
|
||||
$(BINDIR)/os/%.elf: src/%/main.cpp link.ld GNUmakefile $(LIBC_LIB) $(OBJ)/%/main.elf.d
|
||||
mkdir -p $(BINDIR)/os $(OBJ)/$*
|
||||
$(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $(OBJ)/$*/main.elf.d -c src/$*/main.cpp -o $(OBJ)/$*/main.o
|
||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(OBJ)/$*/main.o $(LIBC_LIB) -o $@
|
||||
|
||||
$(OBJ)/%/main.elf.d: ;
|
||||
.PRECIOUS: $(OBJ)/%/main.elf.d
|
||||
-include $(wildcard $(OBJ)/*/main.elf.d)
|
||||
|
||||
# ============================================================================
|
||||
# Native development kit (Montauk SDK): binutils built for MontaukOS
|
||||
@@ -524,7 +539,7 @@ else
|
||||
endif
|
||||
|
||||
clean:
|
||||
rm -rf $(BINDIR) obj $(RUST_DIR)/target
|
||||
rm -rf $(BINDIR) $(OBJ) $(RUST_DIR)/target
|
||||
$(MAKE) -C lib/bearssl clean
|
||||
$(MAKE) -C lib/libc clean
|
||||
$(MAKE) -C lib/libjpeg clean
|
||||
|
||||
Reference in new issue
Block a user