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