Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sys / bus / pci / locate.pl
1 #!/usr/bin/perl
2 # $FreeBSD: src/sys/pci/locate.pl,v 1.2.2.1 2000/08/03 01:09:11 peter Exp $
3
4 $errpos = hex($ARGV[0])/4;
5 $ofs=0;
6
7 open (INPUT, "cc -E ncr.c 2>/dev/null |");
8
9 while ($_ = <INPUT>)
10 {
11     last if /^struct script \{/;
12 }
13
14 while ($_ = <INPUT>)
15 {
16     last if /^\}\;/;
17     ($label, $size) = /ncrcmd\s+(\S+)\s+\[([^]]+)/;
18     $size = eval($size);
19     if ($label) {
20         if ($errpos) {
21             if ($ofs + $size > $errpos) {
22                 printf ("%4x: %s\n", $ofs * 4, $label);
23                 printf ("%4x: %s + %d\n", $errpos * 4, $label, $errpos - $ofs);
24                 last;
25             }
26             $ofs += $size;
27         } else {
28             printf ("%4x: %s\n", $ofs * 4, $label);
29         }
30     }
31 }
32