Page 1 of 1

Loading data from disk

Posted: Sun Jan 20, 2008 11:31 pm
by scorpion007
Hi,

I'm wondering, is the BIOS interrupt 13 the only way to read data from disk?
Is there a way of by-passing the bios?

The reason I ask is two-fold:

1) Don't BIOS's differ from manufacturer to manufacturer? Is this a problem?
2) Don't BIOS interrupts only work in real mode, not protected? Does that mean I have to transition to real mode every time I want to read a file/sector from disk?

How do 'real' OSs do it?

Also, does that interrupt allow me to read form a harddisk as well as a floppy? Or is there a better alternative in general that works in Pmode?

Posted: Mon Jan 21, 2008 12:26 am
by piranha
I found this helpful:
http://osdever.net/tutorials/lba.php

-JL

Re: Loading data from disk

Posted: Mon Jan 21, 2008 4:43 am
by jal
scorpion007 wrote:I'm wondering, is the BIOS interrupt 13 the only way to read data from disk?
No.
Is there a way of by-passing the bios?
Yes.
1) Don't BIOS's differ from manufacturer to manufacturer? Is this a problem?
Yes, no.
2) Don't BIOS interrupts only work in real mode, not protected? Does that mean I have to transition to real mode every time I want to read a file/sector from disk?
Yes, yes if you want to use int 13h.
How do 'real' OSs do it?
They directly access hardware.
Also, does that interrupt allow me to read form a harddisk as well as a floppy? Or is there a better alternative in general that works in Pmode?
Yes, no. You have to write your own hardware drivers. BIOS is nothing more than real-mode hardware drivers with a certain API.

That said, if you need these questions answered, I you really sure you need hanging around an osdev forum?


JAL

Re: Loading data from disk

Posted: Mon Jan 21, 2008 5:07 am
by AJ
scorpion007 wrote: 2) Don't BIOS interrupts only work in real mode, not protected? Does that mean I have to transition to real mode every time I want to read a file/sector from disk?
There is an alternative to this - virtual 8086 mode, but you are strongly advised to write your own drivers in PMode. This is because you will have set up PMode interrupt handlers, tick counter and so on. You are not guaranteed that a BIOS disk method will not try to interfere with this, if it is using port-based IO.

I have never done this, but apparently a hard disk (PATA) driver is apparently not that hard to write. SATA drives often emulate thie PATA interface too, IIRC. Floppy drivers are often a bit more complex, as they generally involve a) interfaceing with an outdated controller and b) using DMA.

Cheers,
Adam

Posted: Mon Jan 21, 2008 5:44 am
by XCHG
I've coded a rather complete open-source IDE library in NASM which you can find in my website provided that you are working under Protected Mode and not Real Mode.

Posted: Mon Jan 21, 2008 6:06 am
by scorpion007
Thanks guys for the help, I'll have a bit of a read, then ask questions later.
That said, if you need these questions answered, I you really sure you need hanging around an osdev forum?
Errm... Were my questions too basic? I was under the impression this forum is for all audiences, including beginners?

Posted: Mon Jan 21, 2008 8:08 am
by jal
scorpion007 wrote:That said, if you need these questions answered, I you really sure you need hanging around an osdev forum?
Errm... Were my questions too basic? I was under the impression this forum is for all audiences, including beginners?[/quote]

Yeah, I'm a bit grumpy sometimes. Whether it is a thorough lack of sleep (why did I want kids again?) or a malicious character, nobody knows. What I meant was that your questions are so basic, you're a very long shot away from actual OS development.


JAL

Posted: Mon Jan 21, 2008 1:59 pm
by JamesM
That said, most of his answers could have been found on the wiki, and definately through other people's posts.

Posted: Mon Jan 21, 2008 2:31 pm
by piranha

Posted: Mon Jan 21, 2008 6:29 pm
by scorpion007
Well, the impression I got from reading some other threads that they were a lot more basic than mine, such as being confused about what a compiler is, and which they should use.

I think interfacing with hardware is a somewhat more complex topic, which is why I asked how it is normally done.

But yeah, thanks for the help so far, I'll just have to digest the information first.