Page 1 of 1
what's the best way to read from cd in unreal mode?
Posted: Wed Jul 30, 2008 3:22 pm
by zhak
Hi all!
I want to load the entire CD-ROM image (not more than 200 MB) in RAM when in (un)real mode. What's the best way of doing this?
First of all, I thought about BIOS int 13h functions. i.e. read 64k of data under 1MB, then move 64k above 1MB where they should be, then read another 64k and so on. But! 40x CD-ROM drive gives approx 6Mb/sec. It's a bit slow, I think. Maybe it's better to use DMA (if possible)? I want the code to stay as compact and as universal as possible. Without vendor-specific drivers for various types of optical drives and etc... If it's possible to use DMA, then could you provide me with some source code or links on using DMA with CD-ROM drives, please? I'm complete noob in DMA controllers programming and don't even know where to start from. Thanks a lot!
Re: what's the best way to read from cd in unreal mode?
Posted: Wed Jul 30, 2008 3:48 pm
by bewing
There is the easy way, and the very hard way.
The easy way is what you already said -- use INT13h.
To use the hard way, you would have to enter protected mode, and create a generic DMA ATAPI driver. That would include creating an interrupt handler for the disk controller, and enumerating the PCI bus to find the PCI address of the controller and its "Bus Master Register". We do not have a good tutorial yet for ATAPI.
You would want to start with this article:
ATA PIO Mode.
Then see this (mostly stubbed and unhelpful) article
ATAPI.
Then, finally:
http://wiki.osdev.org/ATA/ATAPI_using_DMA.
Re: what's the best way to read from cd in unreal mode?
Posted: Thu Jul 31, 2008 10:03 am
by zhak
Thanks a lot, bewing.
I've thought a bit about what I've read... i.e. the first article says
...PIO mode is an excellent and simple interface to utilize during bootup, until the system goes into multitasking mode.
Maybe using DMA transfers in a bootloader is cool, but it's tooo complex for a boot loader that runs just one time per session. I decided to use INT 13h functions. UDMA will be later... in protected mode.
Re: what's the best way to read from cd in unreal mode?
Posted: Thu Jul 31, 2008 12:44 pm
by FlashBurn
There is a way to activate udma for every drive (if possible) in the bios when you are using int13h. I´m using it for my bootloader, but don´t know if it really works.
Re: what's the best way to read from cd in unreal mode?
Posted: Thu Jul 31, 2008 1:08 pm
by zhak
so what's the method? we'll give it a try

Re: what's the best way to read from cd in unreal mode?
Posted: Thu Jul 31, 2008 1:33 pm
by FlashBurn
Take a look here
http://www.ctyme.com/intr/rb-0722.htm. It would be nice if you would tell me/us what you get, it would also be interessting to know what prefetch does.
Re: what's the best way to read from cd in unreal mode?
Posted: Thu Jul 31, 2008 1:55 pm
by zhak
hmm, never paid any attention to this function

i've already got tons of questions, but some hardware tests should be performed first... arrrggghh it's so bad that i don't have neither floppy disk drive nor cd-rws to play with this func right now

it seems that the nearest shop is waiting for me...
Re: what's the best way to read from cd in unreal mode?
Posted: Thu Jul 31, 2008 2:07 pm
by FlashBurn
If you can send me images for floppy and/or cd-rw I could make these tests if you tell me what I have to do!
Re: what's the best way to read from cd in unreal mode?
Posted: Thu Jul 31, 2008 2:23 pm
by zhak
first of all I want to try to set each of available modes and read large portions of data. to check how it affects the speed. as I understand, BIOS won't give control back to user software until read/write operation is complete. the only possible advantage that comes to mind is the decreased time of execution of int 13h read/write functions. but again, if this function is supported by BIOS
Re: what's the best way to read from cd in unreal mode?
Posted: Thu Jul 31, 2008 10:22 pm
by Brendan
Hi,
zhak wrote:I want to load the entire CD-ROM image (not more than 200 MB) in RAM when in (un)real mode. What's the best way of doing this?
Not sure if you've thought of this yet, but the first step would be to compress the data and decompress it after it's loaded - it could take half as long to get the data into RAM that way...
Cheers,
Brendan
Re: what's the best way to read from cd in unreal mode?
Posted: Fri Aug 01, 2008 12:09 am
by zhak
compress/decompress? what for?
Re: what's the best way to read from cd in unreal mode?
Posted: Fri Aug 01, 2008 12:16 am
by 01000101
size I'm assuming.
200MB is quite a bit to load directly into memory.
Re: what's the best way to read from cd in unreal mode?
Posted: Fri Aug 01, 2008 12:53 am
by bewing
At 52X, 200M of data will probably take about 30 seconds to load -- with or without DMA.
If you can compress it to 100M, then it will only take 15 seconds to load, and 2 seconds to decompress (or something like that).
Re: what's the best way to read from cd in unreal mode?
Posted: Fri Aug 01, 2008 1:32 am
by zhak
two seconds? I doubt it... it took me 33 seconds to compress 200MB and 15 seconds to decompress with the zip -fastest method (but it was done under win32). 15 seconds to read 100MB and 15 to decompress - the same 30 seconds... no, it's not an option, I think.
Re: what's the best way to read from cd in unreal mode?
Posted: Fri Aug 01, 2008 7:04 am
by bewing
Heh. You don't want to use something like zip. Just a simple RLE encoding.
