中断注册函数整理
ArchIpcInt_interruptRegister (obj->remoteProcId,
obj->params.localIntId,
_NotifyDriverShm_ISR,
(Ptr) obj);
Int32 ArchIpcInt_interruptRegister (UInt16 procId,
UInt32 intId,
ArchIpcInt_CallbackFxn fxn,
Ptr fxnArgs)
{
ArchIpcInt_object.fxnTable->interruptRegister (procId, intId, fxn, fxnArgs);
..........................
}
Int32 Dm8168IpcInt_interruptRegister (UInt16 procId,
UInt32 intId,
ArchIpcInt_CallbackFxn fxn,
Ptr fxnArgs)
{
OsalIsr_Params isrParams;
isrParams.sharedInt = FALSE;
isrParams.checkAndClearFxn = &_Dm8168IpcInt_checkAndClearFunc;
isrParams.fxnArgs = NULL;
isrParams.intId = intId;
Dm8168IpcInt_state.isrHandle = OsalIsr_create (&_Dm8168IpcInt_isr, NULL, &isrParams);
OsalIsr_install (Dm8168IpcInt_state.isrHandle);
\
Dm8168IpcInt_state.isrObjects [procId].fxn = fxn;
Dm8168IpcInt_state.isrObjects [procId].fxnArgs = fxnArgs;
Dm8168IpcInt_state.isrObjects [procId].recvIntId = intId;
Dm8168IpcInt_interruptEnable (procId, intId);
............................................
}
OsalIsr_Handle OsalIsr_create (OsalIsr_CallbackFxn fxn,
Ptr fxnArgs,
OsalIsr_Params * params)
{
OsalIsr_Object * isrObj = NULL;
OsalThread_Params threadParams;
isrObj = Memory_alloc (NULL, sizeof (OsalIsr_Object), 0, NULL);
threadParams.priority = OsalThread_Priority_High;
threadParams.priorityType = OsalThread_PriorityType_Generic;
threadParams.once = FALSE;
isrObj->bottomHalf = OsalThread_create ((OsalThread_CallbackFxn)fxn,
fxnArgs,
&threadParams);
isrObj->irq = params->intId;
isrObj->isSharedInt = params->sharedInt;
isrObj->checkFunc = params->checkAndClearFxn;
isrObj->checkFuncArg = params->fxnArgs;
isrObj->isrState = OsalIsr_State_Uninstalled;
.............................................
return (OsalIsr_Handle) isrObj;
}
OsalThread_Handle OsalThread_create (OsalThread_CallbackFxn fxn,
Ptr fxnArgs,
OsalThread_Params * params)
{
OsalThread_Object * obj = NULL;
obj = (OsalThread_Object*) Memory_alloc (NULL,
sizeof (OsalThread_Object),
0,
NULL);
obj->cbckFxn = fxn;
obj->cbckData = fxnArgs;
init_completion (&obj->sem);
obj->task = kthread_create (Thread_callback,
(Ptr) obj,
"kernelThread_%d",
(tid - 1));
wake_up_process (obj->task);
........................................................
return (OsalThread_Handle) obj;
}
int Thread_callback (Void * arg)
{
OsalThread_Object * obj = (OsalThread_Object *) arg;
if (obj != NULL)
{
for (;!kthread_should_stop ();)
{
wait_for_completion (&obj->sem);
while (atomic_read (&obj->count))
{
obj->cbckFxn (obj->cbckData) ;
atomic_dec (&obj->count) ;
. .............................................
}
}
............................
}
}
static Bool _Dm8168IpcInt_isr (Ptr ref)
{
for (i = 0 ; i < Dm8168IpcInt_state.maxProcessors ; i++)
{
Dm8168IpcInt_state.isrObjects [i].fxn (Dm8168IpcInt_state.isrObjects [i].fxnArgs);
..................
}
...................
}
int OsalIsr_install (OsalIsr_Handle isrHandle)
{
OsalIsr_Object * isrObj = (OsalIsr_Object *) isrHandle;
request_irq (isrObj->irq,
(Void*) &OsalIsr_callback,
0,
"SYSLINK",
(Void *) isrObj);
..........................
}
irqreturn_t OsalIsr_callback (int irq, Ptr arg, struct pt_regs * regs)
{
OsalIsr_Object * isrObj = (OsalIsr_Object *) arg;
isAsserted = (*isrObj->checkFunc) (isrObj->checkFuncArg);
OsalThread_activate (isrObj->bottomHalf);
}
Void OsalThread_activate (OsalThread_Handle threadHandle)
{
OsalThread_Object * obj = (OsalThread_Object*) threadHandle;
atomic_inc (&obj->count);
complete (&obj->sem);
..............................
}