Link to home
Start Free TrialLog in
Avatar of richgaz
richgaz

asked on

smcinit make

I downloaded this free (so far) bouquet of manure and have got most of the bugs fixed except one;

When I do a make I get an error of too few arguments to function 'pci_get_dev'

the line in questions is
dev = pci_get_dev(acc, BUS-LPC, LPC_DEV, LPC_FUNC);

I cannot find any .h file or anything on the web that gives me any hints on what arguments are missing.  

Please help I am almost there.  I really am hesitant to go to the freebee site since so far nothing they have has fixed what I have mitigated to this point.  It HAS been a challenge.

THx worth buku points to me
Avatar of Duncan Roe
Duncan Roe
Flag of Australia image

If you get this error, the compiler must have gotten a prototype for pci_get_dev from somewhere. You just have to find out where that somewhere is.
On my system, I found one in /usr/include:-
   ./pci/pci.h:121:struct pci_dev *pci_get_dev(struct pci_access *acc, int bus, int dev, int func); /* Raw access to specified device */
That one would seem to agree with the source line you provided. It's a part of the PCI Library: there's no such prototype in the Linux source tree.
Perhaps you have an old version of PCI Library?
Or perhaps I have an old version - you never know
Avatar of richgaz
richgaz

ASKER

Thx duncan I got the past that by simply adding another value of 0 in the second position. but now am in C coding where I really am an alien.  I now get implicit declaration of function for a slew of pci_ "types"  followed by assignment makes pointer from integer without cast.  What the hell does this mean?
Adding 0 is not a fix, sorry. You must get the version of PCI library that the package was written to work with. Otherwise the header file will be wrong and you'll have all manner of trouble (as you are having). Looks like the package was written for an old version of the PCI lib where the function ony took 3 args, probably the first 3. The 4th arg is a function pointer which sounds like the one giving trouble from your description. What made you think the extra arg needed to go in the 2nd position? Post the failing source line if you like - as was originally. Possilbly adding NULL as the 4th arg instead will compile, but I don't fancy its chances of running.
Ok the library comes from pci utils. The master site for this is ftp://atrey.karlin.mff.cuni.cz/pub/linux/pci/
I'm trolling through the old versions to find a match
Oh yes, you posted the original line and it agreed with the prototype that I had. So I have a version of pci-utils that agrees with your code and you have a newer version that doesn't agree.
So far I have found that version 2.1.8 agrees. So you could get, build & install that, but maybe there's a newer one, see next post.
It seems I have pciutils-2.1.11
Yep, pciutils-2.2.0 has the new prototype:
struct pci_dev *pci_get_dev(struct pci_access *acc, int domain, int bus, int dev, int func); /* Raw access to specified device */
2.1.11 was the last 2.1. So if you get that, you should be in business
Avatar of richgaz

ASKER

okay I downloaded and used 2.1.8.of pciutil and that accpeted the pci_get_dev arument of 4.  BUt now I still get
linux:/tmp/smcinit-0.4-1 # make
gcc -c -pipe -Wall -W -O2   -o tosh1800-smcinit.o tosh1800-smcinit.c
gcc  -o tosh1800-smcinit tosh1800-smcinit.o
tosh1800-smcinit.o(.text+0x544): In function `main':
: undefined reference to `pci_alloc'
tosh1800-smcinit.o(.text+0x566): In function `main':
: undefined reference to `pci_filter_init'
tosh1800-smcinit.o(.text+0x57c): In function `main':
: undefined reference to `pci_init'
tosh1800-smcinit.o(.text+0x586): In function `main':
: undefined reference to `pci_scan_bus'
tosh1800-smcinit.o(.text+0x5ae): In function `main':
: undefined reference to `pci_filter_match'
tosh1800-smcinit.o(.text+0x611): In function `main':
: undefined reference to `pci_cleanup'
tosh1800-smcinit.o(.text+0x63a): In function `main':
: undefined reference to `pci_read_byte'
tosh1800-smcinit.o(.text+0x716): In function `main':
: undefined reference to `pci_read_byte'
tosh1800-smcinit.o(.text+0x730): In function `main':
: undefined reference to `pci_write_byte'
collect2: ld returned 1 exit status
make: *** [tosh1800-smcinit] Error 1


I have tried their smcinit and toch2450.c - this one seems to be the cleanest - any suggestions?   Like give it up?
You need to add " -lpci" on the 2nd gcc line.
BTW I'd recommend 2.1.11 of pciutil
Avatar of richgaz

ASKER

When I add that command I get
usr/lib/gcc-lib/i586-suse-linux/3.3.4/../../../../i586-suse-linux/bin/ld: cannot find -lpci
collect2: ld returned 1 exit status
At least you aren't picking up the old one. Did you actually build and install pciutil-2.1.x? (I still recommend you get 2.1.11) The library file libpci.a will be created. If you do a build and not an install, it will be in the source dir somewhere (use "locate libpci.a" to see where it is). You can tell gcc / ld to pick it up from there by adding " -L{dir containing libpci.a}" before " -lpci". The header (.h) file you were having trouble with is for the functions in this library
If it's now in /usr/local/lib you still need -L/usr/local/lib
Any progress?
Avatar of richgaz

ASKER

Right now in between my normal job I am trying to get clean complies of pciutil. I am now into ports.c after correcting filter.c access.c and dump.c.  Then I will be able to point to libpci.a.  I have no /usr/local on this linux SuSE R9.2 OS.  I do have a /usr/locale/lib.  Symantics I guess.  believe me I will let you know.  Your assistance has been greatly appreciated.  
/usr/locale/lib? Sounds like something to do with internationalisation. Ah well...
Avatar of richgaz

ASKER

okay i got the pciutil installed and now with the make smcinit I get
gcc -c -pipe -Wall -W -O2                 -o tosh2450-smcinit.o tosh2450-smcinit.c
o tosh2450-smcinit tosh2450-smcinit.o  lspci
make: o: Command not found
make: [tosh2450-smcinit] Error 127 (ignored)
/usr/bin/install -c -p -D -m 755 -s  tosh2450-smcinit /usr/local/sbin/tosh2450-smcinit
/usr/bin/install: cannot stat `tosh2450-smcinit': No such file or directory
make: *** [install-bin] Error 1
What happened to tosh1800? Looks like a garbled line in the Makefile - can you check that? As if "gcc -" had been chopped off the front and lspci appended instead of -lpci
Avatar of richgaz

ASKER

Here is the makefile - i chose 2450 over 1800 tosh cuz its a later model.   lspci IS the function added by pciutil.  





CC       = gcc
CFLAGS   = -pipe -Wall -W -O2
INCPATH  =
LIBS     = lspci
LIBS1    =
LIBS2    =
LIBS3    =
LINK     =
LFLAGS   =
INSTALL  = /usr/bin/install -c -p
INSTALL_PROGRAM = ${INSTALL} -D -m 755 -s
INSTALL_DATA    = ${INSTALL} -D -m 644
INSTALL_SCRIPT  = ${INSTALL}
INSTALL_HEADER  = $(INSTALL_DATA)
SOURCES1 = tosh2450-smcinit.c
SOURCES  = $(SOURCES1)
OBJECTS1 = $(SOURCES1:%.c=%.o)
OBJECTS  = $(OBJECTS1)
TARGETS1 = tosh2450-smcinit
TARGETS = $(TARGETS1)
The LIBS line is wrong.
The posted Makefile is incomplete surely? There are no targets.
Avatar of richgaz

ASKER

all: $(TARGETS)

install: install-bin

uninstall: uninstall-man uninstall-bin


install-man:
        $(INSTALL_DATA) smcinit.8 $(INSTALL_ROOT)$(PREFIX)/share/man/man8/smcinit.8
        $(INSTALL_DATA) tosh1800-smcinit.8 $(INSTALL_ROOT)$(PREFIX)/share/man/man8/tosh1800-smc$

install-bin: all
        $(INSTALL_PROGRAM) $(TARGETS1) $(INSTALL_ROOT)$(PREFIX)/sbin/$(TARGETS1)
        $(INSTALL_PROGRAM) $(TARGETS2) $(INSTALL_ROOT)$(PREFIX)/sbin/$(TARGETS2)
        $(INSTALL_PROGRAM) $(TARGETS3) $(INSTALL_ROOT)$(PREFIX)/sbin/$(TARGETS3)


uninstall-man:
        rm -f $(INSTALL_ROOT)$(PREFIX)/share/man/man7/smcinit.7
        rm -f $(INSTALL_ROOT)$(PREFIX)/share/man/man8/smcinit.8
uninstall-bin:
        rm -f $(INSTALL_ROOT)$(PREFIX)/sbin/$(TARGETS1)
        rm -f $(INSTALL_ROOT)$(PREFIX)/sbin/$(TARGETS2)
        rm -f $(INSTALL_ROOT)$(PREFIX)/sbin/$(TARGETS3)

clean:
        rm -f $(OBJECTS) $(TARGETS)

%.o: %.c
        $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<

config.h: config.h.in
        ./configure

$(SOURCES1): config.h

$(TARGETS1): $(OBJECTS1)
        $(LINK) $(LFLAGS) -o $(TARGETS1) $(OBJECTS1) $(LIBS1) $(LIBS)

What should the LIBS be that is the cmd that was added with pciutils
LINK = gcc
LIBS = -lpci

or

LIBS = -L{dir where libpci.a is} -lpci
Avatar of richgaz

ASKER

linux:/tmp/smcinit-0.4-1 # make install
gcc -c -pipe -Wall -W -O2                 -o tosh2450-smcinit.o tosh2450-smcinit.c
gcc        -o tosh2450-smcinit tosh2450-smcinit.o  -L{/tmp/pciutils-2.1.8/lib} -lpci
/usr/lib/gcc-lib/i586-suse-linux/3.3.4/../../../../i586-suse-linux/bin/ld: cannot find -lpci
collect2: ld returned 1 exit status
make: *** [tosh2450-smcinit] Error 1
Duncan this is beginning to torque me - when I installed pciutil it installed lspci NOT lpci - is that cammnd the same?  And what is the purpose of ths lpci during link?
Avatar of richgaz

ASKER

OKay I can smell it now!!

Here is where I am now at with this  free source "crap"

inux:/tmp/smcinit-0.4-1 # make install
gcc -c -pipe -Wall -W -O2                 -o tosh2450-smcinit.o tosh2450-smcinit.c
gcc        -o tosh2450-smcinit tosh2450-smcinit.o /tmp/pciutils-2.1.8/lib/libpci.a
/usr/bin/install -c -p  -D -m 755 -s  tosh2450-smcinit /usr/local/sbin/tosh2450-smcinit
/usr/bin/install -c -p  -D -m 755 -s   /usr/local/sbin/
/usr/bin/install: too few arguments
Try `/usr/bin/install --help' for more information.
make: *** [install-bin] Error 1
I didn't mean you to type the curly brackets! Would angle brackets have been any clearer? I'll keep using curlies - now you know.

gcc        -o tosh2450-smcinit tosh2450-smcinit.o  -L/tmp/pciutils-2.1.8/lib -lpci

lspci is a *command*. To load a library, the name of a library must start with "lib"  then you specify -l{rest of library name w/out .a}. Some libraries end .so instead of .a - they're shared libraries - anyway that's why you don't want the library suffix on the build command line.

There is no TARGETS2 or TARGETS3 so the install commands for these will fail. But TARGETS1 should have worked so you should be home:

/usr/bin/install -c -p  -D -m 755 -s  tosh2450-smcinit /usr/local/sbin/tosh2450-smcinit

as you posted has done the job.
Avatar of richgaz

ASKER

well my last hurdle is activating this - any pointers would be great
Either ensure /usr/local/sbin/ is in your PATH and then type "tosh2450-smcinit", or invoke it directly:
   /usr/local/sbin/tosh2450-smcinit
This will run the program. What will it do? - I have no idea. You could consult the man pages: "make install-man" may install them. Then type "man smcinit" or "man tosh1800-smcinit" (maybe tosh2450-smcinit).
Or cd to the source dir, look for files ending .8 or maybe .7 and man them directl;y ("man ./smcinit.8" &c).
Avatar of richgaz

ASKER

Duncan

If this does not pan out for me I must say you have been phenominal.  What I get is this (found no hits on google)
gaz@linux:/etc/init.d/rc5.d> /usr/local/sbin/tosh2450-smcinit
Trying method 1......using /proc/bus/pci...OK
Decided to use /proc/bus/pci
tosh2450-smcinit IO hub device 248c not supported.
ASKER CERTIFIED SOLUTION
Avatar of Duncan Roe
Duncan Roe
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of richgaz

ASKER

I found earlier a doc which described changes to smcinit.c I made them but currently at work so I will not be able to test them until later.  

Thx Duncan - You canclose this and acceptm the points.  Yeoman effort again thx.
Avatar of richgaz

ASKER

If this doesn;t work well time to get a Cicsco wireless plugin card.