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

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

1.1       nbrk        1: /*     $OpenBSD: build.c,v 1.3 2005/05/17 18:48:52 jason Exp $ */
                      2:
                      3: /*
                      4:  * Copyright (c) 2004 Theo de Raadt <deraadt@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: #include <sys/types.h>
                     19: #include <sys/uio.h>
                     20: #include <fcntl.h>
                     21: #include <sys/param.h>
                     22:
                     23: #include <dev/usb/ezload.h>
                     24: #include "uyap_firmware.h"
                     25: #define FILENAME "uyap"
                     26:
                     27: int
                     28: main(int argc, char *argv[])
                     29: {
                     30:        const struct ezdata *ptr;
                     31:        u_int16_t address;
                     32:        int fd;
                     33:
                     34:        printf("creating %s length %d\n", FILENAME, sizeof uyap_firmware);
                     35:        fd = open(FILENAME, O_WRONLY|O_CREAT|O_TRUNC, 0644);
                     36:        if (fd == -1)
                     37:                err(1, "%s", FILENAME);
                     38:
                     39:        for (ptr = uyap_firmware; ; ptr++) {
                     40:                struct iovec iov[3];
                     41:                u_int8_t length;
                     42:                ssize_t tlen, rlen;
                     43:
                     44:                length = ptr->length;
                     45:                iov[0].iov_base = &length;
                     46:                iov[0].iov_len = 1;
                     47:
                     48:                address = htole16(ptr->address);
                     49:                iov[1].iov_base = &address;
                     50:                iov[1].iov_len = 2;
                     51:
                     52:                iov[2].iov_base = ptr->data;
                     53:                iov[2].iov_len = ptr->length;
                     54:
                     55:                tlen = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
                     56:
                     57:                rlen = writev(fd, iov, 3);
                     58:                if (rlen == -1)
                     59:                        err(1, "%s", FILENAME);
                     60:                if (rlen != tlen)
                     61:                        err(1, "%s: short write", FILENAME);
                     62:
                     63:                if (ptr->length == 0)
                     64:                        break;
                     65:        }
                     66:
                     67:        return 0;
                     68: }

CVSweb