80386

4.3.4.4 LDT DESCRIPTORS (S = 0, TYPE = 2)

LDT descriptors (S = 0 TYPE = 2) contain informa- tion about Local Descriptor Tables. LDTs contain a table of segment descriptors, unique to a particular task. Since the instruction to load the LDTR is only available at privilege level 0, the DPL field is ignored. LDT descriptors are only allowed in the Global De- scriptor Table (GDT).

4.3.4.5TSS DESCRIPTORS (5=0, TVPE= 1, 3, 9, B)

A Task State Segment (TSS) descriptor contains in- formation about the location, size, and privilege level of a Task State Segment (TSS). A TSS in turn is a special fixed format segment which contains all the state information for a task and a linkage field to permit nesting tasks. The TYPE field is used to indi- cate whether the task is currently BUSY (Le. on a chain of active tasks) or the TSS is available. The TYPE field also indicates if the segment contains a 286 or a 386 TSS. The Task Register (TR) contains the selector which points to the current Task State Segment.

4.3.4.6GATE DESCRIPTORS (S=O, TYPE=4-7, C, F)

Gates are used to control access to entry points within the target code segment. The various types of

gate descriptors are call gates, task gates, interrupt gates, and trap gates. Gates provide a level of indirection between the source and destina- tion of the control transfer. This indirection allows the processor to automatically perform protection checks. It also allows system designers to control entry points to the operating system. Call gates are used to change privilege levels (see section 4.4 Protection), task gates are used to perform a task switch, and interrupt and trap gates are used to specify interrupt service routines.

Figure 4-8 shows the format of the four types of gate descriptors. Call gates are primarily used to transfer program control to a more privileged level. The call gate descriptor consists of three fields: the access byte, a long pointer (selector and offset) which points to the start of a routine and a word count which specifies how many parameters are to be cop- ied from the caller'sstack to the stack of the called routine. The word count field is only used by call gates when there is a change in the privilege level, other types of gates ignore the word count field.

Interrupt and trap gates use the destination selector and destination offset fields of the gate descriptor as a pointer to the start of the interrupt or trap handler routines. The difference between interrupt gates and trap gates is that the interrupt gate disables inter- rupts (resets the IF bit) while the trap gate does not.

31

 

24

16

8

5

o

SELECTOR

 

 

OFFSET 15 ... 0

 

 

o

 

 

 

 

 

 

WORD

OFFSET 31 ... 16

 

P DPL 0

TYPE

0 0 0

COUNT +4

 

 

 

 

 

 

4 ... 0

Name

 

Gate Descriptor Fields

 

 

 

Value

 

Description

 

 

 

Type

4

 

286 call gate

 

 

 

 

5

 

Task gate (for 286 or 386 task)

 

 

 

 

6

 

286 interrupt gate

 

 

 

 

7

 

286 trap gate

 

 

 

 

C

 

386 call gate

 

 

 

 

E

 

386 interrupt gate

 

 

 

 

F

 

386 trap gate

 

 

 

P

o

 

Descriptor contents are not valid

 

 

 

Descriptor contents are valid

DPL-Ieast privileged level at which a task may access the gate. WORD COUNT 0-31-the number of parameters to copy from caller'sstack to the called procedure'sstack. The parameters are 32-bit quantities for 386 gates, and 16-bit quantities for 286 gates.

DESTINATION

16-bit

Selector to the target code segment

SELECTOR

selector

or

 

 

Selector to the target task state segment for task gate

DESTINATION

offset

Entry point within the target code segment

OFFSET

16-bit 286

 

 

32-bit 386

 

 

 

Figure 4·8.Gate Descriptor Formats

39

Page 100
Image 100
Intel 80386 manual Selector, Offset 15, Word, Offset 31, DPL Type Count +4