]> git.sur5r.net Git - openocd/blob - src/helper/update_jep106.pl
Fix usage of timeval_ms()
[openocd] / src / helper / update_jep106.pl
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4 use File::Basename;
5
6 if (@ARGV != 1) {
7         die "Usage: $0 <JEP106 PDF document>\n\n"
8         . "Convert the JEDEC document containing manufacturer identification codes\n"
9         . "to an array initializer suitable for incusion into jep106.c. The latest\n"
10         . "version of the document can be found here:\n"
11         . "http://www.jedec.org/standards-documents/results/jep106\n";
12 };
13
14 my $outfile = dirname($0) . "/jep106.inc";
15
16 open(my $out, ">", $outfile) || die "Cannot open $outfile: $!\n";
17 open(my $pdftotext, "pdftotext -layout $ARGV[0] - |") || die "Cannot fork: $!\n";
18
19 print $out "/* Autogenerated with " . basename($0) . "*/\n";
20
21 my $bank = -1;
22
23 while (<$pdftotext>) {
24         if (/^[0-9]+[[:space:]]+(.*?)[[:space:]]+([01][[:space:]]+){8}([0-9A-F]{2})$/) {
25                 if ($3 eq "01") {
26                         $bank++
27                 }
28                 my $id=sprintf("0x%02x",hex($3)&0x7f);
29                 print $out "[$bank][$id - 1] = \"$1\",\n";
30         }
31 }
32
33 close $pdftotext || die "Error: $! $?\n";
34
35 print $out "/* EOF */\n";