A bare-bones kernel
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
./buildkernel.sh
./buildimage.sh
./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
-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.grub.img
as a loop device:
sudo losetup /dev/loop0 references/grub.img
mnt
folder:
sudo mkdir /mnt/sos
sos
directory at /dev/loop0
:
sudo mount /dev/loop0 /mnt/sos
/mnt/sos/SOS
:
sudo cp hydrogen /mnt/sos/SOS
sudo sync
sudo umount /dev/loop0
sudo losetup -d /dev/loop0
qemu-system-i386 -fda references/grub.img
-fda
option tells qemu to use grub.img as a floppy disk image.