what's the best way to read from cd in unreal mode?

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
zhak
Member
Member
Posts: 25
Joined: Wed Jul 30, 2008 10:25 am

what's the best way to read from cd in unreal mode?

Post 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!
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: what's the best way to read from cd in unreal mode?

Post 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.
zhak
Member
Member
Posts: 25
Joined: Wed Jul 30, 2008 10:25 am

Re: what's the best way to read from cd in unreal mode?

Post 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.
FlashBurn
Member
Member
Posts: 313
Joined: Fri Oct 20, 2006 10:14 am

Re: what's the best way to read from cd in unreal mode?

Post 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.
zhak
Member
Member
Posts: 25
Joined: Wed Jul 30, 2008 10:25 am

Re: what's the best way to read from cd in unreal mode?

Post by zhak »

so what's the method? we'll give it a try :)
FlashBurn
Member
Member
Posts: 313
Joined: Fri Oct 20, 2006 10:14 am

Re: what's the best way to read from cd in unreal mode?

Post 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.
zhak
Member
Member
Posts: 25
Joined: Wed Jul 30, 2008 10:25 am

Re: what's the best way to read from cd in unreal mode?

Post by zhak »

hmm, never paid any attention to this function :oops: 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...
FlashBurn
Member
Member
Posts: 313
Joined: Fri Oct 20, 2006 10:14 am

Re: what's the best way to read from cd in unreal mode?

Post 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!
zhak
Member
Member
Posts: 25
Joined: Wed Jul 30, 2008 10:25 am

Re: what's the best way to read from cd in unreal mode?

Post 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
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: what's the best way to read from cd in unreal mode?

Post 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
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.
zhak
Member
Member
Posts: 25
Joined: Wed Jul 30, 2008 10:25 am

Re: what's the best way to read from cd in unreal mode?

Post by zhak »

compress/decompress? what for?
User avatar
01000101
Member
Member
Posts: 1599
Joined: Fri Jun 22, 2007 12:47 pm
Contact:

Re: what's the best way to read from cd in unreal mode?

Post by 01000101 »

size I'm assuming.
200MB is quite a bit to load directly into memory.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: what's the best way to read from cd in unreal mode?

Post 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).
zhak
Member
Member
Posts: 25
Joined: Wed Jul 30, 2008 10:25 am

Re: what's the best way to read from cd in unreal mode?

Post 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.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: what's the best way to read from cd in unreal mode?

Post by bewing »

Heh. You don't want to use something like zip. Just a simple RLE encoding. :wink:
Post Reply