pci 924 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/rc
  2. # pci [-v] - dump pci configuration
  3. rfork e
  4. fn verbose {
  5. if (! test -f /lib/pci)
  6. echo $0: no /lib/pci >[1=2]
  7. awk '
  8. function lower(s) {
  9. gsub(/A/, "a", s)
  10. gsub(/B/, "b", s)
  11. gsub(/C/, "c", s)
  12. gsub(/D/, "d", s)
  13. gsub(/E/, "e", s)
  14. gsub(/F/, "f", s)
  15. return s
  16. }
  17. BEGIN{
  18. file="/lib/pci"
  19. FS="\t"
  20. while(getline <file > 0){
  21. if(/^;/) continue
  22. if(/^[0-9A-F]/){
  23. vid=lower($1)
  24. vendor[vid] = $2
  25. }
  26. if(/^ [0-9]/){
  27. did=lower($2)
  28. id[vid "/" did] = $3
  29. }
  30. }
  31. FS = " "
  32. }
  33. {
  34. print $0
  35. vid = $4
  36. sub(/\/.*/, "", vid)
  37. if(vid in vendor){
  38. s = vendor[vid]
  39. if($4 in id)
  40. s = s " " id[$4]
  41. print "\t" s
  42. }
  43. }
  44. '
  45. }
  46. filter=cat
  47. if(~ $1 -v){
  48. filter=verbose
  49. }
  50. cd '#$/pci' && grep . *ctl | sed '
  51. s/ctl:/: /
  52. s/: 01/: disk 01/
  53. s/: 02/: net 02/
  54. s/: 03/: vid 03/
  55. s/: 06/: brg 06/
  56. s/: 0c\.03/: usb 0c.03/
  57. s/: 0c\.05/: smb 0c.05/
  58. s/: ([0-9])/: --- \1/
  59. ' | $filter