Notify_module和ArchIpcInt_object

现在我们来看看关于Notify_module->notifyHandles [procId][lineId]这个结构是如何赋值的:

主要就是通过下面三个函数:

Int  NotifySetupDm8168_attach (UInt16 procId, Ptr sharedAddr)

{

    NotifySetup_driverHandle [procId] = NotifyDriverShm_create(¬ifyShmParams);

    NotifySetup_notifyHandle [procId] = Notify_create (

                                        NotifySetup_driverHandle [procId],

                                        procId,

                                        0u,

                                        NULL);

............................................................

}

INotifyDriver_Handle  NotifyDriverShm_create (const NotifyDriverShm_Params * params)

{

NotifyDriverShm_Object *     obj       = NULL;

INotifyDriver_Object *       notifyDrvObj = NULL;

notifyDrvObj = Memory_calloc (NULL,

                             sizeof (INotifyDriver_Object),

                             0u,

                             NULL);

    notifyDrvObj->fxnTable.registerEvent = (INotifyDriver_RegisterEventFxn)

                                                &NotifyDriverShm_registerEvent;

notifyDrvObj->fxnTable.unregisterEvent =(INotifyDriver_UnregisterEventFxn)

                                            &NotifyDriverShm_unregisterEvent;

    notifyDrvObj->fxnTable.sendEvent = (INotifyDriver_SendEventFxn)

                                              &NotifyDriverShm_sendEvent;

notifyDrvObj->fxnTable.disable = (INotifyDriver_DisableFxn)

                                              &NotifyDriverShm_disable;

notifyDrvObj->fxnTable.enable  = (INotifyDriver_EnableFxn)

                                              &NotifyDriverShm_enable;

notifyDrvObj->fxnTable.disableEvent= (INotifyDriver_DisableEventFxn)

                                               &NotifyDriverShm_disableEvent;

notifyDrvObj->fxnTable.enableEvent = (INotifyDriver_EnableEventFxn)

                                                &NotifyDriverShm_enableEvent;

notifyDrvObj->fxnTable.setNotifyHandle =(INotifyDriver_SetNotifyHandleFxn)

                                            &NotifyDriverShm_setNotifyHandle;

obj = Memory_calloc (NULL,

                   sizeof (NotifyDriverShm_Object),

                   0u,

                   NULL);

notifyDrvObj->obj = obj;

obj->numEvents = Notify_state.cfg.numEvents;

procCtrlSize = _Ipc_roundup(sizeof (NotifyDriverShm_ProcCtrl),  minAlign);

obj->eventEntrySize = _Ipc_roundup(sizeof(NotifyDriverShm_EventEntry), minAlign);

obj->selfProcCtrl = (NotifyDriverShm_ProcCtrl *)

                  ( (UInt32) params->sharedAddr  +  (obj->selfId * procCtrlSize));

obj->otherProcCtrl = (NotifyDriverShm_ProcCtrl *)

                  ( (UInt32) params->sharedAddr  + (obj->otherId * procCtrlSize));

obj->selfEventChart  = (NotifyDriverShm_EventEntry *)( (UInt32) params->sharedAddr 

       + (2 * procCtrlSize)  + (obj->eventEntrySize * obj->numEvents * obj->selfId));

obj->otherEventChart  = (NotifyDriverShm_EventEntry *)( (UInt32) params->sharedAddr

       + (2 * procCtrlSize) + (obj->eventEntrySize * obj->numEvents * obj->otherId));

ArchIpcInt_interruptRegister (obj->remoteProcId,           /* 这里还有一个重要

                         obj->params.localIntId,          的函数中断注册,

                         _NotifyDriverShm_ISR,         这个暂时先不考虑

                         (Ptr) obj);                  */

...............................

return ((INotifyDriver_Handle) notifyDrvObj);

}

Notify_Handle   Notify_create ( INotifyDriver_Handle driverHandle,

                            UInt16      remoteProcId,

                            UInt16      lineId,

                            const Notify_Params *  params)

{

     Notify_Object * obj    = NULL;

     obj = Memory_calloc (NULL, sizeof (Notify_Object), 0u, NULL);

     obj->remoteProcId = remoteProcId;

     obj->lineId = lineId;

     obj->nesting = 0;

     for (i = 0; i < Notify_module->cfg.numEvents; i++)

     {

             List_Params_init (&listparams);

             List_construct (&(obj->eventList [i]), &listparams);

     }

     obj->driverHandle = driverHandle;

     INotifyDriver_setNotifyHandle (driverHandle, obj);

     Notify_module->notifyHandles [remoteProcId][lineId] = obj;

     上面这条语句即将Notify_Object 此结构体的值赋给了Notify_module;

     ...........................

     return ((Notify_Handle) obj);

}

注意:

/******************************************************************************

*  INotifyDriver_setNotifyHandle (driverHandle, obj);其实就是实现这个功能             *

*  driverHandle->obj->notifyHandle = obj                                           *

*  Notify_Object这个结构体在注册回调函数中有大用处,这里先不考虑,             *

*  只弄清Notify_module->notifyHandles [procId][lineId];中对应的两个值就好了。        *

*******************************************************************************

全局变量ArchIpcInt_object的赋值部分很简单,主要由以下就很清楚:

ArchIpcInt_FxnTable Dm8168IpcInt_fxnTable = {

    Dm8168IpcInt_interruptRegister,

    Dm8168IpcInt_interruptUnregister,

    Dm8168IpcInt_interruptEnable,

    Dm8168IpcInt_interruptDisable,

    Dm8168IpcInt_waitClearInterrupt,

    Dm8168IpcInt_sendInterrupt,

    Dm8168IpcInt_clearInterrupt,

};

Void  Dm8168IpcInt_setup (Dm8168IpcInt_Config * cfg)

{

mapInfo.src      = AINTC_BASE_ADDR;

mapInfo.size     = AINTC_BASE_SIZE;

mapInfo.isCached = FALSE;

Memory_map (&mapInfo);

Dm8168IpcInt_state.archCoreCmBase = mapInfo.dst;

mapInfo.src      = MAILBOX_BASE;

mapInfo.size     = MAILBOX_SIZE;

mapInfo.isCached = FALSE;

Memory_map (&mapInfo);

Dm8168IpcInt_state.mailboxBase = mapInfo.dst;

ArchIpcInt_object.fxnTable = &Dm8168IpcInt_fxnTable;

ArchIpcInt_object.obj      = &Dm8168IpcInt_state;

for (i = 0; i < MultiProc_getNumProcessors(); i++ )

{

     Atomic_set (&(Dm8168IpcInt_state.isrObjects [i].asserted), 0);

}

ArchIpcInt_object.isSetup  = TRUE;

....................

}

你可能感兴趣的:(list,object,Module,null)