1*4bb9ca09Sjsg /* $OpenBSD: build.c,v 1.2 2006/11/13 02:52:46 jsg Exp $ */
287b0bcf2Sderaadt
387b0bcf2Sderaadt /*-
487b0bcf2Sderaadt * Copyright (c) 2006
587b0bcf2Sderaadt * Damien Bergamini <damien.bergamini@free.fr>
687b0bcf2Sderaadt *
787b0bcf2Sderaadt * Permission to use, copy, modify, and distribute this software for any
887b0bcf2Sderaadt * purpose with or without fee is hereby granted, provided that the above
987b0bcf2Sderaadt * copyright notice and this permission notice appear in all copies.
1087b0bcf2Sderaadt *
1187b0bcf2Sderaadt * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1287b0bcf2Sderaadt * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1387b0bcf2Sderaadt * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1487b0bcf2Sderaadt * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1587b0bcf2Sderaadt * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1687b0bcf2Sderaadt * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1787b0bcf2Sderaadt * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1887b0bcf2Sderaadt */
1987b0bcf2Sderaadt
2087b0bcf2Sderaadt #include <sys/types.h>
2187b0bcf2Sderaadt
2287b0bcf2Sderaadt #include <err.h>
2387b0bcf2Sderaadt #include <fcntl.h>
2487b0bcf2Sderaadt #include <stdio.h>
2587b0bcf2Sderaadt #include <unistd.h>
2687b0bcf2Sderaadt
2787b0bcf2Sderaadt #include "microcode.h"
2887b0bcf2Sderaadt
2987b0bcf2Sderaadt static void
output(const char * name,const uint8_t * ucode,int size)3087b0bcf2Sderaadt output(const char *name, const uint8_t *ucode, int size)
3187b0bcf2Sderaadt {
3287b0bcf2Sderaadt ssize_t rlen;
3387b0bcf2Sderaadt int fd;
3487b0bcf2Sderaadt
3587b0bcf2Sderaadt printf("creating %s length %d\n", name, size);
3687b0bcf2Sderaadt
3787b0bcf2Sderaadt fd = open(name, O_WRONLY | O_CREAT | O_TRUNC, 0644);
3887b0bcf2Sderaadt if (fd == -1)
3987b0bcf2Sderaadt err(1, "%s", name);
4087b0bcf2Sderaadt
4187b0bcf2Sderaadt rlen = write(fd, ucode, size);
4287b0bcf2Sderaadt if (rlen == -1)
4387b0bcf2Sderaadt err(1, "%s", name);
4487b0bcf2Sderaadt if (rlen != size)
4587b0bcf2Sderaadt errx(1, "%s: short write", name);
4687b0bcf2Sderaadt
4787b0bcf2Sderaadt close(fd);
4887b0bcf2Sderaadt }
4987b0bcf2Sderaadt
5087b0bcf2Sderaadt int
main(void)5187b0bcf2Sderaadt main(void)
5287b0bcf2Sderaadt {
5387b0bcf2Sderaadt output("zd1211", zd1211_firmware, sizeof zd1211_firmware);
54*4bb9ca09Sjsg output("zd1211b", zd1211b_firmware, sizeof zd1211b_firmware);
5587b0bcf2Sderaadt
5687b0bcf2Sderaadt return 0;
5787b0bcf2Sderaadt }
58