From: shedd timothy allen Newsgroups: comp.os.msdos.djgpp Subject: Device driver needs segment:offset info Date: Sun, 2 Mar 1997 18:39:04 -0600 Organization: University of Illinois at Urbana Lines: 59 Message-ID: NNTP-Posting-Host: ehsn8.cen.uiuc.edu Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp I am trying to port some older C code (circa 1992, apparently for MS C compiler) to djgpp. This code makes up a couple of libraries used to control a vintage TARGA+ framegrabber. I thought I had successfully jumped through the "far" pointer hoops until I realized that these pointers were being passed to the device driver itself, and naively replacing FP_OFF and FP_SEG produced unpredictable results. I have read the FAQ, browsed the DPMI docs and have done some dancing around in the mail archives. Unfortunately, I have no experience with dealing with interrupts and machine-level memory issues (or memory issues at all, for that matter) and, to make matters worse, am a novice with C/C++ (So why am I doing this? I'm a grad student, of course, trying to make old equipment work with new research projects.) As a result, if the answer is in the documentation, I have missed it and I apologize in advance. Would anyone be able to help with the following scenario? The code sets up an IOCommand structure to pass to the driver. The IOCommand structure is passed to the driver by means of an INT 0x21. The driver then writes (or reads) the registers of the framegrabber from (to) the structure TPlusRegs. Along with misc. data, the IOCommand structure contains the following lines to pass along the pointer to the TPlusRegs structure: unsigned short IORegsOff; /*Structure Buffer Ptr Offset*/ unsigned short IORegsSeg; /*Structure Buffer Ptr Segment*/ In the library functions, communication with the driver goes something like this: >>SetRegs: /*Create a pointer to the command structure: */ IOCommandPtr fp; /*Set up the registers for an interrupt call: */ r->x.dx = FP_OFF(fp); /*where r is of type REGS...offset of address of pointer to IOCommand structure */ s->ds = FP_SEG(fp); /*where s is of type SREGS...segment of address of pointer to IOCommand structure */ r->x.ax = 0x4403; /* IOCtl Write */ r->x.bx = TPlusHandle; r->x.cx = sizeof(IOCommand); >>WriteAll: TplusRegsPtr p; /*Pointer to structure containing TPlus Register data to be written */ IOCommand.IORegsOff = FP_OFF(p) ; /* offset of location of TPlusRegs Data */ IOCommand.IORegsSeg = FP_SEG(p); /* segment of location of TPlusRegs Data */ int86x(0x21,®s,®s,&sregs); /*where regs is of type REGS and set as above and sregs is of type SREGS and set as above */