Annotation of XNU/iokit/Drivers/network/drvPPCBMac/BMacEnet.h, revision 1.1

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) 1998-1999 by Apple Computer, Inc., All rights reserved.
        !            24:  *
        !            25:  * Interface definition for the BMac Ethernet Controller 
        !            26:  *
        !            27:  * HISTORY
        !            28:  *
        !            29:  * Dec 10, 1998                jliu
        !            30:  *  Converted to IOKit/C++.
        !            31:  */
        !            32: 
        !            33: #ifndef _BMACENET_H
        !            34: #define _BMACENET_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: #include "BMacEnetRegisters.h"
        !            46: 
        !            47: extern "C" {
        !            48: #include <sys/param.h>
        !            49: #include <sys/mbuf.h>
        !            50: }
        !            51: 
        !            52: // No kernel tracing support at this time.
        !            53: //
        !            54: #define KERNEL_DEBUG(x,a,b,c,d,e)
        !            55: 
        !            56: // #define IOLog kprintf
        !            57: 
        !            58: typedef void  *                IOPPCAddress;
        !            59: 
        !            60: typedef struct enet_dma_cmd_t
        !            61: {
        !            62:     IODBDMADescriptor  desc_seg[2];
        !            63: } enet_dma_cmd_t;
        !            64: 
        !            65: typedef struct enet_txdma_cmd_t
        !            66: {
        !            67:        IODBDMADescriptor       desc_seg[3];
        !            68: } enet_txdma_cmd_t;
        !            69: 
        !            70: class BMacEnet : public IOEthernetController
        !            71: {
        !            72:        OSDeclareDefaultStructors(BMacEnet)
        !            73: 
        !            74: private:
        !            75:        volatile IOPPCAddress                           ioBaseEnet;
        !            76:     volatile IOPPCAddress                      ioBaseHeathrow;
        !            77:     volatile IODBDMAChannelRegisters   *ioBaseEnetRxDMA;       
        !            78:     volatile IODBDMAChannelRegisters   *ioBaseEnetTxDMA;
        !            79:        
        !            80:     enet_addr_t                                myAddress;
        !            81:     IOEthernetInterface *      networkInterface;
        !            82:        IOOQGateFIFOQueue *     transmitQueue;
        !            83:        IOPacketQueue *                 debugQueue;
        !            84:        IOKernelDebugger *      debugger;
        !            85:     bool                                       isPromiscuous;
        !            86:     bool                                       multicastEnabled;
        !            87:        bool                                    isFullDuplex;   
        !            88:        
        !            89:        IOInterruptEventSource *rxIntSrc;
        !            90:        IOMemoryMap *                   maps[MEMORY_MAP_COUNT];
        !            91:        IONetworkStats *        netStats;
        !            92:        IOTimerEventSource *    timerSrc;
        !            93:        IOMBufBigMemoryCursor * mbufCursor;
        !            94: 
        !            95:        bool                                    ready;
        !            96:        bool                                    netifClient;
        !            97:        bool                                    debugClient;
        !            98:        bool                                    debugTxPoll;
        !            99:        bool                    useUnicastFilter;
        !           100:     unsigned int                       enetAddressOffset;
        !           101: 
        !           102:     unsigned long                      chipId;
        !           103: 
        !           104:     unsigned long                      phyType;
        !           105:     unsigned long                      phyMIIDelay;
        !           106: 
        !           107:     unsigned char                      phyId;
        !           108:     unsigned char                      sromAddressBits;
        !           109: 
        !           110:     unsigned short                     phyStatusPrev;
        !           111: 
        !           112:     struct mbuf *                      txMbuf[TX_RING_LENGTH];
        !           113:     struct mbuf *                      rxMbuf[RX_RING_LENGTH];
        !           114:        struct mbuf *                   txDebuggerPkt;
        !           115:     
        !           116:     unsigned int                       txCommandHead;  // Transmit ring descriptor index
        !           117:     unsigned int                       txCommandTail;
        !           118:     unsigned int                       txMaxCommand;           
        !           119:     unsigned int                       rxCommandHead;  // Receive ring descriptor index
        !           120:     unsigned int                       rxCommandTail;
        !           121:     unsigned int               rxMaxCommand;           
        !           122: 
        !           123:        struct {
        !           124:                void    *ptr;
        !           125:                u_int   size;
        !           126:                void    *ptrReal;
        !           127:                u_int   sizeReal;
        !           128:        } dmaMemory;
        !           129: 
        !           130:     unsigned char *                    dmaCommands;
        !           131:     enet_txdma_cmd_t *         txDMACommands;          // TX descriptor ring ptr
        !           132:     unsigned int                       txDMACommandsPhys;
        !           133: 
        !           134:     enet_dma_cmd_t *           rxDMACommands;          // RX descriptor ring ptr
        !           135:     unsigned int                       rxDMACommandsPhys;
        !           136: 
        !           137:     u_int32_t                          txWDInterrupts;
        !           138:     u_int32_t                          txWDCount;
        !           139: 
        !           140:     void *                                     debuggerPkt;
        !           141:     u_int32_t                          debuggerPktSize;
        !           142: 
        !           143:     u_int16_t                          statReg;                // Current STAT register contents
        !           144:    
        !           145:     u_int16_t                          hashTableUseCount[64];
        !           146:     u_int16_t                          hashTableMask[4];
        !           147: 
        !           148:        bool _allocateMemory();
        !           149:        bool _initTxRing();
        !           150:        bool _initRxRing();
        !           151:        bool _initChip();
        !           152:        void _resetChip();
        !           153:        void _disableAdapterInterrupts();
        !           154:        void _enableAdapterInterrupts();
        !           155:        void _setDuplexMode(bool duplexMode);
        !           156:        void _startChip();
        !           157:        bool _updateDescriptorFromMbuf(struct mbuf * m,  enet_dma_cmd_t *desc,
        !           158:                        bool isReceive);
        !           159:        void _restartTransmitter();
        !           160:        void _stopTransmitDMA();
        !           161:        bool _transmitPacket(struct mbuf * packet);
        !           162:        bool _transmitInterruptOccurred();
        !           163:        bool _debugTransmitInterruptOccurred();
        !           164:        bool _receiveInterruptOccurred();
        !           165:        bool _rejectBadUnicastPacket(ether_header_t * etherHeader);
        !           166:        bool _receivePackets(bool fDebugger);
        !           167:        void _packetToDebugger(struct mbuf * packet, u_int size);
        !           168:        void _restartReceiver();
        !           169:        void _stopReceiveDMA();
        !           170:        bool _resetAndEnable(bool enable);
        !           171:        void _sendDummyPacket();
        !           172:        void _resetHashTableMask();
        !           173:        void _addToHashTableMask(u_int8_t *addr);
        !           174:        void _removeFromHashTableMask(u_int8_t *addr);
        !           175:        void _updateBMacHashTableMask();
        !           176: 
        !           177: #ifdef DEBUG
        !           178:        void _dumpRegisters();
        !           179:        void _dumpDesc(void * addr, u_int32_t size);
        !           180:        void _dump_srom();
        !           181: #endif DEBUG
        !           182: 
        !           183:        void _sendPacket(void *pkt, unsigned int pkt_len);
        !           184:        void _receivePacket(void *pkt, unsigned int *pkt_len, unsigned int 
        !           185:                timeout);
        !           186: 
        !           187:        void sendPacket(void *pkt, unsigned int pkt_len);
        !           188:        void receivePacket(void *pkt, unsigned int *pkt_len, unsigned int timeout);
        !           189: 
        !           190:        bool miiReadWord(unsigned short *dataPtr, unsigned short reg,
        !           191:                 unsigned char phy);
        !           192:        bool miiWriteWord(unsigned short data, unsigned short reg,
        !           193:                 unsigned char phy);
        !           194:        void miiWrite(unsigned int miiData, unsigned int dataSize);
        !           195:        int  miiReadBit();
        !           196:        bool miiCheckZeroBit();
        !           197:        void miiOutThreeState();
        !           198:        bool miiResetPHY(unsigned char phy);
        !           199:        bool miiWaitForLink(unsigned char phy);
        !           200:        bool miiWaitForAutoNegotiation(unsigned char phy);
        !           201:        void miiRestartAutoNegotiation(unsigned char phy);
        !           202:        bool miiFindPHY(unsigned char *phy_num);
        !           203:        bool miiInitializePHY(unsigned char phy);
        !           204: 
        !           205:        UInt32 outputPacket(struct mbuf *m);
        !           206: 
        !           207:        void interruptOccurredForSource(IOInterruptEventSource *src, int count);
        !           208: 
        !           209:        void timeoutOccurred(IOTimerEventSource *timer);
        !           210: 
        !           211: public:
        !           212:        virtual bool init(OSDictionary * properties = 0);
        !           213:        virtual bool start(IOService * provider);
        !           214:        virtual void free();
        !           215:        
        !           216:        virtual IOReturn enable(IONetworkInterface * netif);
        !           217:        virtual IOReturn disable(IONetworkInterface * netif);
        !           218:        
        !           219:        virtual IOReturn getHardwareAddress(enet_addr_t *addr);
        !           220: 
        !           221:        virtual IOReturn setMulticastMode(IOEnetMulticastMode mode);
        !           222:        virtual IOReturn setMulticastList(enet_addr_t *addrs, UInt count);
        !           223: 
        !           224:        virtual IOReturn setPromiscuousMode(IOEnetPromiscuousMode mode);
        !           225:        
        !           226:        virtual IOOutputQueue * allocateOutputQueue();
        !           227:        
        !           228:        virtual const char * getVendorString() const;
        !           229:        virtual const char * getModelString() const;
        !           230:        virtual const char * getRevisionString() const;
        !           231: 
        !           232:        virtual IOReturn handleDebuggerOpen(IOKernelDebugger * debugger);
        !           233:        virtual IOReturn handleDebuggerClose(IOKernelDebugger * debugger);
        !           234: };
        !           235: 
        !           236: /*
        !           237:  * Performance tracepoints
        !           238:  *
        !           239:  * DBG_BMAC_RXIRQ      - Receive  ISR run time
        !           240:  * DBG_BMAC_TXIRQ      - Transmit ISR run time
        !           241:  * DBG_BMAC_TXQUEUE     - Transmit packet passed from network stack
        !           242:  * DBG_BMAC_TXCOMPLETE  - Transmit packet sent
        !           243:  * DBG_BMAC_RXCOMPLETE  - Receive packet passed to network stack
        !           244:  */
        !           245: #define DBG_BMAC_ENET          0x0900
        !           246: #define DBG_BMAC_RXIRQ                 DRVDBG_CODE(DBG_DRVNETWORK,(DBG_BMAC_ENET+1))   
        !           247: #define DBG_BMAC_TXIRQ         DRVDBG_CODE(DBG_DRVNETWORK,(DBG_BMAC_ENET+2))   
        !           248: #define DBG_BMAC_TXQUEUE       DRVDBG_CODE(DBG_DRVNETWORK,(DBG_BMAC_ENET+3))   
        !           249: #define DBG_BMAC_TXCOMPLETE    DRVDBG_CODE(DBG_DRVNETWORK,(DBG_BMAC_ENET+4))   
        !           250: #define DBG_BMAC_RXCOMPLETE    DRVDBG_CODE(DBG_DRVNETWORK,(DBG_BMAC_ENET+5))   
        !           251: 
        !           252: #endif /* !_BMACENET_H */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.