root/dev/microcode/tht/build.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. main

    1 /*      $OpenBSD: build.c,v 1.2 2007/04/19 04:08:51 dlg Exp $ */
    2 
    3 /*
    4  * Copyright (c) 2007 David Gwynne <dlg@openbsd.org>
    5  *
    6  * Permission to use, copy, modify, and distribute this software for any
    7  * purpose with or without fee is hereby granted, provided that the above
    8  * copyright notice and this permission notice appear in all copies.
    9  *
   10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
   11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
   12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
   13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
   14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
   15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
   16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   17  */
   18 
   19 #include <sys/types.h>
   20 
   21 #include <err.h>
   22 #include <fcntl.h>
   23 #include <stdio.h>
   24 #include <unistd.h>
   25 
   26 #include "microcode.h"
   27 
   28 #define THT_FW_NAME "tht"
   29 
   30 int
   31 main(int argc, char *argv[])
   32 {
   33         ssize_t         len;
   34         int             fd;
   35         int             i;
   36 
   37         fd = open(THT_FW_NAME, O_WRONLY | O_CREAT | O_TRUNC, 0644);
   38         if (fd == -1)
   39                 err(1, "%s", THT_FW_NAME);
   40 
   41         for (i = 0; i < (sizeof(tht_fw) / sizeof(tht_fw[0])); i++)
   42                 tht_fw[i] = htole32(tht_fw[i]);
   43 
   44         len = write(fd, tht_fw, sizeof(tht_fw));
   45         if (len == -1)
   46                 err(1, "%s write", THT_FW_NAME);
   47         if (len != sizeof(tht_fw))
   48                 errx(1, "%s: short write", THT_FW_NAME);
   49 
   50         close(fd);
   51 
   52         return (0);
   53 }

/* [<][>][^][v][top][bottom][index][help] */