summaryrefslogtreecommitdiff
path: root/devfn
blob: 963fae3f693c2925900abc6efa8cd81c25628871 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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