From d4d57c8053273765b42d654fa0e4db3a90e7cbde Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Fri, 20 Oct 2017 20:58:06 +0100 Subject: [PATCH] Added code + tooling to build os. --- .gitignore | 2 ++ boot.o | Bin 0 -> 864 bytes builddisc.sh | 6 ++++++ checkmultiboot.sh | 6 ++++++ grub.cfg | 3 +++ makefile | 10 ++++++++++ panicoverride.nim | 2 ++ 7 files changed, 29 insertions(+) create mode 100644 boot.o create mode 100755 builddisc.sh create mode 100755 checkmultiboot.sh create mode 100644 grub.cfg create mode 100644 makefile create mode 100644 panicoverride.nim diff --git a/.gitignore b/.gitignore index 67d9b34..2003856 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ nimcache/ +isodir/ +myos.iso diff --git a/boot.o b/boot.o new file mode 100644 index 0000000000000000000000000000000000000000..4896ace704ab601778932ae92a6f7c6e53f9ad20 GIT binary patch literal 864 zcmb7C%Syvg5S=tC6-8787rGH#sEeTBM%=WPwiX)|MO>Do1}nCSG*{4-euAIi4+wsM zAJc^k!BxPO58^rXUQ%)8z+~pkyqu4m%g{l-9-2bLj2ON(1V&8|b{|dbABM7@e7tAw@nMemWAES@MxJ=tm(Mg! z-``%p5O6w|ZFS~HkrKy`V{ue)1vhTRs;fL7-gW24YTOOlKQ*NLBW6A(h9pS`3x2;m z=N#M!u`M%b$T*U89yqH?(na8GKS{d6JnjesNzzq(&0UE%`f>BgNri49!^d#P3S&;%3uz$URoXZ$FFZAV5T4*n?#9Bg{BLp?;u~plV445` literal 0 HcmV?d00001 diff --git a/builddisc.sh b/builddisc.sh new file mode 100755 index 0000000..c99f4c8 --- /dev/null +++ b/builddisc.sh @@ -0,0 +1,6 @@ +#!/bin/sh +rm -r isodir +mkdir -p isodir/boot/grub +cp kernel isodir/boot/kernel +cp grub.cfg isodir/boot/grub/grub.cfg +grub-mkrescue -o myos.iso isodir diff --git a/checkmultiboot.sh b/checkmultiboot.sh new file mode 100755 index 0000000..cf0a37e --- /dev/null +++ b/checkmultiboot.sh @@ -0,0 +1,6 @@ +#!/bin/sh +if grub-file --is-x86-multiboot kernel; then + echo multiboot confirmed +else + echo the file is not multiboot +fi diff --git a/grub.cfg b/grub.cfg new file mode 100644 index 0000000..1e1a972 --- /dev/null +++ b/grub.cfg @@ -0,0 +1,3 @@ +menuentry "myos" { + multiboot /boot/kernel +} diff --git a/makefile b/makefile new file mode 100644 index 0000000..46aad51 --- /dev/null +++ b/makefile @@ -0,0 +1,10 @@ +all: kernel + +kernel: bootloader + nim cc --cc:clang --clang.linkerexe=ld.lld --gc:none --deadCodeElim:on --cpu:i386 --os:standalone --passC:"-ffreestanding -nostdlib --target=i686-pc-none-elf -march=i686" --passL:"-m elf_i386 boot.o" kernel.nim + +bootloader: + nasm -felf32 boot.s -o boot.o + +clean: + rm -r kernel nimcache/ boot.o diff --git a/panicoverride.nim b/panicoverride.nim new file mode 100644 index 0000000..08cced0 --- /dev/null +++ b/panicoverride.nim @@ -0,0 +1,2 @@ +proc rawoutput(s: string) = discard +proc panic(s: string) = discard