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