vxworks驱动开发----2-vxbus与组件以及arp表

vxbus

This driver is designed to work with VxBus.  Therefore, it requires the
default VxBus components to be present in the target image. 

VXBUS是指在vxworks中用于支持设备驱动的特有架构。功能

1、允许设备驱动匹配对应设备;

2、提供驱动程序访问硬件的机制;

3、软件其他部分访问设备功能;

4、在vxworks系统实现驱动的模块化。

vxworks在总线控制器驱动程序服务的支持下,能在总线上发现设备,并执行一些初始化工作,使驱动与硬件设备之间正常通讯。


作为vxworks系统组件的一部分,vxbus使得各种驱动和支持组件的添加与删除完全可以在worksbench工程中进行,不需要bsp和驱动相关的知识,也不会在添加或者删除驱动时增加管理vxworks工程的额外工作。

 vxBus下对设备管理做了更为详细的划分,简单说来,硬件称为device,软件叫做driver。如果一个device出现在硬件列表中,启动时需要到driver的队列中去找相应的driver,如果找到,二者结合成一个instance,否则在vxBusShow里可以看到一个orphan。使用vxBusShow可以比较清晰的看到driver列表和device列表以及orphan列表。

如果需要增加一个设备,首先要修改的是hcfDeviceList,这是hwconf.c中的一个数组,这个数组中列有本系统中所有需要初始化的硬件设备。例如:

 HCF_DEVICE hcfDeviceList[] = {
  #ifdef DRV_SIO_ns16550
  { "ns16550", 0, VXB_BUSID_PLB, 0, ns1655x1Num, ns1655x1Resources },
  { "ns16550", 1, VXB_BUSID_PLB, 0, ns1655x2Num, ns1655x2Resources },
  #endif

第二个ns16550是新加的。在参数中指明了它的名字“ns16550”,初始化的时候根据这个名字去搜索驱动。它的unit是1,区别与前面的0,初始化结束以后,会在设备列表中看到这个unit number。ns1655x2Resources是前面定义的一组资源,跟ns1655x1Resources类似,只是regBase和irq按照实际情况做区分。ns1655x2Num是ns1655x2Resources的长度。

    对于单核CPU,配置到这里就结束了。如果是多核,还需要修改一下sysDeviceFilter,这个函数决定一个设备在哪个核上初始化。如果还有hypervisor,还需要修改wrhvConfig.xml和vxworksX.xml,将特定的终端放开到指定的核。

驱动开发

设备驱动初始化



内核预初始化阶段

在vxworks内核预初始化早期,bsp的sysHwInit()函数被执行,在这个函数汇总,设备驱动初始化工作第一步被执行。sysHwInit( )函数执行一些早期的初始化,调用hardWareInterFaceInit( )函数,执行初始化硬件内存分配机制,限制为设备驱动分配内存,这个函数接着调用hardWareInterFaceBusInit( ),在hardWareInterFaceBusInit( )函数中完成所有设备驱动和模块的注册工作。PCI2040的注册函数是vxbPci2040Register()。vxbPci2040Register()通过数据结构,向系统注册一些设备初始化函数。

    当所有驱动在VxWorks注册之后,sysHwInit( ) 完成非VxBus 驱动的初始化并返回。sysHwInit( ) 函数返回后,VxWorks内核被初始化。

 为了使设备和驱动能够在VxWorks系统中使用,让应用程序、中间件、VxWorks内核模块访问设备,执行一些操作,最基本的方法是在VxWorks中采用VxBus方法来实现硬件设备的访问。VxBus方法是在驱动中公开一个入口,使VxBus中API函数可以调用这些入口函数。

 采用VxBus驱动的一个主要优点是:设备的驱动程序可以被看成VxWorks 系统的一个组件,通过集成的Workbench开发环境来配置设备驱动。

ARP

ip协议栈

ifnet

是协议栈中的接口的概念,跟ARP相关处理的最重要的三个成员是:

if_ioctl用于接口上的ioctl命令;

if_resolve用于进行地址解析的函数;

if_output用于在接口上发送数据包。

ipAttach时,这三个值都进行了初始化:

pIfp->if_ioctl = (FUNCPTR)ipIoctl;

pIfp->if_outpu = ipOutput;

pIfp->if_resolve = muxAddrResFuncGet(mib2Tbl.ifType,0800);

其中if_resolve的值,实际上就是arpresolve函数。

arpresolve函数:功能是进行目的ip地址到mac地址的转换映射。

ARP输入处理

arp输入由arpintr驱动,调用in_arpinput以处理跟ip相碰的arp报文。

首先,in_arpinput会调用arplookup,以检查发送者是不是在我们当前的arp缓存中(如果在前面发送了arp请求,那么就应该存在一个无效的arp项,如果是对方主请求,那么说明对方想与我们通讯,也需要检查对方在不在)。arplookup传入的第二个参数,表示在不存在arp项时候,是不是要建立,什么时候建立呢?由于arp请求是广播发送的,所以我们可能接收到请求的目的ip不是我们自己的ip地址,在这种情况下,只需要更新arp信息(时标,以防止老化),只有请求是针对我们自己的情况下(因为对方可能要与我通讯了,我马上要使用对方的mac地址了),才会创建新的arp项

arp表项的建立

arp就是主机直接路由,通过clone接口子网路由产生。

接口网络路由的建立

当给接口增加/删除地址时,都会影响路由表,通过设置地址/掩码,也就确定一个可以直达的网络,如ifAddrAdd("mottsec2","10.0.0.8","10.0.255.255",0xffff0000).这个函数经过一系列传递后,会调用到in_control,然后调用到in_ifinit。

clone路由的产生

当调用rtalloc查找主机路由时,它实际调用的是rtalloc1,首先在路由表中查找路由,如果找到了并具有clone标志RTF_CLONING,则需要调用rtrequest进行RTM_RESOLVE,这个过程就是clone过程,也就是建立主机直接路由的过程,也就是建立arp过程。

被动创建的arp项

当对方请求本地接口地址的Mac信息时,我们会创建相应的arp项,这其实是通过arplookup实现的,其实arplookup也是通过调用rtalloc1的。

组件

组件构成

组件实际上是一个功能部件具体实现部分的描述信息,它定义了与组件相关的源代码或目标代码、集成信息以及与组件相关的参数。组件包含以下元素:

(1)NAME:一个可读的名称,在工程组件管理器中出现在组件图标旁边。

(2)SYNOPSIS:对组件的简洁的描述。

(3)MODULES:与组件关联的目标文件。

(4)HDR_FILES:使用该组件时需要用到的相关头文件。

(5)CFG_PARAMS:与组件相关的一些配置参数,通常为一系列的宏。

Wind River公司将部分组件安装在其传统位置上。

(1)源码模块可在target/src或target/config目录下找到。

(2)标题头至于target/h中;目标模块在target/lib/objARCH中。

(3)组件描述文件在target/config/comps/VxWorks中。

(4)组件配置文件(源码片段)位于target/config/copms/src

在同一NET内的所以机器是通过MAC地址通讯。方法为,PC和另一台设备通讯,PC会先寻找对方的IP地址,然后在通过ARP(ARP

表里面有所以可以通讯IP和IP所对应的MAC地址)调出相应的MAC地址。通过MAC地址与对方通讯。也就是说在内网中各设备

互相寻找和用来通讯的地址是MAC地址,而不是IP地址。

组件network utility components下arpLib

linkSyms.c和prjConfig.c工程动态产生的配置文件,包含组件初始化和缩放支持;

romInit.c,sysAlib.s,sysLib.s,romStart.c总的开始文件

usrAppInit.c初始化用户程序,用户需要修改此文件来满足自己要求

prjComps.h和prjParam.h工程动态产生的头文件,包含组件选择和参数值。

vxworks image所有可加载的部件和功能,黑体显示的是包含部件,浅平显示的是未包含进来的部件,斜体显示的是无效的部件。选中每个部件时,右击可以include或者exclude此部件,并可修改此部件的属性。

如果没被选上,则相应的功能没有。

ARP表

设备通过ARP解析到目的MAC地址后,将会在自己的ARP表中增加IP地址到MAC地址的映射表项,以用于后续到同一目的地报文的转发。

ARP表项分为动态ARP表项和静态ARP表项

动态ARP表项

动态ARP表项由ARP协议通过ARP报文自动生成和维护,可以被老化,可以被新的ARP报文更新,可以被静态ARP表项覆盖。当到达老化时间、接口down时会删除相应的动态ARP表项。

静态ARP表项

静态ARP表项通过手工配置和维护,不会被老化,不会被动态ARP表项覆盖

配置静态ARP表项可以增加通信的安全性。静态ARP表项可以限制和指定IP地址的设备通信时只使用指定的MAC地址,此时攻击报文无法修改此表项的IP地址和MAC地址的映射关系,从而保护了本设备和指定设备间的正常通信。

静态ARP表项分为短静态ARP表项和长静态ARP表项。

在配置长静态ARP表项时,除了配置IP地址和MAC地址项外,还必须配置该ARP表项所在VLAN和出接口。长静态ARP表项可以直接用于报文转发。

在配置短静态ARP表项时,只需要配置IP地址和MAC地址项。如果出接口是三层以太网接口,短静态ARP表项可以直接用于报文转发;如果出接口是VLAN虚接口,短静态ARP表项不能直接用于报文转发,当要发送IP数据包时,先发送ARP请求报文,如果收到的响应报文中的源IP地址和源MAC地址与所配置的IP地址和MAC地址相同,则将接收ARP响应报文的接口加入该静态ARP表项中,之后就可以用于IP数据包的转发。


  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
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 ........
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值