GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / cfe / cfe / hosttools / mkpcidb.c
bloba47f7fefa9aa1ad514cd35865ed395e5dd1cf145
1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
4 * PCI Table Generator File: mkpcidb.c
5 *
6 * Author: Mitch Lichtenberg (mpl@broadcom.com)
7 *
8 * This program munges the PCI table into a form that uses
9 * fewer embedded pointers. Pointers are evil for the
10 * relocatable version of CFE since they chew up valuable
11 * initialized data segment space, and we only have
12 * 64KB of that.
14 *********************************************************************
16 * Copyright 2000,2001,2002,2003
17 * Broadcom Corporation. All rights reserved.
19 * This software is furnished under license and may be used and
20 * copied only in accordance with the following terms and
21 * conditions. Subject to these conditions, you may download,
22 * copy, install, use, modify and distribute modified or unmodified
23 * copies of this software in source and/or binary form. No title
24 * or ownership is transferred hereby.
26 * 1) Any source code used, modified or distributed must reproduce
27 * and retain this copyright notice and list of conditions
28 * as they appear in the source file.
30 * 2) No right is granted to use any trade name, trademark, or
31 * logo of Broadcom Corporation. The "Broadcom Corporation"
32 * name may not be used to endorse or promote products derived
33 * from this software without the prior written permission of
34 * Broadcom Corporation.
36 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
37 * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
38 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
39 * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
40 * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
41 * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
42 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
43 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
44 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
45 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
46 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
47 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
48 * THE POSSIBILITY OF SUCH DAMAGE.
49 ********************************************************************* */
51 #include <stdio.h>
52 #include <string.h>
53 #include <unistd.h>
55 typedef unsigned short pci_vendor_id_t;
56 typedef unsigned short pci_product_id_t;
58 struct pci_knowndev {
59 pci_vendor_id_t vendor;
60 pci_product_id_t product;
61 int flags;
62 char *vendorname, *productname;
65 #include "../pci/pcidevs.h"
66 #define PCI_KNOWNDEV_NOPROD 0x01
67 #include "../pci/pcidevs_data.h"
71 struct pci_knowndev2 {
72 pci_vendor_id_t vendor;
73 pci_product_id_t product;
74 int flags;
75 int vendorname;
76 int productname;
79 #define MAXPCIDEVS 5000
80 #define MAXSTRINGTABLE (1024*1024)
82 struct pci_knowndev2 knowndevs[MAXPCIDEVS];
83 char stringtable[MAXSTRINGTABLE];
84 int curstringptr = 0;
86 int allocstring(char *string)
88 int ptr;
90 if (!string) return -1;
92 ptr = curstringptr;
93 strcpy(&stringtable[ptr],string);
94 curstringptr += strlen(string)+1;
95 return ptr;
98 int main(int argc,char *argv[])
100 struct pci_knowndev2 *outdev;
101 const struct pci_knowndev *indev;
102 int cnt = 0;
103 int idx;
105 indev = pci_knowndevs;
106 outdev = knowndevs;
107 cnt = 0;
109 while (indev->vendorname) {
110 outdev->vendor = indev->vendor;
111 outdev->product = indev->product;
112 outdev->flags = indev->flags;
113 outdev->vendorname = allocstring(indev->vendorname);
114 outdev->productname = allocstring(indev->productname);
115 cnt++;
116 indev++;
117 outdev++;
120 outdev->vendor = 0;
121 outdev->product = 0;
122 outdev->flags = 0;
123 outdev->vendorname = -1;
124 outdev->productname = -1;
125 cnt++;
127 fprintf(stderr,"%d total devices (%d bytes), %d bytes of strings\n",
128 cnt,cnt*sizeof(struct pci_knowndev2),curstringptr);
130 printf("\n\n\n");
131 printf("const static struct pci_knowndev2 _pci_knowndevs[] __attribute__ ((section (\".text\"))) = {\n");
132 for (idx = 0; idx < cnt; idx++) {
133 printf("\t{0x%04X,0x%04X,0x%08X,%d,%d},\n",
134 knowndevs[idx].vendor,
135 knowndevs[idx].product,
136 knowndevs[idx].flags,
137 knowndevs[idx].vendorname,
138 knowndevs[idx].productname);
140 printf("};\n\n\n");
141 printf("const static char _pci_knowndevs_text[] __attribute__ ((section (\".text\"))) = {\n");
142 for (idx = 0; idx < curstringptr; idx++) {
143 if ((idx % 16) == 0) printf("\t");
144 printf("0x%02X,",stringtable[idx]);
145 if ((idx % 16) == 15) printf("\n");
147 printf("0};\n\n");
149 printf("static const struct pci_knowndev2 *pci_knowndevs = _pci_knowndevs;\n");
150 printf("static const char *pci_knowndevs_text = _pci_knowndevs_text;\n");
151 printf("#define PCI_STRING_NULL (-1)\n");
152 printf("#define PCI_STRING(x) (&pci_knowndevs_text[(x)])\n\n");
156 exit(0);