19
Data segments (S = 1, E = 0) may be either read-only or read-
write as controlled by the W bit of the access rights byte.
Read-only (W = 0) data segments may not be written into.
Data segments may grow in two directions, as determined by
the Expansion Direction (ED) bit: upwards (ED = 0) for data
segments, and downwards (ED = 1) for a segment containing
a stack. The limit field for a data segment descriptor is inter-
preted differently depending on the ED bit (see Table 10).
A code segment (S = 1, E = 1) may be execute-only or exe-
cute/read as determined by the Readable (R) bit. Code seg-
ments may never be written into and execute-only code
segments (R = 0) may not be read. A code segment may
also have an attribute called conforming (C). A conforming
code segment may be shared by programs that execute at
different privilege levels. The DPL of a conforming code seg-
ment defines the range of privilege levels at which the seg-
ment may be executed (refer to privilege discussion below).
The limit field identifies the last byte of a code segment.
System Segment Descriptors (S = 0, Type = 1-3)
In addition to code and data segment descriptors, the pro-
tected mode 80C286 defines System Segment Descriptors.
These descriptors define special system data segments
which contain a table of descriptors (Local Descriptor Table
Descriptor) or segments which contain the execution state of
a task (Task State Segment Descriptor).
Table 11 gives the formats for the special system data seg-
ment descriptors. The descriptors contain a 24-bit base
address of the segment and a 16-bit limit. The access byte
defines the type of descriptor, its state and privilege level.
The descriptor contents are valid and the segment is in
physical memory if P = 1. If P = 0, the segment is not valid.
The DPL field is only used in Task State Segment descrip-
tors and indicates the privilege level at which the descriptor
may be used (see Privilege). Since the Local Descriptor
Table descriptor may only be used by a special privileged
instruction, the DPL field is not used. Bit 4 of the access byte
is 0 to indicate that it is a system control descriptor. The type
field specifies the descriptor type as indicated in Table 11.
Gate Descriptors (S = 0, Type = 4-7)
Gates are used to control access to entry points within the
target code segment. The gate descriptors are call gates,
task gates, interrupt gates and trap gates. Gates provide a
level of indirection between the source and destination of the
control transfer. This indirection allows the CPU to automati-
cally perform protection checks and control entry point of the
destination. Call gates are used to change privilege levels
(see Privilege), task gates are used to perform a task switch,
and interrupt and trap gates are used to specify interrupt ser-
vice routines. The interrupt gate disables interrupts (resets
IF) while the trap gate does not.
Table 12 shows the format of the gate descriptors. The
descriptor contains a destination pointer that points to the
descriptor of the target segment and the entry point offset.
The destination selector in an interrupt gate, trap gate, and
call gate must refer to a code segment descriptor. These gate
descriptors contain the entry point to prevent a program from
constructing and using an illegal entry point. Task gates may
only refer to a task state segment. Since task gates invoke a
task switch, the destination offset is not used in the task gate.
Exception 13 is generated when the gate is used if a destina-
tion selector does not refer to the correct descriptor type. The
word count field is used in the call gate descriptor to indicate
the number of parameters (0-31 words) to be automatically
copied from the caller’s stack to the stack of the called routine
when a control transfer changes privilege levels. The word
count field is not used by any other gate descriptor.
The access byte format is the same for all descriptors. P = 1
indicates that the gate contents are valid. P = 0 indicates the
contents are not valid and causes exception 11 if refer-
enced. DPL is the descriptor privilege level and specifies
when this descriptor may be used by a task (refer to privilege
discussion below). Bit 4 must equal 0 to indicate a system
control descriptor. The type field specifies the descriptor type
as indicated in Table 12.
RESERVED
PDPL 0
TYPE
BASE 23 - 16
BASE 15 - 0
LIMIT 15 - 0
15
70 7
7
80
0
+6
+4
+2
0
+7
+5
+3
+1
MUST BE SET TO 0 FOR COMPATIBILITY WITH FUTURE UPGRADES
FIGURE 10. SYSTEM SEGMENT DESCRIPTOR
TABLE 11. SYSTEM SEGMENT DESCRIPTOR FORMAT FIELDS
NAME
VALUE
DESCRIPTION
TYPE
1
Available Task State Segment (TSS)
2
Local Descriptor Table
3
Busy Task State Segment (TSS)
P
0
Descriptor contents are not valid
1
Descriptor contents are valid
DPL
0-3
Descriptor Privilege Level
BASE
24-Bit
Number
Base Address of special system data
segment in real memory
LIMIT
16-Bit
Number
Offset of last byte in segment
80C286