Accessing disk in Protected 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
leledumbo
Member
Member
Posts: 103
Joined: Wed Apr 23, 2008 8:46 pm

Accessing disk in Protected Mode

Post by leledumbo »

I've read some bootloader code from brokenthorn that has FAT12 driver. The problem that it's calling BIOS interrupt (0x10?) while I'm already in pmode due to usage of GRUB as my bootloader. How can I implement in in pmode?
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Accessing disk in Protected Mode

Post by AJ »

Hi,

If you want the int 0x10 functions, you have two options - switch back to real mode or run a v86 task. See the GRUB page on the wiki, which has a link at the bottom to a thread about switching back to real mode.

You can also create a protected mode wrapper function for BIOS calls, which automatically switches back to real mode, executes a function, and returns to PMode. This may be worth doing if you plan on running a lot of real mode code (for disk IO, for example).

Cheers,
Adam
tantrikwizard
Member
Member
Posts: 153
Joined: Sun Jan 07, 2007 9:40 am
Contact:

Re: Accessing disk in Protected Mode

Post by tantrikwizard »

AJ wrote:If you want the int 0x10 functions, you have two options
Another route is to write a pmode driver that accesses the floppy directly without using BIOS. It will likely be much faster than real mode or a v86 task.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Accessing disk in Protected Mode

Post by AJ »

leledumbo wrote:The problem that it's calling BIOS interrupt (0x10?)
tantrikwizard wrote:
AJ wrote:If you want the int 0x10 functions, you have two options
Another route is to write a pmode driver that accesses the floppy directly without using BIOS.
Agreed for disk access. Int 0x10 is, however, for video services which may only be accessible via the BIOS unless you write a specific driver for each individual video card. Alternatively rely on the fact that the VESA PMode interface is present, which is a bit of a dodgy assumption.

Cheers,
Adam
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: Accessing disk in Protected Mode

Post by Dex »

Hre is a demo i wrote, of a pmode floppy driver http://dex4u.com/demos/FddDemo.zip
tantrikwizard wrote:
AJ wrote:If you want the int 0x10 functions, you have two options
Another route is to write a pmode driver that accesses the floppy directly without using BIOS. It will likely be much faster than real mode or a v86 task.
In my OS, i have both a bios (as in go back to realmode) and a pmode floppy driver, and there is no differance in read/write speed between the two drivers, and its not because the pmode driver is not written well, because its faster to load a whole disk by going back and forth to realmode, than load the same disk from with in XP or linux.
Note: the bios driver only read/writes one sector, each time it goes to and from realmode, this shows how fast it is to goto and from realmode to pmode.
tantrikwizard
Member
Member
Posts: 153
Joined: Sun Jan 07, 2007 9:40 am
Contact:

Re: Accessing disk in Protected Mode

Post by tantrikwizard »

Dex wrote:...and there is no differance in read/write speed between the two drivers...
Right, there will be no difference between the read/write speed of the drive. Those are set by the hardware's limitation. The slight performance increase will be from the reduced overhead of switching in and out of different execution modes.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: Accessing disk in Protected Mode

Post by JamesM »

Interesting - is this test performed on a purely PIO protected mode driver or one that utilises full burst-DMA too?
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: Accessing disk in Protected Mode

Post by Dex »

JamesM wrote:Interesting - is this test performed on a purely PIO protected mode driver or one that utilises full burst-DMA too?
Full burst-DMA
From my tests, the problem seem to be controller timing, if you implement the times as per the floppy controller spec, for things like floppy get to full speed delay etc, your driver will be slower than the bios driver, if you try and use smaller delays than the spec, than the code does not work.
Why this is i do not know.
If you want to test it you can download DexOS, than from the CLI if you can type:
pmode <enter>
You will be using the pmode floppy driver, if you try to run a program from floppy, if you type:
bios <enter>
You will be using the bios, as in going to and from realmode for each sector loaded.
Post Reply