/*********************************************************************
*
*	TITLE:	RMXINTFC
*
*	DATE:	07-19-90
*
*	ABSTRACT: This module contains PASCAL calling convention interface
*                 routines for the DOSRMX Real Time Extensions.
*
*
*   MODIFIED: 
*
***********************************************************************/

/*
 *			 INTEL CORPORATION PROPRIETARY INFORMATION
 *
 *		  This software is supplied under the terms of a 
 *		  license agreement or nondisclosure agreement with
 *		  Intel Corporation and may not be copied or disclosed
 *		  except in accordance with the terms of that agreement.
 *
 */
#include <dos.h>

/* DOSRMX Real Time Extension Interrupt Level */

#define dosrte 184

/* DOSRMX Real Time Extension Function Codes. */

#define creatembx 0
#define deletembx 1
#define sendmsg   2
#define senddata  3
#define recvmsg   4
#define recvdata  5
#define createsem 6
#define deletesem 7
#define sendunits 8
#define recvunits 9
#define createreg 10
#define deletereg 11
#define sendcntrl 12
#define recvcntrl 13
#define acptcntrl 14
#define createseg 15
#define deleteseg 16
#define getsize   17
#define getaddr   18
#define creatdscp 19
#define deletdscp 20
#define changdscp 21
#define catalobj  22
#define ucatalobj 23
#define lookupobj 24
#define insobjdir 25
#define gettsktkn 26
#define gettype   27
#define sleep     28
#define esleep    29
#define readseg   30
#define writeseg  31

union REGS regs;

union {
       struct
            {
            void far *cp;
            } p;
       struct
            {
            unsigned long DWORD;
            } l;
       struct
            {
            unsigned int OFFSET;
            unsigned int SEG;
            } bp;
       } convert;

/******************************************************************
*
*    TITLE: RQCreateMailbox
*
*    CALLING SEQUENCE: mailbox_tkn = RQCreateMailbox( mailbox_flags,
*                                                     except_ptr );
*
*    INTERFACE VARIABLES: mailbox_flags WORD - contains information
*                                              about the mailbox.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function creates an RMX mailbox TOKEN.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
unsigned pascal RQCreateMailbox(mailbox_flags, except_ptr)

unsigned int mailbox_flags;
unsigned int *except_ptr;

{

  regs.x.ax = creatembx;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

  return ( regs.x.ax);
}

/******************************************************************
*
*    TITLE: RQDeleteMailbox
*
*    CALLING SEQUENCE:  RQDeleteMailbox( mailbox_token,
*                                        except_ptr );
*
*    INTERFACE VARIABLES: mailbox_token WORD - contains the RMX token
*                                              for the mailbox.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function deletes an RMX mailbox.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
void pascal RQDeleteMailbox(mailbox_token, except_ptr)

unsigned int mailbox_token;
unsigned int *except_ptr;

{

  regs.x.ax = deletembx;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

}

/******************************************************************
*
*    TITLE: RQSendMessage
*
*    CALLING SEQUENCE:  RQSendMessage( mailbox_token,
*                                      object,
*                                      response,
*                                      except_ptr );
*
*    INTERFACE VARIABLES: mailbox_token WORD - contains the RMX token
*                                              for the mailbox.
*                         object        WORD - contains the TOKEN to be
*                                              sent to the mailbox.
*                         response      WORD - a TOKEN for a reply mailbox
*                                              to which the receiving task
*                                              can reply. If no reply is
*                                              expected then it is set to
*                                              SELECTOR$OF(nil) (zero).
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function sends an RMX TOKEN to an RMX mailbox.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
void pascal RQSendMessage(mailbox_token, object, response, except_ptr)

unsigned int mailbox_token;
unsigned int object;
unsigned int response;
unsigned int *except_ptr;

{

  regs.x.ax = sendmsg;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

}

/******************************************************************
*
*    TITLE: RQSendData
*
*    CALLING SEQUENCE:  RQSendData( mailbox_token,
*                                   message_ptr,
*                                   message_lngth,
*                                   except_ptr );
*
*    INTERFACE VARIABLES: mailbox_token WORD - contains the RMX token
*                                              for the mailbox.
*                         meesage_ptr   POINTER - a pointer to the data
*                                              to be sent to the mailbox.
*                         message_lngth WORD - is the length of the message
*                                              pointed to by message_ptr.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function sends a buffer of data to an RMX mailbox.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
void pascal RQSendData(mailbox_token, message_ptr, message_lngth, except_ptr)

unsigned int mailbox_token;
void *message_ptr;
unsigned int message_lngth;
unsigned int *except_ptr;

{

  regs.x.ax = senddata;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

}

/******************************************************************
*
*    TITLE: RQReceiveMessage
*
*    CALLING SEQUENCE:  message_token = RQReceiveMessage( mailbox_token,
*                                                         time_limit,
*                                                         response_ptr,
*                                                         except_ptr );
*
*    INTERFACE VARIABLES: mailbox_token WORD - contains the RMX token
*                                              for the mailbox.
*                         time_limit    WORD - the number of RMX ticks
*                                              the call task is will
*                                              to wait at the mailbox.
*                         response_ptr POINTER - a pointer to a TOKEN
*                                              in which RMX can place
*                                              the mailbox for the receiving
*                                              task to reply too.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function waits for an RMX TOKEN at an RMX mailbox for
*              a given time period, time_limit.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
unsigned int pascal RQReceiveMessage(mailbox_token, time_limit,
                                     response_ptr, except_ptr)

unsigned int mailbox_token;
unsigned int time_limit;
unsigned int *response_ptr;
unsigned int *except_ptr;

{

  regs.x.ax = recvmsg;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

 return ( regs.x.ax);
}

/******************************************************************
*
*    TITLE: RQReceiveData
*
*    CALLING SEQUENCE:  Actual = RQReceiveData( mailbox_token,
*                                               message_ptr,
*                                               time_limit,
*                                               except_ptr );
*
*    INTERFACE VARIABLES: actual        WORD - the number of bytes 
*                                              received from the mailbox.
*                         message_ptr POINTER - a pointer to a buffer
*                                              in which received data will
*                                              be placed.
*                         time_limit    WORD - the number of RMX ticks
*                                              the call task is will
*                                              to wait at the mailbox.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function waits for a buffer of data from an RMX mailbox
*              for a given time period, time_limit.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
unsigned int pascal RQReceiveData(mailbox_token, message_ptr,
                                     time_limit, except_ptr)

unsigned int mailbox_token;
void *message_ptr;
unsigned int time_limit;
unsigned int *except_ptr;

{

  regs.x.ax = recvdata;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

 return ( regs.x.ax);
}

/******************************************************************
*
*    TITLE: RQCreateSemaphore
*
*    CALLING SEQUENCE: semaphore = RQCreateSemaphore( initial_value,
*                                                     max_value,
                                                      semaphore_flags,
*                                                     except_ptr );
*
*    INTERFACE VARIABLES: initial_value WORD - contains initial number
*                                              of units the semaphore
*                                              will contain.
*                         max_value     WORD - contains maximum number
*                                              of units the semaphore
*                                              will contain.
*                         semaphore_flags WORD - contains flags that
*                                              set up the semaphore.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function creates an RMX semaphore TOKEN.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
unsigned pascal RQCreateSemaphore(initial_value, max_value,
                                  semaphore_flags, except_ptr)

unsigned int initial_value;
unsigned int max_value;
unsigned int semaphore_flags;
unsigned int *except_ptr;

{

  regs.x.ax = createsem;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

  return ( regs.x.ax);
}

/******************************************************************
*
*    TITLE: RQDeleteSemaphore
*
*    CALLING SEQUENCE:  RQDeleteSemaphore( semaphore,
*                                          except_ptr );
*
*    INTERFACE VARIABLES: semaphore  WORD - contains the RMX token
*                                           for the semaphore.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function deletes an RMX semaphore.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
void pascal RQDeleteSemaphore(semaphore, except_ptr)

unsigned int semaphore;
unsigned int *except_ptr;

{

  regs.x.ax = deletesem;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

}

/******************************************************************
*
*    TITLE: RQSendUnits
*
*    CALLING SEQUENCE:  RQSendUnits( semaphore,
*                                    units,
*                                    except_ptr );
*
*    INTERFACE VARIABLES: semaphore     WORD - contains the RMX token
*                                              for the semaphore.
*                         units         WORD - contains the number of units
*                                              for the semphore.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function sends a number of units to an RMX semaphore.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
void pascal RQSendUnits(semaphore, units, except_ptr)

unsigned int semaphore;
unsigned int units;
unsigned int *except_ptr;

{

  regs.x.ax = sendunits;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

}

/******************************************************************
*
*    TITLE: RQReceiveUnits
*
*    CALLING SEQUENCE:  value = RQReceiveUnits( semaphore,
*                                               units,
*                                               time_limit,
*                                               except_ptr );
*
*    INTERFACE VARIABLES: semaphore    WORD - contains the RMX token
*                                             for the semaphore.
*                         units        WORD - the number of units requested.
*                         time_limit    WORD - the number of RMX ticks
*                                              the call task is will
*                                              to wait at the semaphore.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function waits for a number of units from an RMX
*              semaphore, The calling task is only prepared to wait
*              a period of RMX ticks, time_limit.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
unsigned int pascal RQReceiveUnits(semaphore, units, time_limit, except_ptr)

unsigned int semaphore;
unsigned int units;
unsigned int time_limit;
unsigned int *except_ptr;

{

  regs.x.ax = recvunits;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

 return ( regs.x.ax);
}

/******************************************************************
*
*    TITLE: RQCreateRegion
*
*    CALLING SEQUENCE: Region_tkn = RQCreateRegion( region_flags,
*                                                   except_ptr );
*
*    INTERFACE VARIABLES: region_flags WORD - contains information
*                                             about the region.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function creates an RMX region.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
unsigned pascal RQCreateRegion(region_flags, except_ptr)

unsigned int region_flags;
unsigned int *except_ptr;

{

  regs.x.ax = createreg;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

  return ( regs.x.ax);
}

/******************************************************************
*
*    TITLE: RQDeleteRegion
*
*    CALLING SEQUENCE:  RQDeleteRegion( region_token,
*                                       except_ptr );
*
*    INTERFACE VARIABLES: region_token WORD - contains the RMX token
*                                             for the region.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function deletes an RMX region.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
void pascal RQDeleteRegion(region_token, except_ptr)

unsigned int region_token;
unsigned int *except_ptr;

{

  regs.x.ax = deletereg;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

}

/******************************************************************
*
*    TITLE: RQSendControl
*
*    CALLING SEQUENCE:  RQSendControl( except_ptr );
*
*    INTERFACE VARIABLES: except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function releases control of the RMX region.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
void pascal RQSendControl(except_ptr)

unsigned int *except_ptr;

{

  regs.x.ax = sendcntrl;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

}

/******************************************************************
*
*    TITLE: RQReceveControl
*
*    CALLING SEQUENCE:  RQReceiveControl( region_token,
*                                         except_ptr );
*
*    INTERFACE VARIABLES: region_token WORD - contains the RMX token
*                                             for the region.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function waits on an RMX region for control of
*              that region.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
void pascal RQReceiveControl(region_token, except_ptr)

unsigned int region_token;
unsigned int *except_ptr;

{

  regs.x.ax = recvcntrl;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

}

/******************************************************************
*
*    TITLE: RQAcceptControl
*
*    CALLING SEQUENCE:  RQAcceptControl( region_token,
*                                        except_ptr );
*
*    INTERFACE VARIABLES: region_token WORD - contains the RMX token
*                                             for the region.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function performs the same function as RQReceiveControl,
*              but does not wait for the region to become free, it returns
*              immediately and the exception is set to E$BUSY if it is not
*              free.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
void pascal RQAcceptControl(region_token, except_ptr)

unsigned int region_token;
unsigned int *except_ptr;

{

  regs.x.ax = recvcntrl;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

}

/******************************************************************
*
*    TITLE: RQCreateSegment
*
*    CALLING SEQUENCE: segment_tkn = RQCreateSegment( size,
*                                                     except_ptr );
*
*    INTERFACE VARIABLES: size        DWORD - contains size of the
*                                             segment in bytes.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function creates an RMX segment token.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
unsigned pascal RQCreateSegment(size, except_ptr)

unsigned long size;
unsigned int *except_ptr;

{

  regs.x.ax = createseg;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

  return ( regs.x.ax);
}

/******************************************************************
*
*    TITLE: RQDeleteSegment
*
*    CALLING SEQUENCE:  RQDeleteSegment( segment_token,
*                                        except_ptr );
*
*    INTERFACE VARIABLES: segment_token WORD - contains the RMX token
*                                             for the segment.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function deletes an RMX segment.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
void pascal RQDeleteSegment(segment_token, except_ptr)

unsigned int segment_token;
unsigned int *except_ptr;

{

  regs.x.ax = deleteseg;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

}

/******************************************************************
*
*    TITLE: RQGetSize
*
*    CALLING SEQUENCE: segment_size = RQGetSize( segment_tkn,
*                                                except_ptr );
*
*    INTERFACE VARIABLES: segment_size WORD - contains the RMX TOKEN
*                                             for the segment.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function returns the size of an RMX token (unsigned long
*              int).
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
unsigned long pascal RQGetSize(segment_tkn, except_ptr)

unsigned int segment_tkn;
unsigned int *except_ptr;

{

  regs.x.ax = getsize;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

  convert.bp.OFFSET = regs.x.ax; /* convert ax and dx to a DWORD */
  convert.bp.SEG    = regs.x.dx;

  return (convert.l.DWORD);
}

/******************************************************************
*
*    TITLE: RQGetAddress
*
*    CALLING SEQUENCE: physical_addr = RQGetAddress( addr_ptr,
*                                                    except_ptr );
*
*    INTERFACE VARIABLES: addr_ptr   POINTER - the pointer to be converted
*                                              to a physical address.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function returns the 24 bit physical address for a pointer.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
unsigned long pascal RQGetAddress(addr_ptr, except_ptr)

void *addr_ptr;
unsigned int *except_ptr;

{

  regs.x.ax = getaddr;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

  convert.bp.OFFSET = regs.x.ax; /* convert AX and DX to a DWORD */
  convert.bp.SEG    = regs.x.dx;

  return (convert.l.DWORD);
}

/******************************************************************
*
*    TITLE: RQECreateDescriptor
*
*    CALLING SEQUENCE: descrip_tkn = RQECreateDescriptor( physical_addr,
*                                                         size,
*                                                         except_ptr );
*
*    INTERFACE VARIABLES: physical_adr DWORD - contains the physical
*                                              address of the memory.
*                         size         WORD - contains size of the
*                                             segment in bytes.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function creates descriptor in the Global Descriptor
*              Table (GDT).
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
unsigned pascal RQECreateDescriptor(physical_addr, size, except_ptr)

unsigned long physical_addr;
unsigned int size;
unsigned int *except_ptr;

{

  regs.x.ax = creatdscp;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

  return ( regs.x.ax);
}

/******************************************************************
*
*    TITLE: RQEDeleteDescriptor
*
*    CALLING SEQUENCE:  RQEDeleteDescriptor( descrip_token,
*                                            except_ptr );
*
*    INTERFACE VARIABLES: discrip_token WORD - contains the RMX token
*                                             for the descriptor.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function deletes a descriptor from the Global Descriptor
*              Table (GDT).
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
void pascal RQEDeleteDescriptor(descrip_token, except_ptr)

unsigned int descrip_token;
unsigned int *except_ptr;

{

  regs.x.ax = deletdscp;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

}

/******************************************************************
*
*    TITLE: RQEChangeDescriptor
*
*    CALLING SEQUENCE:  RQEChangeDescriptor( descriptor,
*                                            physical_addr,
*                                            size,
*                                            except_ptr );
*
*    INTERFACE VARIABLES: descriptor    WORD - contains the RMX token
*                                              for the descriptor.
*                         physical_adr DWORD - contains the physical
*                                              address of the memory.
*                         size         DWORD - contains size of the
*                                             segment in bytes.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function changes a descriptor in the Global Descriptor
*              Table (GDT).
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
void pascal RQEChangeDescriptor(descriptor, physical_addr, size, except_ptr)

unsigned int  descriptor;
unsigned long physical_addr;
unsigned long size;
unsigned int  *except_ptr;

{

  regs.x.ax = changdscp;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

}

/******************************************************************
*
*    TITLE: RQCatalogObject
*
*    CALLING SEQUENCE:  RQCatalogObject( job,
*                                        object,
*                                        name_ptr,
*                                        except_ptr );
*
*    INTERFACE VARIABLES: job          WORD - contains the RMX token
*                                             for the job the object
*                                             is to be catalogued under.
*                         object       WORD - contains the RMX token
*                                             to be catalogued.
*                         name_ptr  POINTER - a pointer to an RMX string
*                                             used to catalogue the object.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function catalogues an RMX object in a job dorectory
*              under the name provided by the name_ptr variable.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
void pascal RQCatalogObject(job, object, name_ptr, except_ptr)

unsigned int  job;
unsigned int  object;
unsigned char (*name_ptr) [];
unsigned int  *except_ptr;

{

  regs.x.ax = catalobj;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

}

/******************************************************************
*
*    TITLE: RQUncatalogObject
*
*    CALLING SEQUENCE:  RQUncatalogObject( job,
*                                          name_ptr,
*                                          except_ptr );
*
*    INTERFACE VARIABLES: job          WORD - contains the RMX token
*                                             for the job the object
*                                             is catalogued under.
*                         name_ptr  POINTER - a pointer to an RMX string
*                                             used to find the object under.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function removes a catalogued RMX object in the job
*              directory.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
void pascal RQUncatalogObject(job, name_ptr, except_ptr)

unsigned int  job;
unsigned char (*name_ptr) [];
unsigned int  *except_ptr;

{

  regs.x.ax = ucatalobj;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

}

/******************************************************************
*
*    TITLE: RQLookupObject
*
*    CALLING SEQUENCE:  object_token = RQLookupObject( job,
*                                                      name_ptr,
*                                                      time_limit,
*                                                      except_ptr );
*
*    INTERFACE VARIABLES: job          WORD - contains the RMX token
*                                             for the job the object
*                                             is catalogued under.
*                         name_ptr  POINTER - a pointer to an RMX string
*                                             used to find the object under.
*                         time_limit    WORD - the number of RMX ticks
*                                              the call task is willing
*                                              to wait.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function looks up a RMX object in the job directory
*              under the name pointed to by name_ptr and returns the object.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
unsigned pascal RQLookupObject(job, name_ptr, time_limit, except_ptr)

unsigned int  job;
unsigned char (*name_ptr) [];
unsigned int  time_limit;
unsigned int  *except_ptr;

{

  regs.x.ax = lookupobj;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

  return(regs.x.ax);
}

/******************************************************************
*
*    TITLE: RQgetTaskTokens
*
*    CALLING SEQUENCE:  object_token = RQGetTaskTokens( selection,
*                                                       except_ptr );
*
*    INTERFACE VARIABLES: selection    BYTE - contains type of token
*                                             the calling task wants.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function returns the RMX token for the selection requested.
*              The selection can be either the calling task, calling tasks job,
*              calling tasks parameter object or the root jobs RMX token.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
unsigned pascal RQGetTaskTokens(selection, except_ptr)

unsigned char selection;
unsigned int  *except_ptr;

{

  regs.x.ax = gettsktkn;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

  return(regs.x.ax);
}

/******************************************************************
*
*    TITLE: RQGetType
*
*    CALLING SEQUENCE:  type_code = RQGetType( object,
*                                              except_ptr );
*
*    INTERFACE VARIABLES: object       WORD - contains the RMX object
*                                             token for the type request.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function returns the type of the RMX token passed in the
*              parameter object.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
unsigned pascal RQGetType(object, except_ptr)

unsigned int  object;
unsigned int  *except_ptr;

{

  regs.x.ax = gettype;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

  return(regs.x.ax);
}

/******************************************************************
*
*    TITLE: RQSleep
*
*    CALLING SEQUENCE:  RQSleep( time_limit,
*                                except_ptr );
*
*    INTERFACE VARIABLES: time_limit   WORD - the number of RMX ticks
*                                             the calling process wishes
*                                             suspend execution.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function suspends the calling task for a number of
*              RMX ticks specified in the parameter time_limit.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
void pascal RQSleep(time_limit, except_ptr)

unsigned int  time_limit;
unsigned int  *except_ptr;

{

  regs.x.ax = sleep;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

}

/******************************************************************
*
*    TITLE: RQEReadSegment
*
*    CALLING SEQUENCE:  RQEReadSegment( pvam_seg,
*                                       pvam_offset,
*                                       realmode_ptr,
*                                       size,
*                                       except_ptr );
*
*    INTERFACE VARIABLES: pvam_seg     WORD - the protected mode segment
*                                             to be copied from.
*                         pvam_offset DWORD - the protected mode offset
*                                             to be copied from.
*                         realmode_ptr POINTER - a pointer to the real
*                                             mode address space to be copied
*                                             to.
*                         size         WORD - the number of bytes to be copied.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function copies data from a protected mode segment to 
*              real mode address space.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
void pascal RQEReadSegment(pvam_seg, pvam_offset,
                           realmode_ptr, size, except_ptr)

unsigned int  pvam_seg;
unsigned long pvam_offset;
void          *realmode_ptr;
unsigned int  size;
unsigned int  *except_ptr;

{

  regs.x.ax = readseg;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

}

/******************************************************************
*
*    TITLE: RQEWriteSegment
*
*    CALLING SEQUENCE:  RQEWriteSegment( realmode_ptr,
*                                        pvam_seg,
*                                        pvam_offset,
*                                        size,
*                                        except_ptr );
*
*    INTERFACE VARIABLES: realmode_ptr POINTER - a pointer to the real
*                                             mode address space to be copied
*                                             from.
*                         pvam_seg     WORD - the protected mode segment
*                                             to be copied to.
*                         pvam_offset DWORD - the protected mode offset
*                                             to be copied to.
*                         size         WORD - the number of bytes to be copied.
*                         except_ptr POINTER - a pointer to a WORD
*                                              where the RMX exception
*                                              is returned.
*
*    PARAMETERS: NONE
*
*    GLOBAL VARIABLES: NONE
*
*
*    ABSTRACT: This function copies data to a protected mode segment from a
*              real mode address space.
*
*    NOTE. the function must be called in PASCAL convention.
*
******************************************************************/
void pascal RQEWriteSegment(realmode_ptr, pvam_seg,
                            pvam_offset, size, except_ptr)

unsigned int  pvam_seg;
unsigned long pvam_offset;
void          *realmode_ptr;
unsigned int  size;
unsigned int  *except_ptr;

{

  regs.x.ax = writeseg;
  convert.p.cp = &except_ptr;
  regs.x.si = convert.bp.OFFSET;

  int86(dosrte,&regs,&regs);

}

