boot from cd [fixed]

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
GLneo
Member
Member
Posts: 237
Joined: Wed Dec 20, 2006 7:56 pm

boot from cd [fixed]

Post by GLneo »

hi all, i have a boot loader that boots from a floppy disk but i want to boot from a cdrom, does the bios have a function for this and how do i use it.

my old code is attached...

thx
Attachments
loaderblack.ASM
(2.19 KiB) Downloaded 33 times
Last edited by GLneo on Wed Jan 03, 2007 5:17 pm, edited 1 time in total.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

Well.. You could try reading up on the El Torito standard.

http://www.phoenix.com/NR/rdonlyres/98D ... scdrom.pdf

I should also note that since BSD and Linux offer bootable cdroms, Their bootloaders are usually open source.

http://www.openbsd.org/cgi-bin/cvsweb/s ... nd/cdboot/
http://www.kernel.org/git/?p=boot/sysli ... olinux.asm (See line 297 onward..)

Nothing wrong with also reading up on:
BIOS INT 13 Specifications, including any extensions.
ATAPI Specifications and the ISO 9660 Specification.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
Otter
Member
Member
Posts: 75
Joined: Sun Dec 31, 2006 11:56 am
Location: Germany

Post by Otter »

To boot from cd using El Torito is very easy. You need a bootloader image like when you're booting from floppy, with a few differences:
1) the boot image can be larger than 512 Byte
2) you dont need the 55AA in the end

In general, the image is loaded at address 0x7C00, but El Torito allows to select another base address. The simplest is to use a ISO9660 creator like mkisofs oder UltraISO or whatever.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

The easiest thing to do is to create a floppy image (you might already have it), then instruct mkisofs to make an el-torito emulation CD
From my makefile:

Code: Select all

mos.iso: floppy.img
        -mkdir cd
        cp floppy.img cd
        mkisofs -o mos.iso -A MOSCD -b floppy.img cd
        rm -r -f cd/*
        rmdir cd
i.e. create a empty dir (cd), stuff in there whatever you want on the cd (incl image)
call mkisofs:
-o mos.iso = the output is mos.iso
-A MOSCD = the CD label
-b floppy.img = your bootloader
cd = the directory to get everything
after that i remove the temporary directory.

The result is a CD (image) that boots as if it were a floppy.

(Note: El-Torito emulation isnt the same as no-emulation El-Torito. some bioses seem to support one but not the other)
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

The KISS way to do it , is to open up your cd burn software and click on the make bootable (some time in the new projects), it will pop up a window asking for a bootable floppy image point it to your floppy image then burn it and that's it you have a bootable cd.

PS: Make sure your BIOS is set to boot from CD before hdd.
GLneo
Member
Member
Posts: 237
Joined: Wed Dec 20, 2006 7:56 pm

Post by GLneo »

i like Combuster idea, but does floppy.img have to know its on a cd? becouse my boot loader trys to load the kernel from floppy?, well i'll just try it

thx everyone!
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

GLneo wrote:i like Combuster idea, but does floppy.img have to know its on a cd? becouse my boot loader trys to load the kernel from floppy?, well i'll just try it
Nope. Like i said, it boots from the cd as if it were an actual floppy. (unless you do low level hardware access or tell the bios to end the emulation)
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
GLneo
Member
Member
Posts: 237
Joined: Wed Dec 20, 2006 7:56 pm

Post by GLneo »

Code: Select all

root@COMPUTER:~# mkdir cd
root@COMPUTER:~# cp a.img cd
root@COMPUTER:~# mkisofs -o LOS.iso -A LemonOS -b a.img cd
Size of boot image is 56 sectors -> mkisofs: Error - boot image 'cd/a.img' has not an allowable size.
root@COMPUTER:~#
what does this mean???
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

your floppy image is 'wrong' in the sense that it isnt 1.44MB (2880 sectors). You'll have to append zeroes to it
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
GLneo
Member
Member
Posts: 237
Joined: Wed Dec 20, 2006 7:56 pm

Post by GLneo »

o i see, what comand would do that?
GLneo
Member
Member
Posts: 237
Joined: Wed Dec 20, 2006 7:56 pm

Post by GLneo »

solved it!, i made an addition to makeboot: "attached"
Attachments
makeboot.c
(1.68 KiB) Downloaded 48 times
forkart
Posts: 1
Joined: Tue Jan 16, 2007 11:19 am

Re: boot from cd [fixed]

Post by forkart »

GLneo wrote:hi all, i have a boot loader that boots from a floppy disk but i want to boot from a cdrom, does the bios have a function for this and how do i use it.

my old code is attached...

thx
you can try to use magiciso to make bootable iso image from bootable floppy disk. Just read guide below.
http://www.magiciso.com/FAQ/FAQ0006.htm
User avatar
kataklinger
Member
Member
Posts: 381
Joined: Fri Nov 04, 2005 12:00 am
Location: Serbia

Post by kataklinger »

Word of the warnning:
If you use 'No emulation' mode you should know that you specify size of boot image, which is going to be loaded into memory, in _sectors_ ! Specification says that _sector_ size is 2048 bytes not 512 (_virtual_sector_ size is 512), but some BIOSes use _virtual_sector size and others use _sector_ size to calculate total size of boot image.
I hate those guys!
Post Reply