]>
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_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
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
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
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
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.
23 * @APPLE_LICENSE_HEADER_END@
26 * Copyright (c) 1997 Apple Computer, Inc.
31 * Simon Douglas 10 Nov 97
32 * - first checked in, mostly from machdep/ppc/dbdma.c
37 #include <IOKit/ppc/IODBDMA.h>
38 #include <IOKit/IOLib.h>
41 IODBDMAStart( volatile IODBDMAChannelRegisters
*registers
, volatile IODBDMADescriptor
*physicalDescPtr
)
44 if( ((int) physicalDescPtr
) & 0xf)
45 panic("IODBDMAStart: unaligned IODBDMADescriptor");
48 IOSetDBDMAInterruptSelect(registers
, 0xff000000); // clear out interrupts
50 IOSetDBDMAChannelControl( registers
,
51 IOClearDBDMAChannelControlBits( kdbdmaRun
| kdbdmaPause
| kdbdmaFlush
| kdbdmaWake
| kdbdmaDead
| kdbdmaActive
));
53 while( IOGetDBDMAChannelStatus( registers
) & kdbdmaActive
)
56 IOSetDBDMACommandPtr( registers
, (unsigned int) physicalDescPtr
);
58 IOSetDBDMAChannelControl( registers
,
59 IOSetDBDMAChannelControlBits( kdbdmaRun
| kdbdmaWake
));
64 IODBDMAStop( volatile IODBDMAChannelRegisters
*registers
)
67 IOSetDBDMAChannelControl( registers
,
68 IOClearDBDMAChannelControlBits( kdbdmaRun
)
69 | IOSetDBDMAChannelControlBits( kdbdmaFlush
));
71 while( IOGetDBDMAChannelStatus( registers
) & ( kdbdmaActive
| kdbdmaFlush
))
77 IODBDMAFlush( volatile IODBDMAChannelRegisters
*registers
)
80 IOSetDBDMAChannelControl( registers
,
81 IOSetDBDMAChannelControlBits( kdbdmaFlush
));
83 while( IOGetDBDMAChannelStatus( registers
) & kdbdmaFlush
)
89 IODBDMAReset( volatile IODBDMAChannelRegisters
*registers
)
92 IOSetDBDMAChannelControl( registers
,
93 IOClearDBDMAChannelControlBits( kdbdmaRun
| kdbdmaPause
| kdbdmaFlush
| kdbdmaWake
| kdbdmaDead
| kdbdmaActive
));
95 while( IOGetDBDMAChannelStatus( registers
) & kdbdmaActive
)
101 IODBDMAContinue( volatile IODBDMAChannelRegisters
*registers
)
104 IOSetDBDMAChannelControl( registers
,
105 IOClearDBDMAChannelControlBits( kdbdmaPause
| kdbdmaDead
)
106 | IOSetDBDMAChannelControlBits( kdbdmaRun
| kdbdmaWake
));
111 IODBDMAPause( volatile IODBDMAChannelRegisters
*registers
)
114 IOSetDBDMAChannelControl( registers
,
115 IOSetDBDMAChannelControlBits( kdbdmaPause
));
117 while( IOGetDBDMAChannelStatus( registers
) & kdbdmaActive
)
123 IOAllocatePhysicallyContiguousMemory(
124 unsigned int /* size */, unsigned int /* options */,
125 IOVirtualAddress
* /* logical */,
126 IOPhysicalAddress
* /* physical */ )
132 if( (size
> 4096) || (options
))
133 return( kIOReturnUnsupported
);
135 mem
= (vm_offset_t
) IOMalloc( size
);
136 *logical
= (IOVirtualAddress
) mem
;
139 err
= IOPhysicalFromVirtual( IOVmTaskSelf(), mem
, (vm_offset_t
*) physical
);
141 IOFree( (char *)mem
, size
);
144 err
= kIOReturnNoMemory
;
150 return (kIOReturnUnsupported
);
154 IOFreePhysicallyContiguousMemory( IOVirtualAddress
* logical
, unsigned int size
)
156 IOFree( logical
, size
);
157 return( kIOReturnSuccess
);