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.
Actually Candy if you read the Intel manual it says that you must reload CS with a segment that has a limit of 64K before returning to Real Mode.
So you do have to create a new entry in your GDT (if you want to follow Intel's instructions). Admittedly it doesn't have to be 16 bit, and could be a 32 bit code segment with a limit of 64K, so I was wrong there. But u may as well go to 16 bit mode as well.
Also its a lot easier to do this in raw assembly rather than trying to write inline asm. I still haven't managed to understand inline ASM.
tom1000000 wrote:
Actually Candy if you read the Intel manual it says that you must reload CS with a segment that has a limit of 64K before returning to Real Mode.
So you do have to create a new entry in your GDT (if you want to follow Intel's instructions). Admittedly it doesn't have to be 16 bit, and could be a 32 bit code segment with a limit of 64K, so I was wrong there. But u may as well go to 16 bit mode as well.
*goes back under his rock and fires up his bochs debugger to help ich_will* - will do so tomorrow 6pm when I'm home again...
ich_will wrote:
do you have to reload the idt with real-mode base and limt if you want to use int instructions f.e.:
...
int 0x15
if you how can i load it to this.
Yes, you have to.
Because since the i386 was "born" the processor made the lidt command also available for the real mode.
And because of this, it's neccesary to reload the (original ?) IDT.
For more documentation, read the intel manual.
Actually, in real-mode you have access to all the interrupts through the IVT (interrupt vector table). Once you enter into protected mode, you dont have access to those interrupts anymore.
So in order to use interrupts you must re-map the PIC (programmable interrupt controller) or the interrupts will be the same number as in real-mode, setup an idt with the base and limit just like you did with the GDT upon entering pmode and with entries for exceptions/interrupts, initalize it, enable interrupts.
I suggest either taking a look at osdever.net for tutorials on this, or look through the intel manuals. Also check the quicklinks for this forum for info and possibly http://my.execpc.com/~geezer/os/ for help.
EDIT: I just realized this thread is about going back to real-mode. In this case, the lidt does need to be re-initialized with real-mode values. Other wise, you probably wont have ints.
and, as a final stuff, if you ever want your RealMode code to play with FPU after your Pmode code made some task switch, remember to CLearTaskSwitch in your "back to real mode" procedure.
This is certainly useless for just shutting down the system, but you'll need it for instance if you want to recover to some DOS session and run heavy programs like a borland IDE, a DOS game, etc.