home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / portio.zip / readme < prev    next >
Text File  |  1993-05-03  |  2KB  |  58 lines

  1. To:   Laboratory users of OS/2
  2. From: Michael Thompson
  3.       tommy@msc.cornell.edu
  4. RE:   portio.h, portio.lib, portio.dll
  5.       Access to I/O ports from IBM CSET/2 programs
  6. Date: 3-May-93
  7.  
  8. Routines:
  9.    unsigned short inp  (unsigned short port)
  10.    unsigned short inpw (unsigned short port)
  11.    unsigned short outp (unsigned short port, unsigned short byte)
  12.    unsigned short outpw(unsigned short port, unsigned short word)
  13.  
  14. The removal of inp/outp/inpw/outpw in the migration from Microsoft
  15. C6.0 to IBM CSET/2 was very disappointing.  Drivers for laboratory
  16. data acquisition cards simply do not exist under OS/2.  Over the
  17. last few months, I have received numerous requests to provide
  18. example code showing how we directly access I/O ports through OS/2
  19. with the IBM CSET/2 compiler.  Rather than continue to point people
  20. to complex code, I've extracted and more thoroughly documented the
  21. necessary calls and assembly language interludes.
  22.  
  23. The trick to creating these replacements was gleaned from the CSET/2
  24. User Manual section on calling 16:16 C-routines.  Basically, the
  25. inp/outp C calls are passed to an assembly language routine which
  26. runs at Ring 2 with IOPL priveleges.  The procedures use the
  27. _Fastcall convention passing all values in registers and hence
  28. should be reasonably fast.
  29.  
  30. Because of the mixed programming modes (flat 32 and 16:16 asm
  31. interlude), there are some subleties to linking and usage.  The
  32. simplest mode is to use the DLL version of the portio routines.
  33.  
  34. DLL version:
  35.   (1) place portio.dll somewhere within the scope of your LIBPATH
  36.   (2) #include "portio.h" in your C program
  37.   (3) link with the portio.lib
  38.  
  39. In a slightly more complex mode, you can statically link the
  40. routines.  However, you must include a .DEF file to give the
  41. inp/outp routines IOPL priveleges.  See the TEST2.DEF example
  42. for the necessary SEGMENT declarations.
  43.  
  44. Static linkage version:
  45.   (1) #include "portio.h" in your C program
  46.   (2) link with portio.obj and an appropriate .DEF file
  47.  
  48. The program test.c is an example direct I/O handler that outputs
  49. a simple string to the printer via direct addressing.  It is
  50. linked with the dynamic module (test.exe) and as a static link
  51. version (test2.exe).  See the makefile for additional comments.
  52.  
  53. Please pass any comments (or if you know of the solution to 
  54. modifying an ASM segment in the .DEF file) to me at the above
  55. address.
  56.  
  57. Good luck.
  58.