Skip to content

Project to bootstrap a custom kernel. Kernel is in C and boot sector is in assembly. Basically a follow through of Nick Blundell excellent paper on writing a custom operating system from scratch. Found some errors and bugs I fixed and got everything working using Ubuntu and Qemu.

License

Notifications You must be signed in to change notification settings

foo74/bootstrapped_kernel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Development Platform
OS: Ubuntu 15.10 - GNU/Linux 4.2.0-35-generic, 64-bit
Hardware: 7.7 GiB RAM, Intel Core i7-4500 CPU @ 1.80GHz x 4

To build and run:
1. make clean
2. make
3. make run


---------------------NOTES----------------------
to compile:
nasm main.asm -f bin -o main

The reason for the run_qemu bash script is that qemu now needs to specify format of raw
so that it won't give a warning. So we pass in the binary as a variable.

-----------

When we get to the point that we are going to load the C kernel we have to pad the os-image with extra space to make it big enough to read 15 sectors. If you don't do this then you will get disk read errors. We need the -m32 since we are compiling on Ubuntu 64-bit but creating a 32-bit output. Also, we need the -melf_i386 in the ld command for same reason. It spots the -m32 from the gcc and knows to create a 32-bit output.

gcc -m32 -ffreestanding -c kernel.c -o kernel.o
ld -melf_i386 -o kernel.bin -Ttext 0x1000 kernel_entry.o kernel.o --oformat binary
cat boot_sect.bin kernel.bin > os-image
dd if=/dev/zero bs=512 count=60 >> os-image
./run_qemu os-image

About

Project to bootstrap a custom kernel. Kernel is in C and boot sector is in assembly. Basically a follow through of Nick Blundell excellent paper on writing a custom operating system from scratch. Found some errors and bugs I fixed and got everything working using Ubuntu and Qemu.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published