Hi,
DrewbyDoobeeDoo wrote:I want to make my own OS and I have made a bootsector on a floppy. The only problem is I have no idea how to use a kernel with the bootsector. I know how to make a kernel, I just don't know how to get it to load with the bootsector. Can anyone help?
The general idea is to use the BIOS functions to load more data from the boot device, possibly starting with the rest of the boot loader or a second stage, followed by loading anything else the OS might need (a boot image, a kernel, a boot script, etc). Typically the boot code also does other things too, like gathering information (e.g. memory map, video information, APM, etc) and configuring basic things so the kernel itself doesn't need to bother (e.g. enabling protected mode or long mode, maybe enabling paging, masking stuff in the PIC, enabling the A20 gate, setting up a default video mode, etc) - especially where doing so makes things easier (for e.g. maybe it's easier if the boot code sets up paging, so that all of the kernel's code can be linked to run at 0xC0000000 without strange hacks).
I'd also recommend that you start by writing a specification that defines the state of the computer when the boot code passes control to the kernel, so that it's easy for anyone to replace the boot code or write a different version of the boot code for any reason. For example, if it's designed carefully it should be easy for someone to write an EFI/UEFI boot loader for your OS just by following your specification, without changing anything in the kernel itself. This specification should include the state of the CPUs (the boot CPU and the other CPUs, including the operating mode (real mode/protected mode/long mode) and the register contents for general registers, segment registers, control registers and eflags), plus the state of various pieces of the computer (PIC, A20, PIT, etc), plus the contents of memory (for e.g. things like "
the file "foo" must be present in RAM at the address contained in <some_sort_of_structure>").
Cheers,
Brendan