123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- #!/bin/rc
- # pci [-v] - 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){
- if(/^;/) continue
- if(/^[0-9A-F]/){
- vid=lower($1)
- vendor[vid] = $2
- }
- if(/^ [0-9]/){
- did=lower($2)
- 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
- }
- }
- '
- }
- filter=cat
- if(~ $1 -v){
- filter=verbose
- }
- cd '#$/pci' && grep . *ctl | sed '
- s/ctl:/: /
- s/: 01/: disk 01/
- s/: 02/: net 02/
- s/: 03/: vid 03/
- s/: 06/: brg 06/
- s/: 0c\.03/: usb 0c.03/
- s/: 0c\.05/: smb 0c.05/
- s/: ([0-9])/: --- \1/
- ' | $filter
|