|
|
1.1.1.2 root 1: /*
1.1 root 2: * Mach Operating System
3: * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
4: * All Rights Reserved.
1.1.1.2 root 5: *
1.1 root 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.
1.1.1.2 root 11: *
1.1 root 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.
1.1.1.2 root 15: *
1.1 root 16: * Carnegie Mellon requests users of this software to return to
1.1.1.2 root 17: *
1.1 root 18: * Software Distribution Coordinator or [email protected]
19: * School of Computer Science
20: * Carnegie Mellon University
21: * Pittsburgh PA 15213-3890
1.1.1.2 root 22: *
1.1 root 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: 10/88
29: */
30:
31: #ifndef _IO_REQ_
32: #define _IO_REQ_
33:
34: #include <mach/boolean.h>
35: #include <mach/port.h>
36: #include <mach/message.h>
37: #include <mach/vm_param.h>
1.1.1.3 root 38: #include <kern/slab.h>
1.1 root 39: #include <kern/kalloc.h>
40: #include <kern/lock.h>
41: #include <vm/vm_page.h>
42: #include <device/device_types.h>
43: #include <device/dev_hdr.h>
44:
1.1.1.4 ! root 45: #include <kern/macros.h>
1.1 root 46:
47: /*
48: * IO request element, queued on device for delayed replies.
49: */
1.1.1.3 root 50: typedef struct io_req *io_req_t;
1.1 root 51: struct io_req {
52: struct io_req * io_next; /* next, ... */
53: struct io_req * io_prev; /* prev pointers: link in done,
54: defered, or in-progress list */
55: mach_device_t io_device; /* pointer to open-device structure */
56: char * io_dev_ptr; /* pointer to driver structure -
57: filled in by driver if necessary */
58: int io_unit; /* unit number ('minor') of device */
59: int io_op; /* IO operation */
60: dev_mode_t io_mode; /* operation mode (wait, truncate) */
61: recnum_t io_recnum; /* starting record number for
62: random-access devices */
63:
64: union io_un {
65: io_buf_ptr_t data; /* data, for IO requests */
66: } io_un;
67: #define io_data io_un.data
68:
69: long io_count; /* amount requested */
1.1.1.3 root 70: vm_size_t io_alloc_size; /* amount allocated */
1.1 root 71: long io_residual; /* amount NOT done */
72: io_return_t io_error; /* error code */
1.1.1.3 root 73: /* call when done - returns TRUE if IO really finished */
74: boolean_t (*io_done)(io_req_t);
1.1 root 75: struct ipc_port *io_reply_port; /* reply port, for asynchronous
76: messages */
77: mach_msg_type_name_t io_reply_port_type;
78: /* send or send-once right? */
79: struct io_req * io_link; /* forward link (for driver header) */
80: struct io_req * io_rlink; /* reverse link (for driver header) */
81: vm_map_copy_t io_copy; /* vm_map_copy obj. for this op. */
82: long io_total; /* total op size, for write */
83: decl_simple_lock_data(,io_req_lock)
84: /* Lock for this structure */
85: long io_physrec; /* mapping to the physical block
86: number */
87: long io_rectotal; /* total number of blocks to move */
88: };
89:
90: /*
91: * LOCKING NOTE: Operations on io_req's are in general single threaded by
92: * the invoking code, obviating the need for a lock. The usual IO_CALL
93: * path through the code is: Initiating thread hands io_req to device driver,
94: * driver passes it to io_done thread, io_done thread sends reply message. No
95: * locking is needed in this sequence. Unfortunately, a synchronous wait
96: * for a buffer requires a lock to avoid problems if the wait and interrupt
97: * happen simultaneously on different processors.
98: */
99:
100: #define ior_lock(ior) simple_lock(&(ior)->io_req_lock)
101: #define ior_unlock(ior) simple_unlock(&(ior)->io_req_lock)
102:
103: /*
104: * Flags and operations
105: */
106:
107: #define IO_WRITE 0x00000000 /* operation is write */
108: #define IO_READ 0x00000001 /* operation is read */
109: #define IO_OPEN 0x00000002 /* operation is open */
110: #define IO_DONE 0x00000100 /* operation complete */
111: #define IO_ERROR 0x00000200 /* error on operation */
112: #define IO_BUSY 0x00000400 /* operation in progress */
113: #define IO_WANTED 0x00000800 /* wakeup when no longer BUSY */
114: #define IO_BAD 0x00001000 /* bad disk block */
115: #define IO_CALL 0x00002000 /* call io_done_thread when done */
116: #define IO_INBAND 0x00004000 /* mig call was inband */
117: #define IO_INTERNAL 0x00008000 /* internal, device-driver specific */
118: #define IO_LOANED 0x00010000 /* ior loaned by another module */
119:
120: #define IO_SPARE_START 0x00020000 /* start of spare flags */
121:
122: /*
123: * Standard completion routine for io_requests.
124: */
1.1.1.3 root 125: void iodone(io_req_t);
1.1 root 126:
127: /*
1.1.1.3 root 128: * Macros to allocate and free IORs - will convert to caches later.
1.1 root 129: */
130: #define io_req_alloc(ior,size) \
131: MACRO_BEGIN \
132: (ior) = (io_req_t)kalloc(sizeof(struct io_req)); \
133: simple_lock_init(&(ior)->io_req_lock); \
134: MACRO_END
135:
136: #define io_req_free(ior) \
137: (kfree((vm_offset_t)(ior), sizeof(struct io_req)))
138:
139:
1.1.1.3 root 140: struct kmem_cache io_inband_cache; /* for inband reads */
1.1 root 141:
1.1.1.2 root 142: #endif /* _IO_REQ_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.