]>
git.saurik.com Git - apple/xnu.git/blob - iokit/Kernel/ppc/IODBDMA.cpp
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * Copyright (c) 1997 Apple Computer, Inc.
34 * Simon Douglas 10 Nov 97
35 * - first checked in, mostly from machdep/ppc/dbdma.c
40 #include <IOKit/ppc/IODBDMA.h>
41 #include <IOKit/IOLib.h>
44 IODBDMAStart( volatile IODBDMAChannelRegisters
*registers
, volatile IODBDMADescriptor
*physicalDescPtr
)
47 if( ((int) physicalDescPtr
) & 0xf)
48 panic("IODBDMAStart: unaligned IODBDMADescriptor");
51 IOSetDBDMAInterruptSelect(registers
, 0xff000000); // clear out interrupts
53 IOSetDBDMAChannelControl( registers
,
54 IOClearDBDMAChannelControlBits( kdbdmaRun
| kdbdmaPause
| kdbdmaFlush
| kdbdmaWake
| kdbdmaDead
| kdbdmaActive
));
56 while( IOGetDBDMAChannelStatus( registers
) & kdbdmaActive
)
59 IOSetDBDMACommandPtr( registers
, (unsigned int) physicalDescPtr
);
61 IOSetDBDMAChannelControl( registers
,
62 IOSetDBDMAChannelControlBits( kdbdmaRun
| kdbdmaWake
));
67 IODBDMAStop( volatile IODBDMAChannelRegisters
*registers
)
70 IOSetDBDMAChannelControl( registers
,
71 IOClearDBDMAChannelControlBits( kdbdmaRun
)
72 | IOSetDBDMAChannelControlBits( kdbdmaFlush
));
74 while( IOGetDBDMAChannelStatus( registers
) & ( kdbdmaActive
| kdbdmaFlush
))
80 IODBDMAFlush( volatile IODBDMAChannelRegisters
*registers
)
83 IOSetDBDMAChannelControl( registers
,
84 IOSetDBDMAChannelControlBits( kdbdmaFlush
));
86 while( IOGetDBDMAChannelStatus( registers
) & kdbdmaFlush
)
92 IODBDMAReset( volatile IODBDMAChannelRegisters
*registers
)
95 IOSetDBDMAChannelControl( registers
,
96 IOClearDBDMAChannelControlBits( kdbdmaRun
| kdbdmaPause
| kdbdmaFlush
| kdbdmaWake
| kdbdmaDead
| kdbdmaActive
));
98 while( IOGetDBDMAChannelStatus( registers
) & kdbdmaActive
)
104 IODBDMAContinue( volatile IODBDMAChannelRegisters
*registers
)
107 IOSetDBDMAChannelControl( registers
,
108 IOClearDBDMAChannelControlBits( kdbdmaPause
| kdbdmaDead
)
109 | IOSetDBDMAChannelControlBits( kdbdmaRun
| kdbdmaWake
));
114 IODBDMAPause( volatile IODBDMAChannelRegisters
*registers
)
117 IOSetDBDMAChannelControl( registers
,
118 IOSetDBDMAChannelControlBits( kdbdmaPause
));
120 while( IOGetDBDMAChannelStatus( registers
) & kdbdmaActive
)
126 IOAllocatePhysicallyContiguousMemory(
127 unsigned int /* size */, unsigned int /* options */,
128 IOVirtualAddress
* /* logical */,
129 IOPhysicalAddress
* /* physical */ )
135 if( (size
> 4096) || (options
))
136 return( kIOReturnUnsupported
);
138 mem
= (vm_offset_t
) IOMalloc( size
);
139 *logical
= (IOVirtualAddress
) mem
;
142 err
= IOPhysicalFromVirtual( IOVmTaskSelf(), mem
, (vm_offset_t
*) physical
);
144 IOFree( (char *)mem
, size
);
147 err
= kIOReturnNoMemory
;
153 return (kIOReturnUnsupported
);
157 IOFreePhysicallyContiguousMemory( IOVirtualAddress
* logical
, unsigned int size
)
159 IOFree( logical
, size
);
160 return( kIOReturnSuccess
);