Hi,
gamecraftCZ wrote:I want to create os, but i don't know how to create bootloader for load kernel from the cd.
Please help.
How it works is the firmware looks for a Boot Record in a specific sector of the CD; which tells it the disk is bootable and where to find a Boot Catalogue. The Boot Catalogue can have one or more entries (e.g. one for 80x86 BIOS, one for 80x86 UEFI, one for PowerPC, one for Itanium, etc), and the firmware chooses one that suits it (e.g. if the firmware is 80x86 BIOS it'd choose the Boot Catalogue for 80x86 BIOS). In this way you can have (e.g.) a generic "OS installer" CD that works on multiple platforms.
For 80x86 BIOS; there's 3 options: emulate a floppy disk (where the Boot Catalogue points to a floppy disk image), emulate a hard disk (where the Boot Catalogue points to a hard disk image), and "no emulation". The emulation options are mostly intended for crusty old OSs that don't support CD (e.g. DOS).
For the "no emulation" option; the BIOS loads your entire boot loader (which can be up to 500 KiB) and starts it. Typically; the boot loader would find file/s in the ISO9660 file system and load them (by using "int 0x13 extensions" to load 2048-byte sectors), in addition to doing whatever else it likes (getting a memory map and converting it into a nice/consistent representation like GRUB fails to do properly; auto-detecting and then setting the best video mode for the OS, video card and monitor, like GRUB fails to do properly; configuring paging so you don't need an awkward/ugly kludge at the start of your kernel like GRUB fails to do, handling security features like decryption and TPM like GRUB fails to do, etc).
So...
The first thing you're going to need is a utility that creates a ("*.iso") disk image, that can create the Boot Record, Boot Catalogue and data that the Boot Catalogue entries refer to; plus the files in the ISO9660 file system itself. There are existing utilities that can/will do this for you; but if you understand the ISO9660 file system (which you're going to need to understand to write a "no emulation" boot loader anyway) it's not too hard to write your own (e.g. so easy that it can be done with NASM macros alone), and writing your own utility can be more flexible.
Once you've got that working with a dummy "jmp $" boot loader (and tested to make sure other OSs can see files in the file system, and that it boots up to your "jmp $" properly); then start writing the boot loader.
Cheers,
Brendan