Global Descriptor Table: Difference between revisions
Replaced most of my box drawn diagrams with wiki tables.
[unchecked revision] | [unchecked revision] |
Revolution (talk | contribs) m (→Table) |
Revolution (talk | contribs) (Replaced most of my box drawn diagrams with wiki tables.) |
||
Line 7:
The '''GDT''' is pointed to by the value in the '''GDTR''' register. This is loaded using the '''LGDT''' assembly instruction, whose argument is a pointer to a '''GDT Descriptor''' structure:
{| class="wikitable" style="border-width: 3px; width: 720px"
|+style="text-align: left;"|'''GDT
|-
|style="padding: 2px; width: 461px; text-align: left ; border-left: 1px ; border-right: none;" |79 (64-bit Mode / 48 (32-bit Mode)
|style="padding: 2px; width: 10px; text-align: right; border-left: none; border-right: 1px ;" |16
|style="padding: 2px; width: 221px; text-align: left ; border-left: 1px ; border-right: none;" |15
|style="padding: 2px; width: 11px; text-align: right; border-left: none; border-right: 1px ;" |0
|-
|style="padding: 2px; width: 461px; text-align: left ; border-left: 1px ; border-right: none;" |'''Offset'''<br>63 (64-bit Mode) / 31 (32-bit Mode)
|style="padding: 2px; width: 10px; text-align: right; border-left: none; border-right: 1px ;" |<br>0
|style="padding: 2px; width: 221px; text-align: left ; border-left: 1px ; border-right: none;" |'''Size'''<br>15
|style="padding: 2px; width: 11px; text-align: right; border-left: none; border-right: 1px ;" |<br>0
|}
* '''Size:''' The size of the table in bytes subtracted by 1. This subtraction occurs because the maximum value of '''Size''' is 65535, while the '''GDT''' can be up to 65536 bytes in length (8192 entries). Further, no '''GDT''' can have a size of 0 bytes.
Line 49 ⟶ 53:
== Segment Descriptor ==
Each entry in the table
{| class="wikitable" style="border-width: 3px; width: 640px;"
|+style="text-align: left;"|'''SEGMENT DESCRIPTOR:'''
|-
|style="padding: 2px; width: 136px; text-align: left ; border-left: 1px ; border-right: none;"|63
|style="padding: 2px; width: 15px; text-align: right; border-left: none; border-right: 1px ;"|56
|style="padding: 2px; width: 56px; text-align: left ; border-left: 1px ; border-right: none;"|55
|style="padding: 2px; width: 15px; text-align: right; border-left: none; border-right: 1px ;"|52
|style="padding: 2px; width: 56px; text-align: left ; border-left: 1px ; border-right: none;"|51
|style="padding: 2px; width: 15px; text-align: right; border-left: none; border-right: 1px ;"|48
|style="padding: 2px; width: 136px; text-align: left ; border-left: 1px ; border-right: none;"|47
|style="padding: 2px; width: 15px; text-align: right; border-left: none; border-right: 1px ;"|40
|style="padding: 2px; width: 136px; text-align: left ; border-left: 1px ; border-right: none;"|39
|style="padding: 2px; width: 16px; text-align: right; border-left: none; border-right: 1px ;"|32
|-
|style="padding: 2px; width: 136px; text-align: left ; border-left: 1px ; border-right: none;"|'''Base'''<br>31
|style="padding: 2px; width: 15px; text-align: right; border-left: none; border-right: 1px ;"|<br>24
|style="padding: 2px; width: 56px; text-align: left ; border-left: 1px ; border-right: none;"|'''Flags'''<br>4
|style="padding: 2px; width: 15px; text-align: right; border-left: none; border-right: 1px ;"|<br>0
|style="padding: 2px; width: 56px; text-align: left ; border-left: 1px ; border-right: none;"|'''Limit'''<br>19
|style="padding: 2px; width: 15px; text-align: right; border-left: none; border-right: 1px ;"|<br>16
|style="padding: 2px; width: 136px; text-align: left ; border-left: 1px ; border-right: none;"|'''Access Byte'''<br>7
|style="padding: 2px; width: 15px; text-align: right; border-left: none; border-right: 1px ;"|<br>0
|style="padding: 2px; width: 136px; text-align: left ; border-left: 1px ; border-right: none;"|'''Base'''<br>23
|style="padding: 2px; width: 16px; text-align: right; border-left: none; border-right: 1px ;"|<br>16
|}
{| class="wikitable" style="border-width: 3px; width: 640px;"
|-
|style="padding: 2px; width: 296px; border-right: none;" |31
|style="padding: 2px; width: 15px; text-align: right; border-left: none;" |16
|style="padding: 2px; width: 296px; border-right: none;" |15
|style="padding: 2px; width: 16px; text-align: right; border-left: none;" |0
|-
|style="padding: 2px; width: 296px; border-right: none;" |'''Base'''<br>15
|style="padding: 2px; width: 15px; text-align: right; border-left: none;" |<br>0
|style="padding: 2px; width: 296px; border-right: none;" |'''Limit'''<br>15
|style="padding: 2px; width: 16px; text-align: right; border-left: none;" |<br>0
|}
* '''Base:''' A 32-bit value containing the linear address where the segment begins.
Line 74 ⟶ 99:
For more information, see '''Section 3.4.5: Segment Descriptors''' and '''Figure 3-8: Segment Descriptor''' of the Intel Software Developer Manual, Volume 3-A.
{| class="wikitable" style="border-width: 3px; width: 640px;"
|+style="text-align: left;"|'''ACCESS BYTE:'''
|-
|style="padding: 2px; width: 75px; text-align: center; border-left: 1px ; border-right: 1px ;"|7
|style="padding: 2px; width: 76px; text-align: center; border-left: 1px ; border-right: none;"|6
|style="padding: 2px; width: 75px; text-align: center; border-left: none; border-right: 1px ;"|5
|style="padding: 2px; width: 75px; text-align: center; border-left: 1px ; border-right: 1px ;"|4
|style="padding: 2px; width: 75px; text-align: center; border-left: 1px ; border-right: 1px ;"|3
|style="padding: 2px; width: 75px; text-align: center; border-left: 1px ; border-right: 1px ;"|2
|style="padding: 2px; width: 75px; text-align: center; border-left: 1px ; border-right: 1px ;"|1
|style="padding: 2px; width: 76px; text-align: center; border-left: 1px ; border-right: 1px ;"|0
|-
|style="padding: 2px; width: 75px; text-align: left ; border-left: 1px ; border-right: 1px ;"|'''Pr'''
|style="padding: 2px; width: 76px; text-align: left ; border-left: 1px ; border-right: none;"|'''Privl'''
|style="padding: 2px; width: 75px; text-align: left ; border-left: none; border-right: 1px ;"|
|style="padding: 2px; width: 75px; text-align: left ; border-left: 1px ; border-right: 1px ;"|'''S'''
|style="padding: 2px; width: 75px; text-align: left ; border-left: 1px ; border-right: 1px ;"|'''Ex'''
|style="padding: 2px; width: 75px; text-align: left ; border-left: 1px ; border-right: 1px ;"|'''DC'''
|style="padding: 2px; width: 75px; text-align: left ; border-left: 1px ; border-right: 1px ;"|'''RW'''
|style="padding: 2px; width: 76px; text-align: left ; border-left: 1px ; border-right: 1px ;"|'''Ac'''
|}
* '''Pr:''' Present bit. Allows an entry to refer to a valid segment. Must be set ('''1''') for any valid segment.
Line 101 ⟶ 135:
* '''Ac:''' Accessed bit. Best left clear ('''0'''), the CPU will set it when the segment is accessed.
{| class="wikitable" style="border-width: 3px; width: 320px;"
|+style="text-align: left;"|'''FLAGS:'''
|-
|style="padding: 2px; width: 75px; text-align: center; border-left: 1px ; border-right: 1px ;"|3
|style="padding: 2px; width: 75px; text-align: center; border-left: 1px ; border-right: 1px ;"|2
|style="padding: 2px; width: 75px; text-align: center; border-left: 1px ; border-right: 1px ;"|1
|style="padding: 2px; width: 76px; text-align: center; border-left: 1px ; border-right: 1px ;"|0
|-
|style="padding: 2px; width: 75px; text-align: left ; border-left: 1px ; border-right: 1px ;"|'''Gr'''
|style="padding: 2px; width: 75px; text-align: left ; border-left: 1px ; border-right: 1px ;"|'''Sz'''
|style="padding: 2px; width: 75px; text-align: left ; border-left: 1px ; border-right: 1px ;"|'''L'''
|style="padding: 2px; width: 76px; text-align: left ; border-left: 1px ; border-right: 1px ;"|Reserved
|}
* '''Gr:''' Granularity flag, indicates the size the '''Limit''' value is scaled by. If clear ('''0'''), the '''Limit''' is in 1 Byte blocks (byte granularity). If set ('''1'''), the '''Limit''' is in 4 KiB blocks (page granularity).
|