summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore11
-rw-r--r--Makefile.in42
-rwxr-xr-xbootstrap14
-rw-r--r--configure.ac16
-rw-r--r--data/boot/limine.conf12
-rw-r--r--data/boot/wallpaper.jpgbin0 -> 371166 bytes
-rw-r--r--sys/Makefile15
-rw-r--r--sys/arch/amd64/Makefile17
-rw-r--r--sys/arch/amd64/boot.S5
-rw-r--r--sys/arch/amd64/conf/link.ld42
-rwxr-xr-xsys/rv7bin0 -> 4520 bytes
-rw-r--r--tools/build-toolchain.sh33
12 files changed, 207 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5064b6c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,11 @@
+/autom4te.cache
+/Makefile
+/configure
+/boot
+/cc
+*.sys
+*.log
+*.status
+*.iso
+*.o
+*.d
diff --git a/Makefile.in b/Makefile.in
new file mode 100644
index 0000000..803bfeb
--- /dev/null
+++ b/Makefile.in
@@ -0,0 +1,42 @@
+CC = @CC@
+LD = @LD@
+ARCH = @ARCH@
+ISO = rv7.iso
+SYS_CFLAGS = @SYS_CFLAGS@
+SYSROOT = root
+
+.PHONY: all
+all: $(SYSROOT) sys iso
+
+.PHONY: sys
+sys:
+ cd sys/; make CC=$(CC) SYS_CFLAGS="$(SYS_CFLAGS)" ARCH=$(ARCH) LD=$(LD)
+
+.PHONY: iso
+iso:
+ mkdir -p iso_root/boot/
+ cp data/boot/wallpaper.jpg iso_root/boot/
+ cp data/boot/limine.conf boot/limine/limine-bios.sys \
+ boot/limine/limine-bios-cd.bin boot/limine/limine-uefi-cd.bin iso_root/
+ cp sys/rv7 iso_root/boot/
+ 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
+ boot/limine/limine bios-install $(ISO) 1>/dev/null
+ rm -rf iso_root
+
+$(SYSROOT):
+ mkdir -p $(SYSROOT)/
+ mkdir -p $(SYSROOT)/boot/
+ mkdir -p $(SYSROOT)/boot/np/
+ mkdir -p $(SYSROOT)/usr/include/
+ mkdir -p $(SYSROOT)/usr/bin/
+ mkdir -p $(SYSROOT)/usr/sbin/
+
+.PHONY: run
+run:
+ qemu-system-x86_64 -cdrom rv7.iso --enable-kvm -cpu host -m 2G
+
+.PHONY: clean
+clean:
+ cd sys/; make clean ARCH=$(ARCH)
diff --git a/bootstrap b/bootstrap
new file mode 100755
index 0000000..0500d3f
--- /dev/null
+++ b/bootstrap
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+if [[ ! -d cc/toolchain ]]
+then
+ git clone https://github.com/sigsegv7/osmora-toolchain cc/toolchain
+fi
+
+if [[ ! -d boot ]]
+then
+ git clone https://github.com/limine-bootloader/limine.git --branch=v9.3.0-binary --depth=1 boot/limine
+ make -C boot/limine
+fi
+
+autoconf
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..af311d3
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,16 @@
+AC_INIT([rv7], [0.0.1], [ian@osmora.org])
+AC_PROG_CC
+
+CC=$(pwd)/cc/gcc/bin/x86_64-pc-osmora-gcc
+LD=$(pwd)/cc/toolchain/build-binutils/bin/x86_64-pc-osmora-ld
+ARCH="amd64"
+
+MD_CFLAGS="-mno-sse -mno-sse2 -mno-sse3 -mno-mmx -mno-3dnow -mno-avx -mno-avx2"
+CFLAGS="-nostdlib -nostdinc -ffreestanding -mcmodel=kernel -fno-stack-protector $MD_CFLAGS"
+
+AC_SUBST(SYS_CFLAGS, [$CFLAGS])
+AC_SUBST(CC, [$CC])
+AC_SUBST(LD, [$LD])
+AC_SUBST(ARCH, [$ARCH])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
diff --git a/data/boot/limine.conf b/data/boot/limine.conf
new file mode 100644
index 0000000..10ecfee
--- /dev/null
+++ b/data/boot/limine.conf
@@ -0,0 +1,12 @@
+timeout: 10
+randomize_hhdm_base: no
+interface_branding_color: 3
+interface_help_hidden: yes
+${WALLPAPER_PATH}=boot():/boot/wallpaper.jpg
+wallpaper: ${WALLPAPER_PATH}
+term_background: 40000000
+resolution: 1280x720
+
+/RV7
+ protocol: limine
+ kernel_path: boot():/boot/rv7
diff --git a/data/boot/wallpaper.jpg b/data/boot/wallpaper.jpg
new file mode 100644
index 0000000..5c1e616
--- /dev/null
+++ b/data/boot/wallpaper.jpg
Binary files differ
diff --git a/sys/Makefile b/sys/Makefile
new file mode 100644
index 0000000..bfac75a
--- /dev/null
+++ b/sys/Makefile
@@ -0,0 +1,15 @@
+CC =
+LD =
+SYS_CFLAGS =
+ARCH =
+
+.PHONY: all
+all: arch
+
+.PHONY: arch
+arch:
+ cd arch/$(ARCH); make CC=$(CC) LD=$(LD) SYS_CFLAGS="$(SYS_CFLAGS)"
+
+.PHONY: clean
+clean:
+ cd arch/$(ARCH); make clean
diff --git a/sys/arch/amd64/Makefile b/sys/arch/amd64/Makefile
new file mode 100644
index 0000000..1090a38
--- /dev/null
+++ b/sys/arch/amd64/Makefile
@@ -0,0 +1,17 @@
+CC =
+LD =
+SYS_CFLAGS =
+ASMFILES = $(shell find . -name "*.S")
+ASMOBJS = $(ASMFILES:.S=.S.o)
+MISC_OFILES = $(shell find ../../ -name "*.o")
+
+.PHONY: all
+all: $(ASMOBJS)
+ $(LD) -Tconf/link.ld $(MISC_OFILES) -o ../../rv7
+
+%.S.o: %.S
+ $(CC) -c $(SYS_CFLAGS) $< -o $@
+
+.PHONY: clean
+clean:
+ rm $(MISC_OFILES)
diff --git a/sys/arch/amd64/boot.S b/sys/arch/amd64/boot.S
new file mode 100644
index 0000000..0d2e0d2
--- /dev/null
+++ b/sys/arch/amd64/boot.S
@@ -0,0 +1,5 @@
+ .globl _start
+_start:
+1: cli
+ hlt
+ jmp 1b
diff --git a/sys/arch/amd64/conf/link.ld b/sys/arch/amd64/conf/link.ld
new file mode 100644
index 0000000..92222b0
--- /dev/null
+++ b/sys/arch/amd64/conf/link.ld
@@ -0,0 +1,42 @@
+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
+
+ /DISCARD/ : {
+ *(.eh_frame .eh_frame.*)
+ *(.note .note.*)
+ }
+}
+
diff --git a/sys/rv7 b/sys/rv7
new file mode 100755
index 0000000..e66971a
--- /dev/null
+++ b/sys/rv7
Binary files differ
diff --git a/tools/build-toolchain.sh b/tools/build-toolchain.sh
new file mode 100644
index 0000000..580aafc
--- /dev/null
+++ b/tools/build-toolchain.sh
@@ -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 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