⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sysel3c90xend.c

📁 cpc-1631的BSP包for VxWorks操作系统
💻 C
📖 第 1 页 / 共 2 页
字号:
/* sysEl3c90xEnd.c - system configuration module for el3c90xEnd driver */
 
/* Copyright 1984-1999 Wind River Systems, Inc. */
#include "copyright_wrs.h"
 
/*
modification history
--------------------
01b,07mar02,kab  SPR 70817: *EndLoad returns NULL on failure
01a,19oct99,mtl   written from yk 750 by teamF1
*/
 
/*
DESCRIPTION
This is the WRS-supplied configuration module for the VxWorks
el3c90xEnd (lnPci) END driver.
 
It initializes the resources for all the 3c90x devices found.

It performs the dynamic parameterization of the el3c90xEnd 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.
*/

#include "vxWorks.h"
#include "config.h"
 
#include "vmLib.h"
#include "stdio.h"
#include "sysLib.h"
#include "logLib.h"
#include "stdlib.h"
#include "string.h"
#include "end.h"
#include "intLib.h"
#include "drv/pci/pciIntLib.h"
 
#include "drv/end/el3c90xEnd.h"

#ifdef INCLUDE_EL_3C90X_END

/* imports */
 
IMPORT END_OBJ *	el3c90xEndLoad (char *);

/* defines */

/*
 * default values if PCI_CFG_TYPE defined to be PCI_CFG_FORCE
 * note: memory addresses must be aligned on MMU page boundaries
 */

#define EL_3C90X_IO_ADR0   	0xf400
#define EL_3C90X_MEM_ADR0  	0xfd000000
#define EL_3C90X_INT_LVL0  	0x03
#define EL_3C90X_INT_VEC0  	0x03

#define EL_3C90X_IO_ADR1   	0xf420
#define EL_3C90X_MEM_ADR1  	0xfd200000
#define EL_3C90X_INT_LVL1  	0x02
#define EL_3C90X_INT_VEC1  	0x02

#define EL_3C90X_IO_ADR2   	0xf440
#define EL_3C90X_MEM_ADR2  	0xfd300000
#define EL_3C90X_INT_LVL2  	0x01
#define EL_3C90X_INT_VEC2  	0x01

#define EL_3C90X_IO_ADR3   	0xf460
#define EL_3C90X_MEM_ADR3  	0xfd400000
#define EL_3C90X_INT_LVL3  	0x0
#define EL_3C90X_INT_VEC3  	0x0

#define EL_3C90X_MAX_DEV 	4

#define EL_3C90X_END_FLAGS	0
#define EL_3C90X_BUFF_MTPLR	NONE

#define PCI_DEV_MMU_MSK         (~(VM_PAGE_SIZE - 1))   /* Mask MMU page */
 
#define PCI_DEV_ADRS_SIZE       VM_PAGE_SIZE    /* one page */
 
/* Offsets of PCI resources in host space */
 
#ifndef CPU_PCI_IO_ADRS
#define CPU_PCI_IO_ADRS         0               /* base of PCI I/O addr */
#endif /* CPU_PCI_IO_ADRS */
 
#ifndef CPU_PCI_MEM_ADRS
#define CPU_PCI_MEM_ADRS        0               /* base of PCI mem address */
#endif /* CPU_PCI_MEM_ADRS */
 
#ifndef PCI2DRAM_BASE_ADRS
#define PCI2DRAM_BASE_ADRS      0               /* DRAM base addrs from PCI */
#endif /* PCI2DRAM_BASE_ADRS */
 
/* typedefs */
 
typedef struct el3c90xPciResource              /* EL_3C90X_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 */
    UINT32      boardType;              /* type of LAN board for this unit */
    UINT32      pciBus;                 /* PCI Bus number */
    UINT32      pciDevice;              /* PCI Device number */
    UINT32      pciFunc;                /* PCI Function number */
    } EL_3C90X_PCI_RESOURCES;
 
typedef struct el3c90xBoardResource            /* EL_3C90X_BOARD_RESOURCES */
    {
    UINT32      type;                   /* type of the board */
    UINT32      vendorId;               /* Vendor ID */
    UINT32      deviceId;               /* Device ID */
    UINT32      lnUsrFlags;             /* LN driver user flags */
    FUNCPTR     mediaSelectFunc;        /* media select routine */
    } EL_3C90X_BOARD_RESOURCES;
 
/* 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 EL_3C90X_PCI_RESOURCES el3c90xPciResrcs [] =
    {
    {EL_3C90X_IO_ADR0, EL_3C90X_MEM_ADR0, EL_3C90X_INT_LVL0, EL_3C90X_INT_VEC0,
     PCI_CFG_TYPE, 0, 0, 0, 0},
    {EL_3C90X_IO_ADR1, EL_3C90X_MEM_ADR1, EL_3C90X_INT_LVL1, EL_3C90X_INT_VEC1,
     PCI_CFG_TYPE, 0, 0, 0, 0},
    {EL_3C90X_IO_ADR2, EL_3C90X_MEM_ADR2, EL_3C90X_INT_LVL2, EL_3C90X_INT_VEC2,
     PCI_CFG_TYPE, 0, 0, 0, 0},
    {EL_3C90X_IO_ADR3, EL_3C90X_MEM_ADR3, EL_3C90X_INT_LVL3, EL_3C90X_INT_VEC3,
     PCI_CFG_TYPE, 0, 0, 0, 0}
    };

/* 
 * this table will be filled up with the actual resources used by this
 * device.
 */

EL_3C90X_PCI_RESOURCES * 	pEl3c90xActualRsrc [EL_3C90X_MAX_DEV];	

/*
 * 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 EL_3C90X_BOARD_RESOURCES el3c90xBrds [] =
    {
	{0, TC_VENDORID, TC_DEVICEID_BOOMERANG_10BT, 0, NULL},
		
	{0, TC_VENDORID, TC_DEVICEID_BOOMERANG_10BT_COMBO, 0, NULL},
		
	{0, TC_VENDORID, TC_DEVICEID_BOOMERANG_10_100BT, 0, NULL},
		
	{0, TC_VENDORID, TC_DEVICEID_BOOMERANG_100BT4, 0, NULL},
		
	{0, TC_VENDORID, TC_DEVICEID_CYCLONE_10BT, 0, NULL},
		
	{0, TC_VENDORID, TC_DEVICEID_CYCLONE_10BT_COMBO, 0, NULL},
		
	{0, TC_VENDORID, TC_DEVICEID_CYCLONE_10_100BT, 0, NULL},
		
	{0, TC_VENDORID, TC_DEVICEID_CYCLONE_10_100BT4, 0, NULL},
		
	{0, TC_VENDORID, TC_DEVICEID_CYCLONE_10_100FX, 0, NULL},
		
	{0, TC_VENDORID, TC_DEVICEID_CYCLONE_10_100BT_SERV, 0, NULL}
    };

/* forward declarations */

/*******************************************************************************
*
* sysEl3c90xPciInit - prepare LAN adapter for EL_3C90X initialization
*
* This routine finds out the PCI device, maps its memory and IO address.
* It must be done prior to initializing the driver.  Also
* must be done prior to MMU initialization, usrMmuInit().
*
* RETURNS: OK/ERROR
*/

STATUS sysEl3c90xPciInit (void)
    {
    UINT32 		membaseCsr;
    UINT32 		iobaseCsr;
    char 		irq;
    int 		pciBus;
    int 		pciDevice;
    int 		pciFunc;
    int 		unit;
    int 		found = 0;
    int 		netEndUnits = 0;
    UINT16		tmpWord;
    UINT32		tmpLong;
    UINT32		tmpLong2;
 

    /* for all the support network devices find if some of them exist */
    
    for (unit = 0; unit < NELEMENTS (el3c90xBrds); unit++)
	{
	if (pciFindDevice (el3c90xBrds [unit].vendorId,
                           el3c90xBrds [unit].deviceId,
                           netEndUnits, &pciBus, &pciDevice, &pciFunc) == OK)
	    {
             /* board detected */
             /* for now, we're ignoring the possibility of duplicates */

	     found = TRUE;

             /* load up the PCI device table */
             
             pEl3c90xActualRsrc [unit] = el3c90xPciResrcs + netEndUnits; 

             pEl3c90xActualRsrc [unit]->pciBus    = pciBus;
             pEl3c90xActualRsrc [unit]->pciDevice = pciDevice;
             pEl3c90xActualRsrc [unit]->pciFunc   = pciFunc;

             netEndUnits++;   	/* number of units found */
             }
        }

    if ((found != TRUE) || (pciDevice > PCI_MAX_DEV))
	return (ERROR);

    /* Now initialize all the units we found */

    for (unit = 0; ((unit < netEndUnits) &&
                    (unit < NELEMENTS (el3c90xPciResrcs)));
         unit++)
	{
        /* Fill in the resource entry */

        pEl3c90xActualRsrc [unit] = el3c90xPciResrcs + unit;

        if (pEl3c90xActualRsrc [unit]->configType == PCI_CFG_FORCE) 
            {
            /* write the iobase, membase, and irq */

            pciConfigOutLong (pEl3c90xActualRsrc [unit]->pciBus, 
			      pEl3c90xActualRsrc [unit]->pciDevice, 
			      pEl3c90xActualRsrc [unit]->pciFunc,
                              PCI_CFG_BASE_ADDRESS_0, 
			      pEl3c90xActualRsrc [unit]->iobaseCsr |
                              PCI_BASE_IO);

            pciConfigOutLong (pEl3c90xActualRsrc [unit]->pciBus, 
			      pEl3c90xActualRsrc [unit]->pciDevice, 
			      pEl3c90xActualRsrc [unit]->pciFunc,
                              PCI_CFG_BASE_ADDRESS_1, 
			      pEl3c90xActualRsrc [unit]->membaseCsr);

            pciConfigOutByte (pEl3c90xActualRsrc [unit]->pciBus, 
			      pEl3c90xActualRsrc [unit]->pciDevice, 
			      pEl3c90xActualRsrc [unit]->pciFunc,
                              PCI_CFG_DEV_INT_LINE, 
			      pEl3c90xActualRsrc [unit]->irq);
            }
	    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -