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