Mercurial > mplayer.hg
annotate vidix/pci_db2c.awk @ 23004:beb4ac492c5e
preserve alpha channel when converting rgb32 to bgr32 in plain C
author | ivo |
---|---|
date | Wed, 18 Apr 2007 16:40:58 +0000 |
parents | 20c5536265da |
children | 99c7b632130d |
rev | line source |
---|---|
22900
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
1 # 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
|
2 # 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
|
3 # Copyright 2002 Nick Kurshev |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
4 # |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
5 # Usage: awk -f pci_db2c.awk pci.db |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
6 # |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
7 # 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
|
8 # 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
|
9 # (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
|
10 # |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
11 |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
12 BEGIN { |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
13 |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
14 if(ARGC != 2) { |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
15 # check for arguments: |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
16 print "Usage awk -f pci_db2c.awk pci.db (and make sure pci.db file exists first)"; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
17 exit(1); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
18 } |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
19 in_file = ARGV[1]; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
20 vendor_file = "pci_vendors.h"; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
21 ids_file = "pci_ids.h" |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
22 name_file = "pci_names.c" |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
23 name_h_file = "pci_names.h" |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
24 dev_ids_file = "pci_dev_ids.c" |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
25 line=0; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
26 # print out head lines |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
27 print_head(vendor_file); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
28 print_head(ids_file); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
29 print_head(name_file); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
30 print_head(name_h_file); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
31 print_head(dev_ids_file); |
22912 | 32 print_includes(dev_ids_file); |
22900
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
33 print "#ifndef PCI_VENDORS_INCLUDED" >vendor_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
34 print "#define PCI_VENDORS_INCLUDED 1">vendor_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
35 print "" >vendor_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
36 print "#ifndef PCI_IDS_INCLUDED" >ids_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
37 print "#define PCI_IDS_INCLUDED 1">ids_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
38 print "" >ids_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
39 print "#include \"pci_vendors.h\"">ids_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
40 print "" >ids_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
41 |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
42 print "#ifndef PCI_NAMES_INCLUDED" >name_h_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
43 print "#define PCI_NAMES_INCLUDED 1">name_h_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
44 print "" >name_h_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
45 print_name_struct(name_h_file); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
46 print "#include <stddef.h>">name_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
47 print "#include \"pci_names.h\"">name_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
48 print "#include \"pci_dev_ids.c\"">name_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
49 print "">name_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
50 print "static struct vendor_id_s vendor_ids[] = {">name_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
51 first_pass=1; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
52 init_name_db(); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
53 while(getline <in_file) |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
54 { |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
55 # count up lines |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
56 line++; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
57 n=split($0, field, "[\t]"); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
58 name_field = kill_double_quoting(field[3]) |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
59 if(field[1] == "v" && length(field[3])>0 && field[4] == "0") |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
60 { |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
61 init_device_db() |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
62 svend_name = get_short_vendor_name(field[3]) |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
63 printf("#define VENDOR_%s\t", svend_name) >vendor_file; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
64 if(length(svend_name) < 9) printf("\t") >vendor_file; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
65 printf("0x%s /*%s*/\n",field[2], name_field) >vendor_file; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
66 printf("{ 0x%s, \"%s\", dev_lst_%s },\n",field[2], name_field, field[2]) >name_file; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
67 printf("/* Vendor: %s: %s */\n", field[2], name_field) > ids_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
68 if(first_pass == 1) { first_pass=0; } |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
69 else { print "{ 0xFFFF, NULL }\n};" >dev_ids_file; } |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
70 printf("static const struct device_id_s dev_lst_%s[]={\n", field[2])>dev_ids_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
71 } |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
72 if(field[1] == "d" && length(field[3])>0 && field[4] == "0") |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
73 { |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
74 sdev_name = get_short_device_name(field[3]) |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
75 full_name = sprintf("#define DEVICE_%s_%s", svend_name, sdev_name); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
76 printf("%s\t", full_name) >ids_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
77 if(length(full_name) < 9) printf("\t") >ids_file; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
78 if(length(full_name) < 17) printf("\t") >ids_file; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
79 if(length(full_name) < 25) printf("\t") >ids_file; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
80 if(length(full_name) < 32) printf("\t") >ids_file; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
81 if(length(full_name) < 40) printf("\t") >ids_file; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
82 if(length(full_name) < 48) printf("\t") >ids_file; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
83 printf("0x%s /*%s*/\n", substr(field[2], 5), name_field) >ids_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
84 printf("{ 0x%s, \"%s\" },\n", substr(field[2], 5), name_field) >dev_ids_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
85 } |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
86 if(field[1] == "s" && length(field[3])>0 && field[4] == "0") |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
87 { |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
88 subdev_name = get_short_subdevice_name(field[3]) |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
89 full_name = sprintf("#define SUBDEVICE_%s_%s", svend_name, subdev_name) |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
90 printf("\t%s\t", full_name) >ids_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
91 if(length(full_name) < 9) printf("\t") >ids_file; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
92 if(length(full_name) < 17) printf("\t") >ids_file; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
93 if(length(full_name) < 25) printf("\t") >ids_file; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
94 if(length(full_name) < 32) printf("\t") >ids_file; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
95 if(length(full_name) < 40) printf("\t") >ids_file; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
96 printf("0x%s /*%s*/\n", substr(field[2], 9), name_field) >ids_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
97 } |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
98 } |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
99 print "Total lines parsed:", line; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
100 print "">vendor_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
101 print "#endif/*PCI_VENDORS_INCLUDED*/">vendor_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
102 print "">ids_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
103 print "#endif/*PCI_IDS_INCLUDED*/">ids_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
104 print "">name_h_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
105 print "#endif/*PCI_NAMES_INCLUDED*/">name_h_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
106 print "};">name_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
107 print "{ 0xFFFF, NULL }" >dev_ids_file; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
108 print "};">dev_ids_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
109 print_func_bodies(name_file); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
110 } |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
111 |
22912 | 112 function print_includes(out_file) |
113 { | |
114 print "#include <stdlib.h>" >out_file; | |
115 print "#include \"pci_names.h\"" >out_file; | |
116 return; | |
117 } | |
118 | |
22900
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
119 function print_head( out_file) |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
120 { |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
121 print "/*" >out_file; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
122 printf(" * File: %s\n", out_file) >out_file; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
123 printf(" * This file was generated automatically. Don't modify it.\n") >out_file; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
124 print "*/" >out_file; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
125 return; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
126 } |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
127 |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
128 function print_name_struct(out_file) |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
129 { |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
130 print "#ifdef __cplusplus" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
131 print "extern \"C\" {" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
132 print "#endif" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
133 print "">out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
134 print "struct device_id_s" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
135 print "{" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
136 print "\tunsigned short\tid;" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
137 print "\tconst char *\tname;" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
138 print "};" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
139 print "">out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
140 print "struct vendor_id_s" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
141 print "{" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
142 print "\tunsigned short\tid;" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
143 print "\tconst char *\tname;" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
144 print "\tconst struct device_id_s *\tdev_list;" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
145 print "};" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
146 print "extern const char *pci_vendor_name(unsigned short id);">out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
147 print "extern const char *pci_device_name(unsigned short vendor_id, unsigned short device_id);">out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
148 print "">out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
149 print "#ifdef __cplusplus" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
150 print "}" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
151 print "#endif" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
152 return |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
153 } |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
154 |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
155 function print_func_bodies(out_file) |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
156 { |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
157 print "">out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
158 print "const char *pci_vendor_name(unsigned short id)" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
159 print "{" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
160 print " unsigned i;" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
161 print " for(i=0;i<sizeof(vendor_ids)/sizeof(struct vendor_id_s);i++)">out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
162 print " {" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
163 print "\tif(vendor_ids[i].id == id) return vendor_ids[i].name;" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
164 print " }" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
165 print " return NULL;" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
166 print "}">out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
167 print "" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
168 print "const char *pci_device_name(unsigned short vendor_id, unsigned short device_id)" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
169 print "{" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
170 print " unsigned i, j;" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
171 print " for(i=0;i<sizeof(vendor_ids)/sizeof(struct vendor_id_s);i++)">out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
172 print " {" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
173 print "\tif(vendor_ids[i].id == vendor_id)" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
174 print "\t{" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
175 print "\t j=0;" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
176 print "\t while(vendor_ids[i].dev_list[j].id != 0xFFFF)" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
177 print "\t {">out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
178 print "\t\tif(vendor_ids[i].dev_list[j].id == device_id) return vendor_ids[i].dev_list[j].name;">out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
179 print "\t\tj++;">out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
180 print "\t };">out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
181 print "\t break;" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
182 print "\t}" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
183 print " }" >out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
184 print " return NULL;">out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
185 print "}">out_file |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
186 return |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
187 } |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
188 |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
189 function kill_double_quoting(fld) |
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 n=split(fld,phrases, "[\"]"); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
192 new_fld = phrases[1] |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
193 for(i=2;i<=n;i++) new_fld = sprintf("%s\\\"%s", new_fld, phrases[i]) |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
194 return new_fld |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
195 } |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
196 |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
197 function init_name_db() |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
198 { |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
199 vendor_names[1]="" |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
200 } |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
201 |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
202 function init_device_db() |
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 # delete device_names |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
205 for( i in device_names ) delete device_names[i]; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
206 device_names[1]="" |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
207 # delete subdevice_names |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
208 for( i in subdevice_names ) delete subdevice_names[i]; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
209 subdevice_names[1] = "" |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
210 } |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
211 |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
212 function get_short_vendor_name(from) |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
213 { |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
214 n=split(from, name, "[ ]"); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
215 new_name = toupper(name[1]); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
216 if(length(new_name)<3) new_name = sprintf("%s_%s", new_name, toupper(name[2])); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
217 n=split(new_name, name, "[^0-9A-Za-z]"); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
218 svendor = name[1]; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
219 for(i=2;i<=n;i++) svendor=sprintf("%s%s%s", svendor, length(name[i])?"_":"", name[i]); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
220 new_name = svendor; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
221 vend_suffix = 2; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
222 # check for unique |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
223 while(new_name in vendor_names) |
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 new_name = sprintf("%s%u", svendor, vend_suffix) |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
226 vend_suffix = vend_suffix + 1; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
227 } |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
228 # Add new name in array of vendor's names |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
229 vendor_names[new_name] = new_name |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
230 return new_name; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
231 } |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
232 |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
233 function get_short_device_name(from_name) |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
234 { |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
235 n=split(from_name, name, "[ ]"); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
236 new_name = toupper(name[1]); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
237 if(length(name[2])) new_name = sprintf("%s_%s", new_name, toupper(name[2])); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
238 if(length(name[3])) new_name = sprintf("%s_%s", new_name, toupper(name[3])); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
239 n=split(new_name, name, "[^0-9A-Za-z]"); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
240 sdevice = name[1]; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
241 for(i=2;i<=n;i++) sdevice=sprintf("%s%s%s", sdevice, length(name[i])?"_":"", name[i]); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
242 new_name = sdevice; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
243 dev_suffix = 2; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
244 # check for unique |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
245 while(new_name in device_names) |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
246 { |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
247 new_name = sprintf("%s%u", sdevice, dev_suffix) |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
248 dev_suffix = dev_suffix + 1; |
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 # Add new name in array of device names |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
251 device_names[new_name] = new_name |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
252 return new_name; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
253 } |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
254 |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
255 function get_short_subdevice_name(from_name) |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
256 { |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
257 n=split(from_name, name, "[ ]"); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
258 new_name = toupper(name[1]); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
259 if(length(name[2])) new_name = sprintf("%s_%s", new_name, toupper(name[2])); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
260 if(length(name[3])) new_name = sprintf("%s_%s", new_name, toupper(name[3])); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
261 n=split(new_name, name, "[^0-9A-Za-z]"); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
262 ssdevice = name[1]; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
263 for(i=2;i<=n;i++) ssdevice=sprintf("%s%s%s", ssdevice, length(name[i])?"_":"", name[i]); |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
264 new_name = ssdevice; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
265 sdev_suffix = 2; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
266 # check for unique |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
267 while(new_name in subdevice_names) |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
268 { |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
269 new_name = sprintf("%s%u", ssdevice, sdev_suffix) |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
270 sdev_suffix = sdev_suffix + 1; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
271 } |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
272 # Add new name in array of subdevice names |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
273 subdevice_names[new_name] = new_name |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
274 return new_name; |
a9e111b88c4a
merged libdha and libvidix, moved all files from libdha to vidix directory
ben
parents:
diff
changeset
|
275 } |