2011-03-30 14:14:36 +00:00
|
|
|
#!/bin/rc
|
|
|
|
# pci [-bv] - dump pci configuration
|
|
|
|
rfork e
|
|
|
|
fn verbose {
|
|
|
|
if (! test -f /lib/pci)
|
|
|
|
echo $0: no /lib/pci >[1=2]
|
|
|
|
awk '
|
|
|
|
|
|
|
|
function lower(s) {
|
|
|
|
gsub(/A/, "a", s)
|
|
|
|
gsub(/B/, "b", s)
|
|
|
|
gsub(/C/, "c", s)
|
|
|
|
gsub(/D/, "d", s)
|
|
|
|
gsub(/E/, "e", s)
|
|
|
|
gsub(/F/, "f", s)
|
|
|
|
return s
|
|
|
|
}
|
|
|
|
BEGIN{
|
|
|
|
file="/lib/pci"
|
|
|
|
FS="\t"
|
|
|
|
while(getline <file > 0){
|
2014-12-21 05:41:34 +00:00
|
|
|
if(/^[#;]/) continue
|
|
|
|
if(/^[0-9A-Fa-f]/){
|
|
|
|
vid=$1 #vid=lower($1)
|
2011-03-30 14:14:36 +00:00
|
|
|
vendor[vid] = $2
|
|
|
|
}
|
2014-12-21 05:41:34 +00:00
|
|
|
if(/^ [0-9A-Fa-f]/){
|
|
|
|
did=$2 #lower($2)
|
2011-03-30 14:14:36 +00:00
|
|
|
id[vid "/" did] = $3
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FS = " "
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
print $0
|
|
|
|
vid = $4
|
|
|
|
sub(/\/.*/, "", vid)
|
|
|
|
if(vid in vendor){
|
|
|
|
s = vendor[vid]
|
|
|
|
if($4 in id)
|
|
|
|
s = s " " id[$4]
|
|
|
|
print "\t" s
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'
|
|
|
|
}
|
2014-12-21 05:41:34 +00:00
|
|
|
|
|
|
|
filter=cat
|
|
|
|
flagfmt=v,b
|
|
|
|
args='[vid/did ...]'
|
|
|
|
if(! ifs=() eval `{aux/getflags $*}){
|
|
|
|
aux/usage
|
2011-03-30 14:14:36 +00:00
|
|
|
exit usage
|
|
|
|
}
|
|
|
|
|
2014-12-21 05:41:34 +00:00
|
|
|
if(! ~ $#* 0){
|
|
|
|
{
|
|
|
|
for(i in `{echo $* | tr 'A-Z' 'a-z'})
|
|
|
|
echo '- - -' $i
|
|
|
|
} | verbose | sed 's:^- - - ::'
|
|
|
|
exit ''
|
2011-03-30 14:14:36 +00:00
|
|
|
}
|
|
|
|
|
2014-12-21 05:41:34 +00:00
|
|
|
if(~ $#flagv 1)
|
|
|
|
filter=verbose
|
|
|
|
builtin cd '#$/pci' && grep . `{ls -n | grep ctl} | {
|
|
|
|
if (~ $#flagb 1)
|
2011-03-30 14:14:36 +00:00
|
|
|
sed /:06/d
|
|
|
|
if not
|
|
|
|
cat
|
|
|
|
} |
|
|
|
|
sed '
|
|
|
|
s/ctl:/: /
|
|
|
|
t noop
|
|
|
|
: noop
|
|
|
|
s/: 01/: disk 01/
|
|
|
|
s/: 02/: net 02/
|
|
|
|
s/: 03/: vid 03/
|
|
|
|
s/: 04/: aud 04/
|
|
|
|
s/: 05/: mem 05/
|
|
|
|
s/: 06/: brg 06/
|
|
|
|
s/: 07/: ser 07/
|
2014-12-21 05:41:34 +00:00
|
|
|
s/: 08/: base 08/
|
|
|
|
s/: 09/: inpt 09/
|
|
|
|
s/: 0a/: dock 0a/
|
|
|
|
s/: 0b/: proc 0b/
|
2011-03-30 14:14:36 +00:00
|
|
|
s/: 0c\.03/: usb 0c.03/
|
|
|
|
s/: 0c\.05/: smb 0c.05/
|
2014-12-21 05:41:34 +00:00
|
|
|
s/: 0c\.07/: ipmi 0c.07/
|
2011-03-30 14:14:36 +00:00
|
|
|
s/: 0d/: rad 0d/
|
2014-12-21 05:41:34 +00:00
|
|
|
s/: 0e/: intl 0e/
|
|
|
|
s/: 0f/: sat 0f/
|
2011-03-30 14:14:36 +00:00
|
|
|
s/: 10/: cryp 10/
|
2014-12-21 05:41:34 +00:00
|
|
|
s/: 11/: sigl 11/
|
|
|
|
s/: 12/: exl 12/
|
2011-03-30 14:14:36 +00:00
|
|
|
t
|
|
|
|
s/ / --- /
|
|
|
|
' | $filter
|