home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / os / os2 / programm / 3744 < prev    next >
Encoding:
Text File  |  1992-07-23  |  2.0 KB  |  46 lines

  1. Newsgroups: comp.os.os2.programmer
  2. Path: sparky!uunet!mcsun!Germany.EU.net!news.netmbx.de!zrz.tu-berlin.de!math.fu-berlin.de!informatik.tu-muenchen.de!rommel
  3. From: rommel@Informatik.TU-Muenchen.DE (Kai-Uwe Rommel)
  4. Subject: Re: IOPL or Accessing hardware ports
  5. Keywords: IOPL Ring 2
  6. References: <4012@news.duke.edu>
  7. Sender: news@Informatik.TU-Muenchen.DE (USENET Newssystem)
  8. Organization: Technische Universitaet Muenchen, Germany
  9. Date: Thu, 23 Jul 1992 18:44:22 GMT
  10. Message-ID: <1992Jul23.184422.24547@Informatik.TU-Muenchen.DE>
  11. Lines: 33
  12.  
  13. In article <4012@news.duke.edu> jan@acpub.duke.edu (Jan Gittelman) writes:
  14. >Hi,
  15. >
  16. >Has anyone managed to use IOPL to access hardware ports? I'm having trouble 
  17. >with it. I get an access violation (SYS3175) whenever the code tries to call 
  18. >a subroutine in the IOPL'd (ring 2) segment.
  19. >
  20. >I'm currently using a 16 bit compiler (Microsoft 6.00A) and assembler 
  21. >(Microsoft 5.1). There are 6 assembler subroutines that do the actual 
  22. >i/o and the rest of the code is written in C. I have a .DEF file to define the
  23. >assembler routines segment as IOPL and list the exported subroutines. In fact,
  24. >it follows the examples in both Duncan's "Advanced OS/2 Programming" and 
  25. >Steven Mastrianni's "Writing OS2 2.0 Device Drivers in C".
  26.  
  27. I have used IOPL code in my SCRUTIL screen saver. This is a 16-bit
  28. program, and I have not yet tried such things in a 32-bit app. You need
  29. to follow the following steps:
  30.  
  31. - isolate the code with I/O instructions in one segment (use MS C -NT
  32.   option to give this module a special name instead of _TEXT)
  33. - mark this segment name as IOPL in the module definition file
  34. - use the DosPortAccess call before doing actual port I/O
  35. - set IOPL=YES in config.sys or add the module name to the IOPL list
  36.  
  37. This is what I did in SCRUTIL and it works under 1.x and 2.0.
  38.  
  39. Kai Uwe Rommel
  40.  
  41. /* Kai Uwe Rommel --- rommel@informatik.tu-muenchen.de */
  42.  
  43. DOS ... is still a real mode only non-reentrant interrupt
  44. handler, and always will be.                -Russell Williams
  45.  
  46.