|
|
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:
1.1.1.2 ! root 31: /*
! 32: * Mach device emulation definitions (i386at version).
! 33: *
! 34: * Copyright (c) 1996 The University of Utah and
! 35: * the Computer Systems Laboratory at the University of Utah (CSL).
! 36: * All rights reserved.
! 37: *
! 38: * Permission to use, copy, modify and distribute this software is hereby
! 39: * granted provided that (1) source code retains these copyright, permission,
! 40: * and disclaimer notices, and (2) redistributions including binaries
! 41: * reproduce the notices in supporting documentation, and (3) all advertising
! 42: * materials mentioning features or use of this software display the following
! 43: * acknowledgement: ``This product includes software developed by the
! 44: * Computer Systems Laboratory at the University of Utah.''
! 45: *
! 46: * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
! 47: * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
! 48: * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
! 49: *
! 50: * CSL requests users of this software to return to [email protected] any
! 51: * improvements that they make and grant CSL redistribution rights.
! 52: *
! 53: * Author: Shantanu Goel, University of Utah CSL
! 54: */
! 55:
1.1 root 56: #ifndef _DEVICE_DEV_HDR_H_
57: #define _DEVICE_DEV_HDR_H_
58:
1.1.1.2 ! root 59: #include <ipc/ipc_types.h>
1.1 root 60: #include <mach/port.h>
61: #include <kern/lock.h>
62: #include <kern/queue.h>
63:
64: #include <device/conf.h>
65:
1.1.1.2 ! root 66: /* This structure is associated with each open device port.
! 67: The port representing the device points to this structure. */
! 68: struct device
! 69: {
! 70: struct device_emulation_ops *emul_ops;
! 71: void *emul_data;
! 72: };
! 73:
! 74: typedef struct device *device_t;
! 75:
! 76: #define DEVICE_NULL ((device_t) 0)
1.1 root 77:
78: /*
79: * Generic device header. May be allocated with the device,
80: * or built when the device is opened.
81: */
82: struct mach_device {
83: decl_simple_lock_data(,ref_lock)/* lock for reference count */
84: int ref_count; /* reference count */
85: decl_simple_lock_data(, lock) /* lock for rest of state */
86: short state; /* state: */
87: #define DEV_STATE_INIT 0 /* not open */
88: #define DEV_STATE_OPENING 1 /* being opened */
89: #define DEV_STATE_OPEN 2 /* open */
90: #define DEV_STATE_CLOSING 3 /* being closed */
91: short flag; /* random flags: */
92: #define D_EXCL_OPEN 0x0001 /* open only once */
93: short open_count; /* number of times open */
94: short io_in_progress; /* number of IOs in progress */
95: boolean_t io_wait; /* someone waiting for IO to finish */
96:
97: struct ipc_port *port; /* open port */
98: queue_chain_t number_chain; /* chain for lookup by number */
99: int dev_number; /* device number */
100: int bsize; /* replacement for DEV_BSIZE */
101: struct dev_ops *dev_ops; /* and operations vector */
102: struct device dev; /* the real device structure */
103: };
104: typedef struct mach_device *mach_device_t;
105: #define MACH_DEVICE_NULL ((mach_device_t)0)
106:
107: /*
108: * To find and remove device entries
109: */
1.1.1.2 ! root 110: mach_device_t device_lookup(char *); /* by name */
1.1 root 111:
1.1.1.2 ! root 112: void mach_device_reference(mach_device_t);
! 113: void mach_device_deallocate(mach_device_t);
1.1 root 114:
115: /*
116: * To find and remove port-to-device mappings
117: */
1.1.1.2 ! root 118: device_t dev_port_lookup(ipc_port_t);
! 119: void dev_port_enter(mach_device_t);
! 120: void dev_port_remove(mach_device_t);
1.1 root 121:
122: /*
123: * To call a routine on each device
124: */
1.1.1.2 ! root 125: boolean_t dev_map(boolean_t (*)(), mach_port_t);
1.1 root 126:
127: /*
128: * To lock and unlock state and open-count
129: */
130: #define device_lock(device) simple_lock(&(device)->lock)
131: #define device_unlock(device) simple_unlock(&(device)->lock)
132:
1.1.1.2 ! root 133: /*
! 134: * device name lookup
! 135: */
! 136: extern boolean_t dev_name_lookup(
! 137: char * name,
! 138: dev_ops_t *ops, /* out */
! 139: int *unit); /* out */
! 140:
! 141: /*
! 142: * Change an entry in the indirection list.
! 143: */
! 144: extern void dev_set_indirection(
! 145: char *name,
! 146: dev_ops_t ops,
! 147: int unit);
! 148:
1.1 root 149: #endif /* _DEVICE_DEV_HDR_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.