diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d163863 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b7250a6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM rustlang/rust:nightly +# add intermezzOS deps +ENV DEBIAN_FRONTEND noninteractive +RUN apt-get update && apt-get install -y \ + nasm \ + xorriso \ + qemu \ + build-essential \ + grub-pc-bin && apt-get clean \ + && cargo install xargo \ + && rustup component add rust-src \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..b60d265 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Usage + +To build a new image - `docker-compose build` + +To test against the intermezzOS chapter 3 - `docker-compose run test` \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5018634 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +# docker-compose.yml +test: + build: . + command: make + volumes: + - ./test:/src + working_dir: /src \ No newline at end of file diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..d03e063 --- /dev/null +++ b/test/Makefile @@ -0,0 +1,28 @@ +default: run + +.PHONY: default build run clean + +build/multiboot_header.o: multiboot_header.asm + mkdir -p build + nasm -f elf64 multiboot_header.asm -o build/multiboot_header.o + +build/boot.o: boot.asm + mkdir -p build + nasm -f elf64 boot.asm -o build/boot.o + +build/kernel.bin: build/multiboot_header.o build/boot.o linker.ld + ld -n -o build/kernel.bin -T linker.ld build/multiboot_header.o build/boot.o + +build/os.iso: build/kernel.bin grub.cfg + mkdir -p build/isofiles/boot/grub + cp grub.cfg build/isofiles/boot/grub + cp build/kernel.bin build/isofiles/boot/ + grub-mkrescue -o build/os.iso build/isofiles + +run: build/os.iso + qemu-system-x86_64 -curses -net none -cdrom build/os.iso + +build: build/os.iso + +clean: + rm -rf build diff --git a/test/boot.asm b/test/boot.asm new file mode 100644 index 0000000..cb69197 --- /dev/null +++ b/test/boot.asm @@ -0,0 +1,19 @@ +global start + +section .text +bits 32 +start: + mov word [0xb8000], 0x0248 ; H + mov word [0xb8002], 0x0265 ; e + mov word [0xb8004], 0x026c ; l + mov word [0xb8006], 0x026c ; l + mov word [0xb8008], 0x026f ; o + mov word [0xb800a], 0x022c ; , + mov word [0xb800c], 0x0220 ; + mov word [0xb800e], 0x0277 ; w + mov word [0xb8010], 0x026f ; o + mov word [0xb8012], 0x0272 ; r + mov word [0xb8014], 0x026c ; l + mov word [0xb8016], 0x0264 ; d + mov word [0xb8018], 0x0221 ; ! + hlt \ No newline at end of file diff --git a/test/grub.cfg b/test/grub.cfg new file mode 100644 index 0000000..98bfeb6 --- /dev/null +++ b/test/grub.cfg @@ -0,0 +1,7 @@ +set timeout=0 +set default=0 + +menuentry "intermezzOS" { + multiboot2 /boot/kernel.bin + boot +} \ No newline at end of file diff --git a/test/linker.ld b/test/linker.ld new file mode 100644 index 0000000..b5f1f76 --- /dev/null +++ b/test/linker.ld @@ -0,0 +1,16 @@ +ENTRY(start) + +SECTIONS { + . = 1M; + + .boot : + { + /* ensure that the multiboot header is at the beginning */ + *(.multiboot_header) + } + + .text : + { + *(.text) + } +} \ No newline at end of file diff --git a/test/multiboot_header.asm b/test/multiboot_header.asm new file mode 100644 index 0000000..a802f1c --- /dev/null +++ b/test/multiboot_header.asm @@ -0,0 +1,14 @@ +section .multiboot_header +header_start: + dd 0xe85250d6 ; magic number + dd 0 ; protected mode code + dd header_end - header_start ; header length + + ; checksum + dd 0x100000000 - (0xe85250d6 + 0 + (header_end - header_start)) + + ; required end tag + dw 0 ; type + dw 0 ; flags + dd 8 ; size +header_end: