summaryrefslogtreecommitdiff
path: root/devfn
diff options
context:
space:
mode:
authorNoe Rubinstein <nrubinstein@avencall.com>2012-05-30 11:48:45 +0200
committerNoe Rubinstein <nrubinstein@avencall.com>2012-05-30 11:48:45 +0200
commit2d482cb18a2dde2c4a78540c912fc0be5041f5f7 (patch)
treef785b4bb5c7c796d938676ff3fbb6116ac27913d /devfn
parent9c6a07a2f10361294135d9935b3dde57211ebcfa (diff)
Add a script to compute PCI DEVFN
Diffstat (limited to 'devfn')
-rwxr-xr-xdevfn18
1 files changed, 18 insertions, 0 deletions
diff --git a/devfn b/devfn
new file mode 100755
index 0000000..963fae3
--- /dev/null
+++ b/devfn
@@ -0,0 +1,18 @@
+#!/usr/bin/env ruby
+def devfn slot, func
+ ((((slot) & 0x1f) << 3) | ((func) & 0x07))
+end
+def slot devfn
+ (((devfn) >> 3) & 0x1f)
+end
+def func devfn
+ ((devfn) & 0x07)
+end
+
+ARGV.map!{|i| i.to_i 0 }
+if ARGV[1]
+ printf "%x\n", devfn(*ARGV)
+else
+ printf "%x.%02x\n", slot(*ARGV), func(*ARGV)
+end
+