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