annotate vidix/pci_db2c.awk @ 31707:6d8c5cae2b66

Synced with help_mp-en.h rev. 31752
author jrash
date Fri, 23 Jul 2010 13:08:31 +0000
parents e11d2e31353c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30005
835d6e5e5de0 Make vidix/pci_db2c.awk executable.
diego
parents: 29263
diff changeset
1 #!/usr/bin/awk -f
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
2 # This file converts given pci.db to "C" source and header files
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
3 # For latest version of pci ids see: http://pciids.sf.net
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
4 # Copyright 2002 Nick Kurshev
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
5 #
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
6 # Tested with Gawk v 3.0.x and Mawk 1.3.3
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
7 # But it should work with standard Awk implementations (hopefully).
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
8 # (Nobody tested it with Nawk, but it should work, too).
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
9 #
23292
99c7b632130d Add standard license header, confirmed by Nick in private mail.
diego
parents: 22912
diff changeset
10 # This file is part of MPlayer.
99c7b632130d Add standard license header, confirmed by Nick in private mail.
diego
parents: 22912
diff changeset
11 #
99c7b632130d Add standard license header, confirmed by Nick in private mail.
diego
parents: 22912
diff changeset
12 # MPlayer is free software; you can redistribute it and/or modify
99c7b632130d Add standard license header, confirmed by Nick in private mail.
diego
parents: 22912
diff changeset
13 # it under the terms of the GNU General Public License as published by
99c7b632130d Add standard license header, confirmed by Nick in private mail.
diego
parents: 22912
diff changeset
14 # the Free Software Foundation; either version 2 of the License, or
99c7b632130d Add standard license header, confirmed by Nick in private mail.
diego
parents: 22912
diff changeset
15 # (at your option) any later version.
99c7b632130d Add standard license header, confirmed by Nick in private mail.
diego
parents: 22912
diff changeset
16 #
99c7b632130d Add standard license header, confirmed by Nick in private mail.
diego
parents: 22912
diff changeset
17 # MPlayer is distributed in the hope that it will be useful,
99c7b632130d Add standard license header, confirmed by Nick in private mail.
diego
parents: 22912
diff changeset
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
99c7b632130d Add standard license header, confirmed by Nick in private mail.
diego
parents: 22912
diff changeset
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
99c7b632130d Add standard license header, confirmed by Nick in private mail.
diego
parents: 22912
diff changeset
20 # GNU General Public License for more details.
99c7b632130d Add standard license header, confirmed by Nick in private mail.
diego
parents: 22912
diff changeset
21 #
26719
3abd1629658b Use standard license headers.
diego
parents: 26516
diff changeset
22 # You should have received a copy of the GNU General Public License along
3abd1629658b Use standard license headers.
diego
parents: 26516
diff changeset
23 # with MPlayer; if not, write to the Free Software Foundation, Inc.,
3abd1629658b Use standard license headers.
diego
parents: 26516
diff changeset
24 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
25
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
26 BEGIN {
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
27
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
28 if (ARGC != 3) {
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
29 # check for arguments:
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
30 print "Usage ./pci_db2c.awk pci.db (and make sure pci.db file exists first)";
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
31 exit(1);
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
32 }
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
33 in_file = ARGV[1];
25271
4ba5a1593296 add new configure option to disable VIDIX PCI device name database (saves a 300 kB on mplayer binary)
ben
parents: 23292
diff changeset
34 with_pci_db = ARGV[2];
30049
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
35 dev_ids_c_file = "vidix/pci_dev_ids.c"
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
36 ids_h_file = "vidix/pci_ids.h"
30172
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
37 names_c_file = "vidix/pci_names.c"
30049
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
38 vendors_h_file = "vidix/pci_vendors.h";
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
39 # print out head lines
30049
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
40 print_head(vendors_h_file);
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
41 print_head(ids_h_file);
30172
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
42 print_head(names_c_file);
30049
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
43 print_head(dev_ids_c_file);
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
44 print "#include <stdlib.h>" > dev_ids_c_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
45 print "#include \"pci_names.h\"" > dev_ids_c_file;
30048
3acbd834b269 Eliminate completely pointless print_includes function.
diego
parents: 30046
diff changeset
46
30049
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
47 print_guards_start(vendors_h_file);
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
48 print_guards_start(ids_h_file);
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
49 print "#include \"pci_vendors.h\"" > ids_h_file
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
50 print "" > ids_h_file
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
51
30172
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
52 print "#include <stddef.h>" > names_c_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
53 print "#include \"pci_names.h\"" > names_c_file
25271
4ba5a1593296 add new configure option to disable VIDIX PCI device name database (saves a 300 kB on mplayer binary)
ben
parents: 23292
diff changeset
54 if (with_pci_db) {
30172
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
55 print "#include \"pci_dev_ids.c\"" > names_c_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
56 print "" > names_c_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
57 print "static struct vendor_id_s vendor_ids[] = {" > names_c_file
25271
4ba5a1593296 add new configure option to disable VIDIX PCI device name database (saves a 300 kB on mplayer binary)
ben
parents: 23292
diff changeset
58 }
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
59 first_pass = 1;
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
60 init_name_db();
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
61 while (getline < in_file) {
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
62 n = split($0, field, "[\t]");
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
63 name_field = kill_double_quoting(field[3])
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
64 if (field[1] == "v" && length(field[3]) > 0 && field[4] == "0") {
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
65 init_device_db()
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
66 svend_name = get_short_vendor_name(field[3])
30049
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
67 printf("#define VENDOR_%s\t", svend_name) > vendors_h_file;
30173
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
68 if (length(svend_name) < 9)
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
69 printf("\t") > vendors_h_file;
30049
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
70 printf("0x%s /*%s*/\n", field[2], name_field) > vendors_h_file;
30173
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
71 if (with_pci_db)
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
72 printf("{ 0x%s, \"%s\", dev_lst_%s },\n", field[2], name_field, field[2]) > names_c_file;
30049
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
73 printf("/* Vendor: %s: %s */\n", field[2], name_field) > ids_h_file
30173
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
74 if (first_pass == 1)
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
75 first_pass = 0;
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
76 else
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
77 print "{ 0xFFFF, NULL }\n};" > dev_ids_c_file;
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
78 printf("static const struct device_id_s dev_lst_%s[] = {\n", field[2]) > dev_ids_c_file
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
79 }
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
80 if (field[1] == "d" && length(field[3]) > 0 && field[4] == "0") {
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
81 sdev_name = get_short_device_name(field[3])
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
82 full_name = sprintf("#define DEVICE_%s_%s", svend_name, sdev_name);
30049
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
83 printf("%s\t", full_name) > ids_h_file
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
84 if (length(full_name) < 9) printf("\t") > ids_h_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
85 if (length(full_name) < 17) printf("\t") > ids_h_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
86 if (length(full_name) < 25) printf("\t") > ids_h_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
87 if (length(full_name) < 32) printf("\t") > ids_h_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
88 if (length(full_name) < 40) printf("\t") > ids_h_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
89 if (length(full_name) < 48) printf("\t") > ids_h_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
90 printf("0x%s /*%s*/\n", substr(field[2], 5), name_field) > ids_h_file
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
91 printf("{ 0x%s, \"%s\" },\n", substr(field[2], 5), name_field) > dev_ids_c_file
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
92 }
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
93 if (field[1] == "s" && length(field[3]) > 0 && field[4] == "0") {
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
94 subdev_name = get_short_subdevice_name(field[3])
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
95 full_name = sprintf("#define SUBDEVICE_%s_%s", svend_name, subdev_name)
30049
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
96 printf("\t%s\t", full_name) > ids_h_file
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
97 if (length(full_name) < 9) printf("\t") > ids_h_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
98 if (length(full_name) < 17) printf("\t") > ids_h_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
99 if (length(full_name) < 25) printf("\t") > ids_h_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
100 if (length(full_name) < 32) printf("\t") > ids_h_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
101 if (length(full_name) < 40) printf("\t") > ids_h_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
102 printf("0x%s /*%s*/\n", substr(field[2], 9), name_field) > ids_h_file
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
103 }
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
104 }
30049
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
105 print_guards_end(vendors_h_file);
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
106 print_guards_end(ids_h_file);
30173
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
107 if (with_pci_db)
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
108 print "};" > names_c_file
30049
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
109 print "{ 0xFFFF, NULL }" > dev_ids_c_file;
dde551eed572 Employ slightly better variable names for output files.
diego
parents: 30048
diff changeset
110 print "};" > dev_ids_c_file
30172
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
111 print_func_bodies(names_c_file);
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
112 }
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
113
30041
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
114 function construct_guard_name(out_file)
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
115 {
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
116 split(out_file, path_components, "/");
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
117 sub(".h","_h", path_components[2]);
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
118 return "MPLAYER_" toupper(path_components[2]);
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
119 }
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
120
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
121 function print_guards_start(out_file)
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
122 {
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
123 guard_name = construct_guard_name(out_file);
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
124 printf("#ifndef %s\n", guard_name) > out_file
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
125 printf("#define %s\n", guard_name) > out_file
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
126 print "" > out_file
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
127 }
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
128
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
129 function print_guards_end(out_file)
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
130 {
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
131 guard_name = construct_guard_name(out_file);
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
132 print "" > out_file
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
133 printf("#endif /* %s */\n", guard_name) > out_file
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
134 }
dea60722b5a3 Move code to write multiple inclusion guards to generated files into functions.
diego
parents: 30038
diff changeset
135
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
136 function print_head(out_file)
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
137 {
30038
d1c5b275d3f9 cosmetics: Use more consistent formatting style for generated files.
diego
parents: 30037
diff changeset
138 printf("/* File: %s\n", out_file) > out_file;
d1c5b275d3f9 cosmetics: Use more consistent formatting style for generated files.
diego
parents: 30037
diff changeset
139 printf(" * This file was generated automatically. Don't modify it. */\n") > out_file;
d1c5b275d3f9 cosmetics: Use more consistent formatting style for generated files.
diego
parents: 30037
diff changeset
140 print "" > out_file
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
141 }
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
142
30172
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
143 function print_func_bodies(out_file)
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
144 {
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
145 print "" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
146 print "const char *pci_vendor_name(unsigned short id)" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
147 print "{" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
148 if (with_pci_db) {
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
149 print " unsigned i;" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
150 print " for (i = 0; i < sizeof(vendor_ids) / sizeof(struct vendor_id_s); i++) {" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
151 print " if (vendor_ids[i].id == id)" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
152 print " return vendor_ids[i].name;" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
153 print " }" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
154 }
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
155 print " return NULL;" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
156 print "}" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
157 print "" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
158 print "const char *pci_device_name(unsigned short vendor_id, unsigned short device_id)" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
159 print "{" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
160 if (with_pci_db) {
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
161 print " unsigned i, j;" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
162 print " for (i = 0; i < sizeof(vendor_ids) / sizeof(struct vendor_id_s); i++) {" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
163 print " if (vendor_ids[i].id == vendor_id) {" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
164 print " j = 0;" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
165 print " while (vendor_ids[i].dev_list[j].id != 0xFFFF) {" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
166 print " if (vendor_ids[i].dev_list[j].id == device_id)" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
167 print " return vendor_ids[i].dev_list[j].name;" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
168 print " j++;" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
169 print " };" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
170 print " break;" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
171 print " }" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
172 print " }" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
173 }
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
174 print " return NULL;" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
175 print "}" > out_file
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
176 }
fbff89bae6a4 Remove previous failed attempt at disabling that auto-generation of some C code.
diego
parents: 30052
diff changeset
177
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
178 function kill_double_quoting(fld)
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
179 {
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
180 n = split(fld, phrases, "[\"]");
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
181 new_fld = phrases[1]
30173
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
182 for (i = 2; i <= n; i++)
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
183 new_fld = sprintf("%s\\\"%s", new_fld, phrases[i])
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
184 return new_fld
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
185 }
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
186
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
187 function init_name_db()
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
188 {
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
189 vendor_names[1] = ""
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
190 }
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
191
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
192 function init_device_db()
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
193 {
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
194 # delete device_names
30173
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
195 for (i in device_names)
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
196 delete device_names[i];
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
197 device_names[1] = ""
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
198 # delete subdevice_names
30173
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
199 for (i in subdevice_names)
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
200 delete subdevice_names[i];
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
201 subdevice_names[1] = ""
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
202 }
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
203
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
204 function get_short_vendor_name(from)
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
205 {
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
206 n = split(from, name, "[ ]");
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
207 new_name = toupper(name[1]);
30173
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
208 if (length(new_name) < 3)
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
209 new_name = sprintf("%s_%s", new_name, toupper(name[2]));
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
210 n = split(new_name, name, "[^0-9A-Za-z]");
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
211 svendor = name[1];
30173
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
212 for (i = 2; i <= n; i++)
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
213 svendor = sprintf("%s%s%s", svendor, length(name[i]) ? "_" : "", name[i]);
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
214 new_name = svendor;
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
215 vend_suffix = 2;
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
216 # check for unique
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
217 while (new_name in vendor_names) {
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
218 new_name = sprintf("%s%u", svendor, vend_suffix)
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
219 vend_suffix = vend_suffix + 1;
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
220 }
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
221 # Add new name in array of vendor's names
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
222 vendor_names[new_name] = new_name
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
223 return new_name;
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
224 }
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
225
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
226 function get_short_device_name(from_name)
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
227 {
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
228 n = split(from_name, name, "[ ]");
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
229 new_name = toupper(name[1]);
30173
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
230 if (length(name[2]))
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
231 new_name = sprintf("%s_%s", new_name, toupper(name[2]));
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
232 if (length(name[3]))
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
233 new_name = sprintf("%s_%s", new_name, toupper(name[3]));
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
234 n = split(new_name, name, "[^0-9A-Za-z]");
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
235 sdevice = name[1];
30173
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
236 for (i = 2; i <= n; i++)
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
237 sdevice = sprintf("%s%s%s", sdevice, length(name[i]) ? "_" : "", name[i]);
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
238 new_name = sdevice;
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
239 dev_suffix = 2;
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
240 # check for unique
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
241 while (new_name in device_names) {
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
242 new_name = sprintf("%s%u", sdevice, dev_suffix)
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
243 dev_suffix = dev_suffix + 1;
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
244 }
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
245 # Add new name in array of device names
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
246 device_names[new_name] = new_name
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
247 return new_name;
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
248 }
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
249
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
250 function get_short_subdevice_name(from_name)
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
251 {
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
252 n = split(from_name, name, "[ ]");
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
253 new_name = toupper(name[1]);
30173
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
254 if (length(name[2]))
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
255 new_name = sprintf("%s_%s", new_name, toupper(name[2]));
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
256 if (length(name[3]))
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
257 new_name = sprintf("%s_%s", new_name, toupper(name[3]));
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
258 n = split(new_name, name, "[^0-9A-Za-z]");
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
259 ssdevice = name[1];
30173
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
260 for (i = 2; i <= n; i++)
e11d2e31353c cosmetics: Break multiple statements on one line apart.
diego
parents: 30172
diff changeset
261 ssdevice = sprintf("%s%s%s", ssdevice, length(name[i]) ? "_" : "", name[i]);
30037
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
262 new_name = ssdevice;
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
263 sdev_suffix = 2;
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
264 # check for unique
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
265 while (new_name in subdevice_names) {
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
266 new_name = sprintf("%s%u", ssdevice, sdev_suffix)
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
267 sdev_suffix = sdev_suffix + 1;
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
268 }
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
269 # Add new name in array of subdevice names
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
270 subdevice_names[new_name] = new_name
bd46aa50b605 cosmetics: Use a consistent formattting style; tabs to spaces.
diego
parents: 30005
diff changeset
271 return new_name;
22900
a9e111b88c4a merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff changeset
272 }