13.07.2015 Views

iAPX 286 Operating System Writers Guide 1983

iAPX 286 Operating System Writers Guide 1983

iAPX 286 Operating System Writers Guide 1983

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

SYSTEM INITIALIZATIONINITIALIZING FOR PROTECTED MODEYou can do most of the initialization needed for protected mode either before or after switching intoprotected mode. If done after, however, you must be careful to order the code so that it does not useprotected mode features that require initialization that is not yet completed.Interrupt VectorThe initial state of the 80<strong>286</strong> leaves interrupts disabled; however, to ensure a predictable action in casean exception or non-maskable interrupt (NMI) occurs, it is a good idea to initialize the IDT register.Since it is unlikely that the NMI interrupt handler or any exception handler has been initialized, themost appropriate value to load into the IDT register is zeros, thereby guaranteeing a shutdown shouldan interrupt happen. (The 80<strong>286</strong> signals shutdown externally as an indication of a severe problem.)Later, when interrupt service routines are ready, you can change the IDT register to point to an actualIDT that contains gate descriptors for the interrupt routines. Interrupts may be enabled at that time.StackBefore you perform any stack operations, whether in real-address mode or in protected, virtual-addressmode, you must load the SS register with a descriptor to a stack segment in RAM. If the SS registeris loaded in real-address mode, it continues to point to the same segment after the switch into protected,virtual-address mode.Global Descriptor TableBefore you change any segment register in protected, virtual-address mode, the GDT register mustpoint to a valid GDT.The GDT (as well as LDTs) should reside in RAM because the processor modifies the accessed bit ofdescriptors.To allow full 16-megabyte addressing in the initialization code, you may find it convenient to build atemporary GDT that contains only enough descriptors to permit the initialization procedure to readthe GDT segment from ROM or from a bootloadable module. After placing the real GDT into RAM,you can change the GDT register.STARTING FIRST TASKThe initialization procedure can run awhile in protected mode without initializing the task register;however, before the first task switch, two conditions must prevail:• There must be a valid task state segment (TSS) for the new task. The register fields of the TSSshould have appropriate values, the segment register fields must point to valid segments or be null,the stack pointers for privilege levels numerically less than or equal to the initial CPL must pointto valid stack segments, the LDT pointer must point to the GDT entry for a valid LDT (or be nullif the task does not use an LDT) and, just as insurance, the back link of the TSS should be null.• The task register must point to an area in which to save the current task state. After the first taskswitch, the information dumped in this area is not needed, and the area can be used for otherpurposes.10-2 121960·001

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!