From 5cb5188112476b82af1e9f0a8f61866becca31e0 Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Mon, 8 Apr 2019 18:24:00 +0200 Subject: Initial commit --- .gitignore | 4 ++++ init/Makefile | 17 +++++++++++++++++ init/init.c | 13 +++++++++++++ init/init.o | Bin 0 -> 1672 bytes packroot.sh | 5 +++++ start.sh | 4 ++++ 6 files changed, 43 insertions(+) create mode 100644 .gitignore create mode 100644 init/Makefile create mode 100644 init/init.c create mode 100644 init/init.o create mode 100755 packroot.sh create mode 100755 start.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1978fd3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +bzImage +initramfs* +*.elf +root/* diff --git a/init/Makefile b/init/Makefile new file mode 100644 index 0000000..53a64ea --- /dev/null +++ b/init/Makefile @@ -0,0 +1,17 @@ +CC = gcc +CFLAGS = +LDFLAGS = --static +OUTPUT = init.elf + +SRC = init.c + +build: init.o + $(CC) $(CFLAGS) $(SRC) $(LDFLAGS) -o $(OUTPUT) + +.PHONY: copy clean + +clean: + rm -df $(OUTPUT) + +copy: + objcopy -O binary $(OUTPUT) ../root/init diff --git a/init/init.c b/init/init.c new file mode 100644 index 0000000..00836b5 --- /dev/null +++ b/init/init.c @@ -0,0 +1,13 @@ +#include +#include + +int main(int argc, char* argv[]) +{ + printf("I'm a kernel!\r\n"); + + while(1) + { + printf("Still running!\r\n"); + sleep(1); + } +} diff --git a/init/init.o b/init/init.o new file mode 100644 index 0000000..6a8fc22 Binary files /dev/null and b/init/init.o differ diff --git a/packroot.sh b/packroot.sh new file mode 100755 index 0000000..b9a6572 --- /dev/null +++ b/packroot.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +cd root +find . -print -depth | cpio -ov -H newc > ../initramfs.cpio.gz + diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..f26c99b --- /dev/null +++ b/start.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +screen qemu-system-x86_64 -nographic -no-reboot -kernel bzImage -initrd initramfs.cpio.gz -m 256M -append "console=ttyS0 panic=1" + -- cgit v1.2.3