_Allocate_GDT_Selector

include vmm.inc

VMMcall _Allocate_GDT_Selector, <DescDWORD1, DescDWORD2, flags>

mov ecx, eax ; zero in eax and edx if error

or ecx, edx

jz error

mov [Selector], eax ; new selector

mov word ptr [GDTSel], dx ; selector for the GDT

ror edx, 10h

mov word ptr [SelCount], dx ; number of selectors in GDT


The _Allocate_GDT_Selector service creates a new selector and adds it to the Global Descriptor Table (GDT).

Parameters

DescDWORD1

Specifies the high doubleword of the descriptor for the selector. This parameter contains the high 16 bits of the base address, the high 4 bits of the limit, and the status and type bits.

DescDWORD2

Specifies the low doubleword of the descriptor for the selector. This parameter contains the low 16 bits of the base address and limit.

flags

Specifies the operation flags. This parameter must be set to 0.

Return Value

If the service is successful, the EAX and EDX registers contain the following values:

Register Description

EAX Contains the new selector.
EDX Contains the selector for and the size of the GDT. The low 16 bits contains the selector for the GDT, and the high 16 bits contains the size of the GDT expressed as the number of selectors in the table.

If an error occurs, such as an invalid descriptor value or the GDT is full, the EAX and EDX registers contain zero to indicate an error.

Comments

Although this service returns the selector for the GDT, virtual devices should
not attempt to edit the GDT directly. Virtual devices can instead use the
_SetDescriptor service to change selectors in the GDT.

Virtual devices should use the BuildDescriptorDWORDs service to set the DescDWORD1 and DescDWORD2 parameters to the appropriate values.

This service sets the RPL of the selector to the DPL of the selector set in the DescDWORD1 parameter.

Uses

EAX, EDX

See Also

_Allocate_LDT_Selector, _Free_GDT_Selector