]> git.saurik.com Git - apple/xnu.git/blob - iokit/Kernel/ppc/IODBDMA.cpp
xnu-792.13.8.tar.gz
[apple/xnu.git] / iokit / Kernel / ppc / IODBDMA.cpp
1 /*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 /*
31 * Copyright (c) 1997 Apple Computer, Inc.
32 *
33 *
34 * HISTORY
35 *
36 * Simon Douglas 10 Nov 97
37 * - first checked in, mostly from machdep/ppc/dbdma.c
38 *
39 */
40
41
42 #include <IOKit/ppc/IODBDMA.h>
43 #include <IOKit/IOLib.h>
44
45 void
46 IODBDMAStart( volatile IODBDMAChannelRegisters *registers, volatile IODBDMADescriptor *physicalDescPtr)
47 {
48
49 if( ((int) physicalDescPtr) & 0xf)
50 panic("IODBDMAStart: unaligned IODBDMADescriptor");
51
52 eieio();
53 IOSetDBDMAInterruptSelect(registers, 0xff000000); // clear out interrupts
54
55 IOSetDBDMAChannelControl( registers,
56 IOClearDBDMAChannelControlBits( kdbdmaRun | kdbdmaPause | kdbdmaFlush | kdbdmaWake | kdbdmaDead | kdbdmaActive ));
57
58 while( IOGetDBDMAChannelStatus( registers) & kdbdmaActive)
59 eieio();
60
61 IOSetDBDMACommandPtr( registers, (unsigned int) physicalDescPtr);
62
63 IOSetDBDMAChannelControl( registers,
64 IOSetDBDMAChannelControlBits( kdbdmaRun | kdbdmaWake ));
65
66 }
67
68 void
69 IODBDMAStop( volatile IODBDMAChannelRegisters *registers)
70 {
71
72 IOSetDBDMAChannelControl( registers,
73 IOClearDBDMAChannelControlBits( kdbdmaRun )
74 | IOSetDBDMAChannelControlBits( kdbdmaFlush ));
75
76 while( IOGetDBDMAChannelStatus( registers) & ( kdbdmaActive | kdbdmaFlush))
77 eieio();
78
79 }
80
81 void
82 IODBDMAFlush( volatile IODBDMAChannelRegisters *registers)
83 {
84
85 IOSetDBDMAChannelControl( registers,
86 IOSetDBDMAChannelControlBits( kdbdmaFlush ));
87
88 while( IOGetDBDMAChannelStatus( registers) & kdbdmaFlush)
89 eieio();
90
91 }
92
93 void
94 IODBDMAReset( volatile IODBDMAChannelRegisters *registers)
95 {
96
97 IOSetDBDMAChannelControl( registers,
98 IOClearDBDMAChannelControlBits( kdbdmaRun | kdbdmaPause | kdbdmaFlush | kdbdmaWake | kdbdmaDead | kdbdmaActive ));
99
100 while( IOGetDBDMAChannelStatus( registers) & kdbdmaActive)
101 eieio();
102
103 }
104
105 void
106 IODBDMAContinue( volatile IODBDMAChannelRegisters *registers)
107 {
108
109 IOSetDBDMAChannelControl( registers,
110 IOClearDBDMAChannelControlBits( kdbdmaPause | kdbdmaDead )
111 | IOSetDBDMAChannelControlBits( kdbdmaRun | kdbdmaWake ));
112
113 }
114
115 void
116 IODBDMAPause( volatile IODBDMAChannelRegisters *registers)
117 {
118
119 IOSetDBDMAChannelControl( registers,
120 IOSetDBDMAChannelControlBits( kdbdmaPause ));
121
122 while( IOGetDBDMAChannelStatus( registers) & kdbdmaActive)
123 eieio();
124
125 }
126
127 IOReturn
128 IOAllocatePhysicallyContiguousMemory(
129 unsigned int /* size */, unsigned int /* options */,
130 IOVirtualAddress * /* logical */,
131 IOPhysicalAddress * /* physical */ )
132 {
133 #if 0
134 IOReturn err;
135 vm_offset_t mem;
136
137 if( (size > 4096) || (options))
138 return( kIOReturnUnsupported);
139
140 mem = (vm_offset_t) IOMalloc( size);
141 *logical = (IOVirtualAddress) mem;
142
143 if( mem) {
144 err = IOPhysicalFromVirtual( IOVmTaskSelf(), mem, (vm_offset_t *) physical);
145 if( err)
146 IOFree( (char *)mem, size);
147
148 } else {
149 err = kIOReturnNoMemory;
150 *physical = 0;
151 }
152
153 return( err);
154 #endif /* 0 */
155 return (kIOReturnUnsupported);
156 }
157
158 IOReturn
159 IOFreePhysicallyContiguousMemory( IOVirtualAddress * logical, unsigned int size)
160 {
161 IOFree( logical, size);
162 return( kIOReturnSuccess);
163 }