سؤال

how to create simple bootloader that load kernel into iso? it has been 5 days , I searching in google and do trial and error many times but got nothing.....I have tried many tutorial like mikeos,osdev,supernova,cosmos os but still get no solution..... my computer doesn't have floopy disk so I can't make bootloader using floopy disk... I see in mikeos tutorial first sector 512 byte is for bootloader and second for kernel can be made using imdisk but using floopy disk also he can made bootloader & kernel load another file into iso...how he can do it(make iso without using floopy disk)? I want to make bootloader and kernel using assembly...it's not first time I using assembly and have experinced some other language like c++,vb,php,phyton and others.... how to make first sector for bootloader that seacrhing/load kernel compiled into iso?also adding some file and folder into iso?thanks..

هل كانت مفيدة؟

المحلول 2

I recommend you to use a standard bootloader if you are going to write an OS and use an emulator instead of real machine any way (not because you bootloader could break computer - it probably couldn't, but because it is a simpler way to start up with and debug. You will almost certainly get bored of burning a CD each update.

Also, note that ISO uses a more complicated boot protocol than floppy/harddisks does. The best approach is to use GRUB or ISOLINUX if you wish to use CD and use a floppy image (which can be attached to CD by emulation latter) if you wish to have you very own bootloader.

نصائح أخرى

You can do that only following my simple steps:

  1. Compile bootloader.asm with NASM using this code:

    nasm -f bin -o bootloader.bin bootloader.asm
    
  2. Download 'dd for windo*s' (search on Google), and put the program dd.exe into the directory you saved the bootloader file. Open command prompt and move to directory you saved the bootloader, and type this command:

    dd if=bootloader.bin of=bootloader.flp
    
  3. Download imdisk (search on Google), and install it. After you install, open command prompt and go to the directory you saved the bootloader. Type this command:

    imdisk -a -f bootloader.flp -s 1440k -m B:
    

Windows will then create a virtual floppy drive with the letter B. Copy your KERNEL file into that B drive.

  1. Open command prompt again and type:

    imdisk -D -m B:
    

Windows will then unmount the drive B and your bootloader.flp is ready to mount by emulator.

I recommend you QEMU because it is so small and fast program to launch your os file. To run bootloader.flp with qemu, type this command in the command prompt:

qemu -fda bootloader.flp

If you want to produce the ISO file of your bootloader.flp file, you must have a program named mkisofs and move the program mkisofs.exe into the directory you saved the bootloader. Then move your bootloader.flp file into the folder called cdiso (make it first). Then open command prompt and type this:

mkisofs -no-emul-boot -boot-load-size 4 -o myos.iso -b bootloader.flp cdiso/

It will then produce ISO file and you can run it on emulator.

If you want to ask me more, you can email me at danasap90 {add} gmail {dot} com

I'll assume you are on a x86 PC. The El Torito bootable cdrom specification supports 3 operating modes:

  1. floppy emulation
  2. hard disk emulation
  3. no emulation

For the floppy and hard disk emulation modes, you have to specify an appropriate image file and the bios will load the boot sector as usual, providing an emulated drive that accesses the image file.

For the no emulation mode, you can specify a load base segment and the size of your code and the bios will perform the loading accordingly. You won't be able to access the cdrom through the disk interrupt functions in this case.

If you are on linux, you can use the genisoimage tool with the -b, -hard-disk-boot or the -no-emul-boot options, respectively.

Also note that a USB flash drive may be more convenient than a cdrom, if your bios supports booting from such a device (most of them do).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top