diff options
author | Noe Rubinstein <nrubinstein@avencall.com> | 2012-05-30 11:48:45 +0200 |
---|---|---|
committer | Noe Rubinstein <nrubinstein@avencall.com> | 2012-05-30 11:48:45 +0200 |
commit | 2d482cb18a2dde2c4a78540c912fc0be5041f5f7 (patch) | |
tree | f785b4bb5c7c796d938676ff3fbb6116ac27913d /devfn | |
parent | 9c6a07a2f10361294135d9935b3dde57211ebcfa (diff) |
Add a script to compute PCI DEVFN
Diffstat (limited to 'devfn')
-rwxr-xr-x | devfn | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -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 + |