5 segment descriptors – Intel IA-32 User Manual

Page 92

Advertising
background image

3-12 Vol. 3A

PROTECTED-MODE MEMORY MANAGEMENT

3.4.5

Segment Descriptors

A segment descriptor is a data structure in a GDT or LDT that provides the processor with the
size and location of a segment, as well as access control and status information. Segment
descriptors are typically created by compilers, linkers, loaders, or the operating system or exec-
utive, but not application programs. Figure 3-8 illustrates the general descriptor format for all
types of segment descriptors.

The flags and fields in a segment descriptor are as follows:

Segment limit field

Specifies the size of the segment. The processor puts together the two segment
limit fields to form a 20-bit value. The processor interprets the segment limit
in one of two ways, depending on the setting of the G (granularity) flag:

If the granularity flag is clear, the segment size can range from 1 byte to
1 MByte, in byte increments.

If the granularity flag is set, the segment size can range from 4 KBytes to
4 GBytes, in 4-KByte increments.

The processor uses the segment limit in two different ways, depending on
whether the segment is an expand-up or an expand-down segment. See Section
3.4.5.1, “Code- and Data-Segment Descriptor Types”, for m
ore information
about segment types. For expand-up segments, the offset in a logical address
can range from 0 to the segment limit. Offsets greater than the segment limit
generate general-protection exceptions (#GP). For expand-down segments, the

Figure 3-8. Segment Descriptor

31

24 23 22 21 20 19

16 15

13

14

12 11

8 7

0

P

Base 31:24

G

D
P

L

Type

S

L

4

31

16 15

0

Base Address 15:00

Segment Limit 15:00

0

Base 23:16

D

/

B

A
V

L

Seg.

Limit

19:16

G

— Granularity

LIMIT — Segment Limit
P

— Segment present

S

— Descriptor type (0 = system; 1 = code or data)

TYPE — Segment type

DPL

— Descriptor privilege level

AVL

— Available for use by system software

BASE — Segment base address

D/B

— Default operation size (0 = 16-bit segment; 1 = 32-bit segment)

L

— 64-bit code segment (IA-32e mode only)

Advertising