can't compile with inb(), outb(); linking errors

can't compile with inb(), outb(); linking errors

Post by Randall Jon » Wed, 29 Nov 1995 04:00:00



Hi.

  I'm trying to write a *very* basic hardware interface to a card I have.
I'm trying to use the outb() and inb() functions under C.
#include <asm/io.h>

main() { outb (0x00, 0x2e1); }

  This compiles fine, but wont link...


Reading specs from /usr/lib/gcc-lib/i486-linux/2.7.0/specs
gcc version 2.7.0
 /usr/i486-linux/bin/ld -m elf_i386 -dynamic-linker /lib/ld-linux.so.1 -o poke
/usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o
-L/usr/lib/gcc-lib/i486-linux/2.7.0 -L/usr/i486-linux/lib poke.o -lgcc -lc
-lgcc /usr/lib/crtend.o /usr/lib/crtn.o
poke.o(.text+0x54): undefined reference to `__outbc'
poke.o(.text+0x6b): undefined reference to `__outb'

Is the io stuff in a different library?  I've looked around with no luck.

..also, I don't seem to have man pages for outb() and inb().  where might I
find these?

TIA for the help!

++
Randall Jones

NRAO AOC - Interference Protection
--
++
Randall Jones

NRAO AOC - Interference Protection

 
 
 

can't compile with inb(), outb(); linking errors

Post by Andrew Miles » Thu, 30 Nov 1995 04:00:00



>   I'm trying to write a *very* basic hardware interface to a card I have.
> I'm trying to use the outb() and inb() functions under C.
> #include <asm/io.h>
> main() { outb (0x00, 0x2e1); }
>   This compiles fine, but wont link...

Add -O2 to the GCC command line.

I think you'll find the explanation in the GCC manual under inline functions.

Some pretty ugly macros make inb() and outb() work. For details, run that
test program of yours through the preprocessor (option -E) and look at
the output. The results ain't pretty...but it makes more sense than the
header file.

-- Andrew E. Mileski --

-------------------------------------------------------
Dark Matter Technologies Inc. - Ottawa Ontario, Canada!


 
 
 

can't compile with inb(), outb(); linking errors

Post by Jay Goldbe » Thu, 30 Nov 1995 04:00:00



says...

>Hi.

>  I'm trying to write a *very* basic hardware interface to a card I have.
>I'm trying to use the outb() and inb() functions under C.
>#include <asm/io.h>

>main() { outb (0x00, 0x2e1); }

>  This compiles fine, but wont link...


>Reading specs from /usr/lib/gcc-lib/i486-linux/2.7.0/specs
>gcc version 2.7.0
> /usr/i486-linux/bin/ld -m elf_i386 -dynamic-linker /lib/ld-linux.so.1 -o
poke
>/usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o
>-L/usr/lib/gcc-lib/i486-linux/2.7.0 -L/usr/i486-linux/lib poke.o -lgcc -lc
>-lgcc /usr/lib/crtend.o /usr/lib/crtn.o
>poke.o(.text+0x54): undefined reference to `__outbc'
>poke.o(.text+0x6b): undefined reference to `__outb'

>Is the io stuff in a different library?  I've looked around with no luck.

>..also, I don't seem to have man pages for outb() and inb().  where might I
>find these?

>TIA for the help!

I am not one to talk because I am having my own problems writing a kernel
driver but I don't think you are supposed to link it that way.  I think
linking it into the kernel or if writing a loadable module just use
insmod on the .o file.

--
Procrastinate now!
Jay Goldberg


http://www.tlmworks.com/People/jrg/jhp.html
http://www.iwl.net/customers/jayg

 
 
 

can't compile with inb(), outb(); linking errors

Post by Rogier Wol » Fri, 01 Dec 1995 04:00:00



: says...
: >
: >
: >Hi.
: >
: >  I'm trying to write a *very* basic hardware interface to a card I have.
: >I'm trying to use the outb() and inb() functions under C.
: >#include <asm/io.h>
: >
: >main() { outb (0x00, 0x2e1); }
: >
: >  This compiles fine, but wont link...
: >

Try
        gcc -c -O2 poke.c

This will allow it to be linked with your link line. It will segv on
execution though.

YOu need to add something like
        ioperm (0x2e1,1,1);
before the outb to make it work. The ioperm will fail if you don't have
root privilidges.... (make it setuid-root or run it as root.)

By the way, Maybe we should make a library entry for this. To prevent
these stupid errors. (Who is maintaining "libc"?)

                                Roger.

--
 *** War doesn't determine who's right ****** War determines who's left. ***

 *** <a href="http://einstein.et.tudelft.nl/~wolff/">my own homepage</a> ***

 
 
 

can't compile with inb(), outb(); linking errors

Post by Riku Saikkon » Sat, 02 Dec 1995 04:00:00



>  I'm trying to write a *very* basic hardware interface to a card I have.
>I'm trying to use the outb() and inb() functions under C.

See ftp://sunsite.unc.edu/pub/Linux/docs/HOWTO/mini/IO-Port-Programming or
http://isil.lloke.dna.fi/rjs/tech-writing/ioportprog.html for my I/O port
programming mini-HOWTO.

--

"And with great power comes great responsibility. Use it wisely."
 - AD&D 2nd edition Dungeon Master's Guide

 
 
 

can't compile with inb(), outb(); linking errors

Post by Nat Makarevit » Mon, 04 Dec 1995 04:00:00



 [ problems when linking object files with outb() and inb() calls ]

 RW> Try gcc -c -O2 poke.c

Please be careful with -O2 because some recent versions of gcc may produce
broken binaries. Use at least "-O2 -fno-strength-reduce"

I think that versions 2.7.1 and up are OK.

--
Linux

 
 
 

can't compile with inb(), outb(); linking errors

Post by Koyama Tadayos » Thu, 07 Dec 1995 04:00:00





>    [ problems when linking object files with outb() and inb() calls ]

>    RW> Try gcc -c -O2 poke.c

>   Please be careful with -O2 because some recent versions of gcc may produce
>   broken binaries. Use at least "-O2 -fno-strength-reduce"

 Is there any option to generate these code inlined other than -O[n] ?
it seems that -finline-functions doesn't do this.
--


 
 
 

can't compile with inb(), outb(); linking errors

Post by John Sulliv » Fri, 15 Dec 1995 04:00:00






> [ problems when linking object files with outb() and inb() calls ]

> RW> Try gcc -c -O2 poke.c

>Please be careful with -O2 because some recent versions of gcc may produce
>broken binaries. Use at least "-O2 -fno-strength-reduce"

>I think that versions 2.7.1 and up are OK.

2.7.2 was the latest out when I checked last week. It seems to have
severe problems compiling stuff with asm()s (something about
incompatible constraints). For example, it doesn't like SVGATextMode,
or kernels 1.2.13, 1.3.18. GCC 2.7.0 seems to be safe, and I'd stick
with that, I don't think -O2 breaks it either.

You could always write the IO bits in pure asm and link those in
seperately (makes porting easier too since you know which bits have to
change. If that's a worry of course...)

You should also check the ioperm() call since your program as it
stands will fail even if it compiles - you need to request (as root)
privilege to access the relavent IO areas. Just being root shouldn't
be sufficient to do random in/out() calls.

John
--
I've got nothing to do
'cept hang around here and get screwed up on you.
<a href="http://callisto.girton.cam.ac.uk/users/js10039/">Me!</a>

 
 
 

can't compile with inb(), outb(); linking errors

Post by Leonard N. Zubkof » Fri, 15 Dec 1995 04:00:00


  2.7.2 was the latest out when I checked last week. It seems to have
  severe problems compiling stuff with asm()s (something about
  incompatible constraints). For example, it doesn't like SVGATextMode,
  or kernels 1.2.13, 1.3.18. GCC 2.7.0 seems to be safe, and I'd stick
  with that, I don't think -O2 breaks it either.

I believe the problem is in the source code, not GCC.  The following patch
fixes the problem with GCC 2.7.2 compiling Linux 1.2.13.  I believe GCC
2.7.2 has just become more strict in its constraints, compared to earlier
versions.

                Leonard

--- ./linux/include/asm-i386/io.h-      Mon Aug 15 00:56:19 1994

 #define __OUT(s,s1,x) \
 __OUT1(s,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); } \
-__OUT1(s##c,x) __OUT2(s,s1,"") : : "a" (value), "i" (port)); } \
+__OUT1(s##c,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); } \
 __OUT1(s##_p,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); SLOW_DOWN_IO; } \
-__OUT1(s##c_p,x) __OUT2(s,s1,"") : : "a" (value), "i" (port)); SLOW_DOWN_IO; }
+__OUT1(s##c_p,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); SLOW_DOWN_IO; }

 #define __IN1(s) \

 #define __IN(s,s1,i...) \
 __IN1(s) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) ,##i ); return _v; } \
-__IN1(s##c) __IN2(s,s1,"") : "=a" (_v) : "i" (port) ,##i ); return _v; } \
+__IN1(s##c) __IN2(s,s1,"") : "=a" (_v) : "id" (port) ,##i ); return _v; } \
 __IN1(s##_p) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) ,##i ); SLOW_DOWN_IO; return _v; } \
-__IN1(s##c_p) __IN2(s,s1,"") : "=a" (_v) : "i" (port) ,##i ); SLOW_DOWN_IO; return _v; }
+__IN1(s##c_p) __IN2(s,s1,"") : "=a" (_v) : "id" (port) ,##i ); SLOW_DOWN_IO; return _v; }

 #define __INS(s) \
 extern inline void ins##s(unsigned short port, void * addr, unsigned long count) \

 
 
 

1. Inb, outb in Interactive SVR3.2

Hello
How to make direct I/O in user space in Interactive SVR3.2 v.4.1?
There are inb and outb defined in sys/inline.h. However, their execution
in a C program results in segmentation fault. How to make the I/O ports
accessible for a user program? Linux has iopl, ioperm, BSD/OS has ioport
for this purpose. Is there something like that in Interactive Unix?
Any help will be appreciated.

Andri

2. IP Forwarding...

3. outb/inb functions?

4. Proper perfect filter setup for xircom_tulip_cb.c

5. inb, outb questions

6. ethernet drivers for DEC pathworks cards

7. inb and outb

8. Multiple Boot Set-up

9. inb/inb_p; outb/outb_p

10. Debugging "outb" and "inb"

11. inb and outb

12. inb and outb gives trouble after Kernel 2.4 upgrade

13. outb, inb, modules