Hello.
I want to create os, but i don't know how to create bootloader for load kernel from the cd.
Please help.
bootloader for cd
-
- Member
- Posts: 190
- Joined: Tue Aug 26, 2008 11:24 am
- GitHub: https://github.com/sebihepp
Re: bootloader for cd
Don't create one - use one, like GRUB.
Re: bootloader for cd
Hi,
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
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.gamecraftCZ wrote:I want to create os, but i don't know how to create bootloader for load kernel from the cd.
Please help.
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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: bootloader for cd
Great information! ThanksBrendan wrote:Hi,
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.gamecraftCZ wrote:I want to create os, but i don't know how to create bootloader for load kernel from the cd.
Please help.
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
Re: bootloader for cd
Also, this article may help you a bit.
http://wiki.osdev.org/Bootable_El-Torit ... RUB_Legacy
http://wiki.osdev.org/Bootable_El-Torit ... RUB_Legacy
- BASICFreak
- Member
- Posts: 284
- Joined: Fri Jan 16, 2009 8:34 pm
- Location: Louisiana, USA
Re: bootloader for cd
If you are set on making you own This may help.
@Brendan - I know it's old, but I'm curious if you are working on recreating these as they are some of the best references that I have found on many subjects
@Brendan - I know it's old, but I'm curious if you are working on recreating these as they are some of the best references that I have found on many subjects
BOS Source Thanks to GitHub
BOS Expanded Commentary
Both under active development!
BOS Expanded Commentary
Both under active development!
Sortie wrote:
- Don't play the role of an operating systems developer, be one.
- Be truly afraid of undefined [behavior].
- Your operating system should be itself, not fight what it is.
Re: bootloader for cd
Hi,
I'll be re-implementing similar code in the next/current version of my project; but I've shifted from "viewable source" to closed source, and the current version of my build utility (the utility that builds everything, including the project's web site and documentation) no longer supports "HTMLizing" source code.
Cheers,
Brendan
ThanksBASICFreak wrote:If you are set on making you own This may help.
@Brendan - I know it's old, but I'm curious if you are working on recreating these as they are some of the best references that I have found on many subjects
I'll be re-implementing similar code in the next/current version of my project; but I've shifted from "viewable source" to closed source, and the current version of my build utility (the utility that builds everything, including the project's web site and documentation) no longer supports "HTMLizing" source code.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.