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

📄 sysrtl81x9end.c

📁 8139在vxworks平台下的驱动
💻 C
📖 第 1 页 / 共 2 页
字号:
/* sysRtl81x9End.c - system configuration module for RTL81x9 END driver */
 
/* Copyright 1984-1999 Wind River Systems, Inc. */
#include "copyright_wrs.h"
 
/*
modification history
--------------------
02b,28jan00, Added new define RTL81X9_EARX_THRESH
02a,27jan00, Modified the initialisation and resource table.
01a,12nov99, dgy created.
*/
 
/*
DESCRIPTION
This is the WRS-supplied configuration module for the VxWorks
Realtek 81x9 (rtl) END driver.
 
It initializes the resources for all the 81x9 devices found.

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


#ifdef INCLUDE_RTL_81X9_END


#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/unsupported/rtl81x9.h"


/* imports */
 
IMPORT STATUS           sysMmuMapAdd (void * address, UINT len,
                                      UINT initialStateMask,
                                      UINT initialState);

IMPORT END_TBL_ENTRY    endDevTbl[];    /* end device table */

IMPORT END_OBJ *	rtl81x9EndLoad (char *);

/* defines */

#define RTL_81X9_LOAD_FUNC        rtl81x9EndLoad

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

#define RTL81X9_IO_ADR0   	0xf400
#define RTL81X9_MEM_ADR0  	0xfd000000
#define RTL81X9_INT_LVL0  	0x0b
#define RTL81X9_INT_VEC0  	0

#define RTL81X9_IO_ADR1   	0xf420
#define RTL81X9_MEM_ADR1  	0xfd200000
#define RTL81X9_INT_LVL1  	0x05
#define RTL81X9_INT_VEC1  	0

#define RTL81X9_IO_ADR2   	0xf440
#define RTL81X9_MEM_ADR2  	0xfd300000
#define RTL81X9_INT_LVL2  	0x0c
#define RTL81X9_INT_VEC2  	0

#define RTL81X9_IO_ADR3   	0xf460
#define RTL81X9_MEM_ADR3  	0xfd400000
#define RTL81X9_INT_LVL3  	0x9
#define RTL81X9_INT_VEC3  	0

#define RTL81X9_MAX_DEV 	4

#define RTL81X9_EARX_THRESH	10
#define RTL81X9_END_FLAGS	(RTL81X9_EARX_THRESH << 16)

#define RTL81X9_BUFF_MTPLR	NONE

#define EXT_INTERRUPT_BASE      INT_NUM_IRQ0    /* irq0     */
 
#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 rtl81x9PciResource              /* RTL81X9_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 */
    } RTL81X9_PCI_RESOURCES;
 
typedef struct rtl81x9BoardResource            /* RTL81X9_BOARD_RESOURCES */
    {
    UINT32      type;                   /* type of the board */
    UINT32      vendorId;               /* Vendor ID */
    UINT32      deviceId;               /* Device ID */
    UINT32      RtlUsrFlags;             /* RTL driver user flags */
    FUNCPTR     mediaSelectFunc;        /* media select routine */
    } RTL81X9_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 RTL81X9_PCI_RESOURCES rtl81x9PciResrcs [] =
    {
    {RTL81X9_IO_ADR0, RTL81X9_MEM_ADR0, RTL81X9_INT_LVL0, RTL81X9_INT_VEC0,
     PCI_CFG_TYPE, 0, 0, 0, 0},
    {RTL81X9_IO_ADR1, RTL81X9_MEM_ADR1, RTL81X9_INT_LVL1, RTL81X9_INT_VEC1,
     PCI_CFG_TYPE, 0, 0, 0, 0},
    {RTL81X9_IO_ADR2, RTL81X9_MEM_ADR2, RTL81X9_INT_LVL2, RTL81X9_INT_VEC2,
     PCI_CFG_TYPE, 0, 0, 0, 0},
    {RTL81X9_IO_ADR3, RTL81X9_MEM_ADR3, RTL81X9_INT_LVL3, RTL81X9_INT_VEC3,
     PCI_CFG_TYPE, 0, 0, 0, 0}
    };

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

RTL81X9_PCI_RESOURCES * 	pRsrc [RTL81X9_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 RTL81X9_BOARD_RESOURCES rtl81x9Brds [] =
    {
	{0, RTL_VENDORID, 		RTL_8139_DEV_ID, 		0, 	NULL},
	{0, RTL_VENDORID, 		RTL_8129_DEV_ID, 		0, 	NULL},		
	{0, RTL_VENDOR_ID_MIS, 	RTL_MIS_DEV_ID, 		0, 	NULL},
	{0, ADDTRON_VENDORID, 	ADDTRON_DEVICEID_8139, 	0, 	NULL},
	{0, DELTA_VENDORID, 	DELTA_DEVICEID_8139, 	0, 	NULL},
	{0, ACCTON_VENDORID, 	ACCTON_DEVICEID_5030, 	0, 	NULL},
    };

/* forward declarations */
 
STATUS	sysRtl81x9PciInit (void);

/*******************************************************************************
*
* sysRtl81x9PciInit - prepare LAN adapter for RTL_81X9 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 sysRtl81x9PciInit (void)
    {
    UINT32 		membaseCsr;
    UINT32 		iobaseCsr;
    char 		irq;
    int 		pciBus;
    int 		pciDevice;
    int 		pciFunc;
    int 		ix;
    int 		unit;
    int 		found = 0;
    int 		netEndUnits = 0;

    /* for all the support network devices find if some of them exist */
    


    for (unit = 0; unit < RTL81X9_MAX_DEV; unit++)
		{
		for (ix=0; ix < NELEMENTS (rtl81x9Brds); ix++)
			{
			if (pciFindDevice (	rtl81x9Brds [ix].vendorId,
                           		rtl81x9Brds [ix].deviceId,
                           		unit, &pciBus, &pciDevice, &pciFunc) == OK)
	    		{

        		/* board detected */


	    		found = TRUE;

        		/* load up the PCI device table */
             
        		pRsrc [unit] = rtl81x9PciResrcs + netEndUnits; 

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

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

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

    /* Now initialize all the units we found */

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

        pRsrc [unit] = rtl81x9PciResrcs + unit;

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

            pciConfigOutLong (pRsrc[unit]->pciBus, 
			      pRsrc[unit]->pciDevice, 

⌨️ 快捷键说明

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