A bare-bones kernel that prints "Hello, World!" on the screen.
1. QEMU:
QEMU is a machine emulator and virtualizer.
Install it using:
1. Linux: $ sudo apt-get install qemu-system
2. Mac OS: brew install qemu
2. NASM:
NASM is an assembler and disassembler for the Intel x86 architecture.
Install it using: $ sudo apt-get install nasm
- Build kernel executable:
./buildkernel.sh
- Place the kernel executable in the grub image:
./buildimage.sh
- Run the kernel:
./run.sh
-
Use NASM to produce an object file of
entry.asm
.
*nasm -f elf32 entry.asm -o entry.o
*elf32
flag is used to produce a 32-bit ELF object file. -
Use cc to produce an object file of
c_start.c
. *cc -m32 -c -Wall c_start.c
* From the man page of gcc:
-m32
Generate code for a 32-bit or 64-bit environment.
The -m32 option sets "int", "long", and pointer
types to 32 bits, and generates code that runs on
any i386 system.
-
Use ld (the GNU Linker) to link the above object files into a single executable (hydrogen). *
ld -m elf_i386 -T link.ld -o hydrogen c_start.o entry.o
*elf_i386
flag is used to emulate the elf_i386 linker. *link.ld
is a linker template file.
sudo losetup /dev/loop0 references/grub.img
sudo mkdir /mnt/sos
sudo mount /dev/loop0 /mnt/sos
sudo cp hydrogen /mnt/sos/SOS
sudo sync
sudo umount /dev/loop0
sudo losetup -d /dev/loop0
-fda
option tells qemu to use grub.img as a floppy disk image.