开发者

"STI", in the protected mode,CPU will restart

开发者 https://www.devze.com 2022-12-24 01:18 出处:网络
INTEL X86 Platform. My programme开发者_Go百科 run start at 2M absolute address in protected mode,everything seems ok, but when i enable interrupt with \"sti\", the CPU will restart.

INTEL X86 Platform. My programme开发者_Go百科 run start at 2M absolute address in protected mode,everything seems ok, but when i enable interrupt with "sti", the CPU will restart. Why? is there any necessary initialization before "enbale interrupt"? i have setup the idtptr, but it seems no work.


You either don't have an IDT defined, or you've done it incorrectly. According to one of your comments 'but i used the "sidt" ,the base and the limit are right'... SIDT is "Store Interrupt Descriptor Table". You need to use LIDT to load the IDT and IDTR.

Also, you should have handlers defined for each of the Intel CPU exceptions (e.g. GPF, PF, etc..). See the Intel Programmer's Manuals 3A & 3B.

Also might be a good idea to mask any IRQs on the PIC or IO APIC until you've written handlers (drivers) for those.


Do you have interrupt handlers that will work in protected mode?


The CPU is probably triple-faulting, which happens when an exception occurs while processing a double-fault. When a CPU triple faults, it resets.

This is probably causes by an incorrectly setup Interrupt Descriptor Table.

The OSDev Wiki has a good article that may help you here: http://wiki.osdev.org/Interrupt_Descriptor_Table


With 99% probability you have experienced the phenomenon which has been called triple fault. According to the IA-32 architecture, in the case of exception triggered CPU automatically tries to execute appropriate exception handler. If this attempt lead to another exception (this situation is called double fault) then CPU tries to execute double fault exception handler (0x08 in IDT). If during this attempt another one exception is triggered then CPU comes into a triple fault state. CPU replies to it by a shutdown cycle, this typically causes the motherboard hardware to initiate a CPU reset which in turn causes the whole computer to reboot.

In your case you have the next sequence of actions:

interrupt from some device -> exception -> exception    -> reset
normal execution           -> fault     -> double fault -> triple fault

Make sure that you have correctly initialized IDT with all 256 descriptors installed, each of which points to the correct handler. Note! You are allowed to load IDT with arbitrary sized table. But this doesn't mean that CPU just stops to receive interrupts and exceptions with vectors out of the table limit! In fact each of this interrupts will lead to the general protection exception!

0

精彩评论

暂无评论...
验证码 换一张
取 消