📄 sysdec21x40end.c
字号:
/* sysDec21x40End.c - system configuration module for Dec21x40 END */
/* Copyright 1984 - 1999 Wind River Systems, Inc. */
/*
modification history
--------------------
01d,07mar02,kab SPR 70817: *EndLoad returns NULL on failure
01c,24jan02,pcs Remove Warnings (DIAB) .
01b,21mar01,pcs Removed references to DEC_USR_PHY_CHK, since it is no longer
needed.
01a,10oct99,mtl written from yk 750 by teamF1
*/
/*
DESCRIPTION
This is the WRS-supplied configuration module for the VxWorks
dec21x40End (dc) END driver. It performs the dynamic parameterization
of the dec21x40End driver. This technique of 'just-in-time'
parameterization allows driver parameter values to be declared as
any other defined constants rather than as static strings.
*/
#if (defined(INCLUDE_NETWORK) && defined(INCLUDE_DC_END) \
&& defined (INCLUDE_END))
/* includes */
#include "vxWorks.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "end.h"
#include "config.h"
#include "drv/end/dec21x40End.h"
/* defines */
/* DEC 21X4X 10/100Base-TX Board type */
#define EB143 1 /* DEC 21143 10/100Base-TX Evaluation Board */
#define DC140 2 /* DEC 21140 10/100Base-TX Based Board */
#define DC040 3 /* DEC 21040 10/100Base-TX Based Board */
#define BOARD_TYPE_NB 3
/* 040/140/143 DEC driver user flags */
#define DEC_USR_FLAGS_143 (DEC_USR_21143 )
#define DEC_USR_FLAGS_140 (DEC_USR_BAR_RX | DEC_USR_RML | DEC_USR_CAL_08 | \
DEC_USR_PBL_04 | DEC_USR_21140 )
#define DEC_USR_FLAGS_040 (DEC_USR_BAR_RX | DEC_USR_CAL_08 | DEC_USR_PBL_04)
/* 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 */
/* This is where our dec pci memory space resides which depends on the map
* This is the address used to call dcattach
*/
#define DEC_PCI_MEMBASE_MAP_A 0x80000000
#define DEC_DEVADDR_MAP_A 0xC0000000
#define DEC_PCI_MEMBASE_MAP_B 0x00000000
#define DEC_DEVADDR_MAP_B 0x80000000
/* forward declarations */
STATUS sysDec21143MediaSelect (DEC21X40_DRV_CTRL *, UINT *);
STATUS sysDec21140MediaSelect (DEC21X40_DRV_CTRL *, UINT *);
/* typedefs */
typedef struct sysDecPciRsrc /* SYS_DEC_PCI_RSRC */
{
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 */
UINT32 boardType; /* type of LAN board this unit is */
UINT32 pciBus; /* PCI Bus number */
UINT32 pciDevice; /* PCI Device number */
UINT32 pciFunc; /* PCI Function number */
} SYS_DEC_PCI_RSRC;
typedef struct sysDecBoardRsrc /* SYS_DEC_BD_RSRC */
{
UINT32 type; /* type of the board */
UINT32 vendorId; /* Vendor ID */
UINT32 deviceId; /* Device ID */
UINT32 decUsrFlags; /* DEC driver user flags */
FUNCPTR mediaSelectFunc; /* media select routine */
} SYS_DEC_BD_RSRC;
/* 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().
*/
LOCAL SYS_DEC_PCI_RSRC sysDecPciRsrcs [PCI_MAX_DEV] =
{
{0, 0, 0, 0, 0, DC140, 0, 0, 0},
{0, 0, 0, 0, 0, DC040, 0, 0, 0},
{0, 0, 0, 0, 0, EB143, 0, 0, 0},
{0, 0, 0, 0, 0, EB143, 0, 0, 0},
};
/*
* This array defines board-specific vendor and device ids, flags to pass to
* the driver load routine and the function used to select the media.
*/
LOCAL SYS_DEC_BD_RSRC sysDecBoardRsrc [BOARD_TYPE_NB] =
{
{EB143, DEC21X4X_PCI_VENDOR_ID, DEC21143_PCI_DEVICE_ID, DEC_USR_FLAGS_143,\
sysDec21143MediaSelect},
{DC140, DEC21X4X_PCI_VENDOR_ID, DEC21140_PCI_DEVICE_ID, DEC_USR_FLAGS_140,\
sysDec21140MediaSelect},
{DC040, DEC21X4X_PCI_VENDOR_ID, DEC21040_PCI_DEVICE_ID, DEC_USR_FLAGS_040,\
NULL},
};
LOCAL UINT32 sysDecPciDevNo = 0; /* PCI device populated */
LOCAL UINT32 sysDecBoardTypeNo = 0; /* board type used */
IMPORT END_OBJ* dec21x40EndLoad (char *);
IMPORT int pciIntToIrq(int devNo, int pciInt);
/******************************************************************************
*
* sysDec21x40EndLoad - create load string and load a dec21x40 (dc) device.
*
* This routine loads the dc device with initial parameters probed
* during dec21x40PciInit().
*
* RETURNS: pointer to END object or NULL.
*
* SEE ALSO: dec21x40EndLoad()
*/
END_OBJ * sysDec21x40EndLoad
(
char * pParamStr, /* ptr to initialization parameter string */
void * unused /* unused optional argument */
)
{
/*
* The dec21x40End driver END_LOAD_STRING should be:
* The format of the parameter string is:
*
* "<device_addr>:<PCI_addr>:<ivec>:<ilevel>:<num_rds>:<num_tds>:
* <mem_base>:<mem_size>:<user_flags>"
*
* Note that dec21x40 unit number is prepended in muxDevLoad, so we
* don't put it here!
*/
char * cp;
char paramStr [END_INIT_STR_MAX]; /* end.h */
END_OBJ * pEnd;
static char decParamTemplate[] = "0x%x:0x%x:0x%x:0x%x:-1:-1:-1:0:0x%x";
SYS_DEC_PCI_RSRC * pRsrc = &(sysDecPciRsrcs[sysDecPciDevNo]);
if (strlen (pParamStr) == 0)
{
/*
* muxDevLoad() calls us twice. If the string is
* zero length, then this is the first time through
* this routine, so we just return.
*/
pEnd = dec21x40EndLoad (pParamStr);
}
else
{
/*
* On the second pass though here, we actually create
* the initialization parameter string on the fly.
* Note that we will be handed our unit number on the
* second pass through and we need to preserve that information.
* So we use the unit number handed from the input string.
*/
cp = strcpy (paramStr, pParamStr); /* cp points to paramStr */
/* Now, we advance cp, by finding the end the string */
cp += strlen (paramStr);
/* finish off the initialization parameter string */
sprintf (cp, decParamTemplate,
/* device memory Io base */
(UINT) PCI_MEMIO2LOCAL (pRsrc->membaseCsr),
(UINT) PCI_SLV_MEM_LOCAL, /* pciMemBase */
pRsrc->irqvec, /* interrupt IRQ vector */
pRsrc->irq, /* interrupt irq number */
sysDecBoardRsrc[sysDecBoardTypeNo].decUsrFlags);
if ((pEnd = dec21x40EndLoad (paramStr)) == (END_OBJ *)NULL)
{
printf ("Error: Dec21x4x device failed dec21x40EndLoad routine.\n");
}
}
return (pEnd);
}
/*******************************************************************************
*
* sysDec21x40PciInit - prepare LAN adapter for DEC21X4X initialization
*
* This routine finds the PCI device, and maps its memory and IO address.
* It must be done prior to initializing the DEC21X4X, sysDec21x40Init().
*
* RETURNS: N/A
*/
STATUS sysDec21x40PciInit (void)
{
SYS_DEC_PCI_RSRC * pRsrc; /* dec resource */
INT32 pciBus; /* PCI Bus number */
INT32 pciDevice; /* PCI Device number */
INT32 pciFunc; /* PCI Function number */
UINT32 membaseCsr; /* Base Address Register 1 */
UINT32 iobaseCsr; /* Base Address Register 0 */
char irq; /* Interrupt Request Level */
UINT32 boardType = NONE; /* board type detected */
BOOL found = FALSE;
/*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -