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., 220 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.)

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.

31

 

 

16

 

 

 

o

 

SEGMENT BASE 15 ... 0

 

SEGMENT LIMIT 15 ... 0

 

o

BASE 31 ... 24

LIMIT

P

 

TYPE

BASE

+4

19 ... 16

 

23 ... 16

 

 

 

 

 

 

 

Type

Defines

 

Type

Defines

 

 

o

Invalid

 

8

Invalid

 

 

1

Available 286 TSS

 

9

Available 386 TSS

 

 

2

LDT

 

 

A

Undefined (Intel Reserved)

 

 

3

Busy 286 TSS

 

B

Busy 386 TSS

 

 

4

286

Call Gate

 

C

386

Call Gate

 

 

5

Task Gate (for 286 or 386 Task)

 

D

Undefined (Intel Reserved)

 

 

6

286

Interrupt Gate

 

E

386

Interrupt Gate

 

 

7

286

Trap Gate

 

F

386

Trap Gate

 

 

Figure 4·7. System Segments Descriptors

38

Page 99
Image 99
Intel 80386 manual System Descriptor Formats