build.c revision 1.1.54.2 1 1.1.54.2 bouyer /* $OpenBSD: build.c,v 1.2 2006/11/13 02:52:46 jsg Exp $ */
2 1.1.54.2 bouyer
3 1.1.54.2 bouyer /*-
4 1.1.54.2 bouyer * Copyright (c) 2006
5 1.1.54.2 bouyer * Damien Bergamini <damien.bergamini (at) free.fr>
6 1.1.54.2 bouyer *
7 1.1.54.2 bouyer * Permission to use, copy, modify, and distribute this software for any
8 1.1.54.2 bouyer * purpose with or without fee is hereby granted, provided that the above
9 1.1.54.2 bouyer * copyright notice and this permission notice appear in all copies.
10 1.1.54.2 bouyer *
11 1.1.54.2 bouyer * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 1.1.54.2 bouyer * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 1.1.54.2 bouyer * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 1.1.54.2 bouyer * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 1.1.54.2 bouyer * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 1.1.54.2 bouyer * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 1.1.54.2 bouyer * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 1.1.54.2 bouyer */
19 1.1.54.2 bouyer
20 1.1.54.2 bouyer #include <sys/types.h>
21 1.1.54.2 bouyer
22 1.1.54.2 bouyer #include <err.h>
23 1.1.54.2 bouyer #include <fcntl.h>
24 1.1.54.2 bouyer #include <stdio.h>
25 1.1.54.2 bouyer #include <unistd.h>
26 1.1.54.2 bouyer
27 1.1.54.2 bouyer #include "microcode.h"
28 1.1.54.2 bouyer
29 1.1.54.2 bouyer static void
30 1.1.54.2 bouyer output(const char *name, const uint8_t *ucode, int size)
31 1.1.54.2 bouyer {
32 1.1.54.2 bouyer ssize_t rlen;
33 1.1.54.2 bouyer int fd;
34 1.1.54.2 bouyer
35 1.1.54.2 bouyer printf("creating %s length %d\n", name, size);
36 1.1.54.2 bouyer
37 1.1.54.2 bouyer fd = open(name, O_WRONLY | O_CREAT | O_TRUNC, 0644);
38 1.1.54.2 bouyer if (fd == -1)
39 1.1.54.2 bouyer err(1, "%s", name);
40 1.1.54.2 bouyer
41 1.1.54.2 bouyer rlen = write(fd, ucode, size);
42 1.1.54.2 bouyer if (rlen == -1)
43 1.1.54.2 bouyer err(1, "%s", name);
44 1.1.54.2 bouyer if (rlen != size)
45 1.1.54.2 bouyer errx(1, "%s: short write", name);
46 1.1.54.2 bouyer
47 1.1.54.2 bouyer close(fd);
48 1.1.54.2 bouyer }
49 1.1.54.2 bouyer
50 1.1.54.2 bouyer int
51 1.1.54.2 bouyer main(void)
52 1.1.54.2 bouyer {
53 1.1.54.2 bouyer output("zyd-zd1211", zd1211_firmware, sizeof zd1211_firmware);
54 1.1.54.2 bouyer output("zyd-zd1211b", zd1211b_firmware, sizeof zd1211b_firmware);
55 1.1.54.2 bouyer
56 1.1.54.2 bouyer return 0;
57 1.1.54.2 bouyer }
58