summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore15
-rw-r--r--admin/conf/limine.conf8
-rwxr-xr-xhost/bootstrap17
-rwxr-xr-xhost/iso-limine24
-rwxr-xr-xhost/toolchain33
-rw-r--r--mk/defaults.mk30
-rw-r--r--mos/sys/Makefile17
-rw-r--r--mos/sys/arch/x86_64/Makefile22
-rw-r--r--mos/sys/arch/x86_64/admin/mos.lds55
-rw-r--r--mos/sys/arch/x86_64/cpu/locore.S14
-rwxr-xr-xmos/sys/sys.mosbin0 -> 4600 bytes
-rw-r--r--usr/.keep0
12 files changed, 235 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2e79262
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,15 @@
+*.iso
+*.d
+*.o
+*.a
+*.log
+*.bin
+*.sys
+*.status
+/var
+/root
+/cc
+/Makefile
+/mos/boot
+/var/autom4te.cache
+/var/configure
diff --git a/admin/conf/limine.conf b/admin/conf/limine.conf
new file mode 100644
index 0000000..1ede9c4
--- /dev/null
+++ b/admin/conf/limine.conf
@@ -0,0 +1,8 @@
+timeout: 10
+interface_branding_color: 1
+interface_help_hidden: no
+randomize_hhdm_base: no
+
+/OpenMOS
+ protocol: limine
+ kernel_path: boot():/boot/sys.mos
diff --git a/host/bootstrap b/host/bootstrap
new file mode 100755
index 0000000..511b88c
--- /dev/null
+++ b/host/bootstrap
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+set -e
+
+mkdir -p var/
+mkdir -p var/root/usr/include/
+
+if [[ ! -d var/cc/toolchain ]]
+then
+ git clone https://github.com/sigsegv7/osmora-toolchain var/cc/toolchain
+fi
+
+if [[ ! -d mos/boot ]]
+then
+ git clone https://github.com/limine-bootloader/limine.git --branch=v9.3.0-binary --depth=1 mos/boot/limine/
+ make -C mos/boot/limine
+fi
diff --git a/host/iso-limine b/host/iso-limine
new file mode 100755
index 0000000..3d3caa1
--- /dev/null
+++ b/host/iso-limine
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+set -e
+
+ISO=live-mos.iso
+
+mkdir -p iso_root/boot/
+
+# Copy the kernel to the ISO root
+cp mos/sys/sys.mos iso_root/boot
+
+# Copy boot files
+cp admin/conf/limine.conf mos/boot/limine/limine-bios.sys \
+ mos/boot/limine/limine-bios-cd.bin \
+ mos/boot/limine/limine-uefi-cd.bin \
+ iso_root/
+
+# Generate the ISO
+xorriso -as mkisofs -b limine-bios-cd.bin -no-emul-boot -boot-load-size 4 \
+ -boot-info-table --efi-boot limine-uefi-cd.bin -efi-boot-part \
+ --efi-boot-image --protective-msdos-label iso_root/ -o $ISO 1>/dev/null
+
+mos/boot/limine/limine bios-install $ISO 1>/dev/null
+rm -rf iso_root
diff --git a/host/toolchain b/host/toolchain
new file mode 100755
index 0000000..23756e6
--- /dev/null
+++ b/host/toolchain
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+TARGET=x86_64-pc-osmora
+MAKE=make
+
+# Don't build again if the lock exists
+if [[ -f cc/.lock ]]
+then
+ echo "cc/.lock exists, skipping toolchain build"
+ exit 1
+fi
+
+# Build binutils and patch gcc
+cd var/cc/toolchain/
+bash build.sh
+
+# Prep the build directory
+cd ../
+mkdir -p gcc
+cd gcc/
+
+# Configure gcc
+../toolchain/gcc-patched/configure --target=$TARGET \
+ --prefix=$(pwd) --with-sysroot=$(pwd)/../../root/ \
+ --disable-nls --enable-languages=c --disable-multilib
+
+# Build gcc
+$MAKE all-gcc
+$MAKE install-gcc
+
+# Lock the directory
+cd ../
+touch .lock
diff --git a/mk/defaults.mk b/mk/defaults.mk
new file mode 100644
index 0000000..ae85cfd
--- /dev/null
+++ b/mk/defaults.mk
@@ -0,0 +1,30 @@
+#
+# Copyright (c) 2025, Ian Moffett
+# Provided under the BSD-3 clause.
+#
+
+ARCH = x86_64
+QEMU = qemu-system-$(ARCH)
+
+CC = $(shell pwd)/var/cc/gcc/bin/$(ARCH)-pc-osmora-gcc
+LD = $(shell pwd)/var/cc/toolchain/build-binutils/bin/$(ARCH)-pc-osmora-ld
+
+SYS_CFLAGS = \
+ -nostdlib \
+ -nostdinc \
+ -ffreestanding \
+ -fexceptions \
+ --std=gnu11 \
+ -mcmodel=kernel \
+ -Wno-attributes
+
+ifeq ($(ARCH),x86_64)
+ SYS_CFLAGS += \
+ -mno-sse \
+ -mno-sse2 \
+ -mno-sse3 \
+ -mno-avx \
+ -mno-avx2 \
+ -mno-80387 \
+ -mno-3dnow
+endif
diff --git a/mos/sys/Makefile b/mos/sys/Makefile
new file mode 100644
index 0000000..59b4a84
--- /dev/null
+++ b/mos/sys/Makefile
@@ -0,0 +1,17 @@
+#
+# Copyright (c) 2025, Ian Moffett.
+# Provided under the BSD-3 clause.
+#
+
+CC =
+LD =
+
+SYS_CFLAGS =
+ARCH =
+
+.PHONY: all
+all: arch
+
+.PHONY: arch
+arch:
+ cd arch/$(ARCH); make CC=$(CC) LD=$(LD) SYS_CFLAGS="$(SYS_CFLAGS)"
diff --git a/mos/sys/arch/x86_64/Makefile b/mos/sys/arch/x86_64/Makefile
new file mode 100644
index 0000000..e7d352e
--- /dev/null
+++ b/mos/sys/arch/x86_64/Makefile
@@ -0,0 +1,22 @@
+#
+# Copyright (c) 2025, Ian Moffett
+# Provided under the BSD-3 clause.
+#
+
+ASMFILES = $(shell find . -name "*.S")
+ASMOFILES = $(ASMFILES:.S=.S.o)
+MISC_OFILES = $(shell find ../../ -name "*.o")
+
+CC =
+LD =
+
+SYS_CFLAGS =
+LDFLAGS = -Tadmin/mos.lds
+MOS_OUT = ../../sys.mos
+
+.PHONY: all
+all: $(ASMOFILES)
+ $(LD) $(LDFLAGS) $(MISC_OFILES) -o $(MOS_OUT)
+
+%.S.o: %.S
+ $(CC) $(SYS_CFLAGS) -c $< -o $@
diff --git a/mos/sys/arch/x86_64/admin/mos.lds b/mos/sys/arch/x86_64/admin/mos.lds
new file mode 100644
index 0000000..8b4aa82
--- /dev/null
+++ b/mos/sys/arch/x86_64/admin/mos.lds
@@ -0,0 +1,55 @@
+OUTPUT_FORMAT(elf64-x86-64)
+OUTPUT_ARCH(i386:x86-64)
+ENTRY(_start)
+
+PHDRS
+{
+ text PT_LOAD FLAGS((1 << 0) | (1 << 2)) ;
+ rodata PT_LOAD FLAGS((1 << 2)) ;
+ data PT_LOAD FLAGS((1 << 1) | (1 << 2)) ;
+}
+
+SECTIONS
+{
+ . = 0xFFFFFFFF80000000;
+
+ .text : {
+ *(.text .text.*)
+ } :text
+
+ .trampoline : {
+ *(.trampoline)
+ }
+
+ . += CONSTANT(MAXPAGESIZE);
+
+ .rodata : {
+ *(.rodata .rodata.*)
+ } :rodata
+
+ . += CONSTANT(MAXPAGESIZE);
+
+ /* Used for embedded hive modules */
+ .em_module : {
+ __em_module_begin = .;
+ KEEP(*(.em_module .em_module.*))
+ __em_module_end = .;
+ } :rodata
+
+ . += CONSTANT(MAXPAGESIZE);
+
+ .data : {
+ *(.data)
+ } :data
+
+ .bss : {
+ *(COMMON)
+ *(.bss .bss.*)
+ } :data
+
+ /DISCARD/ : {
+ *(.eh_frame .eh_frame.*)
+ *(.note .note.*)
+ }
+}
+
diff --git a/mos/sys/arch/x86_64/cpu/locore.S b/mos/sys/arch/x86_64/cpu/locore.S
new file mode 100644
index 0000000..c8ffc4c
--- /dev/null
+++ b/mos/sys/arch/x86_64/cpu/locore.S
@@ -0,0 +1,14 @@
+/*
+ * Copyright (c) 2025, Ian Moffett.
+ * Provided under the BSD-3 clause.
+ */
+
+ .text
+ .globl _start
+_start:
+ cli
+ cld
+
+1: cli
+ hlt
+ jmp 1b
diff --git a/mos/sys/sys.mos b/mos/sys/sys.mos
new file mode 100755
index 0000000..9654402
--- /dev/null
+++ b/mos/sys/sys.mos
Binary files differ
diff --git a/usr/.keep b/usr/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/usr/.keep