先介绍一下vxWorks的设备以及驱动的表示方法,以及总的关系:设备和驱动根本都抽象成一个结构体,设备结构体中包含了设备名字、ID号、功能函数指针等必备的信息,驱动结构体包含了初始化函数、名字、ID等信息。总的如图看一下重要的几个结构体的关系:
vxbus结构设计了几个链表:
/*放置驱动的链表*/
struct vxbDevRegInfo * pDriverListHead = NULL;
/*放置注册的总线的链表*/
struct vxbBusTypeInfo * pBusListHead = NULL;
/*匹配好的设备和驱动称为instlist,没有找到驱动的设备链表,*/
struct vxbBusPresent * pBusHead = NULL;
当一个设备注册进来之后,就会从pDriverListHead中查找驱动,如果找到了就会放到pBusHead链表中的instList链表中,没有找到驱动就会放置到pBusHead->devList中;而当一个新的总线注册进来后就会放置到pBusListHead链表中。
vxbus的初始化。
vxbus的初始化流程中的函数调用:
usrInit
sysHwInit
hardWareInterFaceInit
hardWareInterFaceBusInit
vxbLibInit (vxbInitPhase = 0)
plbRegister
vxbInit(vxbInitPhase = 1)
plbInit1
usrRoot
sysClkInit
sysClkConnect
sysHwInit2
vxbDevInit
vxbDevInitInternal (vxbInitPhase = 2)
vxbDevInit2Helper(对所有设备进行)
vxbDevConnect
vxbDevConnectInternal(vxbInitPhase = 3)
vxbDevConnectHelper(对所有设备进行)
vxbus的初始化分为按照vxbInitPhase=0,1,2,3分为4部分进行,接下来分别进行介绍。
vxbInitPhase=0时:函数vxbLibInit所做工作"
STATUS vxbLibInit (void)
{
vxbInitPhase = 0;
return(OK);
}
只是声明了这是vxbInitPhase=0阶段,之后就是驱动函数的注册。也就是说0阶段只要是驱动函数的注册。
vxbInitPhase=1:
STATUS vxbInit (void)
{
vxbInitPhase = 1;
plbInit1(pPlbDev);
return(OK);
}
STATUS plbInit1
(
struct vxbDev * pCtlr
)
{
int i, j;
char regBase[] = "regBase0";
struct vxbDev * pDev;
HCF_DEVICE * pHcf;
VXBPLB_DEBUG_MSG1("plbInit1() called\n", 1,2,3,4,5,6);
#ifdef VXB_LEGACY_ACCESS
/* call the function to initialize the access module of PLB */
plbAccessInit ();
#endif /* VXB_LEGACY_ACCESS */
/*
* now populate the bus with devices from the table created by the
* configuration tool
*/
for ( i = 0 ; i < hcfDeviceNum ; i++ )
{
if ( hcfDeviceList[i].busType != VXB_BUSID_PLB )
{
VXBPLB_DEBUG_MSG1("plbInit1(): skipping non-PLB device %s\n",
(int)hcfDeviceList[i].devName, 2,3,4,5,6);
}
else
{
VXBPLB_DEBUG_MSG1("plbInit1(): processing device %s\n",
(int)hcfDeviceList[i].devName, 2,3,4,5,6);
pHcf = &hcfDeviceList[i];
/* allocate device structure */
pDev = vxbDevStructAlloc(WAIT_FOREVER);
if ( pDev == NULL )
{
return(ERROR);
}
/* bus subsystem overhead */
pDev->busID = VXB_BUSID_PLB;
pDev->pNext = NULL;
/* save resources with device */
pDev->pBusSpecificDevInfo = (void *)&h