1*5d123b09Sotto /* $OpenBSD: build.c,v 1.9 2017/08/27 08:15:48 otto Exp $ */
2cb612c67Sderaadt
3cb612c67Sderaadt /*
4cb612c67Sderaadt * Copyright (c) 2004 Theo de Raadt <deraadt@openbsd.org>
5cb612c67Sderaadt *
6cb612c67Sderaadt * Permission to use, copy, modify, and distribute this software for any
7cb612c67Sderaadt * purpose with or without fee is hereby granted, provided that the above
8cb612c67Sderaadt * copyright notice and this permission notice appear in all copies.
9cb612c67Sderaadt *
10cb612c67Sderaadt * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11cb612c67Sderaadt * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12cb612c67Sderaadt * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13cb612c67Sderaadt * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14cb612c67Sderaadt * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15cb612c67Sderaadt * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16cb612c67Sderaadt * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17cb612c67Sderaadt */
18cb612c67Sderaadt #include <sys/types.h>
19cb612c67Sderaadt #include <dev/pci/if_bnxreg.h>
20cb612c67Sderaadt #include <fcntl.h>
21cb612c67Sderaadt #include <stdlib.h>
22cb612c67Sderaadt #include <err.h>
23cb612c67Sderaadt #include <unistd.h>
24cb612c67Sderaadt #include <string.h>
25cb612c67Sderaadt #include <stdio.h>
26524fa364Sderaadt
27cb612c67Sderaadt #include "bnxfw.h"
28cb612c67Sderaadt
29687ac9e0Sdlg #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
30687ac9e0Sdlg
31524fa364Sderaadt int bnx_rv2p_proc1len;
32524fa364Sderaadt int bnx_rv2p_proc2len;
33524fa364Sderaadt
34524fa364Sderaadt struct chunks {
35524fa364Sderaadt void *start;
36524fa364Sderaadt int *len;
37687ac9e0Sdlg };
38687ac9e0Sdlg
39687ac9e0Sdlg #define FILENAME_B06 "bnx-b06"
40687ac9e0Sdlg struct chunks chunks_b06[] = {
41524fa364Sderaadt { bnx_COM_b06FwText, &bnx_COM_b06FwTextLen },
42524fa364Sderaadt { bnx_COM_b06FwData, &bnx_COM_b06FwDataLen },
43524fa364Sderaadt { bnx_COM_b06FwRodata, &bnx_COM_b06FwRodataLen },
44524fa364Sderaadt { bnx_COM_b06FwBss, &bnx_COM_b06FwBssLen },
45524fa364Sderaadt { bnx_COM_b06FwSbss, &bnx_COM_b06FwSbssLen },
46524fa364Sderaadt
47524fa364Sderaadt { bnx_RXP_b06FwText, &bnx_RXP_b06FwTextLen },
48524fa364Sderaadt { bnx_RXP_b06FwData, &bnx_RXP_b06FwDataLen },
49524fa364Sderaadt { bnx_RXP_b06FwRodata, &bnx_RXP_b06FwRodataLen },
50524fa364Sderaadt { bnx_RXP_b06FwBss, &bnx_RXP_b06FwBssLen },
51524fa364Sderaadt { bnx_RXP_b06FwSbss, &bnx_RXP_b06FwSbssLen },
52524fa364Sderaadt
53524fa364Sderaadt { bnx_TPAT_b06FwText, &bnx_TPAT_b06FwTextLen },
54524fa364Sderaadt { bnx_TPAT_b06FwData, &bnx_TPAT_b06FwDataLen },
55524fa364Sderaadt { bnx_TPAT_b06FwRodata, &bnx_TPAT_b06FwRodataLen },
56524fa364Sderaadt { bnx_TPAT_b06FwBss, &bnx_TPAT_b06FwBssLen },
57524fa364Sderaadt { bnx_TPAT_b06FwSbss, &bnx_TPAT_b06FwSbssLen },
58524fa364Sderaadt
59524fa364Sderaadt { bnx_TXP_b06FwText, &bnx_TXP_b06FwTextLen },
60524fa364Sderaadt { bnx_TXP_b06FwData, &bnx_TXP_b06FwDataLen },
61524fa364Sderaadt { bnx_TXP_b06FwRodata, &bnx_TXP_b06FwRodataLen },
62524fa364Sderaadt { bnx_TXP_b06FwBss, &bnx_TXP_b06FwBssLen },
63687ac9e0Sdlg { bnx_TXP_b06FwSbss, &bnx_TXP_b06FwSbssLen }
64687ac9e0Sdlg };
65524fa364Sderaadt
66687ac9e0Sdlg #define FILENAME_B09 "bnx-b09"
67687ac9e0Sdlg struct chunks chunks_b09[] = {
68687ac9e0Sdlg { bnx_COM_b09FwText, &bnx_COM_b09FwTextLen },
69687ac9e0Sdlg { bnx_COM_b09FwData, &bnx_COM_b09FwDataLen },
70687ac9e0Sdlg { bnx_COM_b09FwRodata, &bnx_COM_b09FwRodataLen },
71687ac9e0Sdlg { bnx_COM_b09FwBss, &bnx_COM_b09FwBssLen },
72687ac9e0Sdlg { bnx_COM_b09FwSbss, &bnx_COM_b09FwSbssLen },
73687ac9e0Sdlg
74687ac9e0Sdlg { bnx_RXP_b09FwText, &bnx_RXP_b09FwTextLen },
75687ac9e0Sdlg { bnx_RXP_b09FwData, &bnx_RXP_b09FwDataLen },
76687ac9e0Sdlg { bnx_RXP_b09FwRodata, &bnx_RXP_b09FwRodataLen },
77687ac9e0Sdlg { bnx_RXP_b09FwBss, &bnx_RXP_b09FwBssLen },
78687ac9e0Sdlg { bnx_RXP_b09FwSbss, &bnx_RXP_b09FwSbssLen },
79687ac9e0Sdlg
80687ac9e0Sdlg { bnx_TPAT_b09FwText, &bnx_TPAT_b09FwTextLen },
81687ac9e0Sdlg { bnx_TPAT_b09FwData, &bnx_TPAT_b09FwDataLen },
82687ac9e0Sdlg { bnx_TPAT_b09FwRodata, &bnx_TPAT_b09FwRodataLen },
83687ac9e0Sdlg { bnx_TPAT_b09FwBss, &bnx_TPAT_b09FwBssLen },
84687ac9e0Sdlg { bnx_TPAT_b09FwSbss, &bnx_TPAT_b09FwSbssLen },
85687ac9e0Sdlg
86687ac9e0Sdlg { bnx_TXP_b09FwText, &bnx_TXP_b09FwTextLen },
87687ac9e0Sdlg { bnx_TXP_b09FwData, &bnx_TXP_b09FwDataLen },
88687ac9e0Sdlg { bnx_TXP_b09FwRodata, &bnx_TXP_b09FwRodataLen },
89687ac9e0Sdlg { bnx_TXP_b09FwBss, &bnx_TXP_b09FwBssLen },
90687ac9e0Sdlg { bnx_TXP_b09FwSbss, &bnx_TXP_b09FwSbssLen }
91687ac9e0Sdlg };
92687ac9e0Sdlg
93687ac9e0Sdlg #define FILENAME_RV2P "bnx-rv2p"
94687ac9e0Sdlg struct chunks chunks_rv2p[] = {
95524fa364Sderaadt { bnx_rv2p_proc1, &bnx_rv2p_proc1len },
96524fa364Sderaadt { bnx_rv2p_proc2, &bnx_rv2p_proc2len }
97524fa364Sderaadt };
98524fa364Sderaadt
99687ac9e0Sdlg #define FILENAME_XI_RV2P "bnx-xi-rv2p"
100687ac9e0Sdlg struct chunks chunks_xi_rv2p[] = {
101687ac9e0Sdlg { bnx_xi_rv2p_proc1, &bnx_rv2p_proc1len },
102687ac9e0Sdlg { bnx_xi_rv2p_proc2, &bnx_rv2p_proc2len }
103687ac9e0Sdlg };
104687ac9e0Sdlg
105687ac9e0Sdlg #define FILENAME_XI90_RV2P "bnx-xi90-rv2p"
106687ac9e0Sdlg struct chunks chunks_xi90_rv2p[] = {
107687ac9e0Sdlg { bnx_xi90_rv2p_proc1, &bnx_rv2p_proc1len },
108687ac9e0Sdlg { bnx_xi90_rv2p_proc2, &bnx_rv2p_proc2len }
109687ac9e0Sdlg };
110687ac9e0Sdlg
1113615b041Sderaadt void
hswapn(u_int32_t * p,int wcount)1123615b041Sderaadt hswapn(u_int32_t *p, int wcount)
1133615b041Sderaadt {
1143615b041Sderaadt for (; wcount; wcount -=4) {
1153615b041Sderaadt *p = htonl(*p);
1163615b041Sderaadt p++;
1173615b041Sderaadt }
1183615b041Sderaadt }
1193615b041Sderaadt
120687ac9e0Sdlg void
write_firmware(char * filename,void * header,size_t hlen,struct chunks * chunks,u_int nchunks)121687ac9e0Sdlg write_firmware(char *filename, void *header, size_t hlen,
122687ac9e0Sdlg struct chunks *chunks, u_int nchunks)
123cb612c67Sderaadt {
1244455a16fSderaadt int fd, i, total;
125cb612c67Sderaadt ssize_t rlen;
126cb612c67Sderaadt
127687ac9e0Sdlg printf("creating %s", filename);
128687ac9e0Sdlg fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0644);
129cb612c67Sderaadt if (fd == -1)
130*5d123b09Sotto err(1, "%s", filename);
131cb612c67Sderaadt
132687ac9e0Sdlg rlen = write(fd, header, hlen);
133cb612c67Sderaadt if (rlen == -1)
134687ac9e0Sdlg err(1, "%s", filename);
135687ac9e0Sdlg if (rlen != hlen)
136687ac9e0Sdlg errx(1, "%s: short write", filename);
137524fa364Sderaadt total = rlen;
138524fa364Sderaadt printf(" [%d", total);
139524fa364Sderaadt fflush(stdout);
140cb612c67Sderaadt
141687ac9e0Sdlg for (i = 0; i < nchunks; i++) {
1423615b041Sderaadt hswapn(chunks[i].start, *chunks[i].len);
143524fa364Sderaadt rlen = write(fd, chunks[i].start, *chunks[i].len);
144524fa364Sderaadt if (rlen == -1) {
145524fa364Sderaadt printf("\n");
146687ac9e0Sdlg err(1, "%s", filename);
147524fa364Sderaadt }
148524fa364Sderaadt if (rlen != *chunks[i].len) {
149524fa364Sderaadt printf("\n");
150687ac9e0Sdlg errx(1, "%s: short write", filename);
151524fa364Sderaadt }
152867e0126Skrw printf("+%zd", rlen);
153524fa364Sderaadt fflush(stdout);
154524fa364Sderaadt total += rlen;
155524fa364Sderaadt }
156524fa364Sderaadt
157524fa364Sderaadt printf("] total %d\n", total);
158cb612c67Sderaadt
159cb612c67Sderaadt close(fd);
160687ac9e0Sdlg }
161687ac9e0Sdlg
162687ac9e0Sdlg int
main(int argc,char * argv[])163687ac9e0Sdlg main(int argc, char *argv[])
164687ac9e0Sdlg {
165687ac9e0Sdlg struct bnx_firmware_header *bf;
166687ac9e0Sdlg struct bnx_rv2p_header *rh;
167687ac9e0Sdlg
168687ac9e0Sdlg bf = (struct bnx_firmware_header *)malloc(sizeof *bf);
169687ac9e0Sdlg bzero(bf, sizeof *bf);
170687ac9e0Sdlg
171687ac9e0Sdlg /* initialize the file header */
172687ac9e0Sdlg bf->bnx_COM_FwReleaseMajor = htonl(bnx_COM_b06FwReleaseMajor);
173687ac9e0Sdlg bf->bnx_COM_FwReleaseMinor = htonl(bnx_COM_b06FwReleaseMinor);
174687ac9e0Sdlg bf->bnx_COM_FwReleaseFix = htonl(bnx_COM_b06FwReleaseFix);
175687ac9e0Sdlg bf->bnx_COM_FwStartAddr = htonl(bnx_COM_b06FwStartAddr);
176687ac9e0Sdlg bf->bnx_COM_FwTextAddr = htonl(bnx_COM_b06FwTextAddr);
177687ac9e0Sdlg bf->bnx_COM_FwTextLen = htonl(bnx_COM_b06FwTextLen);
178687ac9e0Sdlg bf->bnx_COM_FwDataAddr = htonl(bnx_COM_b06FwDataAddr);
179687ac9e0Sdlg bf->bnx_COM_FwDataLen = htonl(bnx_COM_b06FwDataLen);
180687ac9e0Sdlg bf->bnx_COM_FwRodataAddr = htonl(bnx_COM_b06FwRodataAddr);
181687ac9e0Sdlg bf->bnx_COM_FwRodataLen = htonl(bnx_COM_b06FwRodataLen);
182687ac9e0Sdlg bf->bnx_COM_FwBssAddr = htonl(bnx_COM_b06FwBssAddr);
183687ac9e0Sdlg bf->bnx_COM_FwBssLen = htonl(bnx_COM_b06FwBssLen);
184687ac9e0Sdlg bf->bnx_COM_FwSbssAddr = htonl(bnx_COM_b06FwSbssAddr);
185687ac9e0Sdlg bf->bnx_COM_FwSbssLen = htonl(bnx_COM_b06FwSbssLen);
186687ac9e0Sdlg
187687ac9e0Sdlg bf->bnx_RXP_FwReleaseMajor = htonl(bnx_RXP_b06FwReleaseMajor);
188687ac9e0Sdlg bf->bnx_RXP_FwReleaseMinor = htonl(bnx_RXP_b06FwReleaseMinor);
189687ac9e0Sdlg bf->bnx_RXP_FwReleaseFix = htonl(bnx_RXP_b06FwReleaseFix);
190687ac9e0Sdlg bf->bnx_RXP_FwStartAddr = htonl(bnx_RXP_b06FwStartAddr);
191687ac9e0Sdlg bf->bnx_RXP_FwTextAddr = htonl(bnx_RXP_b06FwTextAddr);
192687ac9e0Sdlg bf->bnx_RXP_FwTextLen = htonl(bnx_RXP_b06FwTextLen);
193687ac9e0Sdlg bf->bnx_RXP_FwDataAddr = htonl(bnx_RXP_b06FwDataAddr);
194687ac9e0Sdlg bf->bnx_RXP_FwDataLen = htonl(bnx_RXP_b06FwDataLen);
195687ac9e0Sdlg bf->bnx_RXP_FwRodataAddr = htonl(bnx_RXP_b06FwRodataAddr);
196687ac9e0Sdlg bf->bnx_RXP_FwRodataLen = htonl(bnx_RXP_b06FwRodataLen);
197687ac9e0Sdlg bf->bnx_RXP_FwBssAddr = htonl(bnx_RXP_b06FwBssAddr);
198687ac9e0Sdlg bf->bnx_RXP_FwBssLen = htonl(bnx_RXP_b06FwBssLen);
199687ac9e0Sdlg bf->bnx_RXP_FwSbssAddr = htonl(bnx_RXP_b06FwSbssAddr);
200687ac9e0Sdlg bf->bnx_RXP_FwSbssLen = htonl(bnx_RXP_b06FwSbssLen);
201687ac9e0Sdlg
202687ac9e0Sdlg bf->bnx_TPAT_FwReleaseMajor = htonl(bnx_TPAT_b06FwReleaseMajor);
203687ac9e0Sdlg bf->bnx_TPAT_FwReleaseMinor = htonl(bnx_TPAT_b06FwReleaseMinor);
204687ac9e0Sdlg bf->bnx_TPAT_FwReleaseFix = htonl(bnx_TPAT_b06FwReleaseFix);
205687ac9e0Sdlg bf->bnx_TPAT_FwStartAddr = htonl(bnx_TPAT_b06FwStartAddr);
206687ac9e0Sdlg bf->bnx_TPAT_FwTextAddr = htonl(bnx_TPAT_b06FwTextAddr);
207687ac9e0Sdlg bf->bnx_TPAT_FwTextLen = htonl(bnx_TPAT_b06FwTextLen);
208687ac9e0Sdlg bf->bnx_TPAT_FwDataAddr = htonl(bnx_TPAT_b06FwDataAddr);
209687ac9e0Sdlg bf->bnx_TPAT_FwDataLen = htonl(bnx_TPAT_b06FwDataLen);
210687ac9e0Sdlg bf->bnx_TPAT_FwRodataAddr = htonl(bnx_TPAT_b06FwRodataAddr);
211687ac9e0Sdlg bf->bnx_TPAT_FwRodataLen = htonl(bnx_TPAT_b06FwRodataLen);
212687ac9e0Sdlg bf->bnx_TPAT_FwBssAddr = htonl(bnx_TPAT_b06FwBssAddr);
213687ac9e0Sdlg bf->bnx_TPAT_FwBssLen = htonl(bnx_TPAT_b06FwBssLen);
214687ac9e0Sdlg bf->bnx_TPAT_FwSbssAddr = htonl(bnx_TPAT_b06FwSbssAddr);
215687ac9e0Sdlg bf->bnx_TPAT_FwSbssLen = htonl(bnx_TPAT_b06FwSbssLen);
216687ac9e0Sdlg
217687ac9e0Sdlg bf->bnx_TXP_FwReleaseMajor = htonl(bnx_TXP_b06FwReleaseMajor);
218687ac9e0Sdlg bf->bnx_TXP_FwReleaseMinor = htonl(bnx_TXP_b06FwReleaseMinor);
219687ac9e0Sdlg bf->bnx_TXP_FwReleaseFix = htonl(bnx_TXP_b06FwReleaseFix);
220687ac9e0Sdlg bf->bnx_TXP_FwStartAddr = htonl(bnx_TXP_b06FwStartAddr);
221687ac9e0Sdlg bf->bnx_TXP_FwTextAddr = htonl(bnx_TXP_b06FwTextAddr);
222687ac9e0Sdlg bf->bnx_TXP_FwTextLen = htonl(bnx_TXP_b06FwTextLen);
223687ac9e0Sdlg bf->bnx_TXP_FwDataAddr = htonl(bnx_TXP_b06FwDataAddr);
224687ac9e0Sdlg bf->bnx_TXP_FwDataLen = htonl(bnx_TXP_b06FwDataLen);
225687ac9e0Sdlg bf->bnx_TXP_FwRodataAddr = htonl(bnx_TXP_b06FwRodataAddr);
226687ac9e0Sdlg bf->bnx_TXP_FwRodataLen = htonl(bnx_TXP_b06FwRodataLen);
227687ac9e0Sdlg bf->bnx_TXP_FwBssAddr = htonl(bnx_TXP_b06FwBssAddr);
228687ac9e0Sdlg bf->bnx_TXP_FwBssLen = htonl(bnx_TXP_b06FwBssLen);
229687ac9e0Sdlg bf->bnx_TXP_FwSbssAddr = htonl(bnx_TXP_b06FwSbssAddr);
230687ac9e0Sdlg bf->bnx_TXP_FwSbssLen = htonl(bnx_TXP_b06FwSbssLen);
231687ac9e0Sdlg
232687ac9e0Sdlg write_firmware(FILENAME_B06, bf, sizeof(*bf), chunks_b06,
233687ac9e0Sdlg nitems(chunks_b06));
234687ac9e0Sdlg
235687ac9e0Sdlg bzero(bf, sizeof *bf);
236687ac9e0Sdlg
237687ac9e0Sdlg bf->bnx_COM_FwReleaseMajor = htonl(bnx_COM_b09FwReleaseMajor);
238687ac9e0Sdlg bf->bnx_COM_FwReleaseMinor = htonl(bnx_COM_b09FwReleaseMinor);
239687ac9e0Sdlg bf->bnx_COM_FwReleaseFix = htonl(bnx_COM_b09FwReleaseFix);
240687ac9e0Sdlg bf->bnx_COM_FwStartAddr = htonl(bnx_COM_b09FwStartAddr);
241687ac9e0Sdlg bf->bnx_COM_FwTextAddr = htonl(bnx_COM_b09FwTextAddr);
242687ac9e0Sdlg bf->bnx_COM_FwTextLen = htonl(bnx_COM_b09FwTextLen);
243687ac9e0Sdlg bf->bnx_COM_FwDataAddr = htonl(bnx_COM_b09FwDataAddr);
244687ac9e0Sdlg bf->bnx_COM_FwDataLen = htonl(bnx_COM_b09FwDataLen);
245687ac9e0Sdlg bf->bnx_COM_FwRodataAddr = htonl(bnx_COM_b09FwRodataAddr);
246687ac9e0Sdlg bf->bnx_COM_FwRodataLen = htonl(bnx_COM_b09FwRodataLen);
247687ac9e0Sdlg bf->bnx_COM_FwBssAddr = htonl(bnx_COM_b09FwBssAddr);
248687ac9e0Sdlg bf->bnx_COM_FwBssLen = htonl(bnx_COM_b09FwBssLen);
249687ac9e0Sdlg bf->bnx_COM_FwSbssAddr = htonl(bnx_COM_b09FwSbssAddr);
250687ac9e0Sdlg bf->bnx_COM_FwSbssLen = htonl(bnx_COM_b09FwSbssLen);
251687ac9e0Sdlg
252687ac9e0Sdlg bf->bnx_RXP_FwReleaseMajor = htonl(bnx_RXP_b09FwReleaseMajor);
253687ac9e0Sdlg bf->bnx_RXP_FwReleaseMinor = htonl(bnx_RXP_b09FwReleaseMinor);
254687ac9e0Sdlg bf->bnx_RXP_FwReleaseFix = htonl(bnx_RXP_b09FwReleaseFix);
255687ac9e0Sdlg bf->bnx_RXP_FwStartAddr = htonl(bnx_RXP_b09FwStartAddr);
256687ac9e0Sdlg bf->bnx_RXP_FwTextAddr = htonl(bnx_RXP_b09FwTextAddr);
257687ac9e0Sdlg bf->bnx_RXP_FwTextLen = htonl(bnx_RXP_b09FwTextLen);
258687ac9e0Sdlg bf->bnx_RXP_FwDataAddr = htonl(bnx_RXP_b09FwDataAddr);
259687ac9e0Sdlg bf->bnx_RXP_FwDataLen = htonl(bnx_RXP_b09FwDataLen);
260687ac9e0Sdlg bf->bnx_RXP_FwRodataAddr = htonl(bnx_RXP_b09FwRodataAddr);
261687ac9e0Sdlg bf->bnx_RXP_FwRodataLen = htonl(bnx_RXP_b09FwRodataLen);
262687ac9e0Sdlg bf->bnx_RXP_FwBssAddr = htonl(bnx_RXP_b09FwBssAddr);
263687ac9e0Sdlg bf->bnx_RXP_FwBssLen = htonl(bnx_RXP_b09FwBssLen);
264687ac9e0Sdlg bf->bnx_RXP_FwSbssAddr = htonl(bnx_RXP_b09FwSbssAddr);
265687ac9e0Sdlg bf->bnx_RXP_FwSbssLen = htonl(bnx_RXP_b09FwSbssLen);
266687ac9e0Sdlg
267687ac9e0Sdlg bf->bnx_TPAT_FwReleaseMajor = htonl(bnx_TPAT_b09FwReleaseMajor);
268687ac9e0Sdlg bf->bnx_TPAT_FwReleaseMinor = htonl(bnx_TPAT_b09FwReleaseMinor);
269687ac9e0Sdlg bf->bnx_TPAT_FwReleaseFix = htonl(bnx_TPAT_b09FwReleaseFix);
270687ac9e0Sdlg bf->bnx_TPAT_FwStartAddr = htonl(bnx_TPAT_b09FwStartAddr);
271687ac9e0Sdlg bf->bnx_TPAT_FwTextAddr = htonl(bnx_TPAT_b09FwTextAddr);
272687ac9e0Sdlg bf->bnx_TPAT_FwTextLen = htonl(bnx_TPAT_b09FwTextLen);
273687ac9e0Sdlg bf->bnx_TPAT_FwDataAddr = htonl(bnx_TPAT_b09FwDataAddr);
274687ac9e0Sdlg bf->bnx_TPAT_FwDataLen = htonl(bnx_TPAT_b09FwDataLen);
275687ac9e0Sdlg bf->bnx_TPAT_FwRodataAddr = htonl(bnx_TPAT_b09FwRodataAddr);
276687ac9e0Sdlg bf->bnx_TPAT_FwRodataLen = htonl(bnx_TPAT_b09FwRodataLen);
277687ac9e0Sdlg bf->bnx_TPAT_FwBssAddr = htonl(bnx_TPAT_b09FwBssAddr);
278687ac9e0Sdlg bf->bnx_TPAT_FwBssLen = htonl(bnx_TPAT_b09FwBssLen);
279687ac9e0Sdlg bf->bnx_TPAT_FwSbssAddr = htonl(bnx_TPAT_b09FwSbssAddr);
280687ac9e0Sdlg bf->bnx_TPAT_FwSbssLen = htonl(bnx_TPAT_b09FwSbssLen);
281687ac9e0Sdlg
282687ac9e0Sdlg bf->bnx_TXP_FwReleaseMajor = htonl(bnx_TXP_b09FwReleaseMajor);
283687ac9e0Sdlg bf->bnx_TXP_FwReleaseMinor = htonl(bnx_TXP_b09FwReleaseMinor);
284687ac9e0Sdlg bf->bnx_TXP_FwReleaseFix = htonl(bnx_TXP_b09FwReleaseFix);
285687ac9e0Sdlg bf->bnx_TXP_FwStartAddr = htonl(bnx_TXP_b09FwStartAddr);
286687ac9e0Sdlg bf->bnx_TXP_FwTextAddr = htonl(bnx_TXP_b09FwTextAddr);
287687ac9e0Sdlg bf->bnx_TXP_FwTextLen = htonl(bnx_TXP_b09FwTextLen);
288687ac9e0Sdlg bf->bnx_TXP_FwDataAddr = htonl(bnx_TXP_b09FwDataAddr);
289687ac9e0Sdlg bf->bnx_TXP_FwDataLen = htonl(bnx_TXP_b09FwDataLen);
290687ac9e0Sdlg bf->bnx_TXP_FwRodataAddr = htonl(bnx_TXP_b09FwRodataAddr);
291687ac9e0Sdlg bf->bnx_TXP_FwRodataLen = htonl(bnx_TXP_b09FwRodataLen);
292687ac9e0Sdlg bf->bnx_TXP_FwBssAddr = htonl(bnx_TXP_b09FwBssAddr);
293687ac9e0Sdlg bf->bnx_TXP_FwBssLen = htonl(bnx_TXP_b09FwBssLen);
294687ac9e0Sdlg bf->bnx_TXP_FwSbssAddr = htonl(bnx_TXP_b09FwSbssAddr);
295687ac9e0Sdlg bf->bnx_TXP_FwSbssLen = htonl(bnx_TXP_b09FwSbssLen);
296687ac9e0Sdlg
297687ac9e0Sdlg write_firmware(FILENAME_B09, bf, sizeof(*bf), chunks_b09,
298687ac9e0Sdlg nitems(chunks_b09));
299687ac9e0Sdlg
3004c67e3eeStedu free(bf);
301687ac9e0Sdlg
302687ac9e0Sdlg rh = (struct bnx_rv2p_header *)malloc(sizeof *rh);
303687ac9e0Sdlg
304687ac9e0Sdlg bzero(rh, sizeof *rh);
305687ac9e0Sdlg bnx_rv2p_proc1len = sizeof bnx_rv2p_proc1;
306687ac9e0Sdlg bnx_rv2p_proc2len = sizeof bnx_rv2p_proc2;
307687ac9e0Sdlg rh->bnx_rv2p_proc1len = htonl(bnx_rv2p_proc1len);
308687ac9e0Sdlg rh->bnx_rv2p_proc2len = htonl(bnx_rv2p_proc2len);
309687ac9e0Sdlg
310687ac9e0Sdlg write_firmware(FILENAME_RV2P, rh, sizeof(*rh), chunks_rv2p,
311687ac9e0Sdlg nitems(chunks_rv2p));
312687ac9e0Sdlg
313687ac9e0Sdlg bzero(rh, sizeof *rh);
314687ac9e0Sdlg bnx_rv2p_proc1len = sizeof bnx_xi_rv2p_proc1;
315687ac9e0Sdlg bnx_rv2p_proc2len = sizeof bnx_xi_rv2p_proc2;
316687ac9e0Sdlg rh->bnx_rv2p_proc1len = htonl(bnx_rv2p_proc1len);
317687ac9e0Sdlg rh->bnx_rv2p_proc2len = htonl(bnx_rv2p_proc2len);
318687ac9e0Sdlg
319687ac9e0Sdlg write_firmware(FILENAME_XI_RV2P, rh, sizeof(*rh), chunks_xi_rv2p,
320687ac9e0Sdlg nitems(chunks_xi_rv2p));
321687ac9e0Sdlg
322687ac9e0Sdlg bzero(rh, sizeof *rh);
323687ac9e0Sdlg bnx_rv2p_proc1len = sizeof bnx_xi90_rv2p_proc1;
324687ac9e0Sdlg bnx_rv2p_proc2len = sizeof bnx_xi90_rv2p_proc2;
325687ac9e0Sdlg rh->bnx_rv2p_proc1len = htonl(bnx_rv2p_proc1len);
326687ac9e0Sdlg rh->bnx_rv2p_proc2len = htonl(bnx_rv2p_proc2len);
327687ac9e0Sdlg
328687ac9e0Sdlg write_firmware(FILENAME_XI90_RV2P, rh, sizeof(*rh), chunks_xi90_rv2p,
329687ac9e0Sdlg nitems(chunks_xi90_rv2p));
330687ac9e0Sdlg
3314c67e3eeStedu free(rh);
332687ac9e0Sdlg
333cb612c67Sderaadt return 0;
334cb612c67Sderaadt }
335