Local Descriptor Table Management Services
==========================================

Function 0000H                                                                
==============
    Allocates a specified number of descriptors from the LDT and returns the  
    base selector.  Pass the following information:                           
                                                                              
    AX = 0000H                                                                
                                                                              
    CX = number of descriptors to be allocated                                
                                                                              
    If the call succeeds, the base selector is returned in AX, and the carry  
    flag is clear.  If the call fails, the carry flag is set.                 
                                                                              
    An allocated descriptor is set to the present data type, with a base and  
    limit of zero.  The privilege level of an allocated descriptor is set to  
    match the code segment privilege level of the application.  To find out   
    the privilege level of a descriptor, use the lar instruction.             
                                                                              
    Allocated descriptors must be filled in by the application.  If more      
    than one descriptor is allocated, the returned selector is the first of   
    a contiguous array.  Use Function 0003H to get the increment for the      
    next selector in the array.                                               
                                                                              
Function 0001H                                                                
==============
    Frees the descriptor specified.  Pass the following information:          
                                                                              
    AX = 0001H                                                                
                                                                              
    BX = the selector to free                                                 
                                                                              
    Use the selector returned with function 0000h when the descriptor was     
    allocated.  To free an array of descriptors, call this function for each  
    descriptor.  Use Function 0003H to find out the increment for each        
    descriptor in the array.                                                  
                                                                              
    If the call succeeds, the carry flag is clear; if it fails, the carry     
    flag is set.                                                              
                                                                              
    You can use this function to free the descriptors allocated for the       
    program's initial CS, DS, and SS segments, but you should not free other  
    segments that were not allocated with Function 0000H or Function 000DH.   
                                                                              
Function 0002H                                                                
==============
    Converts a real-mode segment to a descriptor that a protected-mode        
    program can address.  Pass the following information:                     
                                                                              
    AX = 0002H                                                                
                                                                              
    BX = real-mode segment address                                            
                                                                              
    If the call succeeds, it clears the carry flag and returns the selector   
    mapped to the real-mode segment in AX.  If the call fails, the carry      
    flag is set.                                                              
                                                                              
    If you call this function more than once with the same real-mode segment  
    address, you get the same selector value each time.  The descriptor       
    limit is set to 64KB.                                                     
                                                                              
    The purpose of this function is to give protected-mode programs easy      
    access to commonly used real-mode segments.  However, because you cannot  
    modify or free descriptors created by this function, it should be used    
    infrequently.  Do not use this function to get descriptors for private    
    data areas.                                                               
                                                                              
    To examine real-mode addresses using the same selector, first allocate a  
    descriptor, and then use Function 0007H to change the linear base         
    address.                                                                  
                                                                              
Function 0003H                                                                    Returns the increment value for the next selector.  Use this function to  
==============
    get the value you add to the base address of an allocated array of        
    descriptors to get the next selector address.  Pass the following         
    information:                                                              
                                                                              
    AX = 0003H                                                                
                                                                              
    This call always succeeds.  The increment value is returned in AX.  This  
    value is always a power of two, but no other assumptions can be made.     
                                                                              
Function 0006H                                                                
==============
    Gets the linear base address of a selector.  Pass the following           
    information:                                                              
                                                                              
    AX = 0006H                                                                
                                                                              
    BX = selector                                                             
                                                                              
    If the call succeeds, the carry flag is clear and CX:DX contains the      
    32-bit linear base address of the segment.  If the call fails, it sets    
    the carry flag.                                                           
                                                                              
    If the selector you specify in BX is invalid, the call fails.             
                                                                              
Function 0007H                                                                
==============
    Changes the base address of a specified selector.  Only descriptors       
    allocated through Function 0000H should be modified.  Pass the following  
    information:                                                              
                                                                              
    AX = 0007H                                                                
                                                                              
    BX = selector                                                             
                                                                              
    CX:DX = the new 32-bit linear base address for the segment                
                                                                              
    If the call succeeds, the carry flag is clear; if unsuccessful, the       
    carry flag is set.                                                        
                                                                              
    If the selector you specify in BX is invalid, the call fails.             
                                                                              
Function 0008H                                                                
==============
    Sets the upper limit of a specified segment.  Use this function to        
    modify descriptors allocated with Function 0000H only.  Pass the          
    following information:                                                    
                                                                              
    AX = 0008H                                                                
                                                                              
    BX = selector                                                             
                                                                              
    CX:DX = 32-bit segment limit                                              
                                                                              
    If the call succeeds, the carry flag is clear; if unsuccessful, the       
    carry flag is set.                                                        
                                                                              
    The call fails if the specified selector is invalid, or if the specified  
    limit cannot be set.                                                      
                                                                              
    Segment limits greater than 1MB must be page-aligned.  This means that    
    limits greater than 1MB must have the low 12 bits set.                    
                                                                              
    To get the limit of a segment, use the 32-bit form of lsl for segment     
    limits greater than 64KB.                                                 
                                                                              
Function 0009H                                                                
==============
    Sets the descriptor access rights.  Use this function to modify           
    descriptors allocated with Function 0000H only.  To examine the access    
    rights of a descriptor, use the lar instruction.  Pass the following      
    information:                                                              
                                                                              
    AX = 0009H                                                                
                                                                              
    BX = selector                                                             
                                                                              
    CL = Access rights/type byte                                              
                                                                              
    CH = 386 extended access rights/type byte                                 
                                                                              
    If the call succeeds, the carry flag is clear; if unsuccessful, the       
    carry flag is set.  If the selector you specify in BX is invalid, the     
    call fails.  The call also fails if the access rights/type byte does not  
    match the format and meet the requirements shown in the figures below.    
                                                                              
    The access rights/type byte passed in CL has the format shown in the      
    figure below.  .imbmp 0.0i 4.0i RSI\MEM3 Access Rights/Type               
                                                                              
    The extended access rights/type byte passed in CH has the following       
    format.  .imbmp 0.0i 4.0i RSI\MEM4 Extended Access Rights/Type            
                                                                              
Function 000AH                                                                
==============
    Creates an alias to a code segment.  This function creates a data         
    descriptor that has the same base and limit as the specified code         
    segment descriptor.  Pass the following information:                      
                                                                              
    AX = 000AH                                                                
                                                                              
    BX = code segment selector                                                
                                                                              
    If the call succeeds, the carry flag is clear and the new data selector   
    is returned in AX.  If the call fails, the carry flag is set.  The call   
    fails if the selector passed in BX is not a valid code segment.           
                                                                              
    To deallocate an alias to a code segment, use Function 0001H.             
                                                                              
    After the alias is created, it does not change if the code segment        
    descriptor changes.  For example, if the base or limit of the code        
    segment change later, the alias descriptor stays the same.                
                                                                              
Function 000BH                                                                
==============
    Copies the descriptor table entry for a specified descriptor.  The copy   
    is written into an 8-byte buffer.  Pass the following information:        
                                                                              
    AX = 000BH                                                                
                                                                              
    BX = selector                                                             
                                                                              
    ES:EDI = a pointer to the 8-byte buffer for the descriptor copy           
                                                                              
    If the call succeeds, the carry flag is clear and ES:EDI contains a       
    pointer to the buffer that contains a copy of the descriptor.  If the     
    call fails, the carry flag is set.  The call fails if the selector        
    passed in BX is invalid or unallocated.                                   
                                                                              
Function 000CH                                                                
==============
    Copies an 8-byte buffer into the LDT for a specified descriptor.  The     
    descriptor must first have been allocated with Function 0000H.  Pass the  
    following information:                                                    
                                                                              
    AX = 000CH                                                                
                                                                              
    BX = selector                                                             
                                                                              
    ES:EDI = a pointer to the 8-byte buffer containing the descriptor         
                                                                              
    If the call succeeds, the carry flag is clear; if it fails, the carry     
    flag is set.  The call fails if the descriptor passed in BX is invalid.   
                                                                              
    The type byte, byte 5, has the same format and requirements as the        
    access rights/type byte passed to Function 0009H in CL.  The format is    
    shown in the first figure presented with the description of Function      
    0009H.                                                                    
                                                                              
    The extended type byte, byte 6, has the same format and requirements as   
    the extended access rights/type byte passed to Function 0009H in CH,      
    except that the limit field can have any value, and the low order bits    
    marked reserved are used to set the upper 4 bits of the descriptor        
    limit.  The format is shown in the second figure presented with the       
    description of Function 0009H.                                            

Function 000DH                                                                
==============
    Allocates a specific LDT descriptor.  Pass the following information:     
                                                                              
    AX = 000DH                                                                
                                                                              
    BX = selector                                                             
                                                                              
    If the call succeeds, the carry flag is clear and the specified           
    descriptor is allocated.  If the call fails, the carry flag is set.       
                                                                              
    The call fails if the specified selector is already in use, or if it is   
    not a valid LDT descriptor.  The first 10h (16 decimal) descriptors are   
    reserved for this function, and should not be used by the host.  Some of  
    these descriptors may be in use, however, if another client application   
    is already loaded.                                                        
                                                                              
    To free the descriptor, use Function 0001H.                               
