 unit XMS;

 interface


 TYPE
   EMMStructure     =RECORD
                            BytesToMove   : longint;      { Bytes to move. NB: Must be even! }
                            SrcHandle     : word;         { Handle number of source (SH=0 => conventional memory) }
                            SrcOffset     : pointer;      { Source offset, or SEG:OFS if SH=0 }
                            DestHandle    : word;         { Handle number of destination (DH=0 => conventional memory) }
                            DestOffset    : pointer;      { Destination offset, or SEG:OFS if DH=0 }
                     END;
 CONST
   UseXMS:BOOLEAN        =TRUE;                   { Variable for XMS usage }
   XMSError:BYTE         =0;                      { Variable indicating the errornumber returned from the last XMS operation }

 VAR
   XMSRecord             :EMMStructure;           { Variable for passing values to the XMS routine }
   XMSEntryPoint         :POINTER;                { Entry point of the XMS routine in memory }
   XMSHandles            :array[0..99] of word;

 const
   GDT : array[1..16] of byte =(
   $00,$00,$00,$00,$00,$00,$00,$00,        {GDT indice 0 (null segment)}
   $FF,$FF,$00,$00,$00,$92,$CF,$FF);       {GDT indice 1 (seg 0, limit 4GB)}

 var
   GDT_Off : array[1..6] of byte;

 FUNCTION  XMSPresent:BOOLEAN;

 FUNCTION  XMSMaxAvail:WORD;

 FUNCTION  XMSGetMem(SizeInKB:WORD):WORD;

 PROCEDURE XMSFreeMem(Handle:WORD);

 PROCEDURE XMSMove(VAR EMMParamBlock:EMMStructure);

 procedure Ram_2_XMS(Source : pointer;Longueur : longint;Hdlidx : byte);

 procedure XMS_2_Ram(Hdlidx : byte;Longueur : longint;Dest : pointer);

 function  XMS_lock(Handle : word) : longint;

 procedure XMS_unlock(Handle : word);

 procedure XMS_Enable_A20;

 procedure XMS_Disable_A20;

 procedure Ram_2_RMem(Pos_Ram : pointer;Pos_RMem : longint;Longueur : word);

 procedure RMem_2_Ram(Pos_RMem : longint;Pos_Ram : pointer;Longueur : word);

 procedure Enable4Giga;

 function  ModeV86Enabled : boolean;


end.