|
|
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: 7/89
29: *
30: * Block IO driven from generic kernel IO interface.
31: */
32: #include <mach/kern_return.h>
33:
34: #include <device/param.h>
35: #include <device/device_types.h>
36: #include <device/io_req.h>
37: #include <device/ds_routines.h>
38:
39:
40:
1.1.1.3 root 41: io_return_t block_io(
42: void (*strat)(),
43: void (*max_count)(),
44: io_req_t ior)
1.1 root 45: {
1.1.1.3 root 46: kern_return_t rc;
1.1 root 47: boolean_t wait = FALSE;
48:
49: /*
50: * Make sure the size is not too large by letting max_count
51: * change io_count. If we are doing a write, then io_alloc_size
52: * preserves the original io_count.
53: */
54: (*max_count)(ior);
55:
56: /*
57: * If reading, allocate memory. If writing, wire
58: * down the incoming memory.
59: */
60: if (ior->io_op & IO_READ)
61: rc = device_read_alloc(ior, (vm_size_t)ior->io_count);
62: else
63: rc = device_write_get(ior, &wait);
64:
65: if (rc != KERN_SUCCESS)
66: return (rc);
67:
68: /*
69: * Queue the operation for the device.
70: */
71: (*strat)(ior);
72:
73: /*
74: * The io is now queued. Wait for it if needed.
75: */
76: if (wait) {
77: iowait(ior);
78: return(D_SUCCESS);
79: }
80:
81: return (D_IO_QUEUED);
82: }
83:
84: /*
85: * 'standard' max_count routine. VM continuations mean that this
86: * code can cope with arbitrarily-sized write operations (they won't be
87: * atomic, but any caller that cares will do the op synchronously).
88: */
89: #define MAX_PHYS (256 * 1024)
90:
1.1.1.3 root 91: void minphys(io_req_t ior)
1.1 root 92: {
93: if ((ior->io_op & (IO_WRITE | IO_READ | IO_OPEN)) == IO_WRITE)
94: return;
95:
96: if (ior->io_count > MAX_PHYS)
97: ior->io_count = MAX_PHYS;
98: }
99:
100: /*
101: * Dummy routine placed in device switch entries to indicate that
102: * block device may be mapped.
103: */
1.1.1.4 ! root 104: int block_io_mmap(dev_t dev, vm_offset_t off, int prot)
1.1 root 105: {
106: return (0);
107: }
108:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.