x86dev.org
*

Welcome, Guest. Please login or register.
Login with username, password and session length

+  x86dev.org
|-+  Projects
| |-+  Software and Utilities
| | |-+  PCIUtils for Darwin/OSX - LSPCI
« previous next »
Pages: [1] 2 Print
Author Topic: PCIUtils for Darwin/OSX - LSPCI  (Read 18682 times)
joblo10
Joblo
Administrator
Sr. Member
*****
Posts: 458



View Profile
« on: December 10, 2007, 09:24:22 PM »

Hi everyone,

I have made a port of the well-known pcitulis applications available in linux/bsd. (original application available at ftp://ftp.kernel.org/pub/software/utils/pciutils/) Both PPC and Intel macs are supported.

For those who don't know, it contains the lspci, setpci and update-pciids apps. The first(lspci) is used to print every information available through the pci config space. Setpci is used to set bits in it, and update-pciids to update the pci.ids file which contains vendor and device ids informations. See original author site (http://mj.ucw.cz/pciutils.shtml).

The patch below is applicable to the 2.2.9 version of pcitulis. The zip contains both the diff and the kernel extension used to communicate with the pci space. This is required because the osx kernel protects these memory regions from user space accesses.

It's released under the GPL, so please use it under that license. The code is include and an osx installer package is also included for convenience.

Please note I do not endorse any responsabilities if your computer starts to burn or throw flames while using it. With setpci, also note that it is very dangerous to play with the pci registers if you don't know what you are doing, so please use it with caution.

Thanks to Martin and Drew for your help and recommandations !  Wink

Note for files below:
- lspci_darwin_port_SRC contains the latest source in the format of a DIFF file, and the source for the kernel extension
- pci_osx_installer is an installer pakage that installs both the kernel driver and the pciutils applications. This is all you need to install lspci, setpci etc.

Enjoy!

* lspci_darwin_port_SRC_11dec2007.zip (340.57 KB - downloaded 873 times.)
* pciutils_osx_installer_1.02.zip (199.75 KB - downloaded 491 times.)
* pciutils_osx_installer 1.03.zip (200.47 KB - downloaded 4221 times.)
« Last Edit: February 27, 2008, 08:50:16 PM by joblo10 » Logged

NVIDIA Geforce 7900GS DDR3
GIGABYTE DS-3 965G
INTEL Core2Duo E6400
2048MB DDR2-800 OCZ
Slice
Full Member
***
Posts: 148


View Profile
« Reply #1 on: December 11, 2007, 02:40:51 AM »

I should be first user of the software. Feedback follows later. Roll Eyes
Logged
Slice
Full Member
***
Posts: 148


View Profile
« Reply #2 on: December 11, 2007, 05:19:53 AM »

First attempt
Quote
sergeys-computer:~ root# kextload -t /System/Library/Extensions/lspcidrv.kext 
kextload: extension /System/Library/Extensions/lspcidrv.kext appears to be valid
17lspci_user_client is not compatible with its superclass, 12IOUserClient superclass changed?
kextload: a link/load error occured for kernel extension /System/Library/Extensions/lspcidrv.kext
load failed for extension /System/Library/Extensions/lspcidrv.kext
 (run kextload with -t for diagnostic output)
Logged
logicscience
Newbie
*
Posts: 4


View Profile
« Reply #3 on: December 11, 2007, 07:45:28 AM »

xbx2s:~ xbx2$ lspci
00:00.0 Host bridge: Intel Corporation 82975X Memory Controller Hub
00:01.0 PCI bridge: Intel Corporation 82975X PCI Express Root Port
00:1b.0 Audio device: Intel Corporation 82801G (ICH7 Family) High Definition Audio Controller (rev 01)
00:1c.0 PCI bridge: Intel Corporation 82801G (ICH7 Family) PCI Express Port 1 (rev 01)
00:1c.4 PCI bridge: Intel Corporation 82801GR/GH/GHM (ICH7 Family) PCI Express Port 5 (rev 01)
00:1c.5 PCI bridge: Intel Corporation 82801GR/GH/GHM (ICH7 Family) PCI Express Port 6 (rev 01)
00:1d.0 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #1 (rev 01)
00:1d.1 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #2 (rev 01)
00:1d.2 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #3 (rev 01)
00:1d.3 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #4 (rev 01)
00:1d.7 USB Controller: Intel Corporation 82801G (ICH7 Family) USB2 EHCI Controller (rev 01)
00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev e1)
00:1f.0 ISA bridge: Intel Corporation 82801GH (ICH7DH) LPC Interface Bridge (rev 01)
00:1f.1 IDE interface: Intel Corporation 82801G (ICH7 Family) IDE Controller (rev 01)
00:1f.2 SATA controller: Intel Corporation 82801GR/GH (ICH7 Family) SATA AHCI Controller (rev 01)
00:1f.3 SMBus: Intel Corporation 82801G (ICH7 Family) SMBus Controller (rev 01)
01:00.0 VGA compatible controller: nVidia Corporation G70 [GeForce 7600 GS] (rev a1)
03:00.0 SATA controller: Marvell Technology Group Ltd. 88SE6145 SATA II PCI-E controller (rev a1)
04:00.0 Ethernet controller: Intel Corporation 82573L Gigabit Ethernet Controller
05:04.0 FireWire (IEEE 1394): Texas Instruments TSB43AB23 IEEE-1394a-2000 Controller (PHY/Link)
xbx2s:~ xbx2$

10.5.1 Smiley

Logged
joblo10
Joblo
Administrator
Sr. Member
*****
Posts: 458



View Profile
« Reply #4 on: December 11, 2007, 08:52:19 AM »

First attempt
Quote
sergeys-computer:~ root# kextload -t /System/Library/Extensions/lspcidrv.kext 
kextload: extension /System/Library/Extensions/lspcidrv.kext appears to be valid
17lspci_user_client is not compatible with its superclass, 12IOUserClient superclass changed?
kextload: a link/load error occured for kernel extension /System/Library/Extensions/lspcidrv.kext
load failed for extension /System/Library/Extensions/lspcidrv.kext
 (run kextload with -t for diagnostic output)

I made the package under Leopard, you will have to compile it manually under Tiger. There's a makefile included in the source zip file.
Logged

NVIDIA Geforce 7900GS DDR3
GIGABYTE DS-3 965G
INTEL Core2Duo E6400
2048MB DDR2-800 OCZ
Slice
Full Member
***
Posts: 148


View Profile
« Reply #5 on: December 11, 2007, 11:37:51 AM »

Compilation successful but
Quote
i686-apple-darwin8-gcc-4.0.1: unrecognized option '-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk'
i686-apple-darwin8-gcc-4.0.1: : linker input file unused because linking not done
gcc -o lspcidrv lspcidrv.o lspcidrv_info.c -nostdlib -r -lkmodc++ -lkmod -lcc_kext -lcpp_kext -isysroot /Developer/SDKs/MacOSX10.4u.sdk
and then
Quote
kextload: extension /Users/sergey/ATI/lspci darwin port(UPD12nov2007)/lspcidrv/build/lspcidrv.kext/ appears to be valid
kld(): Undefined symbols:
__Unwind_Resume
___gxx_personality_v0
What I need to change in makefile?
Logged
joblo10
Joblo
Administrator
Sr. Member
*****
Posts: 458



View Profile
« Reply #6 on: December 11, 2007, 01:28:01 PM »

Umm ok, I will post an XCode project file when I come home tonight.

Cheers
Logged

NVIDIA Geforce 7900GS DDR3
GIGABYTE DS-3 965G
INTEL Core2Duo E6400
2048MB DDR2-800 OCZ
joblo10
Joblo
Administrator
Sr. Member
*****
Posts: 458



View Profile
« Reply #7 on: December 11, 2007, 10:26:40 PM »

It didn't work with Tiger because it was using the 10.5 framework. Updated the installer with a 10.4 compiled version and made an XCode file instead of the makefile included in the previous revision.
Logged

NVIDIA Geforce 7900GS DDR3
GIGABYTE DS-3 965G
INTEL Core2Duo E6400
2048MB DDR2-800 OCZ
Slice
Full Member
***
Posts: 148


View Profile
« Reply #8 on: December 23, 2007, 02:36:31 PM »

Sorry, but I can't make it working.
I made lspcidrv.kext for tiger. It loaded successfully and present in ioreg.
But lspci say me
"Bus error". I have no lspci sources to remake.

Code:
Configuring libpci for your system... i386--darwin 8.9.1
Looking for access methods... Unfortunately, your OS is not supported by the PCI Library

* lspcidrv.zip (106.03 KB - downloaded 148 times.)
« Last Edit: December 23, 2007, 02:50:39 PM by Slice » Logged
joblo10
Joblo
Administrator
Sr. Member
*****
Posts: 458



View Profile
« Reply #9 on: December 24, 2007, 12:53:15 PM »

OK thanks for the info, there's a bug in th configure script it seems.
Logged

NVIDIA Geforce 7900GS DDR3
GIGABYTE DS-3 965G
INTEL Core2Duo E6400
2048MB DDR2-800 OCZ
blackman
Newbie
*
Gender: Male
Posts: 1


View Profile
« Reply #10 on: February 21, 2008, 09:42:30 PM »

So uhmm.. You ever plan to kill that bug  Huh Because it jut bit me and over 1000 others in the ass. Don't believe me?  start to pay attention to how many times your file gets downloaded and this page is accessed over the next two or three weeks.
« Last Edit: February 21, 2008, 09:54:32 PM by blackman » Logged
joblo10
Joblo
Administrator
Sr. Member
*****
Posts: 458



View Profile
« Reply #11 on: February 24, 2008, 10:09:20 PM »

Hi,

Sorry for the delay, I have deserted OSX for quite some time now and I forgot about this..

I just looked at the source and I didn't find any bug.

Slice, did you apply the diff correctly? You can make sure by looking for these lines in the configure script in the lib folder of the patched pciutils:

Code:
    gnu)
echo_n " i386-ports"
echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
;;
darwin)
echo >>$c '#define PCI_HAVE_PM_DARWIN_DEVICE'
echo >>$m 'SBINDIR=/usr/local/bin'
echo >>$m 'MANDIR=/usr/share/man'
;;
        *)

Here's some precisions on how to apply the patch and build pciutils:

1- Create a temp folder on your desktop or anywhere you're comfortable with;
2- Place the diff file posted above in that folder (lspci_darwin_port_SRC_11dec2007.zip);
3- Download the pciutils-2.2.9 from the Author's web site (link)
    then extract the content in the temp folder; you should have a directory called "pciutils-2.2.9";
4- From your temp folder, apply the patch by typing the following:
Code:
patch -p0 < darwin_port.diff
This should give you the output:
Code:
patching file pciutils-2.2.9/Makefile
patching file pciutils-2.2.9/lib/Makefile
patching file pciutils-2.2.9/lib/access.c
patching file pciutils-2.2.9/lib/configure
patching file pciutils-2.2.9/lib/darwin-device.c
patching file pciutils-2.2.9/lib/internal.h
patching file pciutils-2.2.9/lib/pci.h

5- Now you have the Darwin code inserted. To install, go in the pciutils-2.2.9 directory and just type "make install" to install the binaries and pci.ids file. It should end with these lines:
Code:
bash-3.2# make install
....
gzip -9 <pci.ids >pci.ids.gz
install -d -m 755 /usr/local/bin /usr/local/share /usr/share/man/man8
install -c -m 755 -s lspci setpci /usr/local/bin
install -c -m 755 update-pciids /usr/local/bin
install -c -m 644 pci.ids.gz /usr/local/share
install -c -m 644 lspci.8 setpci.8 update-pciids.8 /usr/share/man/man8

Hope this helps, and don't hesitate to ask if you have any trouble building it.
« Last Edit: February 25, 2008, 02:54:21 PM by joblo10 » Logged

NVIDIA Geforce 7900GS DDR3
GIGABYTE DS-3 965G
INTEL Core2Duo E6400
2048MB DDR2-800 OCZ
joblo10
Joblo
Administrator
Sr. Member
*****
Posts: 458



View Profile
« Reply #12 on: February 26, 2008, 07:37:51 PM »

I have just updated the package to version 1.03.

I reinstalled Tiger to find out what was the bug you guys were speaking of:
- The default installation path "/usr/local/bin" is within the environment PATH variable on Unix/Linux AND Leopard, but IS NOT in Tiger. Correction has been made, and now lspci, setpci and update-pciids are installed with /usr/bin. (both in Tiger and Leopard)

That's the reason it worked under Leo and not Tiger. The problem occured only in the x86 version of 10.4.
« Last Edit: February 27, 2008, 09:12:13 PM by joblo10 » Logged

NVIDIA Geforce 7900GS DDR3
GIGABYTE DS-3 965G
INTEL Core2Duo E6400
2048MB DDR2-800 OCZ
Slice
Full Member
***
Posts: 148


View Profile
« Reply #13 on: February 28, 2008, 08:33:39 AM »

I have just updated the package to version 1.03.

I reinstalled Tiger to find out what was the bug you guys were speaking of:
- The default installation path "/usr/local/bin" is within the environment PATH variable on Unix/Linux AND Leopard, but IS NOT in Tiger. Correction has been made, and now lspci, setpci and update-pciids are installed with /usr/bin. (both in Tiger and Leopard)

That's the reason it worked under Leo and not Tiger. The problem occured only in the x86 version of 10.4.
Result of kextload -t
Quote
kextload: extension /System/Library/Extensions/lspcidrv.kext appears to be valid
kld(): /System/Library/Extensions/lspcidrv.kext/Contents/MacOS/lspcidrv load command 2 unknown cmd field
kextload: kld_load_from_memory() failed for module /System/Library/Extensions/lspcidrv.kext/Contents/MacOS/lspcidrv
kextload: a link/load error occured for kernel extension /System/Library/Extensions/lspcidrv.kext
load failed for extension /System/Library/Extensions/lspcidrv.kext
 (run kextload with -t for diagnostic output)
and lspci
Quote
lspci: Cannot find any working access method.
Logged
joblo10
Joblo
Administrator
Sr. Member
*****
Posts: 458



View Profile
« Reply #14 on: February 28, 2008, 08:41:28 AM »

Thanks Slice,

That is really weird, I reinstalled Tiger only to test it and it worked fine on mine...

When you manage to build it, in the link you posted above, did you made anything special?

EDIT: Which version of Developer Tools are you running? I saw that this error often happens when the version of XCode does match the OS version. Could it be the case?
« Last Edit: February 28, 2008, 08:50:50 AM by joblo10 » Logged

NVIDIA Geforce 7900GS DDR3
GIGABYTE DS-3 965G
INTEL Core2Duo E6400
2048MB DDR2-800 OCZ
Slice
Full Member
***
Posts: 148


View Profile
« Reply #15 on: February 28, 2008, 02:16:16 PM »

Sorry Joblo!
I just from trip and have no time to look carefully to the package. I only install 1.03 and manually kextload with result shown above. May be later I try to compile.
I have XCode 2.5 full and MacOS 10.4(u) SDK.
System 10.4.6 on laptop Samsung P29
Celeron M 1.3
RAM 1Gb
ATI IXP150 chipset all in one.
Logged
joblo10
Joblo
Administrator
Sr. Member
*****
Posts: 458



View Profile
« Reply #16 on: February 28, 2008, 03:00:40 PM »

Hi Slice,

I think the problem may lie there... XCode 2.5 was primarily built for Leopard.. Tiger had 2.4. It would be interesting to get results from other people.

Can someone report back on this please?

EDIT: And Slice, fyi, when working correctly, the package should automatically load the kext for you.
Logged

NVIDIA Geforce 7900GS DDR3
GIGABYTE DS-3 965G
INTEL Core2Duo E6400
2048MB DDR2-800 OCZ
Slice
Full Member
***
Posts: 148


View Profile
« Reply #17 on: March 01, 2008, 03:41:58 AM »

It is strange. I easy compile your sources without any warning but kextload said me "2 unknown cmd". I think my kernel or frameworks don't support some features used by the kext.
The same result from your installer and from my compilation.
I also can't compile AppleSamplePCI with 2 errors "unknown methods".
Yes my Tiger is too old but there might be some solution like as DPCIManager that works.
Logged
joblo10
Joblo
Administrator
Sr. Member
*****
Posts: 458



View Profile
« Reply #18 on: March 01, 2008, 10:11:15 PM »

I have modified the XCode file to indicate the MACOS_DEPLOYMENT_VERSION varaible to 10.4 and set stripping flags with no_uuid (found a website suggesting this is sometimes the cause of that error).

Can you try it Slice when you have a chance? I have included the built binary + XCode project files.

Thanks

* lspci_drv_March1st08.zip (335.33 KB - downloaded 203 times.)
Logged

NVIDIA Geforce 7900GS DDR3
GIGABYTE DS-3 965G
INTEL Core2Duo E6400
2048MB DDR2-800 OCZ
Slice
Full Member
***
Posts: 148


View Profile
« Reply #19 on: March 03, 2008, 03:59:32 AM »

The same problem
Quote
kextload: extension /Off/lspcidrv.kext appears to be valid
kextload: loading extension /Off/lspcidrv.kext
kld(): /Off/lspcidrv.kext/Contents/MacOS/lspcidrv load command 2 unknown cmd field
kextload: kld_load_from_memory() failed for module /Off/lspcidrv.kext/Contents/MacOS/lspcidrv
kextload: a link/load error occured for kernel extension /Off/lspcidrv.kext
load failed for extension /Off/lspcidrv.kext
 (run kextload with -t for diagnostic output)
I compile it with XCode 2.5 without any changes in project. No one error or warning.

No any information what it unknown field. May be info.plist? Or external methods?
Logged
Pages: [1] 2 Print 
« previous next »
Jump to:  


Get Firefox! Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS! Powered by MySQL Powered by PHP