home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / HOWTO / MINI / IO-PORT < prev    next >
Encoding:
Text File  |  1995-04-20  |  1.3 KB  |  35 lines

  1. >From riku.saikkonen@compart.fi Tue Oct 18 13:01:34 EDT 1994
  2.  
  3. A number of people have been asking for this...
  4.  
  5. To use IO ports in C programs:
  6. 1. #include <asm/io.h>
  7. 2. Call ioperm(port,num,1) at somewhere near the start of the program
  8. (before accessing ports).
  9. 3. Access ports using value=inb(port) and outb(value,port) (note the
  10. order of the parameters). Look into asm/io.h for more system calls.
  11. 4. Call ioperm(port,num,0) at somewhere near the end of the program
  12. (after all port accesses).
  13. 5. Compile your code with -O2 or a higher number, and no -g. (Sorry, you
  14. can't debug...)
  15. 6. The executable has to be setuid root.
  16.  
  17. ioperm() syntax (also see the man page):
  18. The first parameter is the port number to set permissions of.
  19. The second parameter is the number of consecutive ports to set
  20. permissions of (i.e. if num==3, port, port+1, and port+2 are set).
  21. The third parameter is 1 to give the program permissions or 0 to remove
  22. them.
  23.  
  24. Not too difficult... By the way, if anyone wants to add this to a FAQ or
  25. HOW-TO, feel free (but contact me first).
  26.  
  27. -=- Rjs -=- riku.saikkonen@compart.fi - IRC: Rjs
  28. "From cavern pale the moist moon eyes / the white mists that from earth
  29. arise / to hide the morrow's sun and drip / all the grey day from each
  30. twig's tip." - J. R. R. Tolkien
  31.  
  32.  
  33.  
  34.  
  35.