|
|
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: /** ! 26: * Copyright (c) 1994-1996 NeXT Software, Inc. All rights reserved. ! 27: * Copyright 1997 Apple Computer Inc. All Rights Reserved. ! 28: * @author Martin Minow mailto:[email protected] ! 29: * @revision 1997.02.13 Initial conversion from AMDPCSCSIDriver sources. ! 30: * ! 31: * Set tabs every 4 characters. ! 32: * ! 33: * Apple96PCIDBDMA.h - Minimal DBDMA Handler for the Apple 96 PCI driver. This is ! 34: * a temporary file until "real" DBDMA support appears. ! 35: * ! 36: * Edit History ! 37: * 1997.02.13 MM Initial conversion from AMDPCSCSIDriver sources. ! 38: * 1997.07.18 MM Added USE_CURIO_METHODS and wrote macros for the ! 39: * one-liner methods. ! 40: */ ! 41: ! 42: #import "Apple96SCSI.h" ! 43: ! 44: /** ! 45: * Copyright 1984-1997 Apple Computer Inc. All Rights Reserved. ! 46: * @author Martin Minow mailto:[email protected] ! 47: * @revision 1997.02.13 Initial conversion from Copland D12 DBDMA.Rev 9 sources. ! 48: * ! 49: * Set tabs every 4 characters. ! 50: * ! 51: * AppleDBDMADefinitions.h - registers and inline functions for the DBDMA memory controller. ! 52: * ! 53: * Edit History ! 54: * 1997.02.13 MM Initial conversion from AMDPCSCSIDriver sources. ! 55: */ ! 56: ! 57: #import "Apple96DBDMADefs.h" ! 58: #import <machdep/ppc/proc_reg.h> ! 59: ! 60: #if 1 ! 61: /** ! 62: * This is a temporary implementation of EndianSwap32Bit until ! 63: * the correct library/method is made available. ! 64: * @param value The value to change ! 65: * @result The value endian-swapped. ! 66: */ ! 67: static inline unsigned EndianSwap32Bit( ! 68: unsigned value ! 69: ) ! 70: { ! 71: ! 72: register unsigned temp; ! 73: ! 74: temp = ((value & 0xFF000000) >> 24); ! 75: temp |= ((value & 0x00FF0000) >> 8); ! 76: temp |= ((value & 0x0000FF00) << 8); ! 77: temp |= ((value & 0x000000FF) << 24); ! 78: return (temp); ! 79: } ! 80: #endif ! 81: ! 82: /* ! 83: * Don't Endian-swap register read/write operations. ! 84: */ ! 85: #define __DBDMA_READ(reg) EndianSwap32Bit(*((volatile UInt32 *) &gDBDMALogicalAddress->reg)) ! 86: #define __DBDMA_WRITE(reg, value) do { \ ! 87: *((volatile UInt32 *) &gDBDMALogicalAddress->reg) = EndianSwap32Bit(value); \ ! 88: SynchronizeIO(); \ ! 89: } while (0) ! 90: ! 91: #define DBDMASetChannelControl(ctlValue) do { \ ! 92: SynchronizeIO(); \ ! 93: __DBDMA_WRITE(channelControl, ctlValue); \ ! 94: SynchronizeIO(); \ ! 95: } while (0) ! 96: #define DBDMAGetChannelStatus() __DBDMA_READ(channelStatus) ! 97: #define DBDMAGetCommandPtr() __DBDMA_READ(commandPtrLo) ! 98: #define DBDMASetCommandPtr(cclPtr) __DBDMA_WRITE(commandPtrLo, cclPtr) ! 99: #define DBDMAGetInterruptSelect() __DBDMA_READ(interruptSelect) ! 100: #define DBDMASetInterruptSelect(intSelValue) __DBDMA_WRITE(interruptSelect, intSelValue) ! 101: #define DBDMAGetBranchSelect() __DBDMA_READ(branchSelect) ! 102: #define DBDMASetBranchSelect(braSelValue) __DBDMA_WRITE(branchSelect, braSelValue) ! 103: #define DBDMAGetWaitSelect() __DBDMA_READ(waitSelect) ! 104: #define DBDMASetWaitSelect(waitSelValue) __DBDMA_WRITE(waitSelect, waitSelValue) ! 105: ! 106: ! 107: /* ! 108: * Construct a DBDMA Channel Command descriptor with no command dependencies. ! 109: * Opcode and address may not have side-effects. ! 110: * void MakeCCDescriptor( ! 111: * DBDMADescriptor descriptorPtr, ! 112: * unsigned long opcode, ! 113: * unsigned long addr -- physical address ! 114: * ); ! 115: */ ! 116: #define MakeCCDescriptor(descriptorPtr, opcode, addr) do { \ ! 117: (descriptorPtr)->address = EndianSwap32Bit(addr); \ ! 118: (descriptorPtr)->cmdDep = 0; \ ! 119: (descriptorPtr)->result = EndianSwap32Bit(0xDEADBEEF); \ ! 120: sync(); \ ! 121: (descriptorPtr)->operation = EndianSwap32Bit(opcode); \ ! 122: sync(); \ ! 123: } while (0) ! 124: /* ! 125: * Construct a DBDMA Channel Command descriptor with command dependencies. ! 126: * Opcode, address, and dependency may not have side-effects. ! 127: * void MakeCmdDepCCDescriptor( ! 128: * DBDMADescriptor descriptorPtr, ! 129: * unsigned long opcode, ! 130: * unsigned long addr, -- physical address ! 131: * unsigned long dependency ! 132: * ); ! 133: */ ! 134: #define MakeCmdDepCCDescriptor(descriptorPtr, opcode, addr, dep) do { \ ! 135: (descriptorPtr)->address = EndianSwap32Bit(addr); \ ! 136: (descriptorPtr)->cmdDep = EndianSwap32Bit(dep); \ ! 137: (descriptorPtr)->result = EndianSwap32Bit(0xDEADBEEF); \ ! 138: sync(); \ ! 139: (descriptorPtr)->operation = EndianSwap32Bit(opcode); \ ! 140: sync(); \ ! 141: } while (0) ! 142: #define GetCCOperation(descriptorPtr) \ ! 143: (EndianSwap32Bit((descriptorPtr)->operation)) ! 144: #define SetCCOperation(descriptorPtr, opcode) \ ! 145: ((descriptorPtr)->operation = EndianSwap32Bit(opcode)) ! 146: #define GetCCAddress(descriptorPtr) \ ! 147: (EndianSwap32Bit((descriptorPtr)->address)) ! 148: #define SetCCAddress(descriptorPtr, addr) \ ! 149: ((descriptorPtr)->address = EndianSwap32Bit(addr)) ! 150: #define GetCCCmdDep(descriptorPtr) \ ! 151: (EndianSwap32Bit((descriptorPtr)->cmdDep)) ! 152: #define SetCCCmdDep(descriptorPtr, cmdDepValue) \ ! 153: ((descriptorPtr)->cmdDep = EndianSwap32Bit(cmdDepValue)) ! 154: #define GetCCResult(descriptorPtr) \ ! 155: (EndianSwap32Bit((descriptorPtr)->result)) ! 156: #define SetCCResult(descriptorPtr, resultValue) \ ! 157: ((descriptorPtr)->result = EndianSwap32Bit(resultValue)) ! 158: ! 159: /* ! 160: * These macros implement the DBDMA interface. ! 161: */ ! 162: #define __DBDMAreset() do { \ ! 163: DBDMASetChannelControl( \ ! 164: kdbdmaClrRun \ ! 165: | kdbdmaClrPause \ ! 166: | kdbdmaClrDead \ ! 167: ); \ ! 168: } while (0) ! 169: ! 170: #define __DBDMAspinUntilIdle() do { \ ! 171: SynchronizeIO(); \ ! 172: } while ((DBDMAGetChannelStatus() & kdbdmaActive) != 0); \ ! 173: ! 174: #define __DBDMAstartTransfer() do { \ ! 175: DBDMASetChannelControl(kdbdmaSetRun | kdbdmaSetWake); \ ! 176: } while (0) ! 177: ! 178: #define __DBDMAstopTransfer() __DBDMAreset() ! 179: ! 180: #if USE_CURIO_METHODS ! 181: #define DBDMAreset() [self dbdmaReset] ! 182: #define DBDMAstartTransfer() [self dbdmaStartTransfer] ! 183: #define DBDMAstopTransfer() [self dbdmaStopTransfer] ! 184: #define DBDMAspinUntilIdle() [self dbdmaSpinUntilIdle] ! 185: #else ! 186: #define DBDMAreset() __DBDMAreset() ! 187: #define DBDMAstartTransfer() __DBDMAstartTransfer() ! 188: #define DBDMAstopTransfer() __DBDMAstopTransfer() ! 189: #define DBDMAspinUntilIdle() __DBDMAspinUntilIdle() ! 190: #endif /* USE_CURIO_METHODS */ ! 191: ! 192: @interface Apple96_SCSI(Curio_DBDMA) ! 193: ! 194: /** ! 195: * Quit: stop the DBDMA controller and free all memory. ! 196: * This is always a method. ! 197: */ ! 198: - (void) dbdmaTerminate; ! 199: ! 200: #if USE_CURIO_METHODS ! 201: /** ! 202: * Stop the DBDMA controller ! 203: */ ! 204: - (void) dbdmaReset; ! 205: ! 206: /** ! 207: * Start a DMA operation. ! 208: */ ! 209: - (void) dbdmaStartTransfer; ! 210: ! 211: /** ! 212: * Stop a DMA operation. ! 213: */ ! 214: - (void) dbdmaStopTransfer; ! 215: ! 216: /** ! 217: * Spin-wait until the DBDMA channel is inactive. This should be ! 218: * timed to prevent deadlock. ! 219: */ ! 220: - (void) dbdmaSpinUntilIdle; ! 221: ! 222: #endif /* USE_CURIO_METHODS */ ! 223: @end ! 224:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.