vxWorks6.6下基于vxBus的以太网驱动开发

最近更换mpc8313的phy芯片,由原来的lxt972Phy更换为DP83849I,在此记录下本人在驱动开发过程中的点滴记录,以备日后查询,基于vxbus的网络驱动,vxBus驱动的注册遵循一致的方法,驱动接口为:

 device_method_t dp83849PhyMethods[] =
    {
    DEVMETHOD(miiModeGet,      dp83849PhyModeGet),
    DEVMETHOD(miiModeSet,      dp83849PhyModeSet),
    DEVMETHOD(vxbDrvUnlink,    dp83849PhyInstUnlink),
    { 0, 0 }
    };

 struct drvBusFuncs dp83849PhyFuncs =
    {
    dp83849PhyDevInstInit,      /* devInstanceInit */
    dp83849PhyDevInstInit2,     /* devInstanceInit2 */
    dp83849PhyDevInstConnect    /* devInstanceConnect */
    };

struct vxbDevRegInfo dp83849PhyDevRegistration =
    {
    NULL,               /* pNext */
    VXB_DEVID_DEVICE,   /* devID */
    VXB_BUSID_MII,      /* busID = MII Bus */
    VXBUS_VERSION_3,      /* busVer */
    "dp83849Phy",        /* drvName */
    &dp83849PhyFuncs,       /* pDrvBusFuncs */
    dp83849PhyMethods,      /* pMethods */
    dp83849PhyProbe         /* devProbe */
    };

void dp83849PhyRegister(void)
    {
    vxbDevRegister (&dp83849PhyDevRegistration);
    return;
    }

要编写驱动,主要去实现上面模块中的相关功能,首先编写dp83849PhyProbe,在函数中识别flash的ID,编写其他相关的函数,接下来在sysLib.c中注册系统驱动

#include "Dp83849Phy.c"
void sysHwInit (void)
{
 dp83849PhyRegister();
}

接下来,在系统硬件配置hwconf.c中更改phyAddr地址,具体地址参照phy芯片硬件设计


const struct hcfResource motEtsecHEnd0Resources[] = 
    {
    { "regBase",    HCF_RES_INT,    { (void *)(CCSBAR + 0x24000) } },
    { "intr0",      HCF_RES_INT,    { (void *)INUM_TSEC1_TX} },
    { "intr0Level", HCF_RES_INT,    { (void *)INUM_TSEC1_TX } },
    { "intr1",      HCF_RES_INT,    { (void *)INUM_TSEC1_RX } },
    { "intr1Level", HCF_RES_INT,    { (void *)INUM_TSEC1_RX } },
    { "intr2",      HCF_RES_INT,    { (void *)INUM_TSEC1_ERR } },
    { "intr2Level", HCF_RES_INT,    { (void *)INUM_TSEC1_ERR } },
    { "phyAddr",    HCF_RES_INT,    { (void *)14 }},
    { "miiIfName",  HCF_RES_STRING, { (void *)"tsecMdio" } },
    { "miiIfUnit",  HCF_RES_INT,    { (void *)0 } }
    };

接下来,由于本次硬件设计采用RMII接口,所以在config.h中更改硬件配置字

/* RMII */

#define HRCW_HIGH_BYTE2     0x24 

接下来更改系统MAC寄存器,在vxbEtsecEnd.c中修改下列函数,根据系统硬件配置字设置ETSEC_ECNTRL寄存器的ETSEC_ECNTRL_R100M

LOCAL STATUS etsecLinkUpdate
    (
    VXB_DEVICE_ID pDev
    )
{
     switch (IFM_SUBTYPE(pDrvCtrl->etsecCurMedia))
        {
        case IFM_1000_T:
        case IFM_1000_SX:
            CSR_SETBIT_4(pDev, ETSEC_MACCFG2, ETSEC_IFMODE_GMII_TBI);
            /* R100M is "don't care" for gigE, but clear it anyway */
            CSR_CLRBIT_4(pDev, ETSEC_ECNTRL, ETSEC_ECNTRL_R100M);
            pDrvCtrl->etsecEndObj.mib2Tbl.ifSpeed = 1000000000;
            break;

        case IFM_100_TX:
            CSR_SETBIT_4(pDev, ETSEC_MACCFG2, ETSEC_IFMODE_MII);
            //CSR_SETBIT_4(pDev, ETSEC_MACCFG2, ETSEC_MACCFG2_PREAMBLE_LEN | ETSEC_IFMODE_MII | ETSEC_MACCFG2_PADCRC | ETSEC_MACCFG2_FULL_DUPLEX);
            /* Set R100M bit if configured for reduced pin mode RMII */
            if (CSR_READ_4(pDev, ETSEC_ECNTRL) & ETSEC_ECNTRL_RMM)
                CSR_SETBIT_4(pDev, ETSEC_ECNTRL, ETSEC_ECNTRL_R100M);
            //printf("100M ccfg2 = %08x ecntrl = %08x\n", CSR_READ_4(pDev, ETSEC_MACCFG2), CSR_READ_4(pDev, ETSEC_ECNTRL));
            pDrvCtrl->etsecEndObj.mib2Tbl.ifSpeed = 100000000;
            break;

        case IFM_10_T:
            CSR_SETBIT_4(pDev, ETSEC_MACCFG2, ETSEC_IFMODE_MII);
            //CSR_SETBIT_4(pDev, ETSEC_MACCFG2, ETSEC_MACCFG2_PREAMBLE_LEN | ETSEC_IFMODE_MII | ETSEC_MACCFG2_PADCRC | ETSEC_MACCFG2_FULL_DUPLEX);
            /* The R100M bit is always 0 for 10Mbps operation. */
            if(CSR_READ_4(pDev, ETSEC_ECNTRL) & ETSEC_ECNTRL_RMM)
                CSR_CLRBIT_4(pDev, ETSEC_ECNTRL, ETSEC_ECNTRL_R100M);
            //printf("10M ccfg2 = %08x ecntrl = %08x\n", CSR_READ_4(pDev, ETSEC_MACCFG2), CSR_READ_4(pDev, ETSEC_ECNTRL));
            pDrvCtrl->etsecEndObj.mib2Tbl.ifSpeed = 10000000;
            break;

        default:
            break;
        }

}

值此基本上已经完成驱动程序的修改,由于网络不通,无法加载系统镜像,无法调试,本人的解决办法是,先把vxWorks.bin通过仿真器烧写到flash固定位置,boot上电运行时,再从flash加载到RAM_LOW_ADDR地址处开始运行,这样在网络不通的情况下,可以加载系统镜像进行调试,所以修改bootsehll.c程序,并在autoboot函数中调用:

/*启动时从norflash中拷贝系统镜像到VXWORKS启动地址,然后转到此处执行zhb_2020.12.23*/
void copyVxToRam(void)
{
	char *pVxRamAddr = RAM_LOW_ADRS;
	char* pVxFlashAddr = FLASH_BASE_ADRS + 0x400000;
	int i = 0;
	int* pEnterAddr;
	FUNCPTR absEntry;

	for (i = 0; i < 0x300000; i++)
		pVxRamAddr[i] = pVxFlashAddr[i];

	pEnterAddr = (int*)pVxRamAddr;
	printf("start Vxworks at %08x.....\n", pEnterAddr);
	absEntry = pEnterAddr;
	(absEntry)();
}
	

编译boot程序和系统镜像,用仿真器烧写到flash中运行,下面就可以进行调试了。对于phy芯片的调用,可以利用vxBusShow查看设备pDev,然后在shell中用MII_READ,MII_WRITE进行测试

-> vxBusShow
Registered Bus Types:
  MII_Bus @ 0x00208d60
  Local_Bus @ 0x00206138

Registered Device Drivers:
  ppcIntCtlr at 0x00207904 on bus Local_Bus, funcs @ 0x002078f8
        VxBus version 2
  quiccIntCtlr at 0x00208a2c on bus Local_Bus, funcs @ 0x002089f8
  quiccTimerDev at 0x002068ec on bus Local_Bus, funcs @ 0x002068d0
        VxBus version 2
  motetsec at 0x002026b0 on bus Local_Bus, funcs @ 0x00202584
  ns16550 at 0x0020734c on bus Local_Bus, funcs @ 0x002072dc
  ns16550 at 0x00207304 on bus PCI_Bus, funcs @ 0x002072dc
  ppcDecTimerDev at 0x00208f00 on bus Local_Bus, funcs @ 0x00208ee4
  tsecMdio at 0x00208ea4 on bus Local_Bus, funcs @ 0x00208e78
  mv88E1x11Phy at 0x00208e38 on bus MII_Bus, funcs @ 0x00208e08
  lxt972Phy at 0x00207250 on bus MII_Bus, funcs @ 0x00207244
  bcm54xxPhy at 0x00208da8 on bus MII_Bus, funcs @ 0x00208d9c
  miiBus at 0x00208d18 on bus PCI_Bus, funcs @ 0x00208cbc
  miiBus at 0x00208cd8 on bus Local_Bus, funcs @ 0x00208cbc
  plbCtlr at 0x00206160 on bus Local_Bus, funcs @ 0x00206154
  dp83849Phy at 0x00202544 on bus MII_Bus, funcs @ 0x00202538

Busses and Devices Present:
  Local_Bus @ 0x0023f848 with bridge @ 0x002061a0
    Device Instances:
        quiccIntCtlr unit 0 on Local_Bus @ 0x00240808 with busInfo 0x00000000
        ppcIntCtlr unit 0 on Local_Bus @ 0x00240908 with busInfo 0x00000000
        tsecMdio unit 0 on Local_Bus @ 0x00240a08 with busInfo 0x00000000
        motetsec unit 0 on Local_Bus @ 0x00240b08 with busInfo 0x00000000
        motetsec unit 1 on Local_Bus @ 0x00240c08 with busInfo 0x00000000
        ppcDecTimerDev unit 0 on Local_Bus @ 0x00240d08 with busInfo 0x00000000
        quiccTimerDev unit 0 on Local_Bus @ 0x00240e08 with busInfo 0x00000000
        quiccTimerDev unit 1 on Local_Bus @ 0x00240f08 with busInfo 0x00000000
        ns16550 unit 0 on Local_Bus @ 0x00241008 with busInfo 0x00000000
        ns16550 unit 1 on Local_Bus @ 0x00241208 with busInfo 0x00000000
        miiBus unit 0 on Local_Bus @ 0x00241708 with busInfo 0x0023ff08
        miiBus unit 1 on Local_Bus @ 0x00245b08 with busInfo 0x0023ff48
    Orphan Devices:
        legacy unit 0 on Local_Bus @ 0x00241408 with busInfo 0x00000000
  MII_Bus @ 0x0023ff08 with bridge @ 0x00241708
    Device Instances:
        dp83849Phy unit 0 on MII_Bus @ 0x00245908 with busInfo 0x00000000
    Orphan Devices:
  MII_Bus @ 0x0023ff48 with bridge @ 0x00245b08
    Device Instances:
        dp83849Phy unit 1 on MII_Bus @ 0x00245d08 with busInfo 0x00000000
    Orphan Devices:

value = 1 = 0x1

 对于以太网报文的测试,我们可以增加测试程序,从中断中捕获报文分析,测试以太网发送报文


LOCAL int etsecEndEncap
    (
    ETSEC_DRV_CTRL * pDrvCtrl,
    M_BLK_ID pMblk
    )
    {
    ETSEC_DESC * pDesc = NULL, * pFirst;
    ETSEC_TX_FCB * pFcb;
    M_BLK_ID pCurr, pStart;
    UINT32 firstIdx, lastIdx = 0;
    struct ether_header * eh;
    int used = 0, i;
    int j = 0;

   // printf("send net data ......\n");
    //for (j = 0; j < pMblk->mBlkHdr.mLen; j++)
     //   printf("%02x ", pMblk->mBlkHdr.mData[j]);
   // printf("\n");
}

 测试以太网接收报文

void usrPrintNet(ST_INT port, ST_VOID* pM)
{
	char gsBuf[L2_DATA_MSG_SIZE];
	int i = 0;
	M_BLK_ID pMblk = (M_BLK_ID)pM;

	memcpy(gsBuf, pMblk->mBlkHdr.mData, pMblk->mBlkHdr.mLen);
	if (g_debug_net == 1)
	{
		printf("revCnt = %d\n", gsvEthInfo[port].allPacketCount);
		for (i = 0; i < pMblk->mBlkHdr.mLen; i++)
			printf("%02x ", gsBuf[i]);
		printf("\n");
	}
}
LOCAL void etsecEndRxHandle
    (
    void * pArg
    )
{
    usrPrintNet(pDrvCtrl->etsecDev->unitNumber,pMblk);
}

注意:如果你的驱动程序在boot和系统镜像中存在两份,务必保持驱动程序的一致性,否则可能出现奇怪的现象,调试中发现以太网发送中断不能进,最后发现是boot和vxWorks中的驱动程序不一致导致的,折腾了两天,我也是醉了。。。。。

 

  • 1
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
PART I: VXBUS FUNDAMENTALS 1 Getting Started with Device Driver Development .................................... 3 1.1 About Device Drivers ..................................................................................................... 3 1.2 About this Documentation ............................................................................................ 4 1.2.1 Intended Audience ........................................................................................... 4 1.2.2 Navigating this Manual .................................................................................. 4 Experienced VxWorks Device Driver Developers ........................................ 4 Novice VxWorks Device Driver Developers ................................................. 5 1.2.3 Documentation Conventions .......................................................................... 5 1.3 Additional Documentation Resources ....................................................................... 6 2 VxBus and VxBus Device Drivers ............................................................. 7 2.1 Introduction ...................................................................................................................... 7 2.2 About VxBus ................................................................................................................... 7 2.3 VxBus Device Drivers ................................................................................................... 8 2.4 Design Goals ................................................................................................................... 11 2.4.1 Performance ....................................................................................................... 11 2.4.2 Maintenance and Readability .......................................................................... 11 2.4.3 Ease of Configuration ....................................................................................... 12 2.4.4 Performance Testing ......................................................................................... 12 2.4.5 Code Size ............................................................................................................ 12 3 Device Driver Fundamentals ..................................................................... 13 3.1 Introduction ...................................................................................................................... 13 3.2 Driver Classes ................................................................................................................. 14 VxBus Device Driver Developer's Guide, 6.9 iv 3.2.1 General Classes .................................................................................................. 14 Serial Drivers .................................................................................................... 14 Storage Drivers ................................................................................................. 14 Network Interface Drivers .............................................................................. 15 Non-Volatile RAM Drivers ............................................................................. 15 Timer Drivers .................................................................................................... 16 DMA Controller Drivers ................................................................................. 16 Bus Controller Drivers ..................................................................................... 16 USB Drivers ....................................................................................................... 17 Interrupt Controller Drivers ........................................................................... 17 Multifunction Drivers ...................................................................................... 17 Remote Processing Element Drivers ............................................................. 18 Console Drivers ................................................................................................ 18 Resource Drivers .............................................................................................. 19 3.2.2 Other Classes .................................................................................................... 19 3.3 Driver Organization ....................................................................................................... 19 3.3.1 File Location ...................................................................................................... 20 Wind River Drivers ........................................................................................... 20 Third-Party Drivers .......................................................................................... 20 3.3.2 Sample Driver Files: wrsample ....................................................................... 21 3.3.3 Required Files ................................................................................................... 21 Driver Source File ............................................................................................. 22 Component Description File ........................................................................... 24 Driver Configuration Stub Files ..................................................................... 29 README File .................................................................................................... 31 Device Driver Makefiles .................................................................................. 31 3.4 VxBus Driver Methods .................................................................................................. 33 3.4.1 Representing Driver Methods in the Documentation ................................ 33 3.4.2 Parts of a Driver Method ................................................................................. 33 3.4.3 Calling Driver Methods ................................................................................... 34 3.4.4 Advertising Driver Methods .......................................................................... 35 3.4.5 Driver Method Limitations ............................................................................. 36 3.5 Driver Run-time Life Cycle .......................................................................................... 36 3.5.1 Driver Initialization Sequence ........................................................................ 36 Making Assumptions About Initialization Order ....................................... 37 Early in the Boot Process ................................................................................. 37 sysHwInit( ), PLB, and Hardware Discovery ............................................... 37 Driver Registration ........................................................................................... 38 Driver Initialization Phase 1 ........................................................................... 38 Kernel Startup ................................................................................................... 39 Driver Initialization Phase 2 ........................................................................... 39 Driver Initialization Phase 3 ........................................................................... 39 3.5.2 Invoking a Driver Method .............................................................................. 39 3.5.3 Run-time Operation ......................................................................................... 39 Contents v Unloading a Driver .......................................................................................... 40 Removing a Device from the System ............................................................ 40 Dissociating a Device from a Driver .............................................................. 40 3.5.4 Handling a System Shutdown Notification ................................................. 41 3.5.5 Handling Late Driver Registration ................................................................ 41 3.5.6 Driver Registration Order Considerations ................................................... 42 3.5.7 Driver-to-Device Matching and Hardware Availability ............................. 42 PLB ..................................................................................................................... 43 Other Bus Types ................................................................................................ 43 3.6 Services Available to Drivers ....................................................................................... 44 3.6.1 Configuration .................................................................................................... 44 Determining Driver Configuration Information ......................................... 45 Responding to Changes in Device Parameters ............................................ 47 3.6.2 Memory Allocation .......................................................................................... 47 Allocating Memory During System Startup ................................................ 48 Allocating Memory During Normal System Operation ............................. 49 Intermixing Memory Allocation Methods within a Single Driver ........... 49 3.6.3 Non-Volatile RAM Support ............................................................................. 49 3.6.4 Hardware Access .............................................................................................. 50 Finding the Address of the Hardware Registers ......................................... 50 Reading and Writing to the Hardware Registers ........................................ 51 Special Requirements for Hardware Register Access ................................. 53 VxBus Version Considerations ........................................................................ 53 3.6.5 Interrupt Handling ........................................................................................... 54 Overview of Interrupt Handling .................................................................... 54 Interrupt Indexes .............................................................................................. 54 Dynamic Interrupt Handling .......................................................................... 55 Minimizing Work Performed Within an ISR ................................................ 56 3.6.6 Synchronization ................................................................................................ 57 Task-Level Synchronization ............................................................................ 57 Interrupt-Level Synchronization .................................................................... 58 3.6.7 Direct Memory Access (DMA) ....................................................................... 59 vxbDmaBufLib .................................................................................................. 60 DMA Considerations ........................................................................................ 60 Allocating External DMA Engines ................................................................ 63 3.6.8 Atomic Operators ............................................................................................. 65 3.7 BSP Configuration ......................................................................................................... 66 3.7.1 Requirements for PLB Devices ....................................................................... 67 3.7.2 Configuring Device Parameters in the BSP .................................................. 68 3.8 SMP Considerations ...................................................................................................... 69 3.8.1 Lack of Implicit Locking ................................................................................. 69 VxBus Device Driver Developer's Guide, 6.9 vi 3.8.2 True Task-to-Task Contention ......................................................................... 70 3.8.3 Interrupt Routing ............................................................................................. 70 3.8.4 Deferring Interrupt Processing ...................................................................... 71 3.9 Device Memory Mapping in 64-Bit Devices .............................................................. 72 3.10 Physical-to-Virtual Address Translations in 64-Bit VxWorks ................................. 73 3.10.1 64-bit Changes to the Memory Management Model ................................... 73 3.10.2 Porting Drivers That Rely on Physical-to-Virtual Address Translations .. 74 Transfer Using Descriptors .............................................................................. 74 Strategies When Order is Unpredictable ....................................................... 75 4 Development Strategies ............................................................................. 77 4.1 Introduction ...................................................................................................................... 77 4.2 Writing New VxBus Drivers ........................................................................................ 77 4.2.1 Creating the VxBus Infrastructure ................................................................. 78 Writing Driver Source Files ............................................................................. 78 Writing Header Files (Optional) .................................................................... 78 Writing the Component Description File (CDF) .......................................... 78 Writing the Configuration Stub Files ............................................................ 79 Verifying the Infrastructure ............................................................................ 80 4.2.2 Modifying the BSP (Optional) ........................................................................ 80 4.2.3 Adding Debug Code ........................................................................................ 81 4.2.4 Adding the VxBus Driver Methods ............................................................... 81 4.2.5 Removing Global Variables ............................................................................ 82 4.3 VxBus Show Routines ................................................................................................... 83 4.3.1 Available Show Routines ................................................................................ 83 vxBusShow( ) ..................................................................................................... 83 vxbDevStructShow( ) ........................................................................................ 85 vxbDevPathShow( ) .......................................................................................... 86 4.3.2 PCI Show Routines .......................................................................................... 86 pciDevShow( ) ................................................................................................... 87 vxbPciDeviceShow( ) ........................................................................................ 87 vxbPciHeaderShow( ) ....................................................................................... 88 vxbPciFindDeviceShow( ) ................................................................................ 89 vxbPciFindClassShow( ) ................................................................................... 89 vxbPciConfigTopoShow( ) ............................................................................... 90 4.3.3 Using Show Routines from Software ............................................................ 91 4.3.4 Configuring Show Routines into VxWorks .................................................. 93 4.4 Debugging ....................................................................................................................... 94 4.4.1 Configuring Show Routines ........................................................................... 94 Contents vii 4.4.2 Deferring Driver Registration ........................................................................ 95 4.4.3 Including Debug Code .................................................................................... 95 4.4.4 Confirming Register Access ............................................................................ 96 4.4.5 Increasing the Size of HWMEM_POOL ........................................................ 96 4.4.6 Confirming Device and Driver Name Matches ........................................... 96 5 Driver Release Procedure .......................................................................... 99 5.1 Introduction ..................................................................................................................... 99 5.2 Driver Source Location .................................................................................................. 100 5.3 Driver-Specific Directories ............................................................................................ 101 5.4 Driver Installation and the README File ................................................................ 102 5.5 Driver Packaging ............................................................................................................ 103 5.6 Driver Release Procedure ............................................................................................. 104 PART II: DEVICE DRIVER PORTING 6 Class-Specific Driver Development .......................................................... 107 6.1 About VxBus Driver Classes ........................................................................................ 107 6.2 Before You Begin ............................................................................................................. 107 6.3 About the Class-Specific Driver Documentation ..................................................... 108 7 Bus Controller Drivers ................................................................................ 109 7.1 Introduction ..................................................................................................................... 109 7.2 Overview .......................................................................................................................... 109 7.3 VxBus Driver Methods .................................................................................................. 111 7.3.1 {busCtlrDevCfgRead}( ) ................................................................................... 111 7.3.2 {busCtlrCfgRead}( ) ........................................................................................... 112 7.3.3 {busCtlrDevCfgWrite}( ) ................................................................................... 113 7.3.4 {busCtlrCfgWrite}( ) .......................................................................................... 113 7.3.5 {busCtlrDevCtlr}( ) ............................................................................................ 114 7.3.6 {busCtlrAccessOverride}( ) .............................................................................. 115 Override for (*busCfgRead)( ) ......................................................................... 115 Override for (*busCfgWrite)( ) ........................................................................ 116 Override for (*vxbDevControl)( ) ................................................................... 116 VxBus Device Driver Developer's Guide, 6.9 viii 7.3.7 {busCtlrCfgInfo}( ) ............................................................................................. 116 7.3.8 {busCtlrBaseAddrCvt}( ) .................................................................................. 117 7.3.9 {vxbDevRegMap}( ) ........................................................................................... 117 Specifying a Predefined Transaction Type ..................................................... 119 Providing a New Transaction Type ............................................................... 120 7.3.10 {vxbIntDynaVecProgram}( ) ............................................................................. 122 7.4 Header Files ..................................................................................................................... 122 7.5 BSP Configuration .......................................................................................................... 123 7.5.1 PCI Configuration ............................................................................................ 124 7.5.2 PCI Autoconfiguration .................................................................................... 124 7.6 Available Utility Routines ............................................................................................ 125 7.6.1 PCI Configuration ............................................................................................ 125 7.6.2 PCI Autoconfiguration ..................................................................................... 126 7.6.3 vxbBusAnnounce( ) ........................................................................................... 126 7.6.4 vxbPciBusTypeInit( ) ......................................................................................... 127 7.7 Initialization .................................................................................................................... 127 7.7.1 Initialization Example ..................................................................................... 128 vxbBusAnnounce( ) ........................................................................................... 129 vxbDeviceAnnounce( ) ..................................................................................... 130 vxbDevStructAlloc( ) ........................................................................................ 130 vxbDevStructFree( ) .......................................................................................... 130 7.8 Debugging ........................................................................................................................ 130 8 Direct Memory Access Drivers .................................................................. 131 8.1 Introduction ..................................................................................................................... 131 8.2 Overview ........................................................................................................................... 131 8.3 VxBus Driver Methods ................................................................................................... 132 8.3.1 {vxbDmaResourceGet}( ) .................................................................................. 132 8.3.2 {vxbDmaResourceRelease}( ) ........................................................................... 133 8.3.3 {vxbDmaResDedicatedGet}( ) .......................................................................... 133 8.4 Header Files ...................................................................................................................... 133 8.5 BSP Configuration .......................................................................................................... 134 8.6 Available Utility Routines ............................................................................................. 134 8.7 Initialization ..................................................................................................................... 134 Contents ix 8.8 DMA System Structures and Routines ....................................................................... 134 8.8.1 (*dmaRead)( ) ..................................................................................................... 135 8.8.2 (*dmaReadAndWait)( ) ..................................................................................... 135 8.8.3 (*dmaWrite)( ) .................................................................................................... 135 8.8.4 (*dmaWriteAndWait)( ) .................................................................................... 136 8.8.5 (*dmaCancel)( ) .................................................................................................. 136 8.8.6 (*dmaPause)( ) ................................................................................................... 136 8.8.7 (*dmaResume)( ) ................................................................................................ 136 8.8.8 (*dmaStatus)( ) ................................................................................................... 136 8.9 Debugging ....................................................................................................................... 137 9 I2C Drivers ................................................................................................... 139 9.1 Introduction ...................................................................................................................... 139 9.2 Overview ........................................................................................................................... 139 9.3 VxBus Driver Methods ................................................................................................... 140 9.4 Header Files ...................................................................................................................... 141 9.5 BSP Configuration .......................................................................................................... 141 9.6 Initialization ..................................................................................................................... 143 9.7 Implementing Driver Service Routines ...................................................................... 144 (*VXB_I2C_LOCK_BUS_FUNC)( ) ................................................................. 145 (*VXB_I2C_UNLOCK_BUS_FUNC)( ) ........................................................... 145 (*VXB_I2C_START_FUNC)( ) .......................................................................... 145 (*VXB_I2C_STOP_FUNC)( ) ............................................................................ 146 (*VXB_I2C_READ_FUNC)( ) ........................................................................... 146 (*VXB_I2C_WRITE_FUNC)( ) ......................................................................... 146 (*VXB_I2C_DEV_READ)( ) .............................................................................. 147 (*VXB_I2C_DEV_WRITE)( ) ............................................................................ 147 9.8 Device Driver ................................................................................................................... 148 9.8.1 Generic I2C Devices .......................................................................................... 149 10 Interrupt Controller Drivers ........................................................................ 151 10.1 Introduction ..................................................................................................................... 151 10.2 Overview .......................................................................................................................... 152 Interrupt Identification .................................................................................... 152 Interrupt Controller Driver Responsibilities ................................................. 152 Interrupt Controller Configurations ............................................................... 153 Dynamic Vectors ................................................................................................ 153 Interrupt Controller Drivers and Multiprocessing ....................................... 154 VxBus Device Driver Developer's Guide, 6.9 x 10.3 VxBus Driver Methods .................................................................................................. 154 10.3.1 Basic Methods .................................................................................................... 154 {vxbIntCtlrAlloc}( ) ............................................................................................ 154 {vxbIntCtlrFree}( ) ............................................................................................. 155 {vxbIntCtlrConnect}( ) ...................................................................................... 155 {vxbIntCtlrDisconnect}( ) ................................................................................. 155 {vxbIntCtlrEnable}( ) ......................................................................................... 156 {vxbIntCtlrDisable}( ) ........................................................................................ 156 10.3.2 Dynamic Vector Methods ................................................................................ 156 {vxbIntDynaVecConnect}( ) ............................................................................. 156 10.3.3 Multiprocessor Methods ................................................................................. 157 {vxbIntCtlrIntReroute}( ) .................................................................................. 157 {vxbIntCtlrCpuReroute}( ) .............................................................................. 157 {vxIpiControlGet}( ) .......................................................................................... 157 10.4 Header Files ...................................................................................................................... 158 vxbIntrCtlr.h ....................................................................................................... 158 vxbIntCtlrLib.h .................................................................................................. 158 10.5 BSP Configuration .......................................................................................................... 158 10.5.1 Interrupt Input Table ........................................................................................ 159 10.5.2 Dynamic Vector Table ....................................................................................... 160 10.5.3 CPU Routing Table ............................................................................................ 162 10.5.4 Interrupt Priority ............................................................................................... 163 10.5.5 Crossbar Routing Table .................................................................................... 163 10.6 Available Utility Routines ............................................................................................. 164 10.6.1 intCtlrHwConfGet( ) ......................................................................................... 165 10.6.2 intCtlrISRAdd( ) ................................................................................................ 165 10.6.3 intCtlrISRDisable( ) ........................................................................................... 165 10.6.4 intCtlrISREnable( ) ............................................................................................ 166 10.6.5 intCtlrISRRemove( ) .......................................................................................... 166 10.6.6 intCtlrPinFind( ) ................................................................................................ 166 10.6.7 intCtlrTableArgGet( ) ........................................................................................ 166 10.6.8 intCtlrTableFlagsGet( ) ..................................................................................... 166 10.6.9 intCtlrTableIsrGet( ) .......................................................................................... 166 10.6.10 intCtlrHwConfShow( ) ..................................................................................... 166 10.6.11 intCtlrTableCreate( ) ......................................................................................... 167 10.6.12 intCtlrTableFlagsSet( ) ...................................................................................... 167 10.6.13 intCtlrTableUserSet( ) ....................................................................................... 167 10.6.14 VXB_INTCTLR_ISR_CALL( ) ......................................................................... 167 10.6.15 VXB_INTCTLR_PINENTRY_ENABLED( ) ................................................... 167 Contents xi 10.6.16 VXB_INTCTLR_PINENTRY_ALLOCATED( ) ............................................. 167 10.6.17 Dispatch Routines ............................................................................................. 168 vxbIntDynaCtlrInputInit( ) .............................................................................. 168 vxbIntDynaVecProgram( ) ............................................................................... 168 vxbIntDynaVecErase( ) ..................................................................................... 169 10.7 Initialization ..................................................................................................................... 169 10.8 Interrupt Controller Topologies and Hierarchies ..................................................... 169 10.9 Interrupt Priority ............................................................................................................. 170 10.10 ISR Dispatch .................................................................................................................... 171 10.11 Managing Dynamic Interrupt Vectors ........................................................................ 173 Configuring Dynamic Vectors Using the Service Driver Routines ............ 174 Configuring Dynamic Vectors in the BSP ..................................................... 174 Programming Dynamic Vectors ...................................................................... 175 Determining Dynamic Vector Values ............................................................ 175 10.12 Internal Representation of Interrupt Inputs .............................................................. 176 10.13 Multiprocessor Issues with VxWorks SMP ................................................................ 177 10.13.1 Routing Interrupt Inputs to Individual CPUs .............................................. 177 10.13.2 Interprocessor Interrupts ................................................................................. 178 10.13.3 Limitations in Multiprocessor Systems .......................................................... 182 10.14 Debugging ........................................................................................................................ 182 11 Multifunction Drivers .................................................................................. 185 11.1 Introduction ...................................................................................................................... 185 11.2 Overview ........................................................................................................................... 185 11.3 VxBus Driver Methods ................................................................................................... 186 11.4 Header Files ...................................................................................................................... 186 11.5 BSP Configuration .......................................................................................................... 186 11.6 Available Utility Routines ............................................................................................. 187 vxbDevStructAlloc( ) ........................................................................................ 187 vxbDeviceAnnounce( ) ..................................................................................... 187 vxbDevRemovalAnnounce( ) .......................................................................... 187 vxbDevStructFree( ) .......................................................................................... 188 vxbBusAnnounce( ) ........................................................................................... 188 11.7 Initialization ..................................................................................................................... 188 11.8 Device Interconnections ................................................................................................ 188 VxBus Device Driver Developer's Guide, 6.9 xii 11.8.1 Interleaved Registers ........................................................................................ 188 11.8.2 Shared Resources ............................................................................................... 189 11.8.3 Other Interactions ............................................................................................. 190 11.9 Logical Location of Subordinate Devices ................................................................... 190 11.10 Debugging ........................................................................................................................ 190 12 Network Drivers .......................................................................................... 191 12.1 Introduction ...................................................................................................................... 191 12.1.1 Terminology ....................................................................................................... 191 12.1.2 Networking Overview ..................................................................................... 192 Seven Layer OSI Model .................................................................................... 192 Transmission Media and VxWorks ................................................................. 192 Protocols ............................................................................................................. 193 12.2 Network Interface Drivers ............................................................................................. 193 12.2.1 Network Interface Driver Overview .............................................................. 193 IPNET-Native Drivers ...................................................................................... 193 Functional Modules .......................................................................................... 194 Network Driver Interrupts ............................................................................. 195 12.2.2 VxBus Driver Methods for Network Interface Drivers .............................. 196 {muxDevConnect}( ) ......................................................................................... 196 {muxDevConnect2}( ) ....................................................................................... 197 {vxbDrvUnlink}( ) .............................................................................................. 199 {miiMediaUpdate}( ) ......................................................................................... 199 {miiRead}( ) ........................................................................................................ 200 {miiWrite}( ) ........................................................................................................ 201 12.2.3 Header Files for Network Interface Drivers ................................................. 201 12.2.4 BSP Configuration for Network Interface Drivers ...................................... 202 12.2.5 Available Utility Routines for Network Interface Drivers ......................... 203 MUX Interactions .............................................................................................. 203 Job Queueing ..................................................................................................... 204 Buffer Management .......................................................................................... 205 DMA Support .................................................................................................... 209 PHY and MII bus interactions ......................................................................... 210 12.2.6 Initialization for Network Interface Drivers ................................................ 212 12.2.7 MUX: Connecting to Networking Code ........................................................ 212 12.2.8 jobQueueLib: Deferring ISRs ........................................................................... 213 12.2.9 Working with Ipcom_pkt Packets ................................................................... 214 Supporting Scatter-Gather with IPNET-Native Drivers .............................. 217 12.2.10 netBufLib: Transferring Data with M_BLKs ................................................ 218 12.2.11 Protocol Impact on Drivers .............................................................................. 220 Contents xiii 12.2.12 Other Network Interface Driver Issues .......................................................... 232 Receive Handling Method ............................................................................... 233 Receive Stall Handling ..................................................................................... 240 12.2.13 Debugging Network Interface Drivers .......................................................... 241 Using VxBus Show Routines ........................................................................... 241 Deferring Driver Registration ......................................................................... 241 Pairing with a PHY instance ............................................................................ 242 Stress Testing ...................................................................................................... 242 Netperf Test Suite .............................................................................................. 243 Interrupt Validation .......................................................................................... 243 Additional Tests ................................................................................................. 243 12.3 PHY Drivers ...................................................................................................................... 249 12.3.1 PHY Driver Overview ...................................................................................... 250 PHY Device Probing and Discovery .............................................................. 250 MAC and MII Bus Relationship ...................................................................... 251 Generic PHY Driver Support ........................................................................... 252 Generic TBI Driver Support ............................................................................. 252 12.3.2 VxBus Driver Methods for PHY Drivers ....................................................... 253 Upper Edge Methods ........................................................................................ 253 Lower Edge Methods ....................................................................................... 253 12.3.3 Header Files for PHY Drivers ......................................................................... 255 12.3.4 BSP Configuration for PHY Drivers ............................................................... 255 12.3.5 Available Utility Routines for PHY Drivers .................................................. 255 Upper Edge Utility Routines ........................................................................... 256 Lower Edge Utility Routines ........................................................................... 256 12.3.6 Initialization for PHY Drivers ......................................................................... 257 12.3.7 Debugging PHY Drivers .................................................................................. 257 12.4 Wireless Ethernet Drivers .............................................................................................. 258 12.5 Hierarchical END Drivers ............................................................................................. 258 13 Non-Volatile RAM Drivers .......................................................................... 259 13.1 Introduction ...................................................................................................................... 259 NVRAM Drivers and TrueFFS ........................................................................ 259 13.2 Non-Volatile RAM Drivers ........................................................................................... 260 13.2.1 NVRAM Driver Overview ............................................................................... 260 13.2.2 VxBus Driver Methods for NVRAM Drivers ................................................ 260 {nonVolGet}( ) .................................................................................................... 260 {nonVolSet}( ) ..................................................................................................... 261 13.2.3 Header Files ....................................................................................................... 261 13.2.4 BSP Configuration for NVRAM Drivers ....................................................... 261 VxBus Device Driver Developer's Guide, 6.9 xiv 13.2.5 Utility Routines for NVRAM Drivers ............................................................ 262 13.2.6 Initialization for NVRAM Drivers .................................................................. 262 13.2.7 NVRAM Block Sizes ......................................................................................... 262 13.2.8 Stacking NVRAM Instances ............................................................................ 263 13.2.9 Debugging NVRAM Drivers ........................................................................... 263 13.3 Flash File System Support with TrueFFS ................................................................... 263 13.3.1 TrueFFS Overview ............................................................................................. 264 Core Layer .......................................................................................................... 264 MTD Layer ........................................................................................................ 264 Socket Layer ....................................................................................................... 264 Flash Translation Layer .................................................................................... 265 13.3.2 TrueFFS Driver Development Process ........................................................... 265 Using MTD-Supported Flash Devices ........................................................... 265 Writing MTD Components .............................................................................. 269 Socket Drivers .................................................................................................... 276 Flash Translation Layer .................................................................................... 282 14 RapidIO Drivers ........................................................................................... 297 14.1 Introduction ...................................................................................................................... 297 14.2 Overview ........................................................................................................................... 297 14.3 VxBus Driver Methods ................................................................................................... 299 {vxbRapidIoCtlrInfoGet}( ) .............................................................................. 299 {sharedMemSupportAPIGet}( ) ....................................................................... 300 {vxbMsgApiGet}( ) ............................................................................................ 300 14.4 Header Files ...................................................................................................................... 301 14.5 BSP Configuration .......................................................................................................... 301 RapidIO Bus Controller Driver ....................................................................... 301 Virtual Message Network Device Driver ....................................................... 301 14.6 Initialization ..................................................................................................................... 302 Phase 1 ................................................................................................................ 302 Phase 2 ................................................................................................................ 302 Phase 3 ................................................................................................................ 303 14.7 Implementing Driver Service Routines ...................................................................... 303 RapidIO Bus Controller Driver ....................................................................... 303 Message Controller Driver ............................................................................... 307 15 Resource Drivers ........................................................................................ 311 15.1 Introduction ...................................................................................................................... 311 Contents xv 15.2 Overview ........................................................................................................................... 311 15.3 VxBus Driver Methods ................................................................................................... 312 15.4 Header Files ...................................................................................................................... 312 15.5 BSP Configuration .......................................................................................................... 312 15.6 Available Utility Routines ............................................................................................. 313 15.7 Initialization ..................................................................................................................... 313 15.8 Debugging ........................................................................................................................ 313 16 Serial Drivers ............................................................................................... 315 16.1 Introduction ...................................................................................................................... 315 16.2 Overview ........................................................................................................................... 315 16.3 VxBus Driver Methods ................................................................................................... 316 16.3.1 {sioChanGet}( ) ................................................................................................... 316 16.3.2 {sioChanConnect}( ) .......................................................................................... 317 16.4 Header Files ...................................................................................................................... 317 16.5 BSP Configuration .......................................................................................................... 318 16.6 Available Utility Routines ............................................................................................. 318 16.7 Initialization ..................................................................................................................... 318 16.8 Polled Mode Versus Interrupt-Driven Mode ............................................................. 318 16.9 SIO_CHAN and SIO_DRV_FUNCS ............................................................................ 319 16.10 WDB ................................................................................................................................... 321 16.10.1 WDB and Kernel Initialization ........................................................................ 321 16.11 Serial Drivers, Initialization, and Interrupts ............................................................. 321 16.11.1 WDB and Interrupts ......................................................................................... 322 16.11.2 Initialization Order and Interrupts ................................................................. 322 16.11.3 Initialization Order ........................................................................................... 323 16.12 Debugging ........................................................................................................................ 323 17 SPI Drivers ................................................................................................... 325 17.1 Introduction ...................................................................................................................... 325 17.2 Overview ........................................................................................................................... 325 VxBus Device Driver Developer's Guide, 6.9 xvi 17.3 VxBus Driver Methods ................................................................................................... 326 17.4 Header Files ...................................................................................................................... 326 17.5 BSP Configuration .......................................................................................................... 327 17.6 Initialization ..................................................................................................................... 328 17.7 Implementing Driver Service Routines ...................................................................... 329 17.8 Device Driver ................................................................................................................... 329 17.8.1 SPI_EEPROM ..................................................................................................... 330 17.8.2 SPI Flash ............................................................................................................. 330 18 Storage Drivers ........................................................................................... 333 18.1 Introduction ...................................................................................................................... 333 18.2 Overview ........................................................................................................................... 333 Updates in VxWorks 6.9, Update Pack 2, Service Pack 1 ............................ 334 Updates in VxWorks 6.9, Update Pack 3, Service Pack 3 ............................ 334 18.3 VxBus Driver Methods ................................................................................................... 335 18.4 Header Files ...................................................................................................................... 335 18.5 BSP Configuration .......................................................................................................... 336 18.6 Available Utility Routines ............................................................................................. 336 erfHandlerRegister( ) and erfHandlerUnregister( ) ..................................... 336 erfEventRaise( ) ................................................................................................. 336 xbdAttach( ) ....................................................................................................... 336 bio_done( ) .......................................................................................................... 337 18.7 Initialization ..................................................................................................................... 337 18.8 Interface with VxWorks File Systems ......................................................................... 337 18.8.1 Device Creation ................................................................................................. 337 ERF Registration ................................................................................................ 338 Advertisement of XBD Methods ..................................................................... 338 ERF New Device Notification ......................................................................... 339 18.8.2 Processing ........................................................................................................... 340 xbd_request processing .................................................................................... 340 18.8.3 Event Reporting ................................................................................................. 341 18.9 Writing New Storage Drivers ........................................................................................ 342 18.10 Writing New SD/MMC/SDIO host controller Drivers ............................................ 343 18.11 Device Driver ................................................................................................................... 344 Contents xvii 19 Timer Drivers ............................................................................................... 345 19.1 Introduction ...................................................................................................................... 345 19.2 Overview ........................................................................................................................... 345 19.3 VxBus Driver Methods ................................................................................................... 346 19.4 Header Files ...................................................................................................................... 349 19.5 BSP Configuration .......................................................................................................... 349 19.6 Available Utility Routines ............................................................................................. 349 19.7 Initialization ..................................................................................................................... 349 19.8 Data Structure Layout ..................................................................................................... 350 19.9 Implementing Driver Service Routines ...................................................................... 351 19.9.1 (*timerAllocate)( ) .............................................................................................. 351 19.9.2 (*timerRelease)( ) ............................................................................................... 351 19.9.3 (*timerRolloverGet)( ) ....................................................................................... 352 19.9.4 (*timerCountGet)( ) ........................................................................................... 352 19.9.5 (*timerDisable)( ) ............................................................................................... 353 19.9.6 (*timerEnable)( ) ................................................................................................ 354 19.9.7 (*timerISRSet)( ) ................................................................................................. 354 19.9.8 (*timerEnable64)( ) ............................................................................................ 355 19.9.9 (*timerRolloverGet64)( ) ................................................................................... 355 19.9.10 (*timerCountGet64)( ) ....................................................................................... 356 19.10 Integrating a Timer Driver ............................................................................................ 357 19.10.1 VxWorks System Clock .................................................................................... 357 19.10.2 VxWorks Auxiliary Clock ................................................................................ 359 19.10.3 VxWorks Timestamp Driver ............................................................................ 360 19.11 Debugging ........................................................................................................................ 361 19.12 SMP Considerations ....................................................................................................... 361 20 USB Drivers ................................................................................................. 363 20.1 Introduction ...................................................................................................................... 363 20.2 Wind River USB Overview ............................................................................................ 363 20.2.1 USB Host Stack Drivers .................................................................................... 364 VxBus Model Drivers ....................................................................................... 364 Other Host Drivers ............................................................................................ 364 VxBus Device Driver Developer's Guide, 6.9 xviii 20.2.2 USB Target Stack ............................................................................................... 364 20.3 Host Controller and Root Hub Class Drivers ............................................................ 365 20.3.1 VxBus Driver Methods ..................................................................................... 365 20.3.2 Header Files ....................................................................................................... 365 20.3.3 BSP Configuration ............................................................................................. 366 20.3.4 Available Utility Routines ................................................................................ 367 20.3.5 Initialization ....................................................................................................... 367 20.3.6 Debugging .......................................................................................................... 368 21 Other Driver Classes .................................................................................. 371 21.1 Introduction ...................................................................................................................... 371 21.2 Overview ........................................................................................................................... 371 21.3 VxBus Driver Methods ................................................................................................... 372 21.4 Header Files ...................................................................................................................... 373 21.5 BSP Configuration .......................................................................................................... 373 21.6 Available Utility Routines ............................................................................................. 373 21.7 Initialization ..................................................................................................................... 373 21.8 Debugging ........................................................................................................................ 374 PART III: DEVICE DRIVER PORTING 22 Legacy Drivers and Migration ................................................................... 377 22.1 Migration Overview ....................................................................................................... 377 22.2 Legacy Driver Overview ................................................................................................ 377 23 Migrating to VxBus ..................................................................................... 379 23.1 Overview ........................................................................................................................... 379 23.2 Available Resources ........................................................................................................ 379 Template Drivers ............................................................................................... 379 23.3 Porting an Existing VxWorks Driver to VxBus .......................................................... 380 23.3.1 Verifying Your Hardware and Driver Code .................................................. 380 23.3.2 Creating the VxBus Infrastructure ........
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值