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