From d2ad933d73bdf81f30f23b4e567440732f66117e Mon Sep 17 00:00:00 2001 From: Jean-Yves Lamoureux Date: Sun, 20 Dec 2009 13:36:15 +0000 Subject: [PATCH] * Forgot kernel build script --- build-kernel | 67 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 19 deletions(-) diff --git a/build-kernel b/build-kernel index 68adf96..efa5963 100755 --- a/build-kernel +++ b/build-kernel @@ -1,37 +1,66 @@ #! /bin/sh -## Kernel-mode libcaca compilation script -- Sam Hocevar +## Kernel-mode libcaca compilation script -- Sam Hocevar ## $Id$ set -x set -e -CFLAGS="-fno-builtin -O2 -I. -I.. -I../caca/ -Wall" -CPPFLAGS="-D__KERNEL__ -nostdinc -include kernel/kernel.h" +CFLAGS="-fno-builtin -O0 -I. -I.. -I../caca/ -Wall -D__KERNEL__ -fno-stack-protector -m32" LDFLAGS="-nostdlib -Wl,-N -Wl,-Ttext -Wl,100000" ./configure --disable-slang --disable-ncurses --disable-win32 \ - --disable-conio --disable-x11 --disable-gl --disable-network \ - --enable-vga --disable-imlib2 --disable-doc \ - --host i386 - -# We need this. -make clean + --disable-conio --disable-x11 --disable-gl --disable-network \ + --enable-vga --disable-imlib2 --disable-doc \ + --host i386 +# Compile cacademo, leave it as an object cd caca && make && cd .. +cd examples && make dithering.o && cd .. -cd src && make cacademo.o && cd .. -cd kernel && - gcc $CFLAGS -c multiboot.S -o multiboot.o && - gcc $CFLAGS $CPPFLAGS -c kernel.c -o kernel.o && -cd .. +cd kernel + +# Bootsector +nasm -f bin -o bootsect.bin boot/bootsect.asm +# Interruption handlers +nasm -f elf -o int.o boot/int.asm -gcc $LDFLAGS -o src/cacademo kernel/multiboot.o kernel/kernel.o src/cacademo.o caca/.libs/libcaca.a +##### Boot (x86) +# Stage2, loads GDT, PIC, IDT, interrupts, then calls kmain() +gcc $CFLAGS boot/stage2.c -c +# GDT installation, called by stage2 +gcc $CFLAGS boot/gdt.c -c +# PIC installation, called by stage2 +gcc $CFLAGS boot/pic.c -c +# IDT installation, called by stage2 +gcc $CFLAGS boot/idt.c -c +# Interruptions installation, called by stage2 +gcc $CFLAGS boot/interruptions.c -c -objcopy -O binary src/cacademo cacademo.boot +##### Drivers +# Floppy driver +gcc $CFLAGS drivers/floppy.c -c +# Processor driver +gcc $CFLAGS drivers/processor.c -c +# Keyboard handler +gcc $CFLAGS drivers/keyboard.c -c +# Memory driver +gcc $CFLAGS drivers/memory.c -c +# Programmable Interval Timer driver +gcc $CFLAGS drivers/timer.c -c -# For further development: create floppy images using the kernel -gcc -traditional -c -o bootsect.o kernel/bootsect.S -ld -Ttext 0x0 -s --oformat binary bootsect.o -o cacademo.img +# Minimalistic libc +gcc $CFLAGS klibc.c -c + +# Kernel by itself, contains cmain() which calls main() +gcc $CFLAGS kernel.c -c + +# Link everything but bootsector, kernel.o MUST be at the very end +ld --oformat binary -Ttext 1000 stage2.o gdt.o pic.o int.o idt.o interruptions.o keyboard.o memory.o timer.o floppy.o processor.o klibc.o kernel.o -Map kernel.map ../caca/.libs/libcaca.a -o kern.bin + +ls -ail kern.bin +cd .. +# Copy bootsector at the very beginning of the floppy (first sector/512 bytes of the image), then kernel right after +cat kernel/bootsect.bin kernel/kern.bin /dev/zero | dd of=cacademo.img bs=512 count=2500 \ No newline at end of file