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