|
|
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 (c) 1995-1996 NeXT Software, Inc. ! 24: * ! 25: * Interface definition for the Mace Ethernet chip ! 26: * ! 27: * HISTORY ! 28: * ! 29: * 16-Sept-97 ! 30: * Created. ! 31: */ ! 32: ! 33: #ifndef _MACEENET_H ! 34: #define _MACEENET_H ! 35: ! 36: #include <IOKit/network/IOEthernetController.h> ! 37: #include <IOKit/network/IOEthernetInterface.h> ! 38: #include <IOKit/network/IOOQGateFIFOQueue.h> ! 39: #include <IOKit/IOInterruptEventSource.h> ! 40: #include <IOKit/IOTimerEventSource.h> ! 41: #include <IOKit/network/IOMBufMemoryCursor.h> ! 42: #include <IOKit/IODeviceMemory.h> ! 43: #include <IOKit/ppc/IODBDMA.h> ! 44: #include <string.h> /* bcopy */ ! 45: ! 46: #if 0 ! 47: #include <kern/kdebug.h> /* Performance tracepoints */ ! 48: #else ! 49: #define KERNEL_DEBUG(x,a,b,c,d,e) ! 50: #endif ! 51: ! 52: #include "MaceEnetRegisters.h" ! 53: ! 54: extern "C" { ! 55: #include <sys/param.h> ! 56: #include <sys/mbuf.h> ! 57: } ! 58: ! 59: #if 0 ! 60: #define IOLog kprintf ! 61: #endif ! 62: ! 63: typedef void * IOPPCAddress; ! 64: ! 65: typedef struct enet_dma_cmd_t ! 66: { ! 67: IODBDMADescriptor desc_seg[2]; ! 68: } enet_dma_cmd_t; ! 69: ! 70: typedef struct enet_txdma_cmd_t ! 71: { ! 72: IODBDMADescriptor desc_seg[4]; ! 73: } enet_txdma_cmd_t; ! 74: ! 75: class MaceEnet : public IOEthernetController ! 76: { ! 77: OSDeclareDefaultStructors(MaceEnet) ! 78: ! 79: private: ! 80: volatile IOPPCAddress ioBaseEnet; ! 81: volatile IOPPCAddress ioBaseEnetROM; ! 82: volatile IODBDMAChannelRegisters *ioBaseEnetRxDMA; ! 83: volatile IODBDMAChannelRegisters *ioBaseEnetTxDMA; ! 84: ! 85: u_int16_t chipId; ! 86: ! 87: enet_addr_t myAddress; ! 88: IOEthernetInterface * networkInterface; ! 89: IOOQGateFIFOQueue * transmitQueue; ! 90: IOPacketQueue * debugQueue; ! 91: IOKernelDebugger * debugger; ! 92: bool isPromiscuous; ! 93: bool multicastEnabled; ! 94: bool ready; ! 95: bool netifClient; ! 96: bool debugClient; ! 97: bool debugTxPoll; ! 98: ! 99: IOInterruptEventSource *rxIntSrc; ! 100: IOInterruptEventSource *txIntSrc; ! 101: IOMemoryMap * maps[MEMORY_MAP_COUNT]; ! 102: IOMemoryMap * romMap; ! 103: IONetworkStats * netStats; ! 104: IOTimerEventSource * timerSrc; ! 105: IOMBufBigMemoryCursor * mbufCursor; ! 106: ! 107: struct mbuf * txMbuf[TX_RING_LENGTH]; ! 108: struct mbuf * rxMbuf[RX_RING_LENGTH]; ! 109: struct mbuf * txDebuggerPkt; ! 110: ! 111: unsigned int txCommandHead; /* Transmit ring descriptor index */ ! 112: unsigned int txCommandTail; ! 113: unsigned int txMaxCommand; ! 114: unsigned int rxCommandHead; /* Receive ring descriptor index */ ! 115: unsigned int rxCommandTail; ! 116: unsigned int rxMaxCommand; ! 117: ! 118: struct { ! 119: void *ptr; ! 120: u_int size; ! 121: void *ptrReal; ! 122: u_int sizeReal; ! 123: } dmaMemory; ! 124: ! 125: unsigned char * dmaCommands; ! 126: enet_txdma_cmd_t * txDMACommands; /* TX descriptor ring ptr */ ! 127: unsigned int txDMACommandsPhys; ! 128: ! 129: enet_dma_cmd_t * rxDMACommands; /* RX descriptor ring ptr */ ! 130: unsigned int rxDMACommandsPhys; ! 131: ! 132: u_int32_t txWDInterrupts; ! 133: u_int32_t txWDTimeouts; ! 134: bool txWDForceReset; ! 135: ! 136: void * debuggerPkt; ! 137: u_int32_t debuggerPktSize; ! 138: ! 139: u_int16_t hashTableUseCount[64]; ! 140: u_int8_t hashTableMask[8]; ! 141: ! 142: bool _allocateMemory(); ! 143: bool _initTxRing(); ! 144: bool _initRxRing(); ! 145: bool _initChip(); ! 146: void _resetChip(); ! 147: void _disableAdapterInterrupts(); ! 148: void _enableAdapterInterrupts(); ! 149: void _startChip(); ! 150: void _restartChip(); ! 151: void _stopReceiveDMA(); ! 152: void _stopTransmitDMA(); ! 153: bool _transmitPacket(struct mbuf * packet); ! 154: bool _transmitInterruptOccurred(bool fDebugger = false); ! 155: bool _receiveInterruptOccurred(); ! 156: bool _receivePackets(bool fDebugger); ! 157: void _packetToDebugger(struct mbuf * packet, u_int size); ! 158: bool _updateDescriptorFromMbuf(struct mbuf * m, enet_dma_cmd_t *desc, ! 159: bool isReceive); ! 160: void _resetHashTableMask(); ! 161: void _addToHashTableMask(u_int8_t *addr); ! 162: void _removeFromHashTableMask(u_int8_t *addr); ! 163: void _updateHashTableMask(); ! 164: void _dumpRegisters(); ! 165: void _dumpDesc(void * addr, u_int32_t size); ! 166: IOReturn _setPromiscuousMode(IOEnetPromiscuousMode mode); ! 167: void MaceEnet::_sendTestPacket(); ! 168: ! 169: /* ! 170: * Kernel Debugger ! 171: */ ! 172: void _sendPacket(void *pkt, unsigned int pkt_len); ! 173: void _receivePacket(void *pkt, unsigned int *pkt_len, unsigned int ! 174: timeout); ! 175: ! 176: bool resetAndEnable(bool enable); ! 177: void interruptOccurredForSource(IOInterruptEventSource *src, int count); ! 178: void timeoutOccurred(IOTimerEventSource *timer); ! 179: ! 180: public: ! 181: virtual MaceEnet * MaceEnet::probe(IOService * provider, ! 182: unsigned int * score, ! 183: unsigned int * specificity); ! 184: virtual bool init(OSDictionary * properties = 0); ! 185: virtual bool start(IOService * provider); ! 186: virtual void free(); ! 187: ! 188: virtual IOReturn enable(IONetworkInterface * netif); ! 189: virtual IOReturn disable(IONetworkInterface * netif); ! 190: ! 191: virtual IOReturn handleDebuggerOpen(IOKernelDebugger * debugger); ! 192: virtual IOReturn handleDebuggerClose(IOKernelDebugger * debugger); ! 193: ! 194: virtual IOReturn getHardwareAddress(enet_addr_t *addr); ! 195: ! 196: virtual IOReturn setMulticastMode(IOEnetMulticastMode mode); ! 197: virtual IOReturn setMulticastList(enet_addr_t *addrs, UInt count); ! 198: ! 199: virtual IOReturn setPromiscuousMode(IOEnetPromiscuousMode mode); ! 200: ! 201: virtual IOOutputQueue * allocateOutputQueue(); ! 202: ! 203: virtual UInt32 outputPacket(struct mbuf * m); ! 204: ! 205: virtual void sendPacket(void *pkt, UInt pkt_len); ! 206: virtual void receivePacket(void *pkt, UInt *pkt_len, UInt timeout); ! 207: ! 208: virtual const char * getVendorString() const; ! 209: virtual const char * getModelString() const; ! 210: virtual const char * getRevisionString() const; ! 211: }; ! 212: ! 213: #if 0 // no power management stuff in IOKit yet. ! 214: /* ! 215: * Power management methods. ! 216: */ ! 217: - (IOReturn)getPowerState:(PMPowerState *)state_p; ! 218: - (IOReturn)setPowerState:(PMPowerState)state; ! 219: - (IOReturn)getPowerManagement:(PMPowerManagementState *)state_p; ! 220: - (IOReturn)setPowerManagement:(PMPowerManagementState)state; ! 221: #endif ! 222: ! 223: /* ! 224: * Performance tracepoints ! 225: * ! 226: * DBG_MACE_RXIRQ - Receive ISR run time ! 227: * DBG_MACE_TXIRQ - Transmit ISR run time ! 228: * DBG_MACE_TXQUEUE - Transmit packet passed from network stack ! 229: * DBG_MACE_TXCOMPLETE - Transmit packet sent ! 230: * DBG_MACE_RXCOMPLETE - Receive packet passed to network stack ! 231: */ ! 232: #define DBG_MACE_ENET 0x0800 ! 233: #define DBG_MACE_RXIRQ DRVDBG_CODE(DBG_DRVNETWORK,(DBG_MACE_ENET+1)) ! 234: #define DBG_MACE_TXIRQ DRVDBG_CODE(DBG_DRVNETWORK,(DBG_MACE_ENET+2)) ! 235: #define DBG_MACE_TXQUEUE DRVDBG_CODE(DBG_DRVNETWORK,(DBG_MACE_ENET+3)) ! 236: #define DBG_MACE_TXCOMPLETE DRVDBG_CODE(DBG_DRVNETWORK,(DBG_MACE_ENET+4)) ! 237: #define DBG_MACE_RXCOMPLETE DRVDBG_CODE(DBG_DRVNETWORK,(DBG_MACE_ENET+5)) ! 238: ! 239: #endif /* !_MACEENET_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.