[package] base-files: enable conntrack accounting in sysctl. It used to be a compile...
[openwrt.git] / package / ixp4xx-microcode / src / IxNpeMicrocode.h
1 /*
2 * IxNpeMicrocode.h - Headerfile for compiling the Intel microcode C file
3 *
4 * Copyright (C) 2006 Christian Hohnstaedt <chohnstaedt@innominate.com>
5 *
6 * This file is released under the GPLv2
7 *
8 *
9 * compile with
10 *
11 * gcc -Wall IxNpeMicrocode.c -o IxNpeMicrocode
12 *
13 * Executing the resulting binary on your build-host creates the
14 * "NPE-[ABC].xxxxxxxx" files containing the selected microcode
15 *
16 * fetch the IxNpeMicrocode.c from the Intel Access Library.
17 * It will include this header.
18 *
19 * select Images for every NPE from the following
20 * (used C++ comments for easy uncommenting ....)
21 */
22
23 // #define IX_NPEDL_NPEIMAGE_NPEA_ETH_SPAN_MASK_FIREWALL_VLAN_QOS_HDR_CONV_EXTMIB
24 // #define IX_NPEDL_NPEIMAGE_NPEA_ETH_SPAN_VLAN_QOS_HDR_CONV_EXTMIB
25 // #define IX_NPEDL_NPEIMAGE_NPEA_ETH_LEARN_FILTER_SPAN_MASK_FIREWALL_VLAN_QOS_EXTMIB
26 // #define IX_NPEDL_NPEIMAGE_NPEA_HSS_TSLOT_SWITCH
27 #define IX_NPEDL_NPEIMAGE_NPEA_ETH_SPAN_FIREWALL_VLAN_QOS_HDR_CONV
28 // #define IX_NPEDL_NPEIMAGE_NPEA_ETH_LEARN_FILTER_SPAN_FIREWALL_VLAN_QOS
29 // #define IX_NPEDL_NPEIMAGE_NPEA_ETH_LEARN_FILTER_SPAN_FIREWALL
30 // #define IX_NPEDL_NPEIMAGE_NPEA_HSS_2_PORT
31 // #define IX_NPEDL_NPEIMAGE_NPEA_DMA
32 // #define IX_NPEDL_NPEIMAGE_NPEA_ATM_MPHY_12_PORT
33 // #define IX_NPEDL_NPEIMAGE_NPEA_HSS0_ATM_MPHY_1_PORT
34 // #define IX_NPEDL_NPEIMAGE_NPEA_HSS0_ATM_SPHY_1_PORT
35 // #define IX_NPEDL_NPEIMAGE_NPEA_HSS0
36 // #define IX_NPEDL_NPEIMAGE_NPEA_WEP
37
38
39 // #define IX_NPEDL_NPEIMAGE_NPEB_ETH_SPAN_MASK_FIREWALL_VLAN_QOS_HDR_CONV_EXTMIB
40 // #define IX_NPEDL_NPEIMAGE_NPEB_ETH_SPAN_VLAN_QOS_HDR_CONV_EXTMIB
41 // #define IX_NPEDL_NPEIMAGE_NPEB_ETH_LEARN_FILTER_SPAN_MASK_FIREWALL_VLAN_QOS_EXTMIB
42 // #define IX_NPEDL_NPEIMAGE_NPEB_DMA
43 #define IX_NPEDL_NPEIMAGE_NPEB_ETH_SPAN_FIREWALL_VLAN_QOS_HDR_CONV
44 // #define IX_NPEDL_NPEIMAGE_NPEB_ETH_LEARN_FILTER_SPAN_FIREWALL_VLAN_QOS
45 // #define IX_NPEDL_NPEIMAGE_NPEB_ETH_LEARN_FILTER_SPAN_FIREWALL
46
47
48 // #define IX_NPEDL_NPEIMAGE_NPEC_ETH_SPAN_MASK_FIREWALL_VLAN_QOS_HDR_CONV_EXTMIB
49 // #define IX_NPEDL_NPEIMAGE_NPEC_ETH_SPAN_VLAN_QOS_HDR_CONV_EXTMIB
50 // #define IX_NPEDL_NPEIMAGE_NPEC_ETH_LEARN_FILTER_SPAN_MASK_FIREWALL_VLAN_QOS_EXTMIB
51 // #define IX_NPEDL_NPEIMAGE_NPEC_DMA
52 // #define IX_NPEDL_NPEIMAGE_NPEC_CRYPTO_AES_ETH_LEARN_FILTER_SPAN
53 // #define IX_NPEDL_NPEIMAGE_NPEC_CRYPTO_AES_ETH_LEARN_FILTER_FIREWALL
54 #define IX_NPEDL_NPEIMAGE_NPEC_CRYPTO_AES_CCM_ETH
55 // #define IX_NPEDL_NPEIMAGE_NPEC_CRYPTO_AES_CCM_EXTSHA_ETH
56 // #define IX_NPEDL_NPEIMAGE_NPEC_CRYPTO_ETH_LEARN_FILTER_SPAN_FIREWALL
57 // #define IX_NPEDL_NPEIMAGE_NPEC_ETH_SPAN_FIREWALL_VLAN_QOS_HDR_CONV
58 // #define IX_NPEDL_NPEIMAGE_NPEC_ETH_LEARN_FILTER_SPAN_FIREWALL_VLAN_QOS
59 // #define IX_NPEDL_NPEIMAGE_NPEC_ETH_LEARN_FILTER_SPAN_FIREWALL
60
61
62 #include <stdio.h>
63 #include <unistd.h>
64 #include <stdlib.h>
65 #include <netinet/in.h>
66 #include <sys/types.h>
67 #include <sys/stat.h>
68 #include <fcntl.h>
69 #include <errno.h>
70 #include <endian.h>
71 #include <byteswap.h>
72 #include <string.h>
73
74 #if __BYTE_ORDER == __LITTLE_ENDIAN
75 #define to_le32(x) (x)
76 #define to_be32(x) bswap_32(x)
77 #else
78 #define to_be32(x) (x)
79 #define to_le32(x) bswap_32(x)
80 #endif
81
82 struct dl_image {
83 unsigned magic;
84 unsigned id;
85 unsigned size;
86 unsigned data[0];
87 };
88
89 const unsigned IxNpeMicrocode_array[];
90
91 int main(int argc, char *argv[])
92 {
93 struct dl_image *image = (struct dl_image *)IxNpeMicrocode_array;
94 int imgsiz, i, fd, cnt;
95 const unsigned *arrayptr = IxNpeMicrocode_array;
96 const char *names[] = { "IXP425", "IXP465", "unknown" };
97 int bigendian = 1;
98
99 if (argc > 1) {
100 if (!strcmp(argv[1], "-le"))
101 bigendian = 0;
102 else if (!strcmp(argv[1], "-be"))
103 bigendian = 1;
104 else {
105 printf("Usage: %s <-le|-be>\n", argv[0]);
106 return EXIT_FAILURE;
107 }
108 }
109
110 for (image = (struct dl_image *)arrayptr, cnt=0;
111 (image->id != 0xfeedf00d) && (image->magic == 0xfeedf00d);
112 image = (struct dl_image *)(arrayptr), cnt++)
113 {
114 unsigned char field[4];
115 imgsiz = image->size + 3;
116 *(unsigned*)field = to_be32(image->id);
117 char filename[40], slnk[10];
118
119 sprintf(filename, "NPE-%c.%08x", (field[0] & 0xf) + 'A',
120 image->id);
121 sprintf(slnk, "NPE-%c", (field[0] & 0xf) + 'A');
122 printf("Writing image: %s.NPE_%c Func: %2x Rev: %02x.%02x "
123 "Size: %5d to: '%s'\n",
124 names[field[0] >> 4], (field[0] & 0xf) + 'A',
125 field[1], field[2], field[3], imgsiz*4, filename);
126 fd = open(filename, O_CREAT | O_RDWR | O_TRUNC, 0644);
127 if (fd >= 0) {
128 for (i=0; i<imgsiz; i++) {
129 *(unsigned*)field = bigendian ?
130 to_be32(arrayptr[i]) :
131 to_le32(arrayptr[i]);
132 write(fd, field, sizeof(field));
133 }
134 close(fd);
135 unlink(slnk);
136 symlink(filename, slnk);
137 } else {
138 perror(filename);
139 }
140 arrayptr += imgsiz;
141 }
142 close(fd);
143 return 0;
144 }
This page took 0.045323 seconds and 5 git commands to generate.