1/* 2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 * 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 24 * limitations under the License. 25 * 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 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 43void 44IODBDMAStart( 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 66void 67IODBDMAStop( 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 79void 80IODBDMAFlush( volatile IODBDMAChannelRegisters *registers) 81{ 82 83 IOSetDBDMAChannelControl( registers, 84 IOSetDBDMAChannelControlBits( kdbdmaFlush )); 85 86 while( IOGetDBDMAChannelStatus( registers) & kdbdmaFlush) 87 eieio(); 88 89} 90 91void 92IODBDMAReset( 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 103void 104IODBDMAContinue( volatile IODBDMAChannelRegisters *registers) 105{ 106 107 IOSetDBDMAChannelControl( registers, 108 IOClearDBDMAChannelControlBits( kdbdmaPause | kdbdmaDead ) 109 | IOSetDBDMAChannelControlBits( kdbdmaRun | kdbdmaWake )); 110 111} 112 113void 114IODBDMAPause( volatile IODBDMAChannelRegisters *registers) 115{ 116 117 IOSetDBDMAChannelControl( registers, 118 IOSetDBDMAChannelControlBits( kdbdmaPause )); 119 120 while( IOGetDBDMAChannelStatus( registers) & kdbdmaActive) 121 eieio(); 122 123} 124 125IOReturn 126IOAllocatePhysicallyContiguousMemory( 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 156IOReturn 157IOFreePhysicallyContiguousMemory( IOVirtualAddress * logical, unsigned int size) 158{ 159 IOFree( logical, size); 160 return( kIOReturnSuccess); 161} 162