A selector identifies a protected-mode segment. The VMM provides services for creating and destroying selectors, and for converting between selector:offset and flat addresses. Because virtual devices use a flat memory model, these services are used primarily to share memory with 16-bit protected mode applications.
Each segment has a base linear address, limit, and specific permissions. The limit (size) is measured either in bytes or pages depending on the segment's granularity. The properties of a segment are contained in a hardware-defined data structure called a segment descriptor.
Segment descriptors are contained in two arrays called the global descriptor table (GDT) and the local descriptor table (LDT). There is only one GDT, whereas there is a different LDT for each protected mode virtual machine (VM). If bit 2 (value 4) of a selector is zero, the selector is an index into the GDT; otherwise it is an index into the current LDT.
Virtual devices should not modify the GDT or LDT directly. To define a new segment, use the _Allocate_GDT_Selector or _Allocate_LDT_Selector service. You can modify a segment descriptor by using the _SetDescriptor service. For example, you might allocate multiple selectors and then use the _SetDescriptor service to change the base address and limit associated with all but the first selector. You can retrieve the descriptor associated with a selector by using the _GetDescriptor service. To free a selector, use the _Free_GDT_Selector or _Free_LDT_Selector service.
A segment descriptor is a 64-bit structure consisting of several bit fields. You can use the _BuildDescriptorDWORDs service to initialize a selector, rather than performing the necessary bit field operations yourself. You can use the return value of this service when you allocate or change a descriptor.
You can give an application read-only access to system data without allocating a selector. The _GetAppFlatDSAlias service returns a selector that maps the entire linear address space. The selector has read-only access to ensure system integrity. To give an application read-write access to system data, you should allocate a selector with an appropriate base address and limit.
A virtual device can convert a selector:offset address to a flat linear address by using the _SelectorMapFlat service.
_GetAppFlatDSAlias, _GetDescriptor, _SelectorMapFlat, _SetDescriptor, _Allocate_GDT_Selector, _Allocate_LDT_Selector, _BuildDescriptorDWORDs, _Free_GDT_Selector, _Free_LDT_Selector