[BACK]Return to netdev.c CVS log [TXT][DIR] Up to [local] / sys / arch / mvme88k / stand / tftpboot

Annotation of sys/arch/mvme88k/stand/tftpboot/netdev.c, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: netdev.c,v 1.2 2006/05/16 22:52:09 miod Exp $ */
        !             2:
        !             3: /*
        !             4:  * Copyright (c) 1993 Paul Kranenburg
        !             5:  * All rights reserved.
        !             6:  *
        !             7:  * Redistribution and use in source and binary forms, with or without
        !             8:  * modification, are permitted provided that the following conditions
        !             9:  * are met:
        !            10:  * 1. Redistributions of source code must retain the above copyright
        !            11:  *    notice, this list of conditions and the following disclaimer.
        !            12:  * 2. Redistributions in binary form must reproduce the above copyright
        !            13:  *    notice, this list of conditions and the following disclaimer in the
        !            14:  *    documentation and/or other materials provided with the distribution.
        !            15:  * 3. All advertising materials mentioning features or use of this software
        !            16:  *    must display the following acknowledgement:
        !            17:  *      This product includes software developed by Paul Kranenburg.
        !            18:  * 4. The name of the author may not be used to endorse or promote products
        !            19:  *    derived from this software without specific prior written permission
        !            20:  *
        !            21:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
        !            22:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
        !            23:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
        !            24:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
        !            25:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
        !            26:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
        !            27:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
        !            28:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
        !            29:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
        !            30:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        !            31:  */
        !            32:
        !            33: #include <sys/param.h>
        !            34: #include <machine/prom.h>
        !            35: #include <string.h>
        !            36:
        !            37: #include "stand.h"
        !            38: #include "tftpfs.h"
        !            39:
        !            40: #include "libsa.h"
        !            41:
        !            42: struct bugdev_softc {
        !            43:        short   clun;
        !            44:        short   dlun;
        !            45: } bugdev_softc[1];
        !            46:
        !            47: int
        !            48: devopen(f, fname, file)
        !            49:        struct open_file *f;
        !            50:        const char *fname;
        !            51:        char **file;
        !            52: {
        !            53:        struct bugdev_softc *pp = &bugdev_softc[0];
        !            54:
        !            55:        pp->clun = (short)bugargs.ctrl_lun;
        !            56:        pp->dlun = (short)bugargs.dev_lun;
        !            57:
        !            58:        f->f_devdata = (void *)pp;
        !            59:        f->f_dev = &devsw[0];
        !            60:        *file = (char *)fname;
        !            61:        return (0);
        !            62: }
        !            63:
        !            64: #define        NFR_TIMEOUT     5
        !            65:
        !            66: int
        !            67: net_strategy(devdata, func, nblk, size, buf, rsize)
        !            68:        void *devdata;
        !            69:        int func;
        !            70:        daddr_t nblk;
        !            71:        size_t size;
        !            72:        void *buf;
        !            73:        size_t *rsize;
        !            74: {
        !            75:        struct bugdev_softc *pp = (struct bugdev_softc *)devdata;
        !            76:        struct mvmeprom_netfread nfr;
        !            77:        int attempts;
        !            78:
        !            79:        for (attempts = 0; attempts < 10; attempts++) {
        !            80:                nfr.ctrl = pp->clun;
        !            81:                nfr.dev = pp->dlun;
        !            82:                nfr.status = 0;
        !            83:                nfr.addr = (u_long)buf;
        !            84:                nfr.bytes = 0;
        !            85:                nfr.blk = nblk;
        !            86:                nfr.timeout = NFR_TIMEOUT;
        !            87:                mvmeprom_netfread(&nfr);
        !            88:
        !            89:                if (rsize) {
        !            90:                        *rsize = nfr.bytes;
        !            91:                }
        !            92:
        !            93:                if (nfr.status == 0)
        !            94:                        return (0);
        !            95:        }
        !            96:
        !            97:        return (EIO);
        !            98: }
        !            99:
        !           100: int
        !           101: net_open(struct open_file *f, ...)
        !           102: {
        !           103:        va_list ap;
        !           104:        struct mvmeprom_netfopen nfo;
        !           105:        struct bugdev_softc *pp = (struct bugdev_softc *)f->f_devdata;
        !           106:        char *filename;
        !           107:
        !           108:        va_start(ap, f);
        !           109:        filename = va_arg(ap, char *);
        !           110:        va_end(ap);
        !           111:
        !           112:        nfo.ctrl = pp->clun;
        !           113:        nfo.dev = pp->dlun;
        !           114:        nfo.status = 0;
        !           115:        strlcpy(nfo.filename, filename, sizeof nfo.filename);
        !           116:        mvmeprom_netfopen(&nfo);
        !           117:
        !           118: #ifdef DEBUG
        !           119:        printf("tftp open(%s): error %x\n", filename, nfo.status);
        !           120: #endif
        !           121:        return (nfo.status);
        !           122: }
        !           123:
        !           124: int
        !           125: net_close(f)
        !           126:        struct open_file *f;
        !           127: {
        !           128:        return (0);
        !           129: }
        !           130:
        !           131: int
        !           132: net_ioctl(f, cmd, data)
        !           133:        struct open_file *f;
        !           134:        u_long cmd;
        !           135:        void *data;
        !           136: {
        !           137:        return (EIO);
        !           138: }

CVSweb