int 13h, can it be used within protected mode of i386?

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.
User avatar
Pitchu
Member
Member
Posts: 56
Joined: Tue Feb 12, 2008 3:16 am
Location: Kashmir - Paradise On Earth

int 13h, can it be used within protected mode of i386?

Post by Pitchu »

Hi
I am a student working on a multitasking OS over i386 platform.
Well what I wanna know is that can't int13h of real mode be used in protected mode...here is what i think
1. save the ISR address of int 13h from IVT.
2. Load the same vector address into IDT at some other index say 21h.

I think this way can make ISR of int13h be used within prot mode using some other int number say 21h.

Please do correct me
Thanks
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: int 13h, can it be used within protected mode of i386?

Post by jal »

Pitchu wrote:Please do correct me
You are hereby corrected. All BIOS interrupts are written in real mode assembly. They can not be used in protected mode, ever. If you are thinking about v86 mode, forget that too for int 13h, as you'd need to code proper DMA and IRQ handling, in which case it's easier to just write your own disk handling.


JAL
User avatar
Pitchu
Member
Member
Posts: 56
Joined: Tue Feb 12, 2008 3:16 am
Location: Kashmir - Paradise On Earth

Post by Pitchu »

Thanks a lot
Does it mean that no int of ivt can be used(even keyboard)?
What do u mean by saying that they are coded in real mode assembly, i guess the problem will be adrressing ds:si wont point to correct location.

One more thing i read in Barry B. Brey book the say thing i posted earlier.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Hi,

You can use some of the interrupts in v86 mode, but generally using v86 for IO is a Bad Idea (tm). You are alright for things like VBE and switching VGA modes, but for anything which is likely to either fire an IRQ, or which needs DMA (as indicated above), you are better off writing protected mode drivers.

What is meant by real mode assembly, is that the BIOS routines expect to be in an environment where the default operand sizes are 16 bit and that real addressing mode applies.

A word of warning: don't rely on v86 too much if you plan to port your OS to x86-64. In long mode, you can't use v86 at all.

Cheers,
Adam
User avatar
Pitchu
Member
Member
Posts: 56
Joined: Tue Feb 12, 2008 3:16 am
Location: Kashmir - Paradise On Earth

Post by Pitchu »

Thanks a lot
So i concluded that all INTs in IVT which do I/O using DMA or have IRQs associated cannot be used in PM.
Why DMA understood(16 bit operands);
Why IRQs?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

the DMA chip bypasses the memory management of the processor. Once the bios starts accessing it it might start writing or reading data to where you don't want it to. It's not specific for either 8-bit or 16-bit transfers

In protected mode, IRQs always go to the interrupt table of the kernel, and not to the IVT. Which means you need some way of telling userspace that an interrupt has occurred. Doing that is something that can quickly lead to ugly hacks.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post by jal »

Pitchu wrote:What do u mean by saying that they are coded in real mode assembly
You'd do yourself a really big favour if you started reading some Intel documentation about addressing modes.


JAL
User avatar
Pitchu
Member
Member
Posts: 56
Joined: Tue Feb 12, 2008 3:16 am
Location: Kashmir - Paradise On Earth

Post by Pitchu »

Thanks everybody
Nice of u and i wanna mention that i have gone through intel manuals but u know Can it be done like this always clicks me
I learnt;
1. Only int 10h(vbe for SVGA) can be used in PM.
2. I can its ISR address in IDT after raising it to 32 bit.
3. Clearly, DMA and IRQ based INTs are lost in protected mode because of addressing problem.
I wish I am correct
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

Pitchu wrote:Thanks everybody
Nice of u and i wanna mention that i have gone through intel manuals but u know Can it be done like this always clicks me
I learnt;
1. Only int 10h(vbe for SVGA) can be used in PM.
2. I can its ISR address in IDT after raising it to 32 bit.
3. Clearly, DMA and IRQ based INTs are lost in protected mode because of addressing problem.
I wish I am correct
Unfortunately, you don't seem to have picked up on what people have been saying. No BIOS interrupts can be used in (vanilla) protected mode.. You have to create a v8086 task to do that. Then, only BIOS interrupts which do not use the DMA chip or any interrupt requests will work.
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post by jal »

JamesM wrote:Unfortunately, you don't seem to have picked up on what people have been saying.
I'm afraid he's beyond salvation. Perhaps his incredibly bad English doesn't help. I can imagine it's difficult reading the Intel manuals with only a very basic grasp of the language. On the other hand, he doesn't even seem to have tried.


JAL
User avatar
Pitchu
Member
Member
Posts: 56
Joined: Tue Feb 12, 2008 3:16 am
Location: Kashmir - Paradise On Earth

Post by Pitchu »

I'm afraid he's beyond salvation. Perhaps his incredibly bad English doesn't help. I can imagine it's difficult reading the Intel manuals with only a very basic grasp of the language. On the other hand, he doesn't even seem to have tried.


JAL
Yep U may be right about my 'English' because it isn't my native language and im writing these posts under -13 degree with a lots of things in my mind regarding MultiTasking OS im working on.
While Im thinking about Disk Access Im interrupted by Code Relocation.
Thanks 2 everybody for posting and i really misinterpreted posts and got confused by an earlier thread
Warmaster199
Guest

Posted: Sun Oct 06, 2002 4:13 am Post subject: Re:Disk Access Under Pmode

--------------------------------------------------------------------------------

Actually, you can grab a pointer to a function in the VESA BIOS to switch banks. The VESA BIOS Switch Bank function is 32-bit protected mode code, so it's alot faster to get that pointer, rather than use the Bios calls
http://www.osdev.org/phpBB2/viewtopic.p ... cess+pmode
I thought it can be done without using v86 mode (using the address of ISR).
User avatar
Zenith
Member
Member
Posts: 224
Joined: Tue Apr 10, 2007 4:42 pm

Post by Zenith »

I thought it can be done without using v86 mode (using the address of ISR).
The ISRs have a different purpose - they are pointers to handlers for processor exceptions, IRQs, and your own interrupts (not the BIOS ones).
1. Only int 10h(vbe for SVGA) can be used in PM.
Only in v86. No BIOS interrupts are available in PM!!!
2. I can its ISR address in IDT after raising it to 32 bit.
No. You can't just set an ISR to the address of the BIOS interrupt handler - the code's memory addressing won't work. Just write your own disk driver (it'd be quicker and easier to do).
3. Clearly, DMA and IRQ based INTs are lost in protected mode because of addressing problem.
The DMA and PICs (which manage the IRQs) are not affected by this problem. You just have to configure them to use them in protected mode.

EDIT: Also, the above quote about grabbing a pointer to a function is specific to that single function, not the entire BIOS call

Hope this helps,
Julian
"Sufficiently advanced stupidity is indistinguishable from malice."
User avatar
mathematician
Member
Member
Posts: 437
Joined: Fri Dec 15, 2006 5:26 pm
Location: Church Stretton Uk

Re: int 13h, can it be used within protected mode of i386?

Post by mathematician »

Pitchu wrote:Hi
I am a student working on a multitasking OS over i386 platform.
Well what I wanna know is that can't int13h of real mode be used in protected mode...here is what i think
1. save the ISR address of int 13h from IVT.
2. Load the same vector address into IDT at some other index say 21h.

I think this way can make ISR of int13h be used within prot mode using some other int number say 21h.

Please do correct me
Thanks
The primary reason real mode routines (in the BIOS and elsewhere) can't be used is that they will assume that they can play fast and loose with the segment registers, ignoring what's in the GDT (which doesn't exist in real mode).
The continuous image of a connected set is connected.
xyzzy
Member
Member
Posts: 391
Joined: Wed Jul 25, 2007 8:45 am
Libera.chat IRC: aejsmith
Location: London, UK
Contact:

Post by xyzzy »

Some also assume that they can raise other BIOS interrupts, like while debugging my V86 code a while back I found the BIOS call to be using various int instructions.
User avatar
Pitchu
Member
Member
Posts: 56
Joined: Tue Feb 12, 2008 3:16 am
Location: Kashmir - Paradise On Earth

Post by Pitchu »

Thanks everybody
Im not goin to use BIOS interrupts in PM, not even in v86 mode.
The DMA and PICs (which manage the IRQs) are not affected by this problem. You just have to configure them to use them in protected mode.

EDIT: Also, the above quote about grabbing a pointer to a function is specific to that single function, not the entire BIOS call

Hope this helps,
Julian
Why to configure PIC?
I mean, wont IRQ0 invoke INT 08 routine i.e. index 9 in IDT.
Post Reply