Plan 9 from Bell Labs’s /usr/web/sources/patch/applied/pci-did/pci.backup

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/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
}
builtin 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

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].