Page 1 of 2

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

Posted: Tue Feb 12, 2008 3:23 am
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

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

Posted: Tue Feb 12, 2008 3:29 am
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

Posted: Tue Feb 12, 2008 3:47 am
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.

Posted: Tue Feb 12, 2008 4:03 am
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

Posted: Tue Feb 12, 2008 4:23 am
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?

Posted: Tue Feb 12, 2008 4:40 am
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.

Posted: Tue Feb 12, 2008 6:56 am
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

Posted: Wed Feb 13, 2008 12:44 am
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

Posted: Wed Feb 13, 2008 2:25 am
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.

Posted: Wed Feb 13, 2008 2:38 am
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

Posted: Wed Feb 13, 2008 5:46 am
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).

Posted: Wed Feb 13, 2008 9:36 am
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

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

Posted: Wed Feb 13, 2008 2:56 pm
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).

Posted: Thu Feb 14, 2008 1:30 am
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.

Posted: Thu Feb 14, 2008 10:17 am
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.