operating system - Why do interrupts need to be disabled before switching to protected mode from real mode? -


i saw in many many oses (and bootloader), disable interrupt (cli) before switch protected mode real mode. why need that?

bioses use pit interrupt (irq0) track time. enter protected mode, real mode interrupt handling no longer valid; cpu in protected mode requires protected mode idt (interrupt descriptor table). upon entering protected mode, idt limit in idtr (idt register) set 0 (any interrupt number makes cpu generate exception), pit (or else) generates interrupt, cpu generate exception, make exception generated, triggering #df (double fault) and, consequence, #tf (triple fault).

also, irq0 happening in protected mode trigger #de (divide exception) isr (interrupt service routine), interrupt vectors 0 31 reserved exceptions in protected mode.

so, (most probable, other interrupts pit might happen too) order of things happen (note: assumes pit interrupt triggered first, but, said before, can interrupt, each lead #df , triple fault):

  1. pe bit set in cr0.
  2. pit interrupt happens, pic (programmable interrupt controller) gets signal on it's pin #0.
  3. pic remapping isn't set, triggers irq0 on cpu.
  4. irq0 (= #de) attempts execute interrupt handler, idt's limit 0, (iirc) #gp (general protection fault) generated.
  5. idt's limit 0, #df generated.
  6. idt's limit 0, #tf generated.
  7. cpu either stops or reboots.

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -