Loading data from disk

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
scorpion007
Posts: 3
Joined: Sun Jan 20, 2008 11:25 pm

Loading data from disk

Post 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?
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Post by piranha »

I found this helpful:
http://osdever.net/tutorials/lba.php

-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: Loading data from disk

Post 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
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Loading data from disk

Post 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
User avatar
XCHG
Member
Member
Posts: 416
Joined: Sat Nov 25, 2006 3:55 am
Location: Wisconsin
Contact:

Post 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.
On the field with sword and shield amidst the din of dying of men's wails. War is waged and the battle will rage until only the righteous prevails.
scorpion007
Posts: 3
Joined: Sun Jan 20, 2008 11:25 pm

Post 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?
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post 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
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

That said, most of his answers could have been found on the wiki, and definately through other people's posts.
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Post by piranha »

SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
scorpion007
Posts: 3
Joined: Sun Jan 20, 2008 11:25 pm

Post 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.
Post Reply