From 1f58ed49a9526858e2607e515add0678f351a1fe Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Tue, 24 Mar 2026 23:44:28 -0400 Subject: [PATCH] initial commit Signed-off-by: Ian Moffett --- .gitignore | 5 +++++ README.md | 19 ++++++++++++++++ host/bootstrap.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++ host/toolchain.sh | 39 +++++++++++++++++++++++++++++++++ src/mk/default.mk | 37 +++++++++++++++++++++++++++++++ 5 files changed, 155 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100755 host/bootstrap.sh create mode 100755 host/toolchain.sh create mode 100644 src/mk/default.mk diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aab2932 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/var +*.o +*.d +*.sys +*.iso diff --git a/README.md b/README.md new file mode 100644 index 0000000..23684b2 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# The M1X operating system + +M1X is an operating system partially inspired by Solaris aiming to provide a pragmatic +capability based security environment. M1X follows the "(almost) everything is a file" +philosophy in which machine resources and files are accessible through a unified file +interface similar to those found in POSIX environments, however, the underlying file +management mechanisms are to be handled orthogonally to machine resource managment. + +The way this is to be done is by introducing the concept of filepath prefixes which +allow the kernel to differentiate between machine resources and true files. + +## Building M1X + +To build M1X, start with obtaining required dependencies by executing the ``bootstrap.sh`` +script found within the top-level ``host/`` directory. After which, one may build the toolchain +by invoking ``toolchain.sh`` which is found in the same directory. + +Once the toolchain is complete, the world can be built by invoking the ``build.sh`` script located +in the top-level ``host/`` directory. diff --git a/host/bootstrap.sh b/host/bootstrap.sh new file mode 100755 index 0000000..a940959 --- /dev/null +++ b/host/bootstrap.sh @@ -0,0 +1,55 @@ +#!/bin/sh + +# +# Copyright (c) 2026, Mirocom Laboratories +# Provided under the BSD-3 clause +# + +# +# Check if a list of programs are installed on the system +# +# <@>: List of programs to check +# +check_deps() { + for dep in $@; do + printf "Checking if $dep is installed... " + which $dep &>/dev/null + if [ $? -ne 0 ]; then + echo "no" + echo "Please install $dep!" + exit 1 + fi + + echo "yes" + done +} + +# +# Obtain the Mirocom gcc toolchain +# +get_toolchain() { + if [ ! -d var/cc/toolchain ]; then + git clone https://git.mirocom.org/Mirocom/mirocom-toolchain --depth=1 var/cc/toolchain + cd var/cc/toolchain + tar -xzvf toolchain.tar.gz + mv public/* .; rm -rf public/ + cd ../../../ + fi +} + +# +# Obtain all deps +# +get_deps() { + get_toolchain +} + +# Make sure everything is installed +check_deps \ + git \ + make \ + gcc \ + xorriso + +# Obtain all the deps we need +get_deps diff --git a/host/toolchain.sh b/host/toolchain.sh new file mode 100755 index 0000000..a9a54ad --- /dev/null +++ b/host/toolchain.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# +# Copyright (c) 2026, Mirocom Laboratories +# Provided under the BSD-3 clause +# + +TARGET=x86_64-pc-mirocom +MAKE=make + +mkdir -p var/ +mkdir -p var/cc/root/usr/include/ +mkdir -p var/cc/root/usr/bin/ + +# Don't build again if the lock exists +if [ -f var/cc/.lock ]; then + echo "var/cc/.lock exists, skipping toolchain build" + exit 1 +fi + +pushd var/cc/toolchain +bash build.sh + +mkdir -p gcc +pushd gcc + +# Configure gcc +../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 +popd +popd +touch var/cc/.lock diff --git a/src/mk/default.mk b/src/mk/default.mk new file mode 100644 index 0000000..57ddf9b --- /dev/null +++ b/src/mk/default.mk @@ -0,0 +1,37 @@ +ARCH_TARGET = x86_64 + +CC = \ + ../var/cc/toolchain/gcc/bin/$(ARCH_TARGET)-pc-mirocom-gcc +LD = \ + ../var/cc/toolchain/build-binutils/bin/$(ARCH_TARGET)-pc-mirocom-ld +AR = \ + ../var/cc/toolchain/build-binutils/bin/$(ARCH_TARGET)-pc-mirocom-ar + +SYS_CFLAGS = \ + -nostdlib \ + -nostdinc \ + -ffreestanding \ + -fexceptions \ + --std=gnu11 \ + -mcmodel=kernel \ + -Wno-attributes \ + -fno-stack-protector\ + -D_M1X_MULTICORE + +ifeq ($(ARCH_TARGET),x86_64) + SYS_CFLAGS += \ + -mno-sse \ + -mno-sse2 \ + -mno-sse3 \ + -mno-avx \ + -mno-avx2 \ + -mno-80387 \ + -mno-3dnow \ + -mno-mmx +endif + +PASSDOWN_ARGS = \ + ARCH=$(ARCH_TARGET) \ + SYS_CC=$(CC) \ + SYS_LD=$(LD) \ + SYS_CFLAGS="$(SYS_CFLAGS)"