]>
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 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 1997 Apple Computer, Inc.
28 * Simon Douglas 10 Nov 97
29 * - first checked in, mostly from machdep/ppc/dbdma.c
34 #include <IOKit/ppc/IODBDMA.h>
35 #include <IOKit/IOLib.h>
38 IODBDMAStart( volatile IODBDMAChannelRegisters
*registers
, volatile IODBDMADescriptor
*physicalDescPtr
)
41 if( ((int) physicalDescPtr
) & 0xf)
42 panic("IODBDMAStart: unaligned IODBDMADescriptor");
45 IOSetDBDMAInterruptSelect(registers
, 0xff000000); // clear out interrupts
47 IOSetDBDMAChannelControl( registers
,
48 IOClearDBDMAChannelControlBits( kdbdmaRun
| kdbdmaPause
| kdbdmaFlush
| kdbdmaWake
| kdbdmaDead
| kdbdmaActive
));
50 while( IOGetDBDMAChannelStatus( registers
) & kdbdmaActive
)
53 IOSetDBDMACommandPtr( registers
, (unsigned int) physicalDescPtr
);
55 IOSetDBDMAChannelControl( registers
,
56 IOSetDBDMAChannelControlBits( kdbdmaRun
| kdbdmaWake
));
61 IODBDMAStop( volatile IODBDMAChannelRegisters
*registers
)
64 IOSetDBDMAChannelControl( registers
,
65 IOClearDBDMAChannelControlBits( kdbdmaRun
)
66 | IOSetDBDMAChannelControlBits( kdbdmaFlush
));
68 while( IOGetDBDMAChannelStatus( registers
) & ( kdbdmaActive
| kdbdmaFlush
))
74 IODBDMAFlush( volatile IODBDMAChannelRegisters
*registers
)
77 IOSetDBDMAChannelControl( registers
,
78 IOSetDBDMAChannelControlBits( kdbdmaFlush
));
80 while( IOGetDBDMAChannelStatus( registers
) & kdbdmaFlush
)
86 IODBDMAReset( volatile IODBDMAChannelRegisters
*registers
)
89 IOSetDBDMAChannelControl( registers
,
90 IOClearDBDMAChannelControlBits( kdbdmaRun
| kdbdmaPause
| kdbdmaFlush
| kdbdmaWake
| kdbdmaDead
| kdbdmaActive
));
92 while( IOGetDBDMAChannelStatus( registers
) & kdbdmaActive
)
98 IODBDMAContinue( volatile IODBDMAChannelRegisters
*registers
)
101 IOSetDBDMAChannelControl( registers
,
102 IOClearDBDMAChannelControlBits( kdbdmaPause
| kdbdmaDead
)
103 | IOSetDBDMAChannelControlBits( kdbdmaRun
| kdbdmaWake
));
108 IODBDMAPause( volatile IODBDMAChannelRegisters
*registers
)
111 IOSetDBDMAChannelControl( registers
,
112 IOSetDBDMAChannelControlBits( kdbdmaPause
));
114 while( IOGetDBDMAChannelStatus( registers
) & kdbdmaActive
)
120 IOAllocatePhysicallyContiguousMemory(
121 unsigned int /* size */, unsigned int /* options */,
122 IOVirtualAddress
* /* logical */,
123 IOPhysicalAddress
* /* physical */ )
129 if( (size
> 4096) || (options
))
130 return( kIOReturnUnsupported
);
132 mem
= (vm_offset_t
) IOMalloc( size
);
133 *logical
= (IOVirtualAddress
) mem
;
136 err
= IOPhysicalFromVirtual( IOVmTaskSelf(), mem
, (vm_offset_t
*) physical
);
138 IOFree( (char *)mem
, size
);
141 err
= kIOReturnNoMemory
;
147 return (kIOReturnUnsupported
);
151 IOFreePhysicallyContiguousMemory( IOVirtualAddress
* logical
, unsigned int size
)
153 IOFree( logical
, size
);
154 return( kIOReturnSuccess
);