This source file includes following definitions.
- output
- 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 <fcntl.h>
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <err.h>
26 #include <unistd.h>
27
28 #include "rcvbundl.h"
29
30 const u_int32_t fxp_ucode_d101a[] = D101_A_RCVBUNDLE_UCODE;
31 const u_int32_t fxp_ucode_d101b0[] = D101_B0_RCVBUNDLE_UCODE;
32 const u_int32_t fxp_ucode_d101ma[] = D101M_B_RCVBUNDLE_UCODE;
33 const u_int32_t fxp_ucode_d101s[] = D101S_RCVBUNDLE_UCODE;
34 const u_int32_t fxp_ucode_d102[] = D102_B_RCVBUNDLE_UCODE;
35 const u_int32_t fxp_ucode_d102c[] = D102_C_RCVBUNDLE_UCODE;
36 const u_int32_t fxp_ucode_d102e[] = D102_E_RCVBUNDLE_UCODE;
37
38 #define UCODE(x) x, sizeof(x)
39
40 static void
41 output(const char *name, const u_int32_t *ucode, const int ucode_len)
42 {
43 ssize_t rlen;
44 int fd, i;
45 u_int32_t dword;
46
47 printf("creating %s length %d (microcode: %d DWORDS)\n",
48 name, ucode_len, ucode_len / sizeof(u_int32_t));
49 fd = open(name, O_WRONLY|O_CREAT|O_TRUNC, 0644);
50 if (fd == -1)
51 err(1, "%s", name);
52 for (i = 0; i < ucode_len / sizeof(u_int32_t); i++) {
53 dword = htole32(ucode[i]);
54 rlen = write(fd, &dword, sizeof(dword));
55 if (rlen == -1)
56 err(1, "%s", name);
57 if (rlen != sizeof(dword))
58 errx(1, "%s: short write", name);
59 }
60 close(fd);
61 }
62
63 int
64 main(int argc, char *argv[])
65 {
66 output("fxp-d101a", UCODE(fxp_ucode_d101a));
67 output("fxp-d101b0", UCODE(fxp_ucode_d101b0));
68 output("fxp-d101ma", UCODE(fxp_ucode_d101ma));
69 output("fxp-d101s", UCODE(fxp_ucode_d101s));
70 output("fxp-d102", UCODE(fxp_ucode_d102));
71 output("fxp-d102c", UCODE(fxp_ucode_d102c));
72 output("fxp-d102e", UCODE(fxp_ucode_d102e));
73
74 return (0);
75 }