The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/device/dev_hdr.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    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  Software.Distribution@CS.CMU.EDU
   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  * HISTORY
   28  * $Log:        dev_hdr.h,v $
   29  * Revision 2.8  93/05/10  21:18:11  rvb
   30  *      Added block size (bsize) field, replaces DEV_BSIZE.
   31  *      [93/05/06  11:10:35  af]
   32  * 
   33  * Revision 2.7  91/05/14  15:40:30  mrt
   34  *      Correcting copyright
   35  * 
   36  * Revision 2.6  91/02/05  17:08:20  mrt
   37  *      Changed to new Mach copyright
   38  *      [91/01/31  17:27:12  mrt]
   39  * 
   40  * Revision 2.5  90/09/09  14:31:08  rpd
   41  *      Use decl_simple_lock_data.
   42  *      [90/08/30            rpd]
   43  * 
   44  * Revision 2.4  90/08/27  21:54:45  dbg
   45  *      Fix type definitions.
   46  *      [90/07/16            dbg]
   47  * 
   48  * Revision 2.3  90/06/02  14:47:10  rpd
   49  *      Updated for new IPC.
   50  *      [90/03/26  21:43:28  rpd]
   51  * 
   52  * Revision 2.2  89/09/08  11:23:07  dbg
   53  *      Rename to 'struct device' and 'device_t'.  Added open-
   54  *      state.  Removed most of old flags.
   55  *      [89/08/01            dbg]
   56  * 
   57  * 12-Apr-89  David Golub (dbg) at Carnegie-Mellon University
   58  *      Added routine to call a function on each device.
   59  *
   60  *  3-Mar-89  David Golub (dbg) at Carnegie-Mellon University
   61  *      Created.
   62  */
   63 /*
   64  *      Author: David B. Golub, Carnegie Mellon University
   65  *      Date:   3/89
   66  */
   67 
   68 #ifndef _DEVICE_DEV_HDR_H_
   69 #define _DEVICE_DEV_HDR_H_
   70 
   71 #include <mach/port.h>
   72 #include <kern/lock.h>
   73 #include <kern/queue.h>
   74 
   75 #include <device/conf.h>
   76 
   77 /*
   78  * Generic device header.  May be allocated with the device,
   79  * or built when the device is opened.
   80  */
   81 struct device {
   82         decl_simple_lock_data(,ref_lock)/* lock for reference count */
   83         int             ref_count;      /* reference count */
   84         decl_simple_lock_data(, lock)   /* lock for rest of state */
   85         short           state;          /* state: */
   86 #define DEV_STATE_INIT          0       /* not open  */
   87 #define DEV_STATE_OPENING       1       /* being opened */
   88 #define DEV_STATE_OPEN          2       /* open */
   89 #define DEV_STATE_CLOSING       3       /* being closed */
   90         short           flag;           /* random flags: */
   91 #define D_EXCL_OPEN             0x0001  /* open only once */
   92         short           open_count;     /* number of times open */
   93         short           io_in_progress; /* number of IOs in progress */
   94         boolean_t       io_wait;        /* someone waiting for IO to finish */
   95 
   96         struct ipc_port *port;          /* open port */
   97         queue_chain_t   number_chain;   /* chain for lookup by number */
   98         int             dev_number;     /* device number */
   99         int             bsize;          /* replacement for DEV_BSIZE */
  100         struct dev_ops  *dev_ops;       /* and operations vector */
  101 };
  102 typedef struct device   *device_t;
  103 #define DEVICE_NULL     ((device_t)0)
  104 
  105 /*
  106  * To find and remove device entries
  107  */
  108 device_t        device_lookup();        /* by name */
  109 
  110 void            device_reference();
  111 void            device_deallocate();
  112 
  113 /*
  114  * To find and remove port-to-device mappings
  115  */
  116 device_t        dev_port_lookup();
  117 void            dev_port_enter();
  118 void            dev_port_remove();
  119 
  120 /*
  121  * To call a routine on each device
  122  */
  123 boolean_t       dev_map();
  124 
  125 /*
  126  * To lock and unlock state and open-count
  127  */
  128 #define device_lock(device)     simple_lock(&(device)->lock)
  129 #define device_unlock(device)   simple_unlock(&(device)->lock)
  130 
  131 #endif  /* _DEVICE_DEV_HDR_H_ */

Cache object: 3fd81a366d135934b637c09a5f43e3b2


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.