Annotation of Gnu-Mach/device/dev_hdr.h, revision 1.1

1.1     ! root        1: /* 
        !             2:  * Mach Operating System
        !             3:  * Copyright (c) 1991,1990,1989 Carnegie Mellon University
        !             4:  * All Rights Reserved.
        !             5:  * 
        !             6:  * Permission to use, copy, modify and distribute this software and its
        !             7:  * documentation is hereby granted, provided that both the copyright
        !             8:  * notice and this permission notice appear in all copies of the
        !             9:  * software, derivative works or modified versions, and any portions
        !            10:  * thereof, and that both notices appear in supporting documentation.
        !            11:  * 
        !            12:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
        !            13:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
        !            14:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
        !            15:  * 
        !            16:  * Carnegie Mellon requests users of this software to return to
        !            17:  * 
        !            18:  *  Software Distribution Coordinator  or  [email protected]
        !            19:  *  School of Computer Science
        !            20:  *  Carnegie Mellon University
        !            21:  *  Pittsburgh PA 15213-3890
        !            22:  * 
        !            23:  * any improvements or extensions that they make and grant Carnegie Mellon
        !            24:  * the rights to redistribute these changes.
        !            25:  */
        !            26: /*
        !            27:  *     Author: David B. Golub, Carnegie Mellon University
        !            28:  *     Date:   3/89
        !            29:  */
        !            30: 
        !            31: #ifndef        _DEVICE_DEV_HDR_H_
        !            32: #define        _DEVICE_DEV_HDR_H_
        !            33: 
        !            34: #include <mach/port.h>
        !            35: #include <kern/lock.h>
        !            36: #include <kern/queue.h>
        !            37: 
        !            38: #include <device/conf.h>
        !            39: 
        !            40: #ifdef i386
        !            41: #include <i386at/dev_hdr.h>
        !            42: #else
        !            43: #define mach_device                    device
        !            44: #define mach_device_t                  device_t
        !            45: #define MACH_DEVICE_NULL               DEVICE_NULL
        !            46: #define mach_device_reference          device_reference
        !            47: #define mach_device_deallocate         device_deallocate
        !            48: #define mach_convert_device_to_port    convert_device_to_port
        !            49: #endif
        !            50: 
        !            51: /*
        !            52:  * Generic device header.  May be allocated with the device,
        !            53:  * or built when the device is opened.
        !            54:  */
        !            55: struct mach_device {
        !            56:        decl_simple_lock_data(,ref_lock)/* lock for reference count */
        !            57:        int             ref_count;      /* reference count */
        !            58:        decl_simple_lock_data(, lock)   /* lock for rest of state */
        !            59:        short           state;          /* state: */
        !            60: #define        DEV_STATE_INIT          0       /* not open  */
        !            61: #define        DEV_STATE_OPENING       1       /* being opened */
        !            62: #define        DEV_STATE_OPEN          2       /* open */
        !            63: #define        DEV_STATE_CLOSING       3       /* being closed */
        !            64:        short           flag;           /* random flags: */
        !            65: #define        D_EXCL_OPEN             0x0001  /* open only once */
        !            66:        short           open_count;     /* number of times open */
        !            67:        short           io_in_progress; /* number of IOs in progress */
        !            68:        boolean_t       io_wait;        /* someone waiting for IO to finish */
        !            69: 
        !            70:        struct ipc_port *port;          /* open port */
        !            71:        queue_chain_t   number_chain;   /* chain for lookup by number */
        !            72:        int             dev_number;     /* device number */
        !            73:        int             bsize;          /* replacement for DEV_BSIZE */
        !            74:        struct dev_ops  *dev_ops;       /* and operations vector */
        !            75: #ifdef i386
        !            76:        struct device   dev;            /* the real device structure */
        !            77: #endif
        !            78: };
        !            79: typedef        struct mach_device *mach_device_t;
        !            80: #define        MACH_DEVICE_NULL ((mach_device_t)0)
        !            81: 
        !            82: /*
        !            83:  * To find and remove device entries
        !            84:  */
        !            85: mach_device_t  device_lookup();        /* by name */
        !            86: 
        !            87: void           mach_device_reference();
        !            88: void           mach_device_deallocate();
        !            89: 
        !            90: /*
        !            91:  * To find and remove port-to-device mappings
        !            92:  */
        !            93: device_t       dev_port_lookup();
        !            94: void           dev_port_enter();
        !            95: void           dev_port_remove();
        !            96: 
        !            97: /*
        !            98:  * To call a routine on each device
        !            99:  */
        !           100: boolean_t      dev_map();
        !           101: 
        !           102: /*
        !           103:  * To lock and unlock state and open-count
        !           104:  */
        !           105: #define        device_lock(device)     simple_lock(&(device)->lock)
        !           106: #define        device_unlock(device)   simple_unlock(&(device)->lock)
        !           107: 
        !           108: #endif /* _DEVICE_DEV_HDR_H_ */

unix.superglobalmegacorp.com

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