📄 sysend.c
字号:
/* sysEnd.c - System Enhanced network interface support library */
/* Copyright 1997-2002 Wind River Systems, Inc. */
#include "copyright_wrs.h"
/*
modification history
--------------------
V1.09:---------------------------------------------------------------------
05/13/2004 pcd
1. For Intel 82559 controller (fei) work with ks8695p SOHO BSP (embeded ARM922T),
Need to modify following :
(1). since ARM922T PCI host bridge doesn't support I/O base mapping,
all the I/O base mapping access to fei has to change to memory base mapping.
(2). 'endDevTbl' is used for ks8695p END driver. For additional PCI bus interface, like
fei END driver, create a new 'endDevTbl' ('feiEndDevTbl') for it.
(3). CPU's 'external interrupt 0' is used for all the PCI interrupt devices.
Added disable\enable system (CPU) interrupt source for 'external interrupt 0'.
---------------------------------------------------------------------
01k,16jul02,m_h dc driver load string changes (78869)
01j,25apr02,to fix PCI to CPU offset address
01i,03dec01,rec fix compiler warnings
01h,09jul01,jpd fixed compilation warning.
01g,09apr01,rec fix 559 initialization problem
01f,22jan01,jmb add support for Intel InBusiness 10/100 PCI Network Adapter
01e,20nov00,jpd added Intel Ethernet driver (FEI) support; added use of
DEC_USR_SF to do 100 Mbits/s; modified DEC driver support.
01d,17feb00,jpd minor comments corrections.
01c,07feb00,jpd tidied.
01b,07dec99,pr support for PCI/DEC21x4x
01a,10nov99,ajb created based on version 01a from pid7t.
*/
/*
DESCRIPTION
This file contains the board-specific routines for Ethernet adapter
initialisation of Intel (formerly DEC) 21040, 21140 and 21143-based
adapters and Intel Pro 100+ based adapters.
NOTE
At the time of writing, this module has only been tested with the following
Ethernet cards:
21040 controller: Digital DE435.
21140 controller: D-Link DFE-500TX
Kingston KNE-100TX
21143 controller: Intel (formerly DEC) EB143 evaluation card.
Kingston KNE-100TX
Longshine 8038 TXD
82559 controller: Intel PRO/100+ Management Adapter
Intel InBusiness 10/100 PCI Network Adapter
Refer to the BSP reference entry for any eventual limitations or
problems related to the BSP.
SEE ALSO: ifLib,
.I "Digital Semiconductor 21143 PCI/CardBus Fast Ethernet LAN Controller,"
.I "Digital Semiconductor 21143 10/100Base-TX Evaluation Board User's Guide,"
.I "Intel 10/100 MBit Ethernet Family Software technical Reference Manual."
*/
#include "vxWorks.h"
#include "config.h"
#include "cacheLib.h"
#include "stdio.h"
#ifdef INCLUDE_END
#include "drv/end/dec21x40End.h"
#include "drv/end/fei82557End.h"
#ifdef INCLUDE_FEI82557END
#include "ks8695p.h"
#include "ks8695End.h"
#endif
/* defines */
#undef SYS_FEI_DEBUG
#define CSR_BASE_MSK 0x7f /* Mask Base Address Register */
#define END_LD_STR_SIZE 80
/* PCI memory base address register configuration mode */
#define FORCE 0x00 /* overwrite membase address register */
#define AUTO 0x01 /* read membase address register */
/*
* Need to use automatic configuration mode using the resource assigning in
* pciAssignResources().
*/
#define PCI_REG_MOD AUTO /* define the register configuration mode */
#define TYPE_ALLOC 1000
/*
* DEC cards in range 1 -> 1000
*/
#define DEC_START 1
/* DEC 21X4X 10/100Base-TX Board type */
#define EB143 DEC_START + 1 /* DEC 21143 10/100Base-TX */
#define DC140 DEC_START + 2 /* DEC 21140 10/100Base-TX */
#define DC040 DEC_START + 3 /* DEC 21040 10/100Base-TX */
/* Untested types are > 100 */
#define LC82C168 DEC_START + 104 /* Lite-On PNIC */
#define MX98713 DEC_START + 105 /* Macronix 98713 PMAC */
#define MX98715 DEC_START + 106 /* Macronix 98715 PMAC */
#define AX88140 DEC_START + 107 /* ASIX AX88140 */
#define PNIC2 DEC_START + 108 /* Lite-On PNIC-II */
#define COMET DEC_START + 109 /* Comet family */
#define COMPEX9881 DEC_START + 110 /* Compex 9881 */
#define I21145 DEC_START + 111 /* Intel 21145 */
/*
* FEI cards in range 1001 -> 2000
*/
#define FEI_START TYPE_ALLOC + 1
#define PRO100B FEI_START /* Intel EtherExpress PRO-100B PCI */
#define INBUSINESS FEI_START + 1 /* Intel InBusiness 10/100 PCI */
#define XX82559ER FEI_START + 100 /* Arbitrary card with 82559ER */
/*
* DEC driver user flags
*
* Use of the SF (Store and Forward) bit is necessary at the time of
* writing on current boards to support 100 Mbits/s operation, though
* it is not necessary for 10 Mbits/s.
*/
#define DEC_USR_FLAGS_143 (DEC_USR_21143 | DEC_USR_SF)
#define DEC_USR_FLAGS_140 (DEC_USR_BAR_RX | \
DEC_USR_RML | \
DEC_USR_CAL_08 | \
DEC_USR_PBL_04 | \
DEC_USR_21140 | \
DEC_USR_SF)
#define DEC_USR_FLAGS_040 (DEC_USR_BAR_RX | \
DEC_USR_CAL_08 | \
DEC_USR_PBL_04)
/* These are untested */
#define PNIC_USR_FLAGS (DEC_USR_21143)
#define PNIC2_USR_FLAGS (DEC_USR_PNIC2)
#define MX98713_USR_FLAGS (0)
#define MX98715_USR_FLAGS (0)
#define AX88140_USR_FLAGS (0)
#define COMET_USR_FLAGS (0)
#define COMET_USR_FLAGS (0)
#define COMET_USR_FLAGS (0)
#define COMPEX9881_USR_FLAGS (0)
#define I21145_USR_FLAGS (0)
/* END table information */
#define DEC_BUFF_LOAN 1 /* enable buffer loaning */
/* DEC 21X4X PCI/CardBus specific definitions */
#define DEC21X4X_PCI_VENDOR_ID 0x1011 /* PCI vendor ID */
#define DEC21143_PCI_DEVICE_ID 0x0019 /* PCI device ID */
#define DEC21140_PCI_DEVICE_ID 0x0009 /* PCI device ID */
#define DEC21040_PCI_DEVICE_ID 0x0002 /* PCI device ID */
#define PNIC_PCI_VENDOR_ID 0x11AD /* PCI vendor ID */
#define PNIC_PCI_DEVICE_ID 0x0002
#define PNIC2_PCI_DEVICE_ID 0xc115
#define MACRONIX_PCI_VENDOR_ID 0x10d9 /* PCI vendor ID */
#define MX98713_PCI_DEVICE_ID 0x0512
#define MX98715_PCI_DEVICE_ID 0x0531
#define ASIX_PCI_VENDOR_ID 0x125B /* PCI vendor ID */
#define AX88140_PCI_DEVICE_ID 0x1400
#define COMET_PCI_VENDOR_ID 0x1317 /* PCI vendor ID */
#define COMET1_PCI_DEVICE_ID 0x0981
#define COMET2_PCI_DEVICE_ID 0x0985
#define COMET3_PCI_DEVICE_ID 0x1985
#define COMPEX_PCI_VENDOR_ID 0x11F6 /* PCI vendor ID */
#define COMPEX9881_PCI_DEVICE_ID 0x9881
#define INTEL_PCI_VENDOR_ID 0x8086 /* PCI vendor ID */
#define I21145_PCI_DEVICE_ID 0x0039
#define DAVICOM_PCI_VENDOR_ID 0x1282 /* PCI vendor ID */
#define DAVICOM9100_PCI_DEVICE_ID 0x9100
#define DAVICOM9102_PCI_DEVICE_ID 0x9102
#define ACCTON_PCI_VENDOR_ID 0x1113 /* PCI vendor ID */
#define EN1217_PCI_DEVICE_ID 0x1217
#define BOARD_TYPE_NB (NELEMENTS(boardResources))
#ifdef INCLUDE_FEI82557END
/* EEPROM control bits */
#define EE_SK 0x01 /* shift clock */
#define EE_CS 0x02 /* chip select */
#define EE_DI 0x04 /* chip data in */
#define EE_DO 0x08 /* chip data out */
/* EEPROM opcode */
#define EE_CMD_WRITE 0x05 /* WRITE opcode, 101 */
#define EE_CMD_READ 0x06 /* READ opcode, 110 */
#define EE_CMD_ERASE 0x07 /* ERASE opcode, 111 */
/* EEPROM misc. defines */
#define EE_CMD_BITS 3 /* number of opcode bits */
#define EE_ADDR_BITS 6 /* number of address bits */
#define EE_DATA_BITS 16 /* number of data bits */
#define EE_SIZE 0x40 /* 0x40 words */
#define EE_CHECKSUM 0xbaba /* checksum */
/* PC compatibility macros */
#define sysOutWord(addr,data) (*((UINT16 *) (addr)) = ((UINT16) (data)))
#define sysInWord(addr) (*((UINT16 *) (addr)))
#define sysOutLong(addr,data) (*((UINT32 *) (addr)) = ((UINT32) (data)))
#define sysInLong(addr) (*((UINT32 *) (addr)))
#define FEI_MEMSIZE0 0x00001000
#define FEI_INIT_STATE_MASK (-1) /* unused */
#define FEI_INIT_STATE (-1) /* unused */
#define UNKNOWN (-1)
/* 82557/9 PCI specific definitions */
/* Intel PRO-100B PCI specific definitions */
#ifndef PRO100B_PCI_VENDOR_ID
#define PRO100B_PCI_VENDOR_ID 0x8086 /* PCI vendor ID */
#define PRO100B_PCI_DEVICE_ID 0x1229 /* PCI device ID */
#endif /* PRO100B_PCI_VENDOR_ID */
/* Intel InBusiness 10/100 PCI specific definitions */
#ifndef INBUSINESS_PCI_VENDOR_ID
#define INBUSINESS_PCI_VENDOR_ID PRO100B_PCI_VENDOR_ID /* PCI vendor ID */
#define INBUSINESS_PCI_DEVICE_ID 0x1030 /* PCI device ID */
#endif /* INBUSINESS_PCI_VENDOR_ID */
/* 05/13/2004 pcd */
#undef IO_MEM_MAPPING
#endif /* INCLUDE_FEI82557END */
/* typedefs */
typedef struct pciResource /* PCI_RESOURCES */
{
UINT32 iobaseCsr; /* Base Address Register 0 */
UINT32 membaseCsr; /* Base Address Register 1 */
char irq; /* Interrupt Request Level */
UINT32 irqvec; /* Interrupt Request vector */
UINT32 configType; /* type of configuration */
void * buf; /* any allocated buffer space */
UINT32 cpuToPciOffset; /* Any offset from CPU to PCI address */
} PCI_RESOURCES;
typedef struct boardResource /* BOARD_RESOURCES */
{
UINT32 type; /* type of the board */
UINT32 vendorId; /* Vendor ID */
UINT32 deviceId; /* Device ID */
UINT32 decUsrFlags; /* DEC driver user flags */
} BOARD_RESOURCES;
#ifdef INCLUDE_FEI82557END
typedef struct feiResource /* FEI_RESOURCE */
{
UINT32 membaseCsr; /* Base Address Register 0 */
UINT32 iobaseCsr; /* Base Address Register 1 */
UINT32 membaseFlash; /* Base Address Register 2 */
char irq; /* Interrupt Request Level */
UINT32 configType; /* type of configuration - unused */
UINT32 boardType; /* type of LAN board this unit is */
UINT16 eeprom[0x40]; /* Ethernet Address of this unit */
INT32 timeout; /* timeout for the self-test */
INT32 str[2]; /* storage for the self-test result */
volatile INT32 * pResults; /* pointer to the self-test result */
UINT memLength; /* required memory size */
UINT initialStateMask; /* mask parameter to vmStateSet */
UINT initialState; /* state parameter to vmStateSet */
} FEI_RESOURCE;
#endif
/* locals */
/*
* This array defines the board-specific PCI resources, the base address
* register configuration mode and the Ethernet adapter type. It's indexed
* using the device number returned from pciFindDevice().
*
* The mode is set as AUTO so this will be erased by the configuration read
* from the card that is effectively set by pciAssignResources(). See
* sysLanPciInit() for this.
*/
LOCAL PCI_RESOURCES pciResources [KS8695P_MAX_END_DEVS] =
{
{PCI_IO_ADR0, PCI_MEM_ADR0, INT_LVL_EXTI0S, INT_VEC_EXTI0S, PCI_REG_MOD, 0, 0},
{PCI_IO_ADR1, PCI_MEM_ADR1, INT_LVL_EXTI0S, INT_VEC_EXTI0S, PCI_REG_MOD, 0, 0},
{PCI_IO_ADR2, PCI_MEM_ADR2, INT_LVL_EXTI0S, INT_VEC_EXTI0S, PCI_REG_MOD, 0, 0}
};
/*
* This array defines board-specific vendor and device ids, flags to pass to
* the drive load routine and the function used to select the media.
*/
LOCAL BOARD_RESOURCES boardResources [] =
{
#ifdef INCLUDE_DEC21X40END
{EB143, DEC21X4X_PCI_VENDOR_ID, DEC21143_PCI_DEVICE_ID, DEC_USR_FLAGS_143},
{DC140, DEC21X4X_PCI_VENDOR_ID, DEC21140_PCI_DEVICE_ID, DEC_USR_FLAGS_140},
{DC040, DEC21X4X_PCI_VENDOR_ID, DEC21040_PCI_DEVICE_ID, DEC_USR_FLAGS_040},
#ifdef INCLUDE_DEC_UNTESTED
/* Untested cards */
{LC82C168, PNIC_PCI_VENDOR_ID, PNIC_PCI_DEVICE_ID, PNIC_USR_FLAGS},
{PNIC2, PNIC_PCI_VENDOR_ID, PNIC2_PCI_DEVICE_ID, PNIC2_USR_FLAGS},
{MX98713, MACRONIX_PCI_VENDOR_ID, MX98713_PCI_DEVICE_ID, MX98713_USR_FLAGS},
{MX98715, MACRONIX_PCI_VENDOR_ID, MX98715_PCI_DEVICE_ID, MX98715_USR_FLAGS},
{AX88140, ASIX_PCI_VENDOR_ID, AX88140_PCI_DEVICE_ID, AX88140_USR_FLAGS},
{COMET, COMET_PCI_VENDOR_ID, COMET1_PCI_DEVICE_ID, COMET_USR_FLAGS},
{COMET, COMET_PCI_VENDOR_ID, COMET2_PCI_DEVICE_ID, COMET_USR_FLAGS},
{COMET, COMET_PCI_VENDOR_ID, COMET3_PCI_DEVICE_ID, COMET_USR_FLAGS},
{COMPEX9881, COMPEX_PCI_VENDOR_ID, COMPEX9881_PCI_DEVICE_ID,\
COMPEX9881_USR_FLAGS},
{I21145, INTEL_PCI_VENDOR_ID, I21145_PCI_DEVICE_ID, I21145_USR_FLAGS},
{DC140, DAVICOM_PCI_VENDOR_ID, DAVICOM9100_PCI_DEVICE_ID,\
DEC_USR_FLAGS_140},
{DC140, DAVICOM_PCI_VENDOR_ID, DAVICOM9102_PCI_DEVICE_ID,\
DEC_USR_FLAGS_140},
{MX98715, ACCTON_PCI_VENDOR_ID, EN1217_PCI_DEVICE_ID, MX98715_USR_FLAGS},
#endif /* INCLUDE_DEC_UNTESTED */
#endif /* INCLUDE_DEC21X40END */
#ifdef INCLUDE_FEI82557END
{PRO100B, PRO100B_PCI_VENDOR_ID, PRO100B_PCI_DEVICE_ID, 0},
{INBUSINESS, INBUSINESS_PCI_VENDOR_ID, INBUSINESS_PCI_DEVICE_ID, 0},
#ifdef INCLUDE_FEI_UNTESTED
{XX82559ER, PRO100B_PCI_VENDOR_ID, I82559ER_PCI_DEVICE_ID, 0},
#endif
#endif /* INCLUDE_FEI82557END */
};
/* END load strings */
LOCAL char endLoadStr[KS8695P_MAX_END_DEVS][END_LD_STR_SIZE];
/* Index of devices */
LOCAL int currentEndDevice = 0;
#ifdef KS8695P_ENET_FIXED_BUF_ADRS
LOCAL UINT32 sysEnetBufAdrs[] =
{
KS8695P_ENET_PRIMARY_BUF_ADRS,
KS8695P_ENET_SECONDARY_BUF_ADRS,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -