if_mxreg.h
来自「基于组件方式开发操作系统的OSKIT源代码」· C头文件 代码 · 共 715 行 · 第 1/2 页
H
715 行
/* * Copyright (c) 1997, 1998 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Bill Paul. * 4. Neither the name of the author nor the names of any co-contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * $Id: if_mxreg.h,v 1.2.2.3 1999/05/06 15:39:34 wpaul Exp $ *//* * Macronix register definitions. */#define MX_BUSCTL 0x00 /* bus control */#define MX_TXSTART 0x08 /* tx start demand */#define MX_RXSTART 0x10 /* rx start demand */#define MX_RXADDR 0x18 /* rx descriptor list start addr */#define MX_TXADDR 0x20 /* tx descriptor list start addr */#define MX_ISR 0x28 /* interrupt status register */#define MX_NETCFG 0x30 /* network config register */#define MX_IMR 0x38 /* interrupt mask */#define MX_FRAMESDISCARDED 0x40 /* # of discarded frames */#define MX_SIO 0x48 /* MII and ROM/EEPROM access */#define MX_RESERVED 0x50#define MX_TIMER 0x58 /* general timer */#define MX_10BTSTAT 0x60#define MX_SIARESET 0x68#define MX_10BTCTRL 0x70#define MX_WATCHDOG 0x78#define MX_MAGICPACKET 0x80#define MX_NWAYSTAT 0xA0/* * These are magic values that must be written into CSR16 * (MX_MAGICPACKET) in order to put the chip into proper * operating mode. The magic numbers are documented in the * Macronix 98715 application notes. */#define MX_MAGIC_98713 0x0F370000#define MX_MAGIC_98713A 0x0B3C0000#define MX_MAGIC_98715 0x0B3C0000#define MX_MAGIC_98725 0x0B3C0000#define MX_REVISION_98713 0x00#define MX_REVISION_98713A 0x10#define MX_REVISION_98715 0x20#define MX_REVISION_98725 0x30/* * As far as the driver is concerned, there are two 'types' of * chips to be concerned with. One is a 98713 with an external * PHY on the MII. The other covers pretty much everything else, * since all the other Macronix chips have built-in transceivers. * This type setting governs what which mode selection routines * we use (MII or built-in). It also govers which of the 'magic' * numbers we write into CSR16. */#define MX_TYPE_98713 0x1#define MX_TYPE_98713A 0x2#define MX_TYPE_987x5 0x3/* * Bus control bits. */#define MX_BUSCTL_RESET 0x00000001#define MX_BUSCTL_ARBITRATION 0x00000002#define MX_BUSCTL_SKIPLEN 0x0000007C#define MX_BUSCTL_BUF_BIGENDIAN 0x00000080#define MX_BUSCTL_BURSTLEN 0x00003F00#define MX_BUSCTL_CACHEALIGN 0x0000C000#define MX_BUSCTL_TXPOLL 0x000E0000#define MX_BUSCTL_MUSTBEONE 0x04000000#define MX_SKIPLEN_1LONG 0x00000004#define MX_SKIPLEN_2LONG 0x00000008#define MX_SKIPLEN_3LONG 0x00000010#define MX_SKIPLEN_4LONG 0x00000020#define MX_SKIPLEN_5LONG 0x00000040#define MX_CACHEALIGN_NONE 0x00000000#define MX_CACHEALIGN_8LONG 0x00004000#define MX_CACHEALIGN_16LONG 0x00008000#define MX_CACHEALIGN_32LONG 0x0000C000#define MX_BURSTLEN_USECA 0x00000000#define MX_BURSTLEN_1LONG 0x00000100#define MX_BURSTLEN_2LONG 0x00000200#define MX_BURSTLEN_4LONG 0x00000400#define MX_BURSTLEN_8LONG 0x00000800#define MX_BURSTLEN_16LONG 0x00001000#define MX_BURSTLEN_32LONG 0x00002000#define MX_TXPOLL_OFF 0x00000000#define MX_TXPOLL_200U 0x00020000#define MX_TXPOLL_800U 0x00040000#define MX_TXPOLL_1600U 0x00060000#define MX_BUSCTL_CONFIG (MX_BUSCTL_ARBITRATION|MX_CACHEALIGN_8LONG| \ MX_BURSTLEN_8LONG)/* * Interrupt status bits. */#define MX_ISR_TX_OK 0x00000001#define MX_ISR_TX_IDLE 0x00000002#define MX_ISR_TX_NOBUF 0x00000004#define MX_ISR_TX_JABBERTIMEO 0x00000008#define MX_ISR_LINKGOOD 0x00000010#define MX_ISR_TX_UNDERRUN 0x00000020#define MX_ISR_RX_OK 0x00000040#define MX_ISR_RX_NOBUF 0x00000080#define MX_ISR_RX_READ 0x00000100#define MX_ISR_RX_WATDOGTIMEO 0x00000200#define MX_ISR_TX_EARLY 0x00000400#define MX_ISR_TIMER_EXPIRED 0x00000800#define MX_ISR_LINKFAIL 0x00001000#define MX_ISR_BUS_ERR 0x00002000#define MX_ISR_RX_EARLY 0x00004000#define MX_ISR_ABNORMAL 0x00008000#define MX_ISR_NORMAL 0x00010000#define MX_ISR_RX_STATE 0x000E0000#define MX_ISR_TX_STATE 0x00700000#define MX_ISR_BUSERRTYPE 0x03800000#define MX_ISR_100MBPSLINK 0x08000000#define MX_ISR_MAGICKPACK 0x10000000#define MX_RXSTATE_STOPPED 0x00000000 /* 000 - Stopped */#define MX_RXSTATE_FETCH 0x00020000 /* 001 - Fetching descriptor */#define MX_RXSTATE_ENDCHECK 0x00040000 /* 010 - check for rx end */#define MX_RXSTATE_WAIT 0x00060000 /* 011 - waiting for packet */#define MX_RXSTATE_SUSPEND 0x00080000 /* 100 - suspend rx */#define MX_RXSTATE_CLOSE 0x000A0000 /* 101 - close tx desc */#define MX_RXSTATE_FLUSH 0x000C0000 /* 110 - flush from FIFO */#define MX_RXSTATE_DEQUEUE 0x000E0000 /* 111 - dequeue from FIFO */#define MX_TXSTATE_RESET 0x00000000 /* 000 - reset */#define MX_TXSTATE_FETCH 0x00100000 /* 001 - fetching descriptor */#define MX_TXSTATE_WAITEND 0x00200000 /* 010 - wait for tx end */#define MX_TXSTATE_READING 0x00300000 /* 011 - read and enqueue */#define MX_TXSTATE_RSVD 0x00400000 /* 100 - reserved */#define MX_TXSTATE_SETUP 0x00500000 /* 101 - setup packet */#define MX_TXSTATE_SUSPEND 0x00600000 /* 110 - suspend tx */#define MX_TXSTATE_CLOSE 0x00700000 /* 111 - close tx desc *//* * Network config bits. */#define MX_NETCFG_RX_HASHPERF 0x00000001#define MX_NETCFG_RX_ON 0x00000002#define MX_NETCFG_RX_HASHONLY 0x00000004#define MX_NETCFG_RX_BADFRAMES 0x00000008#define MX_NETCFG_RX_INVFILT 0x00000010#define MX_NETCFG_BACKOFFCNT 0x00000020#define MX_NETCFG_RX_PROMISC 0x00000040#define MX_NETCFG_RX_ALLMULTI 0x00000080#define MX_NETCFG_FULLDUPLEX 0x00000200#define MX_NETCFG_LOOPBACK 0x00000C00#define MX_NETCFG_FORCECOLL 0x00001000#define MX_NETCFG_TX_ON 0x00002000#define MX_NETCFG_TX_THRESH 0x0000C000#define MX_NETCFG_TX_BACKOFF 0x00020000#define MX_NETCFG_PORTSEL 0x00040000 /* 0 == 10, 1 == 100 */#define MX_NETCFG_HEARTBEAT 0x00080000#define MX_NETCFG_STORENFWD 0x00200000#define MX_NETCFG_SPEEDSEL 0x00400000 /* 1 == 10, 0 == 100 */#define MX_NETCFG_PCS 0x00800000#define MX_NETCFG_SCRAMBLER 0x01000000#define MX_NETCFG_NO_RXCRC 0x02000000#define MX_OPMODE_NORM 0x00000000#define MX_OPMODE_INTLOOP 0x00000400#define MX_OPMODE_EXTLOOP 0x00000800#define MX_TXTHRESH_72BYTES 0x00000000#define MX_TXTHRESH_96BYTES 0x00004000#define MX_TXTHRESH_128BYTES 0x00008000#define MX_TXTHRESH_160BYTES 0x0000C000/* * Interrupt mask bits. */#define MX_IMR_TX_OK 0x00000001#define MX_IMR_TX_IDLE 0x00000002#define MX_IMR_TX_NOBUF 0x00000004#define MX_IMR_TX_JABBERTIMEO 0x00000008#define MX_IMR_LINKGOOD 0x00000010#define MX_IMR_TX_UNDERRUN 0x00000020#define MX_IMR_RX_OK 0x00000040#define MX_IMR_RX_NOBUF 0x00000080#define MX_IMR_RX_READ 0x00000100#define MX_IMR_RX_WATDOGTIMEO 0x00000200#define MX_IMR_TX_EARLY 0x00000400#define MX_IMR_TIMER_EXPIRED 0x00000800#define MX_IMR_LINKFAIL 0x00001000#define MX_IMR_BUS_ERR 0x00002000#define MX_IMR_RX_EARLY 0x00004000#define MX_IMR_ABNORMAL 0x00008000#define MX_IMR_NORMAL 0x00010000#define MX_IMR_100MBPSLINK 0x08000000#define MX_IMR_MAGICKPACK 0x10000000#define MX_INTRS \ (MX_IMR_RX_OK|MX_IMR_TX_OK|MX_IMR_RX_NOBUF|MX_IMR_RX_WATDOGTIMEO|\ MX_IMR_TX_NOBUF|MX_IMR_TX_UNDERRUN|MX_IMR_BUS_ERR| \ MX_IMR_ABNORMAL|MX_IMR_NORMAL/*|MX_IMR_TX_EARLY*/)/* * Serial I/O (EEPROM/ROM) bits. */#define MX_SIO_EE_CS 0x00000001 /* EEPROM chip select */#define MX_SIO_EE_CLK 0x00000002 /* EEPROM clock */#define MX_SIO_EE_DATAIN 0x00000004 /* EEPROM data output */#define MX_SIO_EE_DATAOUT 0x00000008 /* EEPROM data input */#define MX_SIO_ROMDATA4 0x00000010#define MX_SIO_ROMDATA5 0x00000020#define MX_SIO_ROMDATA6 0x00000040#define MX_SIO_ROMDATA7 0x00000080#define MX_SIO_EESEL 0x00000800#define MX_SIO_ROMSEL 0x00001000#define MX_SIO_ROMCTL_WRITE 0x00002000#define MX_SIO_ROMCTL_READ 0x00004000#define MX_SIO_MII_CLK 0x00010000 /* MDIO clock */#define MX_SIO_MII_DATAOUT 0x00020000 /* MDIO data out */#define MX_SIO_MII_DIR 0x00040000 /* MDIO dir */#define MX_SIO_MII_DATAIN 0x00080000 /* MDIO data in */#define MX_EECMD_WRITE 0x140#define MX_EECMD_READ 0x180#define MX_EECMD_ERASE 0x1c0#define MX_EE_NODEADDR_OFFSET 0x70#define MX_EE_NODEADDR 10/* * General purpose timer register */#define MX_TIMER_VALUE 0x0000FFFF#define MX_TIMER_CONTINUUS 0x00010000/* * 10baseT status register */#define MX_TSTAT_LS100 0x00000002 /* link status of 100baseTX */#define MX_TSTAT_LS10 0x00000004 /* link status of 10baseT */#define MX_TSTAT_AUTOPOLARITY 0x00000008#define MX_TSTAT_REMFAULT 0x00000800#define MX_TSTAT_ANEGSTAT 0x00007000#define MX_TSTAT_LP_CAN_NWAY 0x00008000 /* link partner supports NWAY */#define MX_TSTAT_LPCODEWORD 0xFFFF0000 /* link partner's code word */#define MX_ASTAT_DISABLE 0x00000000#define MX_ASTAT_TXDISABLE 0x00001000#define MX_ASTAT_ABDETECT 0x00002000#define MX_ASTAT_ACKDETECT 0x00003000#define MX_ASTAT_CMPACKDETECT 0x00004000#define MX_ASTAT_AUTONEGCMP 0x00005000#define MX_ASTAT_LINKCHECK 0x00006000/* * PHY reset register */#define MX_SIA_RESET_NWAY 0x00000001#define MX_SIA_RESET_100TX 0x00000002/* * 10baseT control register */#define MX_TCTL_LOOPBACK 0x00000002#define MX_TCTL_POWERDOWN 0x00000004#define MX_TCTL_HALFDUPLEX 0x00000040#define MX_TCTL_AUTONEGENBL 0x00000080#define MX_TCTL_RX_SQUELCH 0x00000100#define MX_TCTL_LINKTEST 0x00001000#define MX_TCTL_100BTXHALF 0x00010000#define MX_TCTL_100BTXFULL 0x00020000#define MX_TCTL_100BT4 0x00040000/* * Watchdog timer register */#define MX_WDOG_JABBERDIS 0x00000001#define MX_WDOG_HOSTUNJAB 0x00000002#define MX_WDOG_JABBERCLK 0x00000004#define MX_WDOG_RXWDOGDIS 0x00000010#define MX_WDOG_RXWDOGCLK 0x00000020#define MX_WDOG_MUSTBEZERO 0x00000100/* * Magic packet register */#define MX_MPACK_DISABLE 0x00400000/* * NWAY status register. */#define MX_NWAY_10BTHALF 0x08000000#define MX_NWAY_10BTFULL 0x10000000#define MX_NWAY_100BTHALF 0x20000000#define MX_NWAY_100BTFULL 0x40000000#define MX_NWAY_100BT4 0x80000000/* * Size of a setup frame. */#define MX_SFRAME_LEN 192/* * Macronix TX/RX list structure. */struct mx_desc { u_int32_t mx_status; u_int32_t mx_ctl; u_int32_t mx_ptr1; u_int32_t mx_ptr2;};#define mx_data mx_ptr1#define mx_next mx_ptr2#define MX_RXSTAT_FIFOOFLOW 0x00000001#define MX_RXSTAT_CRCERR 0x00000002#define MX_RXSTAT_DRIBBLE 0x00000004#define MX_RXSTAT_WATCHDOG 0x00000010#define MX_RXSTAT_FRAMETYPE 0x00000020 /* 0 == IEEE 802.3 */#define MX_RXSTAT_COLLSEEN 0x00000040#define MX_RXSTAT_GIANT 0x00000080#define MX_RXSTAT_LASTFRAG 0x00000100#define MX_RXSTAT_FIRSTFRAG 0x00000200#define MX_RXSTAT_MULTICAST 0x00000400#define MX_RXSTAT_RUNT 0x00000800#define MX_RXSTAT_RXTYPE 0x00003000#define MX_RXSTAT_RXERR 0x00008000
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?