这篇文章主要介绍vxworks中VxBus怎么用,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
Vx5的driver多数情况下与BSP纠缠不清,例如BSP需要包含sysDev.c。而Vx6发明了一种新的接口 - VxBus。它不仅规范了Driver与Device之间的接口,更重要的是让Driver与BSP无关,并最小化了Driver的架构相关性。VxBus的driver分为三步进行初始化,因此写个最最简单例子就是
#include <stdio.h> /* printf */#include <hwif/vxbus/vxBus.h> /* drvBusFuncs */#include <hwif/vxbus/vxbPciLib.h>/* vxbPciRegister */
#define MYDEVNAME "myDev"
static void myDevInstInit (struct vxbDev *pDev);static void myDevInstInit2 (struct vxbDev *pDev);static void myDevInstConnect(struct vxbDev *pDev);
static struct drvBusFuncs myDevFuncs = { myDevInstInit, /* devInstanceInit */ myDevInstInit2, /* devInstanceInit2 */ myDevInstConnect /* devConnect */ };
static struct vxbDevRegInfo myDevReg = { NULL, VXB_DEVID_DEVICE, /* 这是个Device的Driver */ VXB_BUSID_PCI, /* 这是个PCI Device */ VXB_VER_5_0_0, MYDEVNAME, &myDevFuncs, NULL, NULL, NULL };
static void myDevInstInit(struct vxbDev *pDev){ }static void myDevInstInit2(struct vxbDev *pDev){ }static void myDevInstConnect(struct vxbDev *pDev){ }void myDevRegister(){ vxbDevRegister((struct vxbDevRegInfo *)&myDevReg); }
用
vxBusShow() - INCLUDE_VXBUS_SHOW,看看执行效果

哎呀,所有的Orphan Device都被挂接myDev了。看来得过滤一下,先看看有哪些
pci device,随便挑俩空闲的
把myDevReg的类型改为vxbPciRegister,并加上device liststatic struct vxbPciID myDevIDList[] = { /* devID, vendID */ {0x0740, 0x15ad}, {0x0790, 0x15ad} };static struct vxbPciRegister myDevReg = { { NULL, /* pNext */ VXB_DEVID_DEVICE, /* BUS_DEVID_DEVICE or BUS_DEVID_BUSCTRL */ VXB_BUSID_PCI, /* PCI */ VXB_VER_5_0_0, /* vxbVersion */ MYDEVNAME, /* drvName */ &myDevFuncs, /* pDrvBusFuncs */ NULL, /* pMethods */ NULL, /* devProbe */ NULL /* pParamDefaults */ }, NELEMENTS(myDevIDList), myDevIDList };
这次PCI Device里只有两个myDev了,不过怎么unit number都是0?
得让driver每次加载时,能够自动增加这个number:在初始化时,调用一个vxbNextUnitGet()就可以了static void myDevInstInit ( struct vxbDev *pDev) { vxbNextUnitGet(pDev); }
再执行就正常了

以上是“vxworks中VxBus怎么用”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注天达云行业资讯频道!