Chap17 Lect15 Segmentation PDF
Chap17 Lect15 Segmentation PDF
Chap17 Lect15 Segmentation PDF
CMPE 310
Memory System
FFFFFFFF
Descriptor Table
+
...
... 0000FF00
...
0000FF88
Data
Segment
0000FF00
Base
00000000
CMPE 310
16 15
Base
(B23-B0)
byte
DPL
Limit
(L15-L0)
3
TYPE
P Base address:
Starting location of the memory segment.
P Limit:
Length of the segment minus 1.
20-bits allows segments up to 1 MB.
This value is shifted by 12 bits to the left when the G (Granularity bit) is set to 1.
CMPE 310
CMPE 310
DPL
TYPE
A
A=0, Segment not accessed
A=1, Segment has been accessed
S = 0, System descriptor
S = 1, Code, data or stack
Sets the desc. privilege level.
P = 0, descriptor is undefined.
P = 1, descriptor contains a valid
base and limit.
000
001
010
011
100
101
110
111
Data, read-only
Data, read/write
Stack, read-only
Stack, read/write
Code, execute-only
Code, execute/read
Code, execute-only, conforming
Code, execute/read, conforming
The Access Rights (AR) byte controls access to a protected mode segment and how
the segment functions in the system.
4
CMPE 310
63
CMPE 310
CMPE 310
Base + FFFFFFFF
bottom
Growth direction
Base + limit
top
0
CMPE 310
Selector
15
Descriptor Index
13-bits
Selects one of the 8192
descriptors.
TI
RPL
CMPE 310
ESI
000000FF
Note: Descriptor 0
is called the NULL
descriptor and may
not be used to access
memory.
FFFFFF
1000FF
Base
Limit
Data
Segment
100000
DS
0008
...
00 00 92 10 00 00 00 FF 1
...
0
Access rights
000000
So instead of left shifting by 4 bits in Real Mode to form the segment address, we right shift
by 3 bits and use the value as a table index.
9
CMPE 310
10
CMPE 310
CS
Descriptor Cache
Base Address
Limit
Access
DS
ES
SS
FS
GS
TR
LDTR
Selector
Selector
GDTR
IDTR
Base Address
Limit
Access
The addresses of the GDT and IDT and their limits (up to 64K bytes) are loaded in special
registers, GDTR and IDTR, before switching to Protected Mode is possible.
11
CMPE 310
12
CMPE 310
DS
LDT
cache
Data Descriptor
Descriptor
LDTR
GDTR
LDT Descriptor
LDT
32-bit Offset
GDT
ESI
Data
Descriptor
000000
The LDTR selector can be loaded with a new value when another task is run.
13
CMPE 310
16 15
Base
(23-0)
0
Limit
(15-0)
14