[BACK]Return to build.c CVS log [TXT][DIR] Up to [local] / sys / dev / microcode / myx

Annotation of sys/dev/microcode/myx/build.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: build.c,v 1.1 2007/05/31 18:27:59 reyk Exp $  */
                      2:
                      3: /*
                      4:  * Copyright (c) 2007 Reyk Floeter <reyk@openbsd.org>
                      5:  * Copyright (c) 2004 Theo de Raadt <deraadt@openbsd.org>
                      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 <dev/pci/if_myxreg.h>
                     23:
                     24: #include <fcntl.h>
                     25: #include <stdlib.h>
                     26: #include <err.h>
                     27: #include <unistd.h>
                     28: #include <string.h>
                     29: #include <stdio.h>
                     30:
                     31: #include "myxfw.h"
                     32:
                     33: void
                     34: myx_build_firmware(u_int32_t *fw, size_t len, const char *file)
                     35: {
                     36:        int             fd, rlen;
                     37:        size_t          i, total = 0;
                     38:        u_int32_t       data;
                     39:
                     40:        printf("creating %s", file);
                     41:        fd = open(file, O_WRONLY|O_CREAT|O_TRUNC, 0644);
                     42:        if (fd == -1)
                     43:                err(1, file);
                     44:
                     45:        for (i = 0; i < len; i++) {
                     46:                data = letoh32(fw[i]);
                     47:                rlen = write(fd, &data, sizeof(u_int32_t));
                     48:                if (rlen == -1) {
                     49:                        printf("\n");
                     50:                        err(1, "%s", file);
                     51:                }
                     52:                if (rlen != sizeof(u_int32_t)) {
                     53:                        printf("\n");
                     54:                        errx(1, "%s: short write", file);
                     55:                }
                     56:                total += rlen;
                     57:        }
                     58:
                     59:        printf(" total %d\n", total);
                     60:        close(fd);
                     61: }
                     62:
                     63: int
                     64: main(int argc, char *argv[])
                     65: {
                     66:        myx_build_firmware(myxfw_eth_z8e,
                     67:            MYXFW_ETH_Z8E_SIZE, MYXFW_ALIGNED);
                     68:        myx_build_firmware(myxfw_ethp_z8e,
                     69:            MYXFW_ETHP_Z8E_SIZE, MYXFW_UNALIGNED);
                     70:        return (0);
                     71: }

CVSweb