|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 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. ! 11: * ! 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 ! 18: * under the License. ! 19: * ! 20: * @APPLE_LICENSE_HEADER_END@ ! 21: */ ! 22: /* ! 23: * Copyright 1996 1995 by Open Software Foundation, Inc. 1997 1996 1995 1994 1993 1992 1991 ! 24: * All Rights Reserved ! 25: * ! 26: * Permission to use, copy, modify, and distribute this software and ! 27: * its documentation for any purpose and without fee is hereby granted, ! 28: * provided that the above copyright notice appears in all copies and ! 29: * that both the copyright notice and this permission notice appear in ! 30: * supporting documentation. ! 31: * ! 32: * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE ! 33: * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ! 34: * FOR A PARTICULAR PURPOSE. ! 35: * ! 36: * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR ! 37: * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM ! 38: * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, ! 39: * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION ! 40: * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ! 41: * ! 42: */ ! 43: /* ! 44: * Copyright 1996 1995 by Apple Computer, Inc. 1997 1996 1995 1994 1993 1992 1991 ! 45: * All Rights Reserved ! 46: * ! 47: * Permission to use, copy, modify, and distribute this software and ! 48: * its documentation for any purpose and without fee is hereby granted, ! 49: * provided that the above copyright notice appears in all copies and ! 50: * that both the copyright notice and this permission notice appear in ! 51: * supporting documentation. ! 52: * ! 53: * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE ! 54: * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ! 55: * FOR A PARTICULAR PURPOSE. ! 56: * ! 57: * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR ! 58: * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM ! 59: * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, ! 60: * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION ! 61: * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ! 62: */ ! 63: /* ! 64: * MKLINUX-1.0DR2 ! 65: */ ! 66: /* ! 67: * 18 June 1998 sdouglas ! 68: * Start IOKit version. ! 69: */ ! 70: ! 71: #include "AppleVIA6522.h" ! 72: ! 73: typedef struct VIARegisterAddress VIARegisterAddress; ! 74: ! 75: struct VIARegisterAddress ! 76: { ! 77: volatile unsigned char* dataB; ! 78: volatile unsigned char* handshakeDataA; ! 79: volatile unsigned char* dataDirectionB; ! 80: volatile unsigned char* dataDirectionA; ! 81: volatile unsigned char* timer1CounterLow; ! 82: volatile unsigned char* timer1CounterHigh; ! 83: volatile unsigned char* timer1LatchLow; ! 84: volatile unsigned char* timer1LatchHigh; ! 85: volatile unsigned char* timer2CounterLow; ! 86: volatile unsigned char* timer2CounterHigh; ! 87: volatile unsigned char* shift; ! 88: volatile unsigned char* auxillaryControl; ! 89: volatile unsigned char* peripheralControl; ! 90: volatile unsigned char* interruptFlag; ! 91: volatile unsigned char* interruptEnable; ! 92: volatile unsigned char* dataA; ! 93: }; ! 94: ! 95: ! 96: ! 97: // Cuda to VIA signal definition. They are all active low. ! 98: ! 99: enum ! 100: { ! 101: kCudaTransferRequestMask = EVRB_XCVR, // TREQ (input) ! 102: kCudaNegateTransferRequest = EVRB_XCVR, // TREQ ! 103: kCudaAssertTransferRequest = ~EVRB_XCVR, // /TREQ ! 104: ! 105: kCudaByteAcknowledgeMask = EVRB_FULL, // ByteAck (output) ! 106: kCudaNegateByteAcknowledge = EVRB_FULL, // ByteAck ! 107: kCudaAssertByteAcknowledge = ~EVRB_FULL, // /ByteAck ! 108: ! 109: kCudaTransferInProgressMask = EVRB_SYSES, // TIP (output) ! 110: kCudaNegateTransferInProgress = EVRB_SYSES, // TIP ! 111: kCudaAssertTransferInProgress = ~EVRB_SYSES, // /TIP ! 112: ! 113: kCudaTransferMode = VAC_SRMD3, // ! 114: ! 115: kCudaDirectionMask = VAC_SRMD4, // ! 116: kCudaSystemSend = VAC_SRMD4, // ! 117: kCudaSystemRecieve = ~VAC_SRMD4, // ! 118: ! 119: kCudaInterruptMask = VIE_SR, ! 120: kCudaInterruptDisable = VIE_CLEAR | VIE_SR, ! 121: kCudaInterruptEnable = VIE_SET | VIE_SR ! 122: }; ! 123: ! 124: // The bits from Cuda that determines the cause of an interrupt ! 125: ! 126: enum ! 127: { ! 128: kCudaInterruptStateMask = kCudaTransferInProgressMask | ! 129: kCudaTransferRequestMask ! 130: }; ! 131: ! 132: // Interrupt states. Determined by kTransferRequest, kTransferInProgress and ! 133: // kCudaDirection. The names are from the view of the system. ! 134: ! 135: enum ! 136: { ! 137: kCudaReceiveByte = 0, // 0x00 ! 138: kCudaReceiveLastByte = kCudaNegateTransferRequest, // 0x08 ! 139: kCudaCollision = kCudaSystemSend, // 0x10 ! 140: kCudaTransmitByte = kCudaSystemSend | ! 141: kCudaNegateTransferRequest, // 0x18 ! 142: kCudaUnexpectedAttention = kCudaNegateTransferInProgress,// 0x20 ! 143: kCudaIdleState = kCudaNegateTransferInProgress | ! 144: kCudaNegateTransferRequest, // 0x28 ! 145: kCudaExpectedAttention = kCudaSystemSend | ! 146: kCudaNegateTransferInProgress,// 0x30 ! 147: kCudaIllegalState = kCudaSystemSend | ! 148: kCudaNegateTransferInProgress | ! 149: kCudaNegateTransferRequest // 0x38 ! 150: }; ! 151: ! 152: enum ! 153: { ! 154: kCudaSRQAssertMask = 0x01, // inactive device asserted SRQ ! 155: kCudaTimeOutMask = 0x02, // active device did not have data available ! 156: kCudaSRQErrorMask = 0x04, // device asserted excessive SRQ period ! 157: kCudaBusErrorMask = 0x08, // timing error in bit cell was detected ! 158: kCudaAutoPollMask = 0x40, // data is from an AutoPoll ! 159: kCudaResponseMask = 0x80 // response Packet in progress ! 160: }; ! 161: ! 162: #define cuda_write_data(self,theByte) {*self->cuda_via_regs.shift = theByte; eieio(); } ! 163: #define cuda_set_data_direction_to_input(self) {*self->cuda_via_regs.auxillaryControl &= kCudaSystemRecieve; eieio(); } ! 164: #define cuda_set_data_direction_to_output(self) {*self->cuda_via_regs.auxillaryControl |= kCudaSystemSend; eieio(); } ! 165: #define cuda_assert_transfer_in_progress(self) {*self->cuda_via_regs.dataB &= kCudaAssertTransferInProgress; eieio(); } ! 166: #define cuda_neg_transfer_in_progress(self) {*self->cuda_via_regs.dataB |= kCudaNegateTransferInProgress; eieio(); } ! 167: #define cuda_neg_tip_and_byteack(self) {*self->cuda_via_regs.dataB |= kCudaNegateByteAcknowledge | kCudaNegateTransferInProgress; eieio(); } ! 168: #define cuda_toggle_byte_ack(self) {*self->cuda_via_regs.dataB ^= kCudaByteAcknowledgeMask; eieio(); } ! 169: #define cuda_assert_byte_ack(self) {*self->cuda_via_regs.dataB &= kCudaAssertByteAcknowledge; eieio(); } ! 170: #define cuda_neg_byte_ack(self) {*self->cuda_via_regs.dataB |= kCudaNegateByteAcknowledge; eieio(); } ! 171: #define cuda_is_transfer_in_progress(self) ((*self->cuda_via_regs.dataB & kCudaTransferRequestMask) == 0 ) ! 172: #define cuda_disable_interrupt(self) {*self->cuda_via_regs.interruptEnable = kCudaInterruptDisable; eieio(); } ! 173: #define cuda_enable_interrupt(self) {*self->cuda_via_regs.interruptEnable = kCudaInterruptEnable; eieio(); } ! 174: #define cuda_get_interrupt_state(self) (*self->cuda_via_regs.dataB & kCudaInterruptStateMask) | \ ! 175: (*self->cuda_via_regs.auxillaryControl & kCudaDirectionMask) ! 176: #define cuda_wait_for_transfer_request_assert(self) while ( (*self->cuda_via_regs.dataB & kCudaTransferRequestMask) != 0 ) { eieio(); } ; eieio() ! 177: #define cuda_wait_for_transfer_request_neg(self) while ( (*self->cuda_via_regs.dataB & kCudaTransferRequestMask) == 0 ) { eieio(); } ; eieio() ! 178: #define cuda_wait_for_interrupt(self) while ( (*self->cuda_via_regs.interruptFlag & kCudaInterruptMask) == 0 ) { eieio(); } ; eieio()
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.