From 4df50a5373f3579d0515c183b9d71cff1cf67f58 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 16 Apr 2026 18:18:52 -0400 Subject: [PATCH] initial commit Signed-off-by: Ian Moffett --- .gitignore | 6 ++++ README | 11 +++++++ build.sh | 16 +++++++++ tools/bootstrap.sh | 60 ++++++++++++++++++++++++++++++++++ tools/toolchain.sh | 44 +++++++++++++++++++++++++ usr/src/Makefile | 19 +++++++++++ usr/src/README | 10 ++++++ usr/src/mk/sys.mk | 49 +++++++++++++++++++++++++++ usr/src/sp1/Makefile | 18 ++++++++++ usr/src/sp1/amd64/Makefile | 31 ++++++++++++++++++ usr/src/sp1/amd64/conf/link.ld | 54 ++++++++++++++++++++++++++++++ usr/src/sp1/amd64/cpu/locore.S | 22 +++++++++++++ 12 files changed, 340 insertions(+) create mode 100644 .gitignore create mode 100644 README create mode 100755 build.sh create mode 100755 tools/bootstrap.sh create mode 100755 tools/toolchain.sh create mode 100644 usr/src/Makefile create mode 100644 usr/src/README create mode 100644 usr/src/mk/sys.mk create mode 100644 usr/src/sp1/Makefile create mode 100644 usr/src/sp1/amd64/Makefile create mode 100644 usr/src/sp1/amd64/conf/link.ld create mode 100644 usr/src/sp1/amd64/cpu/locore.S diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7f27055 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +*.img +*.bin +*.d +*.o +*.sys +/var diff --git a/README b/README new file mode 100644 index 0000000..6918f90 --- /dev/null +++ b/README @@ -0,0 +1,11 @@ +-- System paw v1 -- + +Hewwo critter!~ System paw is a wovely operating system meant for critters of all kinds to get +their work (or fun! >:3) done while having their machine resources managed cleanly behind the +scenes. SPx is architected by a fluffy kitty cat who likes eating bugs and mice and RATS NOM +NOM NOM !!!! This kitty will protect your wittle den, don't worry critter! + +-- Confidentiality of implementation -- + +This repository and its sources as of Thu Apr 16 is CONFIDENTIAL and PROPRIETARY. +Unauthorized distribution or modification is strictly prohibited. diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..d36ca80 --- /dev/null +++ b/build.sh @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Copyright (c) 2026, Mirocom Laboratories +# All rights reserved. +# +# The following sources are CONFIDENTIAL and PROPRIETARY +# property of Mirocom Laboratories. Unauthorized copying, +# use, distrubution or modification of this file, in whole +# and in part, is strictly prohibited without the prior written +# consent from Mirocom Laboratories. +# + +MAKE=make + +cd usr/src/; \ + $MAKE diff --git a/tools/bootstrap.sh b/tools/bootstrap.sh new file mode 100755 index 0000000..9c1eda0 --- /dev/null +++ b/tools/bootstrap.sh @@ -0,0 +1,60 @@ +#!/bin/sh +# +# Copyright (c) 2026, Mirocom Laboratories +# All rights reserved. +# +# The following sources are CONFIDENTIAL and PROPRIETARY +# property of Mirocom Laboratories. Unauthorized copying, +# use, distrubution or modification of this file, in whole +# and in part, is strictly prohibited without the prior written +# consent from Mirocom Laboratories. +# + +# +# 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/tools/toolchain.sh b/tools/toolchain.sh new file mode 100755 index 0000000..3083422 --- /dev/null +++ b/tools/toolchain.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# +# Copyright (c) 2026, Mirocom Laboratories +# All rights reserved. +# +# The following sources are CONFIDENTIAL and PROPRIETARY +# property of Mirocom Laboratories. Unauthorized copying, +# use, distribution or modification of this file, in whole +# and in part, is strictly prohibited without the prior written +# consent from Mirocom Laboratories. +# + +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/usr/src/Makefile b/usr/src/Makefile new file mode 100644 index 0000000..ab75907 --- /dev/null +++ b/usr/src/Makefile @@ -0,0 +1,19 @@ +# +# Copyright (c) 2026, Mirocom Laboratories +# All rights reserved. +# +# The following sources are CONFIDENTIAL and PROPRIETARY +# property of Mirocom Laboratories. Unauthorized copying, +# use, distrubution or modification of this file, in whole +# and in part, is strictly prohibited without the prior written +# consent from Mirocom Laboratories. +# + +include mk/sys.mk + +.PHONY: all +all: sp1 + +.PHONY: sp1 +sp1: + cd sp1/; $(MAKE) $(PASSDOWN_ARGS) diff --git a/usr/src/README b/usr/src/README new file mode 100644 index 0000000..7a215bb --- /dev/null +++ b/usr/src/README @@ -0,0 +1,10 @@ +------------------------------------------------------------- +Copyright (c) 2026, Mirocom Laboratories +All rights reserved. + +The following sources are CONFIDENTIAL and PROPRIETARY +property of Mirocom Laboratories. Unauthorized copying, +use, distrubution or modification of this file, in whole +and in part, is strictly prohibited without the prior written +consent from Mirocom Laboratories. +------------------------------------------------------------- diff --git a/usr/src/mk/sys.mk b/usr/src/mk/sys.mk new file mode 100644 index 0000000..f408a8a --- /dev/null +++ b/usr/src/mk/sys.mk @@ -0,0 +1,49 @@ +# +# Copyright (c) 2026, Mirocom Laboratories +# All rights reserved. +# +# The following sources are CONFIDENTIAL and PROPRIETARY +# property of Mirocom Laboratories. Unauthorized copying, +# use, distrubution or modification of this file, in whole +# and in part, is strictly prohibited without the prior written +# consent from Mirocom Laboratories. +# + +CC_PREFIX = x86_64-pc-mirocom +ARCH_TARGET = amd64 + +CC = \ + var/cc/toolchain/gcc/bin/$(CC_PREFIX)-gcc +LD = \ + var/cc/toolchain/build-binutils/bin/$(CC_PREFIX)-ld +AR = \ + var/cc/toolchain/build-binutils/bin/$(CC_PREFIX)-ar + +SYS_CFLAGS = \ + -nostdlib \ + -nostdinc \ + -ffreestanding \ + -fexceptions \ + --std=gnu11 \ + -mcmodel=kernel \ + -Wno-attributes \ + -fno-stack-protector\ + -D_SP1_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)" diff --git a/usr/src/sp1/Makefile b/usr/src/sp1/Makefile new file mode 100644 index 0000000..a7e3496 --- /dev/null +++ b/usr/src/sp1/Makefile @@ -0,0 +1,18 @@ +#!/bin/sh +# +# Copyright (c) 2026, Mirocom Laboratories +# All rights reserved. +# +# The following sources are CONFIDENTIAL and PROPRIETARY +# property of Mirocom Laboratories. Unauthorized copying, +# use, distrubution or modification of this file, in whole +# and in part, is strictly prohibited without the prior written +# consent from Mirocom Laboratories. +# + +.PHONY: all +all: $(ARCH) + +.PHONY: $(ARCH) +$(ARCH): + cd $(ARCH); $(MAKE) diff --git a/usr/src/sp1/amd64/Makefile b/usr/src/sp1/amd64/Makefile new file mode 100644 index 0000000..6cfd22f --- /dev/null +++ b/usr/src/sp1/amd64/Makefile @@ -0,0 +1,31 @@ +# +# Copyright (c) 2026, Mirocom Laboratories +# All rights reserved. +# +# The following sources are CONFIDENTIAL and PROPRIETARY +# property of Mirocom Laboratories. Unauthorized copying, +# use, distrubution or modification of this file, in whole +# and in part, is strictly prohibited without the prior written +# consent from Mirocom Laboratories. +# + +ASMFILES = $(shell find . -name "*.S") +ASMOFILES = $(ASMFILES:.S=.S.o) + +MISC_OFILES = $(shell find ../../ -name "*.o") + +CC = \ + ../../../../$(SYS_CC) + +LD = \ + ../../../../$(SYS_LD) + +CFLAGS = \ + $(SYS_CFLAGS) + +.PHONY: all +all: $(ASMOFILES) + $(LD) -Tconf/link.ld $(MISC_OFILES) -o ../../../../sp1.sys + +%.S.o: %.S + $(CC) -c $(CFLAGS) $< -o $@ diff --git a/usr/src/sp1/amd64/conf/link.ld b/usr/src/sp1/amd64/conf/link.ld new file mode 100644 index 0000000..cd46b3c --- /dev/null +++ b/usr/src/sp1/amd64/conf/link.ld @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2026, Mirocom Laboratories + * All rights reserved. + * + * The following sources are CONFIDENTIAL and PROPRIETARY + * property of Mirocom Laboratories. Unauthorized copying, + * use, distribution or modification of this file, in whole + * and in part, is strictly prohibited without the prior written + * consent from Mirocom Laboratories. + */ + +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 + + . += CONSTANT(MAXPAGESIZE); + + .rodata : { + *(.rodata .rodata.*) + } :rodata + + . += CONSTANT(MAXPAGESIZE); + + .data : { + *(.data) + } :data + + .bss : { + *(COMMON) + *(.bss .bss.*) + } :data + + . += CONSTANT(MAXPAGESIZE); + + /DISCARD/ : { + *(.eh_frame .eh_frame.*) + *(.note .note.*) + } +} diff --git a/usr/src/sp1/amd64/cpu/locore.S b/usr/src/sp1/amd64/cpu/locore.S new file mode 100644 index 0000000..0bfde71 --- /dev/null +++ b/usr/src/sp1/amd64/cpu/locore.S @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2026, Mirocom Laboratories + * All rights reserved. + * + * The following sources are CONFIDENTIAL and PROPRIETARY + * property of Mirocom Laboratories. Unauthorized copying, + * use, distribution or modification of this file, in whole + * and in part, is strictly prohibited without the prior written + * consent from Mirocom Laboratories. + */ + + .text + .globl _start +_start: + cli + cld + + xor %rbp, %rbp + + cli +1: hlt + jmp 1b