INF: Programming DB-Library TSR with MS-DOS ExtendersID: Q75295
|
The MS-DOS DB-Library (DB-Lib) versions 1.1 and later use a terminate-and-stay-resident (TSR) utility to interface with the network. This utility, written to the OpenNet specification, is the connection between DB-Lib and whatever network the TSR is coded to communicate with. Because this utility is a TSR, interrupts are required to allow code execution paths from DB-Lib to the TSR. When the MS-DOS Extenders are used in protected mode, the interrupt driver scheme in DB-Lib fails to correctly interface with the TSR in real mode. This document is designed to provide enough information to the DB-Lib application developer to correctly call the TSR from protected mode to real mode.
The TSR consists of eight C routines managed by an assembly language
interrupt manager. The eight routines are accessed via INT 62H, with
AH containing the index to the requested function. The indexes are as
follows:
0 - ConnectionObjectSize
1 - ConnectionOpen
2 - ConnectionRead
3 - ConnectionWrite
4 - ConnectionTransact
5 - ConnectionWriteOOB
6 - ConnectionClose
7 - ConnectionCheckForData
short API
ConnectionTransact(map,ConnectionObject,readbuffer,writebuffer,writeco
unt,readcount,readmax,TimeOut,neterrno)
void *ConnectionObject;
unsigned char *readbuffer;
unsigned char *writebuffer;
unsigned short writecount;
unsigned short readcount;
unsigned short readmax;
short TimeOut;
short *neterrno;
push word (2 bytes: this is the index to the TSR function)
push far void pointer (4 bytes: ConnectionObject)
push far unsigned char pointer (4 bytes: readbuffer)
push far unsigned char pointer (4 bytes: writebuffer)
push word (2 bytes: writecount)
push word (2 bytes: readcount)
push word (2 bytes: readmax)
push word (2 bytes: TimeOut)
push short far pointer (4 bytes: neterrno)
API defines to: cdecl far
/* This structure defines the extra bytes pushed on the stack by the
** series of calls to get from an application to the TSR entry point
** for each C function. These bytes must be accounted for in order for
** the function to correctly index into the stack to get its parameters.
** Remember, this module is ALWAYS compiled in LARGE model, and all
** pointers passed to it are FAR.
*/
typedef struct intrmap
{
int intr_man_ds; /* interrupt manager DS save */
void far *intr_return; /* interrupt return address */
int intr_flags; /* flags */
int intr_call_si; /* save of SI by interrupt caller */
int intr_call_di; /* save of DI by interrupt caller */
int intr_call_bp; /* save of BP by interrupt caller */
void far *intr_call_ret; /* return address of interrupt caller */
int index;
} INTRMAP;
unsigned short API ConnectionRead(map,ConnectionObject,
buffer,readsize,MaxSize,TimeOut,neterrno)
INTRMAP map;
void *ConnectionObject;
unsigned char *buffer; // 512 bytes long
unsigned short readsize;
unsigned short MaxSize;
unsigned short TimeOut;
unsigned short *neterrno;
short API
ConnectionWrite(map,ConnectionObject,buffer,Writecount,neterrno)
INTRMAP map;
void *ConnectionObject;
unsigned char *buffer; // 512 bytes long
short Writecount;
short *neterrno;
short API
ConnectionTransact(map,ConnectionObject,readbuffer,writebuffer,writeco
unt,readcount,readmax,TimeOut,neterrno)
INTRMAP map;
void *ConnectionObject;
unsigned char *readbuffer; // 512 bytes long
unsigned char *writebuffer; // 512 bytes long
unsigned short writecount;
unsigned short readcount;
unsigned short readmax;
short TimeOut;
short *neterrno;
short API ConnectionWriteOOB(map,ConnectionObject, buffer,
OOBsize,neterrno)
INTRMAP map;
void *ConnectionObject;
unsigned char *buffer; // OOBsize bytes long
short OOBsize;
short *neterrno;
short API ConnectionOpen(map,ConnectionObject,ServerName,neterrno)
INTRMAP map;
void *ConnectionObject;
char *ServerName; // null terminated string, variable length
short *neterrno;
short API ConnectionClose(map,ConnectionObject,neterrno)
INTRMAP map;
void *ConnectionObject;
short *neterrno;
short API
ConnectionCheckForData(map,ConnectionObject,bytesavail,neterrno)
INTRMAP map;
void *ConnectionObject;
long *bytesavail; /* pointer to buffer for number of bytes
available */
short *neterrno;
jmp short start ; jump around signature
db 'DBLIBRARY' ; signature
start:
... ; execution code
Additional query words: dblib
Keywords : kbprg SSrvDB_Lib
Version : 4.2
Platform : OS/2
Issue type :
Last Reviewed: March 11, 1999