Annotation of coherent/f/etc/conf/streams/src/ddi_drv.c, revision 1.1

1.1     ! root        1: #define        _DDI_DKI        1
        !             2: #define        _SYSV3          1
        !             3: 
        !             4: /*
        !             5:  * This file contains supplementary definitions used to deal with or aid the
        !             6:  * implementation of the automatically generated device configuration code
        !             7:  * in the "conf.c" file.
        !             8:  *
        !             9:  * Note that we are in the _SYSV3 world because we touch <sys/uproc.h>
        !            10:  */
        !            11: /*
        !            12:  *-IMPORTS:
        !            13:  *     <common/ccompat.h>
        !            14:  *             __USE_PROTO__
        !            15:  *             __ARGS ()
        !            16:  *     <common/xdebug.h>
        !            17:  *             __LOCAL__
        !            18:  *     <sys/debug.h>
        !            19:  *             ASSERT ()
        !            20:  *     <sys/types.h>
        !            21:  *             cred_t
        !            22:  *             n_dev_t
        !            23:  *             o_dev_t
        !            24:  *             makedevice ()
        !            25:  *     <sys/cmn_err.h>
        !            26:  *             CE_PANIC
        !            27:  *             cmn_err ()
        !            28:  *     <sys/file.h>
        !            29:  *             FREAD
        !            30:  *             FWRITE
        !            31:  *             FNDELAY
        !            32:  *             FNONBLOCK
        !            33:  *             FEXCL
        !            34:  *     <sys/open.h>
        !            35:  *             OTYP_BLK
        !            36:  *             OTYP_CHR
        !            37:  *             OTYP_LYR
        !            38:  *     <sys/uio.h>
        !            39:  *             iovec_t
        !            40:  *             uio_t
        !            41:  *     <stddef.h>
        !            42:  *             NULL
        !            43:  *     <sys/errno.h>
        !            44:  *             ENXIO
        !            45:  */
        !            46: 
        !            47: #include <common/ccompat.h>
        !            48: #include <common/xdebug.h>
        !            49: #include <kernel/strmlib.h>
        !            50: #include <sys/debug.h>
        !            51: #include <sys/types.h>
        !            52: #include <sys/cmn_err.h>
        !            53: #include <sys/file.h>
        !            54: #include <sys/open.h>
        !            55: #include <sys/errno.h>
        !            56: #include <sys/uio.h>
        !            57: #include <stddef.h>
        !            58: 
        !            59: #include <sys/confinfo.h>
        !            60: #include <kernel/ddi_base.h>
        !            61: 
        !            62: /*
        !            63:  * These are Coherent header files! Treat with all the caution you would
        !            64:  * normally use for handling toxic waste!
        !            65:  *
        !            66:  *     <sys/stat.h>
        !            67:  *             major ()
        !            68:  *             minor ()
        !            69:  *     <sys/con.h>
        !            70:  *             DFBLK
        !            71:  *
        !            72:  * The following values which used to be in Coherent <sys/inode.h> have been
        !            73:  * moved here so we can use them. <sys/inode.h> is too much of a mess.
        !            74:  *
        !            75:  *     <sys/file.h>
        !            76:  *             IPR
        !            77:  *             IPW
        !            78:  *             IPNDLY
        !            79:  *             IPEXCL
        !            80:  *
        !            81:  * Note that the actual magic u area variable 'u' is extern'ed in
        !            82:  * <kernel/ddi_base.h>
        !            83:  */
        !            84: 
        !            85: #include <sys/stat.h>
        !            86: 
        !            87: #if    __COHERENT__
        !            88: 
        !            89: #define        SETUERROR(e)    u.u_error = (e)
        !            90: 
        !            91: #else
        !            92: 
        !            93: #define        SETUERROR(e)    ASSERT (e == 0 || "Hit error" == NULL)
        !            94: 
        !            95: #endif
        !            96: 
        !            97: 
        !            98: /*
        !            99:  * This function initialises a cred_t structure from Coherent's internal data
        !           100:  * structures. This function would normally be local, but it is also called
        !           101:  * upon by code in "drv_ddi.c" to implement the drv_getparm () and
        !           102:  * drv_setparm () utilities, and also by the STREAMS equivalent to the
        !           103:  * character-driver interface routines.
        !           104:  */
        !           105: 
        !           106: #if    __USE_PROTO__
        !           107: cred_t * (MAKE_CRED) (cred_t * credp)
        !           108: #else
        !           109: cred_t *
        !           110: MAKE_CRED __ARGS ((credp))
        !           111: cred_t       * credp;
        !           112: #endif
        !           113: {
        !           114:        credp->cr_ref = 1;
        !           115:        credp->cr_ngroups = 0;  /* no supplementary groups */
        !           116: 
        !           117: #ifdef __MSDOS__
        !           118:        credp->cr_uid = credp->cr_ruid = credp->cr_suid = 0;
        !           119:        credp->cr_gid = credp->cr_rgid = credp->cr_sgid = 0;
        !           120: #else
        !           121:        credp->cr_uid = u.u_uid;
        !           122:        credp->cr_gid = u.u_gid;
        !           123:        credp->cr_ruid = u.u_ruid;
        !           124:        credp->cr_rgid = u.u_rgid;
        !           125:        credp->cr_suid = u.u_euid;      /* u.u_euid is saved effective uid */
        !           126:        credp->cr_sgid = u.u_egid;      /* u.u_egid is saved effective gid */
        !           127: #endif
        !           128:        return credp;
        !           129: }
        !           130: 
        !           131: 
        !           132: /*
        !           133:  * This local function is called to build a "uio_t" structure from Coherent's
        !           134:  * UIO structure. This function would be local, but it is called by the
        !           135:  * STREAMS equivalent of the mapping routines.
        !           136:  */
        !           137: 
        !           138: #if    __USE_PROTO__
        !           139: uio_t * (MAKE_UIO) (uio_t * uiop, iovec_t * iovp, int mode, IO * iop)
        !           140: #else
        !           141: uio_t *
        !           142: MAKE_UIO __ARGS ((uiop, iovp, mode, iop))
        !           143: uio_t        * uiop;
        !           144: iovec_t              * iovp;
        !           145: int            mode;
        !           146: IO           * iop;
        !           147: #endif
        !           148: {
        !           149:        uiop->uio_iov = iovp;
        !           150:        uiop->uio_iovcnt = 1;
        !           151:        uiop->uio_offset = iop->io_seek;
        !           152:        uiop->uio_segflg = iop->io_seg == IOSYS ? UIO_SYSSPACE : UIO_USERSPACE;
        !           153:        uiop->uio_fmode = mode | ((iop->io_flag & IONDLY) != 0 ? FNDELAY : 0);
        !           154:        uiop->uio_resid = iop->io_ioc;
        !           155: 
        !           156: #ifdef _I386
        !           157:        iovp->iov_base = iop->io.vbase;
        !           158: #else
        !           159:        iovp->iov_base = iop->io_base;
        !           160: #endif
        !           161:        iovp->iov_len = iop->io_ioc;
        !           162: 
        !           163:        return uiop;
        !           164: }
        !           165: 
        !           166: 
        !           167: /*
        !           168:  * This function is used to copy back the information from a "uio_t" structure
        !           169:  * into a Coherent IO structure.
        !           170:  */
        !           171: 
        !           172: #if    __USE_PROTO__
        !           173: void (DESTROY_UIO) (uio_t * uiop, IO * iop)
        !           174: #else
        !           175: void
        !           176: DESTROY_UIO __ARGS ((uiop, iop))
        !           177: uio_t        * uiop;
        !           178: IO           * iop;
        !           179: #endif
        !           180: {
        !           181:        ASSERT (uiop->uio_iov != NULL);
        !           182:        ASSERT (uiop->uio_iov->iov_len == uiop->uio_resid);
        !           183: 
        !           184:        iop->io_ioc = uiop->uio_resid;
        !           185:        iop->io_seek = uiop->uio_offset;
        !           186: #ifdef _I386
        !           187:        iop->io.vbase = uiop->uio_iov->iov_base;
        !           188: #else
        !           189:        iop->io_base = uiop->uio_iov->iov_base;
        !           190: #endif
        !           191: }
        !           192: 
        !           193: 
        !           194: /*
        !           195:  * This function is called upon by the machine-generated code in "conf.c" to
        !           196:  * forward a Coherent device open request to a System V device.
        !           197:  */
        !           198: 
        !           199: #if    __USE_PROTO__
        !           200: int (_forward_open) (o_dev_t dev, int mode, int flags, ddi_open_t funcp)
        !           201: #else
        !           202: int
        !           203: _forward_open __ARGS ((dev, mode, flags, funcp))
        !           204: o_dev_t                dev;
        !           205: int            mode;
        !           206: int            flags;
        !           207: ddi_open_t     funcp;
        !           208: #endif
        !           209: {
        !           210:        n_dev_t         newdev = makedevice (major (dev), minor (dev));
        !           211:        cred_t          cred;
        !           212:        int             newmode;
        !           213:        int             ret;
        !           214: 
        !           215:        newmode = 0;
        !           216: 
        !           217:        /*
        !           218:         * These are the flags documented by the Coherent driver kit. In
        !           219:         * actual fact, there are more (corresponding to the DDI/DKI flags)
        !           220:         * that are passed down from the system file table's flag entry. The
        !           221:         * fact that the others are not documented probably reflects the fact
        !           222:         * that calls to dread () either pass only IPR or IPW directly, while
        !           223:         * the existence of the other flags can only be discovered by tracing
        !           224:         * many layers of calls.
        !           225:         */
        !           226: 
        !           227:        if ((mode & IPR) != 0)
        !           228:                newmode |= FREAD;
        !           229:        if ((mode & IPW) != 0)
        !           230:                newmode |= FWRITE;
        !           231: 
        !           232:        /*
        !           233:         * And the other flags. There is no equivalent for FNONBLOCK.
        !           234:         */
        !           235: 
        !           236:        if ((mode & IPEXCL) != 0)
        !           237:                newmode |= FEXCL;
        !           238:        if ((mode & IPNDLY) != 0)
        !           239:                newmode |= FNDELAY;
        !           240: 
        !           241:        flags = (flags & DFBLK) != 0 ? OTYP_BLK : OTYP_CHR;
        !           242: 
        !           243:        ret = (* funcp) (& newdev, newmode, flags, MAKE_CRED (& cred));
        !           244: 
        !           245:        SETUERROR (ret);
        !           246:        return ret;
        !           247: }
        !           248: 
        !           249: 
        !           250: /*
        !           251:  * This function is called upon by the machine-generated code in "conf.c" to
        !           252:  * forward a Coherent device close request to a System V device.
        !           253:  */
        !           254: 
        !           255: #if    __USE_PROTO__
        !           256: int (_forward_close) (o_dev_t dev, int mode, int flags, ddi_close_t funcp)
        !           257: #else
        !           258: int
        !           259: _forward_close __ARGS ((dev, mode, flags, funcp))
        !           260: o_dev_t                dev;
        !           261: int            mode;
        !           262: int            flags;
        !           263: ddi_close_t    funcp;
        !           264: #endif
        !           265: {
        !           266:        n_dev_t         newdev = makedevice (major (dev), minor (dev));
        !           267:        cred_t          cred;
        !           268:        int             newmode;
        !           269:        int             ret;
        !           270: 
        !           271:        newmode = 0;
        !           272: 
        !           273:        /*
        !           274:         * These are the flags documented by the Coherent driver kit. In
        !           275:         * actual fact, there are more (corresponding to the DDI/DKI flags)
        !           276:         * that are passed down from the system file table's flag entry. The
        !           277:         * fact that the others are not documented probably reflects the fact
        !           278:         * that calls to dread () either pass only IPR or IPW directly, while
        !           279:         * the existence of the other flags can only be discovered by tracing
        !           280:         * many layers of calls.
        !           281:         */
        !           282: 
        !           283:        if ((mode & IPR) != 0)
        !           284:                newmode |= FREAD;
        !           285:        if ((mode & IPW) != 0)
        !           286:                newmode |= FWRITE;
        !           287: 
        !           288:        /*
        !           289:         * And the other flags. There is no equivalent for FNONBLOCK.
        !           290:         */
        !           291: 
        !           292:        if ((mode & IPEXCL) != 0)
        !           293:                newmode |= FEXCL;
        !           294:        if ((mode & IPNDLY) != 0)
        !           295:                newmode |= FNDELAY;
        !           296: 
        !           297:        flags = (flags & DFBLK) != 0 ? OTYP_BLK : OTYP_CHR;
        !           298: 
        !           299:        ret = (* funcp) (newdev, newmode, flags, MAKE_CRED (& cred));
        !           300: 
        !           301:        SETUERROR (ret);
        !           302:        return ret;
        !           303: }
        !           304: 
        !           305: 
        !           306: /*
        !           307:  * This function is called upon by the machine-generated code in "conf.c" to
        !           308:  * forward a Coherent device read request to a System V device.
        !           309:  */
        !           310: 
        !           311: #if    __USE_PROTO__
        !           312: int (_forward_read) (o_dev_t dev, IO * iop, ddi_read_t funcp)
        !           313: #else
        !           314: int
        !           315: _forward_read __ARGS ((dev, iop, funcp))
        !           316: o_dev_t                dev;
        !           317: IO           * iop;
        !           318: ddi_read_t     funcp;
        !           319: #endif
        !           320: {
        !           321:        n_dev_t         newdev = makedevice (major (dev), minor (dev));
        !           322:        cred_t          cred;
        !           323:        iovec_t         iov;
        !           324:        uio_t           uio;
        !           325:        int             ret;
        !           326: 
        !           327:        ret = (* funcp) (newdev, MAKE_UIO (& uio, & iov, FREAD, iop),
        !           328:                                 MAKE_CRED (& cred));
        !           329:        DESTROY_UIO (& uio, iop);
        !           330:        SETUERROR (ret);
        !           331:        return ret;
        !           332: }
        !           333: 
        !           334: 
        !           335: /*
        !           336:  * This function is called upon by the machine-generated code in "conf.c" to
        !           337:  * forward a Coherent device write request to a System V device.
        !           338:  */
        !           339: 
        !           340: #if    __USE_PROTO__
        !           341: int (_forward_write) (o_dev_t dev, IO * iop, ddi_write_t funcp)
        !           342: #else
        !           343: int
        !           344: _forward_write __ARGS ((dev, iop, funcp))
        !           345: o_dev_t                dev;
        !           346: IO           * iop;
        !           347: ddi_write_t    funcp;
        !           348: #endif
        !           349: {
        !           350:        n_dev_t         newdev = makedevice (major (dev), minor (dev));
        !           351:        cred_t          cred;
        !           352:        iovec_t         iov;
        !           353:        uio_t           uio;
        !           354:        int             ret;
        !           355: 
        !           356:        ret = (* funcp) (newdev, MAKE_UIO (& uio, & iov, FWRITE, iop),
        !           357:                                 MAKE_CRED (& cred));
        !           358:        DESTROY_UIO (& uio, iop);
        !           359:        SETUERROR (ret);
        !           360:        return ret;
        !           361: }
        !           362: 
        !           363: 
        !           364: /*
        !           365:  * This function is called upon by the machine-generated code in "conf.c" to
        !           366:  * forward a Coherent device ioctl request to a System V device.
        !           367:  */
        !           368: 
        !           369: #if    __USE_PROTO__
        !           370: int (_forward_ioctl) (o_dev_t dev, int cmd, _VOID * arg, int mode,
        !           371:                      ddi_ioctl_t funcp)
        !           372: #else
        !           373: int
        !           374: _forward_ioctl __ARGS ((dev, cmd, arg, mode, funcp))
        !           375: o_dev_t                dev;
        !           376: int            cmd;
        !           377: _VOID        * arg;
        !           378: int            mode;
        !           379: ddi_ioctl_t    funcp;
        !           380: #endif
        !           381: {
        !           382:        n_dev_t         newdev = makedevice (major (dev), minor (dev));
        !           383:        cred_t          cred;
        !           384:        int             rval;
        !           385:        int             newmode;
        !           386:        int             ret;
        !           387: 
        !           388:        newmode = 0;
        !           389: 
        !           390:        /*
        !           391:         * These are the flags documented by the Coherent driver kit. In
        !           392:         * actual fact, there are more (corresponding to the DDI/DKI flags)
        !           393:         * that are passed down from the system file table's flag entry. The
        !           394:         * fact that the others are not documented probably reflects the fact
        !           395:         * that calls to dread () either pass only IPR or IPW directly, while
        !           396:         * the existence of the other flags can only be discovered by tracing
        !           397:         * many layers of calls.
        !           398:         */
        !           399: 
        !           400:        if ((mode & IPR) != 0)
        !           401:                newmode |= FREAD;
        !           402:        if ((mode & IPW) != 0)
        !           403:                newmode |= FWRITE;
        !           404: 
        !           405:        /*
        !           406:         * And the other flags. There is no equivalent for FNONBLOCK.
        !           407:         */
        !           408: 
        !           409:        if ((mode & IPEXCL) != 0)
        !           410:                newmode |= FEXCL;
        !           411:        if ((mode & IPNDLY) != 0)
        !           412:                newmode |= FNDELAY;
        !           413: 
        !           414:        ret = (* funcp) (newdev, cmd, arg, mode, MAKE_CRED (& cred), & rval);
        !           415: 
        !           416:        SETUERROR (ret);
        !           417:        return rval;
        !           418: }
        !           419: 
        !           420: 
        !           421: 
        !           422: #if 0
        !           423: /*
        !           424:  * This function is called upon by the machine-generated code in "conf.c" to
        !           425:  * forward a Coherent device block request to a System V device.
        !           426:  */
        !           427: 
        !           428: #if    __USE_PROTO__
        !           429: int (_forward_strategy) (BUF * buf, ddi_strategy_t funcp)
        !           430: #else
        !           431: int
        !           432: _forward_strategy __ARGS ((buf, funcp))
        !           433: BUF          * buf;
        !           434: ddi_strategy_t funcp;
        !           435: #endif
        !           436: {
        !           437:        cmn_err (CE_PANIC, "DDI/DKI block drivers not yet supported");
        !           438: }
        !           439: #endif
        !           440: 
        !           441: 
        !           442: /*
        !           443:  * This function is called upon by the machine-generated code in "conf.c" to
        !           444:  * forward a Coherent device poll request to a System V device.
        !           445:  */
        !           446: 
        !           447: #if    __USE_PROTO__
        !           448: int (_forward_poll) (o_dev_t dev, int events, int msec, ddi_chpoll_t funcp)
        !           449: #else
        !           450: int
        !           451: _forward_poll __ARGS ((dev, events, msec, funcp))
        !           452: o_dev_t                dev;
        !           453: int            events;
        !           454: int            msec;
        !           455: ddi_chpoll_t   funcp;
        !           456: #endif
        !           457: {
        !           458:        int             ret;
        !           459: 
        !           460:        cmn_err (CE_PANIC, "DDI/DKI polling not yet supported");
        !           461: 
        !           462: #if    0
        !           463:        ret = (* funcp) (newdev, events, msec == 0, & revents, pollhead);
        !           464: #else
        !           465:        ret = EIO;
        !           466: #endif
        !           467:        SETUERROR (ret);
        !           468:        return 0;
        !           469: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.