A flat model device driver for OS/2:Appendix A – Listings

OS/2 parallel device driver, 16-bit version
// sample 8255 parallel port device driver for OS/2


 * 1) include "drvlib.h"
 * 2) include "digio.h"

extern void STRATEGY;	      /* name of strat rout. in drvstart */ extern void TIMER_HANDLER;  /* timer handler in drvstart	   */

DEVICEHDR devhdr = { (void far *) 0xFFFFFFFF,           /* link                          */ (DAW_CHR | DAW_OPN | DAW_LEVEL1),  /* attribute word                */ (OFF) STRATEGY,                    /* &strategy                     */ (OFF) 0,                           /* &IDC routine                  */ "DIGIO$ "                          /* name/#units                   */ };

FPFUNCTION DevHlp=0;       /* pointer to DevHlp entry point */ UCHAR     opencount = 0;   /* keeps track of open's        */ USHORT    savepid=0;       /* save thread pid              */ LHANDLE   lock_seg_han;    /* handle for locking appl. seg */ PHYSADDR  appl_buffer=0;   /* address of caller's buffer   */ ERRCODE   err=0;           /* error return                 */ ULONG     ReadID=0L;       /* current read pointer         */ USHORT    num_rupts=0;     /* count of interrupts          */ USHORT    temp_char;       /* temp character for in-out    */ void      far *ptr;        /* temp far pointer             */ FARPOINTER appl_ptr=0;     /* pointer to application buffer */ char      input_char,output_char; /* temp character storage */ char      input_mask;      /* mask for input byte          */

/* messages */

char      CrLf[]= "\r\n"; char      InitMessage1[] = " 8 bit Digital I/O "; char      InitMessage2[] = " driver installed\r\n"; char      FailMessage[] = " driver failed to install.\r\n";

/* common entry point for calls to Strategy routines */

int main(PREQPACKET rp) {  void far *ptr; PLINFOSEG liptr;	/* pointer to global info seg */ int i;

switch(rp->RPcommand) {     case RPINIT:	/* 0x00	*/ /* init called by kernel in protected mode */ return Init(rp);

case RPREAD:             /* 0x04                      */ rp->s.ReadWrite.count = 0; /* in case we fail        */ input_char = inp(DIGIO_INPUT);/* get data            */ if (PhysToVirt( (ULONG) rp->s.ReadWrite.buffer, 1,0,&appl_ptr)) return (RPDONE | RPERR | ERROR_GEN_FAILURE); if (MoveBytes((FARPOINTER)&input_char,appl_ptr,1)) return (RPDONE | RPERR | ERROR_GEN_FAILURE); rp->s.ReadWrite.count = 1; /* one byte read	*/ return (RPDONE);

case RPWRITE:	/* 0x08	*/ rp->s.ReadWrite.count = 0; if (PhysToVirt( (ULONG) rp->s.ReadWrite.buffer, 1,0,&appl_ptr)) return (RPDONE | RPERR | ERROR_GEN_FAILURE); if (MoveBytes(appl_ptr,(FARPOINTER)&output_char,1)) return (RPDONE | RPERR | ERROR_GEN_FAILURE); outp (DIGIO_OUTPUT,output_char); /* send byte	*/ rp->s.ReadWrite.count = 1; /* one byte written	*/ return (RPDONE);

case RPOPEN:	/* 0x0d open driver	*/ /* get current process id */ if (GetDOSVar(2,&ptr)) return (RPDONE | RPERR | ERROR_BAD_COMMAND); /* get process info */ liptr = *((PLINFOSEG far *) ptr); /* if this device never opened, can be opened by anyone*/ if (opencount == 0)	/* first time this dev opened */ {           opencount=1;	/* bump open counter	*/ savepid = liptr->pidCurrent; /* save current PID	*/ }           else {        if (savepid != liptr->pidCurrent) /* another proc */ return (RPDONE | RPERR | ERROR_NOT_READY);/*err*/ ++opencount;	/* bump counter, same pid	*/ }        return (RPDONE);

FIX THIS _ INCOMPLETE ''Figure A-1. OS/2 parallel device driver, 16-bit version.''

Parallel driver header file
/* digio.h memory map for os/2 device driver

''Figure A-2. Parallel driver header file.''
 * 1) define DIGIO_CAT	0x91	  /* category for DosDevIOCtl	*/
 * 2) define DIGIO_BASE	0x2c0	  /* board address	*/
 * 3) define DIGIO_OUTPUT DIGIO_BASE   /* output port	*/
 * 4) define DIGIO_INPUT DIGIO_BASE+1  /* input port	*/
 * 5) define DIGIO_CONFIG DIGIO_BASE+3 /* initialization port	*/

Driver library header file, 16-bit
/ file drvlib.h // This header file contains definitions intended to go with // DRVLIB.LIB, a C-callable subroutine library. // //This file is for OS/2 2.0 typedef unsigned charUCHAR; typedef unsigned short USHORT; typedef unsigned short BOOLEAN; typedef unsigned longULONG; typedef UCHAR near *PUCHAR; typedef UCHAR far *FPUCHAR; typedef USHORT near *PUSHORT; typedef USHORT far *FPUSHORT; typedef ULONG near *PULONG; typedef ULONG far *FPULONG; typedef char near *PCHAR; typedef short near *PSHORT; typedef long near *PLONG; typedef void near *POINTER; typedef POINTER near *PPOINTER; typedef void far *FARPOINTER; typedef FARPOINTER near *PFARPOINTER; typedef FARPOINTER far *FPFARPOINTER;

typedef USHORT ERRCODE; // error code returned typedef ERRCODE far *PERRCODE; // pointer to an error code typedef UCHAR FLAG; // 8-bit flag typedef FLAG far *PFLAG; // pointer to 8-bit flag typedef USHORT SEL; // 16-bit selector

typedef SEL near *PSEL; // pointer to a selector typedef SEL far *FPSEL; // far pointer to selector typedef USHORT SEG; // 16-bit segment typedef USHORT OFF; // 16-bit offset typedef ULONG LOFF; // 32-bit offset typedef USHORT PID; // Process ID typedef USHORT TID; // Thread ID typedef ULONG PHYSADDR; // 32-bit physical address typedef ULONG LINADDR; // 32-bit linear address typedef LINADDR far *PLINADDR; // pointer to 32 bit address typedef PLINADDR far *PPLINADDR; // pointer to linear address typedef PHYSADDR far *PPHYSADDR; // pointer to 32-bit phys addr

typedef char near *PSTRING; // pointer to character string typedef char far *FPSTRING; // far pointer to string typedef USHORT SHANDLE; // short (16-bit) handle typedef SHANDLE far *PSHANDLE; // pointer to a short handle typedef ULONG LHANDLE; // long (32-bit) handle typedef LHANDLE far *PLHANDLE; // pointer to a long handle

// pointers to functions typedef int (pascal near *PFUNCTION) ; typedef int (pascal near *near *PPFUNCTION) ; typedef int (pascal far *FPFUNCTION) ; typedef int (pascal far * near *PFPFUNCTION) ;

// macros
 * 1) define FALSE 0
 * 2) define TRUE 1
 * 3) define NP near pascal

// far pointer from selector-offset
 * 1) define MAKEP(sel, off) ((void far *) MAKEULONG(off, sel))

// get selector or offset from far pointer
 * 1) define SELECTOROF(p) (((USHORT far *) &(p)) [1])
 * 2) define OFFSETOF(p) (((USHORT far *) &(p)) [0])

// Combine l(ow) & h(igh) to form a 32 bit quantity.
 * 1) define MAKEULONG(l, h) ((ULONG)(((USHORT)(l))|((ULONG)((USHORT)(h))) <<16))
 * 2) define MAKELONG(l, h) ((LONG)MAKEULONG(l, h))
 * 3) define MAKEBIGOFFSETOF(p) ((ULONG) (OFFSETOF (p)))

// Combine l(ow) & h(igh) to form a 16 bit quantity.
 * 1) define MAKEUSHORT(l, h) (((USHORT)(l)) | ((USHORT)(h)) << 8)
 * 2) define MAKESHORT(l, h) ((SHORT)MAKEUSHORT(l, h))

// get high and low order parts of a 16 and 32 bit quantity
 * 1) define LOBYTE(w) LOUCHAR(w)
 * 2) define HIBYTE(w) HIUCHAR(w)
 * 3) define LOUCHAR(w) ((UCHAR)(w))
 * 4) define HIUCHAR(w) (((USHORT)(w) >> 8) & 0xff)
 * 5) define LOUSHORT(l) ((USHORT)(l))
 * 6) define HIUSHORT(l) ((USHORT)(((ULONG)(l) >> 16) & 0xffff))

// the driver device header typedef struct DeviceHdr { struct DeviceHdr far *DHnext; // pointer to next header, or FFFF USHORT DHattribute;        // device attribute word OFFDHstrategy;             // offset of strategy routine OFFDHidc;                  // offset of IDC routine UCHAR DHname[8];           // dev name (char) or #units (blk) char reserved[8]; ULONG bit_strip;           // bit 0 DevIOCtl2 } DEVICEHDR; typedef DEVICEHDR near *PDEVICEHDR;

// driver device attributes word
 * 1) define DAW_CHR 0x8000 // 1=char, 0=block
 * 2) define DAW_IDC 0x4000 // 1=IDC available in this DD
 * 3) define DAW_IBM 0x2000 // 1=non-IBM block format
 * 4) define DAW_SHR 0x1000 // 1=supports shared device access
 * 5) define DAW_OPN 0x0800 // 1=open/close, removable media
 * 6) define DAW_LEVEL 1 0x0080 // level 1
 * 7) define DAW_LEVEL 2 0x0100 // level 2 DosDevIOCtl2
 * 8) define DAW_LEVEL 3 0x0180 // level 3 bit strip
 * 9) define DAW_GIO 0x0040 // 1=generic IOCtl supported
 * 10) define DAW_CLK 0x0008 // 1=CLOCK device
 * 11) define DAW_NUL 0x0004 // 1=NUL device
 * 12) define DAW_SCR 0x0002 // 1=STDOUT (screen)
 * 13) define DAW_KBD 0x0001 // 1=STDIN (keyboard)

// capabilities bit strip
 * 1) define CBS_SHD 0x0001 // 1=shutdown/DevIOCtl2
 * 2) define CBS_HMEM 0x0002 // high memory map for adapters
 * 3) define CBS_PP 0x0004 // supports parallel ports
 * 4) define CBS_ADD 0x0010 // driver is an ADD
 * 5) define CBS_INIT 010020 // driver receives InitComplete

// SaveMessage structure typedef struct MessageTable { USHORT id; USHORT fill_in_item; FARPOINTER item1; FARPOINTER item2; FARPOINTER item_last; } MESSAGETABLE;

// OS/2 circular character queues typedef struct CharQueue { USHORT qsize; // number of bytes in queue USHORT qchrout; // index of next char to put out USHORT qcount; // number of charactes in queue UCHAR qbuf[QUEUE_SIZE]; } CHARQUEUE;
 * 1) define QUEUE_SIZE 512 // size of queues

typedef CHARQUEUE near *PCHARQUEUE;

// AttachDD inter device driver communication data area typedef struct AttachArea { OFF realOFF; // offset of idc entry point SEG realCS; // real-mode CS of IDC entry point SEG realDS; // real-mode DS of IDC DD OFF protOFF; // protect-mode offset of entry pt SEL protCS; // protect-mode CS of entry point SEL protDS; // protect-mode DS of other DD } ATTACHAREA;

typedef ATTACHAREA near *PATTACHAREA;

// driver request packet typedef struct ReqPacket { UCHAR RPlength; // request packet length UCHAR RPunit; // unit code for block DD only UCHAR RPcommand; // command code USHORT RPstatus; // status word UCHAR RPreserved[4]; // reserved bytes ULONG RPqlink; // queue linkage

union {// command-specific data UCHAR avail[19]; struct {// init UCHAR units; // number of units FPFUNCTION DevHlp; // &DevHlp char far *args; // &args UCHAR drive; // drive # }Init;

struct { UCHARunits; // same as input OFFfinalCS; // final offset, 1st code segment OFFfinalDS; // final offset, 1st data segment FARPOINTER BPBarray; // &BPB } InitExit;

struct {// read, write, write w/verify UCHAR media; // media descriptor PHYSADDR buffer; // transfer address USHORT count; // bytes/sectors ULONG startsector; // starting sector# USHORT reserved; } ReadWrite;

struct { // cached rd, wr, write w/verify UCHAR media; // media descriptor PHYSADDR buffer; // transfer address USHORT count; // bytes/sectors ULONG startsector; // starting sector# USHORT reserved; } CReadWrite;

struct {// system shutdown UCHAR subcode; // sub request code ULONG reserved; } Shutdown;

struct {// open/close USHORT sysfilenum; // system file number } OpenClose;

struct { // IOCtl UCHAR category; // category code UCHAR function; // function code FARPOINTER parameters; // &parameters FARPOINTER buffer; // &buffer } IOCtl;

struct { // read, no wait UCHAR char_returned; // char to return } ReadNoWait;

struct { // media check UCHAR media; // media descriptor UCHAR return_code; // see #defines FARPOINTER prev_volume; // &previous volume ID } MediaCheck;

struct {// build BPB UCHAR media; // media descriptor FARPOINTER buffer; // 1-sector buffer FAT FARPOINTER BPBarray; // &BPB array UCHAR drive; // drive # } BuildBPB;

struct { // query part. fixed disks UCHAR count; // # disks ULONG reserved; } Partitionable;

struct { // fixed disk LU map ULONG units; // units supported ULONG reserved; } GetFixedMap;

struct { // get driver capabilities UCHAR reserved[3]; FARPOINTER capstruct; // 16:16 pointer to DCS FARPOINTER volcharstruct; // 16:16 pointer to VCS } GetDriverCaps; } s;// command info

} REQPACKET;

typedef REQPACKET far *PREQPACKET; typedef PREQPACKET far *PPREQPACKET; typedef PREQPACKET QHEAD; // Queue Head is &ReqPacket typedef QHEAD near *PQHEAD;

// Global Info Seg typedef struct _GINFOSEG { ULONG   time; ULONG   msecs; UCHAR   hour; UCHAR   minutes; UCHAR   seconds; UCHAR   hundredths; USHORT  timezone; USHORT  cusecTimerInterval; UCHAR   day; UCHAR month; USHORT year; UCHAR weekday; UCHAR uchMajorVersion; UCHAR uchMinorVersion; UCHAR   chRevisionLetter; UCHAR   sgCurrent; UCHAR sgMax; UCHAR cHugeShift; UCHAR fProtectModeOnly; USHORT pidForeground; UCHAR fDynamicSched; UCHAR csecMaxWait; USHORT cmsecMinSlice; USHORT cmsecMaxSlice; USHORT bootdrive; UCHAR amecRAS[32]; UCHAR csgWindowableVioMax; UCHAR   csgPMMax; } GINFOSEG;

typedef GINFOSEG far *PGINFOSEG;

// local info seg typedef struct _LINFOSEG { PIDpidCurrent; PIDpidParent; USHORT prtyCurrent; TIDtidCurrent; USHORT sgCurrent; UCHARrfProcStatus; UCHARdummy1; USHORT fForeground; UCHAR typeProcess; UCHAR dummy2; SELselEnvironment; USHORT offCmdLine; USHORT cbDataSegment; USHORT cbStack; USHORT cbHeap; USHORT hmod; SELselDS; } LINFOSEG; typedef LINFOSEG far *PLINFOSEG;

typedef struct _REGSTACK { // stack usage structure USHORT usStruct; // set to 14 before using USHORT usFlags; // 0x01 means that the interrupt proc // enables interrupts. All others resvd USHORT usIRQ; // IRQ of interrupt handler USHORT usStackCLI; // # of stack bytes with interrupts off USHORT usStackSTI; // # of stack bytes with interrupts on USHORT usStackEOI; // number of bytes needed after EOI USHORT usNest; // max number of nested levels } REGSTACK; typedef REGSTACK near *PREGSTACK;

// page list struct typedef struct _PAGELIST { ULONG pl_Physaddr; ULONG pl_cb; } PAGELIST; typedef PAGELIST far *PPAGELIST;

// RPstatus bit values
 * 1) define RPERR 0x8000 // error occurred, err in RPstatus
 * 2) define RPDEV 0x4000 // error code defined by driver
 * 3) define RPBUSY 0x0200 // device is busy
 * 4) define RPDONE 0x0100 // driver done with request packet

// error codes returned in RPstatus
 * 1) define ERROR_WRITE_PROTECT 0x0000
 * 2) define ERROR_BAD_UNIT 0x0001
 * 3) define ERROR_NOT_READY 0x0002
 * 4) define ERROR_BAD_COMMAND 0x0003
 * 5) define ERROR_CRC 0x0004
 * 6) define ERROR_BAD_LENGTH 0x0005
 * 7) define ERROR_SEEK 0x0006
 * 8) define ERROR_NOT_DOS_DISK 0x0007
 * 9) define ERROR_SECTOR_NOT_FOUND 0x0008
 * 10) define ERROR_OUT_OF_PAPER 0x0009
 * 11) define ERROR_WRITE_FAULT 0x000A
 * 12) define ERROR_READ_FAULT 0x000B
 * 13) define ERROR_GEN_FAILURE 0x000C
 * 14) define ERROR_DISK_CHANGE 0x000D
 * 15) define ERROR_WRONG_DISK 0x000F
 * 16) define ERROR_UNCERTAIN_MEDIA 0x0010
 * 17) define ERROR_CHAR_CALL_INTERRUPTED 0x0011
 * 18) define ERROR_NO_MONITOR_SUPPORT 0x0012
 * 19) define ERROR_INVALID_PARAMETER 0x0013
 * 20) define ERROR_DEVICE_IN_USE 0x0014

// driver request codes B=block, C=character
 * 1) define RPINIT 0x00 // BC
 * 2) define RPMEDIA_CHECK 0x01 // B
 * 3) define RPBUILD_BPB 0x02 // B
 * 4) define RPREAD 0x04 // BC
 * 5) define RPREAD_NO_WAIT 0x05 // C
 * 6) define RPINPUT_STATUS 0x06 // C
 * 7) define RPINPUT_FLUSH 0x07 // C
 * 8) define RPWRITE 0x08 // BC
 * 9) define RPWRITE_VERIFY 0x09 // BC
 * 10) define RPOUTPUT_STATUS 0x0a // C
 * 11) define RPOUTPUT_FLUSH 0x0b // C
 * 12) define RPOPEN 0x0d // BC
 * 13) define RPCLOSE 0x0e // BC
 * 14) define RPREMOVABLE 0x0f // B
 * 15) define RPIOCTL 0x10 // BC
 * 16) define RPRESET 0x11 // B
 * 17) define RPGET_DRIVE_MAP 0x12 // B
 * 18) define RPSET_DRIVE_MAP 0x13 // B
 * 19) define RPDEINSTALL 0x14 // C
 * 20) define RPPARTITIONABLE 0x16 // B
 * 21) define RPGET_FIXED_MAP 0x17 // B
 * 22) define RPSHUTDOWN 0x1c // BC
 * 23) define RPGET_DRIVER_CAPS 0x1d // B

// check for monitor call in DosOpen/DosClose
 * 1) define MON_OPEN_STATUS 0x08 // open from DosMonOpen
 * 2) define MON_CLOSE_STATUS 0x08 // close from DosMonClose

// media descriptor byte
 * 1) define MDB_REMOVABLE    0x04 // 1=removable
 * 2) define MDB_EIGHT_SECTORS 0x02 // 1=8 sectors per track
 * 3) define MDB_DOUBLE_SIDED 0x01 // 1=double-sided media

// return codes from MediaCheck
 * 1) define MC_MEDIA_UNCHANGED 0x01
 * 2) define MC_MEDIA_CHANGED0xFF
 * 3) define MC_MEDIA_UNSURE0x00

// event numbers for SendEvent
 * 1) define EVENT_SM_MOUSE 0x00 // session switch via mouse
 * 2) define EVENT_CTRLBRK  0x01 // control break
 * 3) define EVENT_CTRLC    0x02 // control C
 * 4) define EVENT_CTRLNUMLK 0x03 // control num lock
 * 5) define EVENT_CTRLPRTSC 0x04 // control printscreen
 * 6) define EVENT_SHFTPRTSC 0x05 // shift printscreen
 * 7) define EVENT_SM_KBD   0x06 // session switch hot key

// defines for 1.x movedata function
 * 1) define MOVE_PHYSTOPHYS 0 // move phys to phys memory
 * 2) define MOVE_PHYSTOVIRT 1 // move phys to virt memory
 * 3) define MOVE_VIRTTOPHYS 2 // move virt to phys memory
 * 4) define MOVE_VIRTTOVIRT 3 // move virt to virt memory

// Micro Channel specific int NP GetLIDEntry (USHORT,USHORT,USHORT,FPUSHORT); int NP FreeLIDEntry (USHORT); int NP ABIOSCall (USHORT,USHORT,FARPOINTER); int NP ABIOSComm (USHORT,FARPOINTER); int NP GetDeviceBlock(USHORT,FARPOINTER);

// special routines void NP INT3 (void); void NP Enable (void); void NP Disable (void); void NP Abort (void);

int NP SegLimit (SEL,OFF far*); int NP MoveBytes (FARPOINTER,FARPOINTER,FLAG); int NP MoveData (FARPOINTER,FARPOINTER,USHORT,USHORT);

// system services and misc. int NP GetDOSVar (USHORT,FPFARPOINTER); int NP SendEvent (USHORT,USHORT);

void NP SchedClockAddr (PFARPOINTER); int NP AttachDD (PSTRING,PATTACHAREA); int NP InternalError(PSTRING,USHORT);

int NP SaveMessage(FPSTRING); int NP ProtToReal(void); int NP RealToProt(void); int NP SetROMVector(USHORT,PFUNCTION,PFUNCTION,FARPOINTER);

// process mgmt void NP Yield (void); void NP TCYield (void); int NP Block (ULONG,ULONG,USHORT,FARPOINTER); void NP Run (ULONG); void NP DevDone (PREQPACKET); int NP VideoPause(USHORT);

// memory management int NP AllocPhys (ULONG,USHORT,PPHYSADDR); int NP FreePhys (PHYSADDR); int NP VerifyAccess (SEL,OFF,USHORT,USHORT); int NP LockSeg (SEL, USHORT,USHORT,PLHANDLE); int NP UnLockSeg (LHANDLE);

// address conversion int NP AllocGDTSelector(USHORT,FARPOINTER); int NP PhysToGDTSelector(PHYSADDR,USHORT,SEL,PERRCODE); int NP VirtToPhys (FARPOINTER,PPHYSADDR); int NP PhysToUVirt (PHYSADDR,USHORT,USHORT,FPFARPOINTER); int NP PhysToVirt (PHYSADDR,USHORT,USHORT,FARPOINTER); int NP UnPhysToVirt (void);

// request packet queue stuff int NP AllocReqPacket(USHORT,PPREQPACKET); void NP FreeReqPacket (PREQPACKET); void NP PushReqPacket (PQHEAD,PREQPACKET); void NP SortReqPacket (PQHEAD,PREQPACKET); int NP PullReqPacket (PQHEAD,PPREQPACKET); int NP PullParticular(PQHEAD,PREQPACKET);

// driver semaphores int NP SemHandle (LHANDLE,FLAG,PLHANDLE); int NP SemRequest (LHANDLE,ULONG,PERRCODE); void NP SemClear (LHANDLE);

// circular character queues void NP QueueInit (PCHARQUEUE); void NP QueueFlush (PCHARQUEUE); int NP QueueWrite (PCHARQUEUE,UCHAR); int NP QueueRead (PCHARQUEUE,FPUCHAR);

// interrupt stuff int NP SetIRQ (USHORT,PFUNCTION,USHORT); int NP UnSetIRQ (USHORT); int NP EOI (USHORT); void NP ClaimInterrupt(void); void NP RefuseInterrupt(void); int NP RegisterStackUsage(PREGSTACK);

// timer stuff int NP SetTimer (PFUNCTION); int NP ResetTimer (PFUNCTION); int NP TickCount (PFUNCTION,USHORT);

// device monitors int NP MonCreate (PSHANDLE,FARPOINTER,FARPOINTER,PERRCODE); int NP Register (SHANDLE,USHORT,PID,FARPOINTER,OFF,PERRCODE); int NP MonWrite (SHANDLE,POINTER,USHORT,USHORT,ULONG,PERRCODE); int NP MonFlush (SHANDLE,PERRCODE); int NP DeRegister (SHANDLE,PID,PERRCODE);

// 2.0 specfic int NP RegisterPDD(FPUCHAR,FPFUNCTION); int NP RegisterBeep(FPFUNCTION); int NP Beep(USHORT,USHORT); int NP FreeGDTSelector(USHORT); int NP PhysToGDTSel(PHYSADDR,ULONG,SEL,USHORT,FPUSHORT); int NP VMLock(LINADDR,ULONG,LINADDR,LINADDR,ULONG,FPULONG); int NP VMUnlock(LHANDLE); int NP VMAlloc(PLINADDR,ULONG,ULONG,PLINADDR); int NP VMFree(PHYSADDR); int NP VMProcessToGlobal(LINADDR,ULONG,ULONG,PLINADDR); int NP VMGlobalToProcess(LINADDR,ULONG,ULONG,PLINADDR); int NP VirtToLin(FARPOINTER,PLINADDR); int NP LinToGDTSelector(SEL,LINADDR,ULONG); int NP GetDescInfo(SEL,FPUSHORT,FPULONG,FPULONG); int NP LinToPageList(LINADDR,ULONG,LINADDR,FPULONG); int NP PageListToLin(ULONG,LINADDR,PLINADDR); int NP PageListToGDTSelector(SEL,ULONG,LINADDR,USHORT,FPUSHORT); int NP RegisterTmrDD(FPFUNCTION,FPFARPOINTER,FPFARPOINTER); int NP AllocateCtxHook(OFF,ULONG,PLHANDLE); int NP FreeCtxHook(LHANDLE); int NP ArmCtxHook(ULONG,LHANDLE,ULONG); int NP VMSetMem(LINADDR,ULONG,ULONG); int NP OpenEventSem(LHANDLE); int NP CloseEventSem(LHANDLE); int NP PostEventSem(LHANDLE); int NP ResetEventSem(LHANDLE,FPULONG); int NP DynamicAPI(FARPOINTER,USHORT,USHORT,FPUSHORT);

// these are the only API's available to the driver at Init time


 * 1) define APIENTRY far pascal

USHORT APIENTRY DosBeep(USHORT,USHORT); USHORT APIENTRY DosCaseMap(USHORT,FARPOINTER,FARPOINTER); USHORT APIENTRY DosChgFilePtr(SHANDLE,long,USHORT,FARPOINTER); USHORT APIENTRY DosClose(SHANDLE); USHORT APIENTRY DosDelete(FARPOINTER,ULONG); USHORT APIENTRY DosDevConfig(FARPOINTER,USHORT,USHORT); USHORT APIENTRY DosDevIOCtl(FARPOINTER,FARPOINTER,USHORT, USHORT, USHORT); USHORT APIENTRY DosFindClose(SHANDLE); USHORT APIENTRY DosFindFirst(FARPOINTER,FARPOINTER,USHORT, FARPOINTER,USHORT, FARPOINTER, ULONG); USHORT APIENTRY DosFindNext(SHANDLE,FARPOINTER,USHORT,FARPOINTER); USHORT APIENTRY DosGetEnv(FARPOINTER,FARPOINTER); USHORT APIENTRY DosGetMessage(FARPOINTER,USHORT,FARPOINTER,USHORT,USHORT, FARPOINTER, FARPOINTER); USHORT APIENTRY DosOpen(FARPOINTER,FARPOINTER,FARPOINTER,ULONG,USHORT, USHORT, USHORT, ULONG); USHORT APIENTRY DosPutMessage(SHANDLE,USHORT,FARPOINTER); USHORT APIENTRY DosQCurDir(USHORT,FARPOINTER,FARPOINTER); USHORT APIENTRY DosQCurDisk(FARPOINTER,FARPOINTER); USHORT APIENTRY DosQFileInfo(SHANDLE,USHORT,FARPOINTER,USHORT); USHORT APIENTRY DosQFileMode(FARPOINTER,FARPOINTER,ULONG); USHORT APIENTRY DosRead(SHANDLE,FARPOINTER,USHORT,FARPOINTER); USHORT APIENTRY DosWrite(SHANDLE,FARPOINTER,USHORT,FARPOINTER);

// end of DRVLIB.H  ''Figure A-3. Driver library header file, 16-bit.''