• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 923
  • Last Modified:

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
0
richgaz
Asked:
richgaz
  • 18
  • 13
1 Solution
 
Duncan RoeSoftware DeveloperCommented:
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?
0
 
Duncan RoeSoftware DeveloperCommented:
Or perhaps I have an old version - you never know
0
 
richgazAuthor Commented:
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?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Duncan RoeSoftware DeveloperCommented:
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.
0
 
Duncan RoeSoftware DeveloperCommented:
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
0
 
Duncan RoeSoftware DeveloperCommented:
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.
0
 
Duncan RoeSoftware DeveloperCommented:
It seems I have pciutils-2.1.11
0
 
Duncan RoeSoftware DeveloperCommented:
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
0
 
richgazAuthor Commented:
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?
0
 
Duncan RoeSoftware DeveloperCommented:
You need to add " -lpci" on the 2nd gcc line.
BTW I'd recommend 2.1.11 of pciutil
0
 
richgazAuthor Commented:
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
0
 
Duncan RoeSoftware DeveloperCommented:
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
0
 
Duncan RoeSoftware DeveloperCommented:
If it's now in /usr/local/lib you still need -L/usr/local/lib
0
 
Duncan RoeSoftware DeveloperCommented:
Any progress?
0
 
richgazAuthor Commented:
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.  
0
 
Duncan RoeSoftware DeveloperCommented:
/usr/locale/lib? Sounds like something to do with internationalisation. Ah well...
0
 
richgazAuthor Commented:
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
0
 
Duncan RoeSoftware DeveloperCommented:
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
0
 
richgazAuthor Commented:
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)
0
 
Duncan RoeSoftware DeveloperCommented:
The LIBS line is wrong.
The posted Makefile is incomplete surely? There are no targets.
0
 
richgazAuthor Commented:
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
0
 
Duncan RoeSoftware DeveloperCommented:
LINK = gcc
LIBS = -lpci

or

LIBS = -L{dir where libpci.a is} -lpci
0
 
richgazAuthor Commented:
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?
0
 
richgazAuthor Commented:
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
0
 
Duncan RoeSoftware DeveloperCommented:
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.
0
 
richgazAuthor Commented:
well my last hurdle is activating this - any pointers would be great
0
 
Duncan RoeSoftware DeveloperCommented:
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).
0
 
richgazAuthor Commented:
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.
0
 
Duncan RoeSoftware DeveloperCommented:
This looks very much like the output from lspci with -G (debug) turned on. Except, lspci works (for me, at least). What did you expect from the utilities you are compiling? lspci is also free you know. Do have a look at the man pages as I posted earlier. Maybe try lspci -n to see if it shows the mysterious 248c somewhere. E.g. on my system:

22:42:04$ lspci -G -n
Trying method 1......using /proc/bus/pci...OK
Decided to use /proc/bus/pci
00:00.0 Class 0600: 1106:3188 (rev 01)
00:01.0 Class 0604: 1106:b188
00:06.0 Class 0200: 10b7:9058
00:08.0 Class 0100: 9004:8178 (rev 01)
00:0b.0 Class 0200: 14e4:1653 (rev 03)
00:0f.0 Class 0104: 1106:3149 (rev 80)
00:0f.1 Class 0101: 1106:0571 (rev 06)
00:10.0 Class 0c03: 1106:3038 (rev 81)
00:10.1 Class 0c03: 1106:3038 (rev 81)
00:10.2 Class 0c03: 1106:3038 (rev 81)
00:10.4 Class 0c03: 1106:3104 (rev 86)
00:11.0 Class 0601: 1106:3227
00:11.5 Class 0401: 1106:3059 (rev 60)
00:18.0 Class 0600: 1022:1100
00:18.1 Class 0600: 1022:1101
00:18.2 Class 0600: 1022:1102
00:18.3 Class 0600: 1022:1103
00:19.0 Class 0600: 1022:1100
00:19.1 Class 0600: 1022:1101
00:19.2 Class 0600: 1022:1102
00:19.3 Class 0600: 1022:1103
01:00.0 Class 0300: 1002:5159
0
 
richgazAuthor Commented:
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.
0
 
richgazAuthor Commented:
If this doesn;t work well time to get a Cicsco wireless plugin card.
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 18
  • 13
Tackle projects and never again get stuck behind a technical roadblock.
Join Now