From 8301f87815fe6b4b1a3e8e94b9df17372ae9905f Mon Sep 17 00:00:00 2001 From: Hojun-Cho Date: Wed, 27 Nov 2024 22:56:59 +0900 Subject: [PATCH] add readme --- README.md | 35 ++++++++++++++++++++++++++++++++++- boot/boot.c | 1 - 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 24365d0..cab91ae 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,35 @@ -### MBR bootloader +# FAT16 bootloader + x86 FAT16 bootloader + +### How to run + 1. install image to device + install to device + ./install.sh /dev/sda + create image and install + ./install.sh + 2. run with qemu + qemu-systme-i386 [device | ./build/img] +### Disk layout + 0x0000 ~ 0x0200: "mbr" + 0x8000 ~ * : Using FAT16 filesystem + 0x8000 ~ 0x8200: "biosboot" + exist "boot" somewhere in FAT16 + +### How to work + mbr + 1. bios take us to 0x7C00 + 2. relocate 0x7c00~0x7DFF to 0x7A00~0x7BFF + 3. load "biosboot" to 0x7C00~0x7DFF + 4. jump to 0x7c00 => biosboot + biosboot + 1. find "boot" file in FAT16 file sysytem + 2. load "boot" to 0x40000 + 2-1. 0x40000 ~ 0x401ff: ELF information + 0x40120 ~ * : text, data, bss section + 3. jump to 0x40120 => boot + boot + 1. set Global Descriptor Table + 2. enter protected mode + 2. set Interrupt Descriptor Table + 3. call boot function \ No newline at end of file diff --git a/boot/boot.c b/boot/boot.c index 5106edb..9aa970e 100644 --- a/boot/boot.c +++ b/boot/boot.c @@ -60,7 +60,6 @@ wr8(u8 c, u8 fg, u8 bg, int x, int y) *where = c | (attrib << 8); } - void boot(dev_t bootdev) {