CDROM Boot emulates Floppy: Size?

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
sebihepp
Member
Member
Posts: 195
Joined: Tue Aug 26, 2008 11:24 am
GitHub: https://github.com/sebihepp

CDROM Boot emulates Floppy: Size?

Post by sebihepp »

Hello everyone,

if the system boots from a CD-ROM, then it will emulating a floppy-device. But do I
have access to the hole 1440 KByte? Or is only less data accessible?

TIA Sebihepp
User avatar
Steve the Pirate
Member
Member
Posts: 152
Joined: Fri Dec 15, 2006 7:01 am
Location: Brisbane, Australia
Contact:

Re: CDROM Boot emulates Floppy: Size?

Post by Steve the Pirate »

You don't have to emulate a floppy to boot from CD - far easier is to use the El Torito standard. If you use Grub, making a boot cd image (that can be booted in Bochs, QEMU etc. or burnt to a disk) is as easy as doing the following (on Linux with Grub installed):

Code: Select all

cp /usr/lib/grub/i386-pc/stage2_eltorito image/boot/grub
mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -input-charset utf-8 -boot-info-table -o image.iso image
That's taken from the install target in the makefile. Image is the directory that has the boot directory and my kernel in it. image.iso is the resulting bootable CD image.
My Site | My Blog
Symmetry - My operating system.
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:

Re: CDROM Boot emulates Floppy: Size?

Post by Combuster »

If you use El-Torito emulation, then the BIOS will give you the space you told it to give you.

If you emulate a 1.4M floppy, then it will give you access to 1.4M
If you emulate a 720k floppy, then it will give you that
If you emulate a 30M harddisk, then it will give you that
If you ... :wink:
"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 ]
sebihepp
Member
Member
Posts: 195
Joined: Tue Aug 26, 2008 11:24 am
GitHub: https://github.com/sebihepp

Re: CDROM Boot emulates Floppy: Size?

Post by sebihepp »

Thanks Combuster.
@Steve: I really want to use GRUB but I didn't get it work. I am using Windows Vista, cygwin and Bochs.
I don't know where to get a working image...
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: CDROM Boot emulates Floppy: Size?

Post by Dex »

It is much simpler to use floppy/hdd emulation, as all you have to do is get a working floppy image and use your cd/dvd burn software to make the cd bootable, simply click on make bootable, point it to the floppy image, it will then add 2 bin file to the cd, click to burn and you have a bootable cd, as long as your in real mode the emulation will stay as floppy (eg any code that reads the floppy using int 13h, will read from the cd), once you go to pmode emulation stops, but if you return to real mode emulation starts again.
What could be simpler ?.
sebihepp
Member
Member
Posts: 195
Joined: Tue Aug 26, 2008 11:24 am
GitHub: https://github.com/sebihepp

Re: CDROM Boot emulates Floppy: Size?

Post by sebihepp »

That's the way I do it right now. :)

Hmmm, I can't access the emulated Floppy in PMode, right? I could load the entire
floppy into memory. Very efficient. :lol: :lol:
But... why not... Only for testing ^^
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: CDROM Boot emulates Floppy: Size?

Post by Dex »

sebihepp wrote:That's the way I do it right now. :)

Hmmm, I can't access the emulated Floppy in PMode, right? I could load the entire
floppy into memory. Very efficient. :lol: :lol:
But... why not... Only for testing ^^
In my OS i have two floppy drivers, one a normal pmode driver and the second a go back to real mode and back every 512bytes, this may seem slow but is not noticable slower than read/writing from pmode.
This mean i can read files from the cd (under floppy emulation) just like as if it was a normal floppy.
The above also works fine for read/writing to USB fobs.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: CDROM Boot emulates Floppy: Size?

Post by AJ »

Hi,

I know that the RMode -> PMode -> RMode switches probably don't affect percieved speed as Dex says, but personally, I would recommend reading as much as possible from the disk for each RMode switch rather than just 512b.

My floppy reading routine reads a single sector at a time, but is wrapped in RMode and it increments the destination buffer segment in a loop, allowing the driver to read 508K per real mode switch (I use physical memory between 0x1000 and 0x80000 bytes as my buffer). Although the end user will see about the same speed for a FDD or CD, the CPU is having to do far less work and I guess could give a speed benefit with USB key drives.

Cheers,
Adam

Edit: This assumes you are able to reserve such a large low memory buffer, of course! The RMode code for this is really quite small, though, and can be either copied down to the 0x500->0x1000 location before you perform disk access, or can reside there permanently having been linked there as part of your ELF/COFF executable.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: CDROM Boot emulates Floppy: Size?

Post by Dex »

I would agree with you there AJ, but it does help keep interrupts being off in pmode down to the smallest time, so its swings and round abouts.
User avatar
mystran
Member
Member
Posts: 670
Joined: Thu Mar 08, 2007 11:08 am

Re: CDROM Boot emulates Floppy: Size?

Post by mystran »

Alternatively, once you are in protected mode, can't you just read the CD as if it was a CD? :)

Ok, you need a CD driver for that.. but still..
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
Post Reply