Intel 80386 DJ Equipment User Manual


 
80386
Code
and
data segments have several descriptor
fields
in
common. The accessed A bit
is
set whenev-
er the processor accesses a descriptor. The
A bit
is
used
by
operating systems to keep usage statistics
on a given segment. The
G bit, or granularity bit,
specifies if a segment
length
is
byte-granular or
page-granular.
80386 segments can be one mega-
byte
long with byte granularity
(G
=
0)
or four giga-
bytes with page
granularity
(G
= 1),
(i.e.,
2
20
pages
each page
is
4K bytes
in
length). The granularity
is
totally unrelated to paging. A 80386 system can con-
sist of segments with byte
granularity, and page
granularity, whether or not paging
is
enabled.
The executable E bit tells if a segment
is
a code or
data segment. A code segment
(E
= 1 , S =
1)
may be
execute-only or execute/read
as
determined
by
the
Read
R bit. Code segments are execute only if
R
=
0,
and
execute/read if R =
1.
Code segments
may never be written into.
NOTE:
Code segments may be modified via aliases. Alias-
es
are
writeable data segments which occupy the
same range of
linear address space
as
the code
segment.
The D bit indicates the
default length for operands
and effective addresses.
If D = 1 then 32-bit oper-
ands and 32-bit addressing modes are assumed.
If
D = 0 then 16-bit operands and 16-bit addressing
modes are assumed. Therefore
all existing 286 code
segments
will execute
on
the 80386 assuming the D
bit
is
set
o.
Another attribute of code segments
is
determined by
the conforming
C bit. Conforming segments, C =
1,
can
be
executed
and
shared by programs at differ-
ent privilege
levels. (See section 4.4 Protection.)
31
SEGMENT BASE
15
...
0
BASE
31
...
24
Type
o
1
2
3
4
5
6
7
Defines
Invalid
Available
286 TSS
LDT
Busy 286
TSS
286 Call Gate
Task Gate (for 286 or 386 Task)
286
Interrupt Gate
286 Trap Gate
16
LIMIT
19
...
16
Segments identified
as
data segments
(E
=
0,
S =
1)
are used for two types of 80386 segments: stack
and data segments. The expansion direction
(ED) bit
specifies if a segment expands downward (stack) or
upward (data).
If a segment
is
a stack segment all
offsets must be greater than the segment limit.
On
a
data segment
all offsets must be less than or equal
to the limit.
In
other words, stack segments start at
the base
linear address plus the maximum segment
limit and grow down to the base linear address plus
the limit.
On
the other hand, data segments start at
the base
linear address and expand to the base lin-
ear address plus limit.
The write W bit controls the ability to write into a
segment. Data segments are
read-only if W =
O.
The
stack segment must have
W =
1.
The B bit controls the size of the stack pointer regis-
ter.
If B =
1,
then PUSHes,
POPs,
and CALLs all use
the 32-bit
ESP
register for stack references and as-
sume
an
upper limit of FFFFFFFFH. If B =
0,
stack
instructions
all use the 16-bit
SP
register and as-
sume
an
upper limit of FFFFH.
4.3.4.3 SYSTEM DESCRIPTOR FORMATS
System segments describe information about oper-
ating system
tables, tasks, and gates. Figure 4-7
shows the
general format of system segment de-
scriptors, and the various types of system segments.
80386 system descriptors contain a 32-bit base lin-
ear address and a 20-bit segment limit. 80286 sys-
tem descriptors have a 24-bit base address and a
16-bit segment
limit. 80286 system descriptors are
identified by the upper 16 bits being
all zero.
o
SEGMENT LIMIT 15
...
0
o
P
Type
8
9
A
B
C
D
E
F
Defines
Invalid
TYPE
Available 386 TSS
Undefined (Intel Reserved)
Busy 386
TSS
386 Call Gate
Undefined
(Intel Reserved)
386
Interrupt Gate
386 Trap Gate
BASE
23
...
16
+4
Figure 4·7. System Segments Descriptors
38