This source file includes following definitions.
- myx_build_firmware
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #include <sys/types.h>
21
22 #include <dev/pci/if_myxreg.h>
23
24 #include <fcntl.h>
25 #include <stdlib.h>
26 #include <err.h>
27 #include <unistd.h>
28 #include <string.h>
29 #include <stdio.h>
30
31 #include "myxfw.h"
32
33 void
34 myx_build_firmware(u_int32_t *fw, size_t len, const char *file)
35 {
36 int fd, rlen;
37 size_t i, total = 0;
38 u_int32_t data;
39
40 printf("creating %s", file);
41 fd = open(file, O_WRONLY|O_CREAT|O_TRUNC, 0644);
42 if (fd == -1)
43 err(1, file);
44
45 for (i = 0; i < len; i++) {
46 data = letoh32(fw[i]);
47 rlen = write(fd, &data, sizeof(u_int32_t));
48 if (rlen == -1) {
49 printf("\n");
50 err(1, "%s", file);
51 }
52 if (rlen != sizeof(u_int32_t)) {
53 printf("\n");
54 errx(1, "%s: short write", file);
55 }
56 total += rlen;
57 }
58
59 printf(" total %d\n", total);
60 close(fd);
61 }
62
63 int
64 main(int argc, char *argv[])
65 {
66 myx_build_firmware(myxfw_eth_z8e,
67 MYXFW_ETH_Z8E_SIZE, MYXFW_ALIGNED);
68 myx_build_firmware(myxfw_ethp_z8e,
69 MYXFW_ETHP_Z8E_SIZE, MYXFW_UNALIGNED);
70 return (0);
71 }