0

How are different types of segment identified as different? Wikipedia states:

Segments can be defined to be either code, data, or system segments

It also states:

Descriptors with bit 12 clear are "system descriptors" and are used for specialized purposes.

So, I gather that this "system bit" is used to identify a system segment, but what about code and data segments? Additionally, since these identifiers are stored separately instead of as a single 2-bit value, can you get combination-types, like system code and system data segments?

VortixDev
  • 965
  • 1
  • 10
  • 23
  • https://wiki.osdev.org/Global_Descriptor_Table says the Ex bit makes a descriptor a code-segment descriptor instead of data. https://wiki.osdev.org/GDT_Tutorial#What_should_i_put_in_my_GDT.3F also has more details on what kinds of GDT entries there can be. If you want the full details, see Intel's manuals (vol.3 especially). Links in the x86 tag wiki: https://stackoverflow.com/tags/x86/info – Peter Cordes Sep 04 '18 at 21:59

1 Answers1

3

The Type field of a segment descriptor is not one bit but four.

Format of a segment descriptor with 1 bit for the system/non-system type and 4 bit of sub type

The S field defines if the descriptor is a system descriptor (bit is clear) or not.
The interpretation of the Type field depends on the value of S.

Non system descriptors

Non system descriptors

System descriptors

System descriptors


To better understand how protected/long mode segmentation works I advice you dropping Wikipedia in favour of the Intel manuals.

Margaret Bloom
  • 41,768
  • 5
  • 78
  • 124