home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / linux / 9573 < prev    next >
Encoding:
Text File  |  1992-09-01  |  2.4 KB  |  61 lines

  1. Path: sparky!uunet!mcsun!news.funet.fi!hydra!klaava!torvalds
  2. From: torvalds@klaava.Helsinki.FI (Linus Benedict Torvalds)
  3. Newsgroups: comp.os.linux
  4. Subject: Re: io.h/iopl
  5. Message-ID: <1992Sep1.152745.17949@klaava.Helsinki.FI>
  6. Date: 1 Sep 92 15:27:45 GMT
  7. References: <1992Sep1.123648.18859@cbnewsd.cb.att.com>
  8. Organization: University of Helsinki
  9. Lines: 50
  10.  
  11. In article <1992Sep1.123648.18859@cbnewsd.cb.att.com> asmith@cbnewsd.cb.att.com (arthur.c.smith) writes:
  12. >Hi,
  13. > I have been working on an S3 driver for X and have an 80X86 asm program
  14. >under dos that will setup the S3 chip correctly (and uses the enhanced
  15. >rectangle fill command to clear the screen 8-)). I am trying to port this
  16. >over to Linux. I am having two problems. 1) In trying to use sys_iopl()
  17. >I tried to write it as _syscall1(void,110,int,3) and include unistd.h
  18. >(and __LIBRARY__ defined). I get an error when this compiles. Is there
  19. >a better way to do this?
  20.  
  21. That is not how you are supposed to use the _syscallX macros - they just
  22. build the system call for you. You are supposed to do it like this:
  23.  
  24. static _syscall1(int,iopl,int,level) /* note: no semicolon */
  25.  
  26. main()
  27. {
  28.     if (iopl(3)) {
  29.         perror("iopl");
  30.         exit(1);
  31.     }
  32.     ....
  33. }
  34.  
  35. Also note that gcc-2.2.2d should have the iopl() system call in the
  36. standard library, so the _syscall1() things isn't needed at all if you
  37. use the new gcc. 
  38.  
  39. Then a word of warning: using iopl() is /not/ recommended.  If you do
  40. some stupid programming error, there is simply too big a chance to mess
  41. up: disabling interrupts will totally hose the machine (which is why
  42. iopl() only works for the super-user, but even the super-user should be
  43. careful about it). 
  44.  
  45. If you can get by by using the ioperm() system call (which only works
  46. for the 0-0x3ff range of IO ports), use that instead. ioperm() gives
  47. only access to a selected subset of the IO ports, and doesn't mean you
  48. can disable interrupts etc.
  49.  
  50. >             2) Trying to port to C: When I include /usr/src/linux/
  51. >include/asm/io.h and use outb I get undefined _outb referenced in .text. In
  52. >looking at io.h it appears as if the outb function is defined as extern but
  53. >is also defined in io.h???
  54.  
  55. Sounds weird: the inb() and outb() functions should work fine as long as
  56. you have included <asm/io.h>.  You might want to make sure you have
  57. either "-finline-functions" or "-O" on the gcc command-line: I haven't
  58. checked what gcc thinks about inline-functions without those.
  59.  
  60.         Linus
  61.