/* * ======== WMD_MSG_Create ======== * Create an object to manage message queues. Only one of these objects * can exist per device object. */ DSP_STATUS WMD_MSG_Create(OUT struct MSG_MGR **phMsgMgr, struct DEV_OBJECT *hDevObject, MSG_ONEXIT msgCallback) { struct MSG_MGR *pMsgMgr; struct IO_MGR *hIOMgr; DSP_STATUS status = DSP_SOK; if (!phMsgMgr || !msgCallback || !hDevObject) { status = DSP_EPOINTER; goto func_end; } DEV_GetIOMgr(hDevObject, &hIOMgr); if (!hIOMgr) { status = DSP_EPOINTER; goto func_end; } *phMsgMgr = NULL; /* Allocate MSG manager object */ MEM_AllocObject(pMsgMgr, struct MSG_MGR, MSGMGR_SIGNATURE); if (pMsgMgr) { pMsgMgr->onExit = msgCallback; pMsgMgr->hIOMgr = hIOMgr; /* List of MSG_QUEUEs */ pMsgMgr->queueList = LST_Create(); /* Queues of message frames for messages to the DSP. Message * frames will only be added to the free queue when a * MSG_QUEUE object is created. */ pMsgMgr->msgFreeList = LST_Create(); pMsgMgr->msgUsedList = LST_Create(); if (pMsgMgr->queueList == NULL || pMsgMgr->msgFreeList == NULL || pMsgMgr->msgUsedList == NULL) status = DSP_EMEMORY; if (DSP_SUCCEEDED(status)) status = SYNC_InitializeDPCCS(&pMsgMgr->hSyncCS); /* Create an event to be used by WMD_MSG_Put() in waiting * for an available free frame from the message manager. */ if (DSP_SUCCEEDED(status)) status = SYNC_OpenEvent(&pMsgMgr->hSyncEvent, NULL); if (DSP_SUCCEEDED(status)) *phMsgMgr = pMsgMgr; else DeleteMsgMgr(pMsgMgr); } else { status = DSP_EMEMORY; } func_end: return status; }
DSP_STATUS CHNLSM_EnableInterrupt(struct WMD_DEV_CONTEXT *pDevContext) { DSP_STATUS status = DSP_SOK; u32 numMbxMsg; u32 mbxValue; struct CFG_HOSTRES resources; u32 devType; struct IO_MGR *hIOMgr; DBG_Trace(DBG_ENTER, "CHNLSM_EnableInterrupt(0x%x)\n", pDevContext); /* Read the messages in the mailbox until the message queue is empty */ CFG_GetHostResources((struct CFG_DEVNODE *)DRV_GetFirstDevExtension(), &resources); DEV_GetDevType(pDevContext->hDevObject, &devType); status = DEV_GetIOMgr(pDevContext->hDevObject, &hIOMgr); if (devType == DSP_UNIT) { HW_MBOX_NumMsgGet(resources.dwMboxBase, MBOX_DSP2ARM, &numMbxMsg); while (numMbxMsg != 0) { HW_MBOX_MsgRead(resources.dwMboxBase, MBOX_DSP2ARM, &mbxValue); numMbxMsg--; } /* clear the DSP mailbox as well...*/ HW_MBOX_NumMsgGet(resources.dwMboxBase, MBOX_ARM2DSP, &numMbxMsg); while (numMbxMsg != 0) { HW_MBOX_MsgRead(resources.dwMboxBase, MBOX_ARM2DSP, &mbxValue); numMbxMsg--; udelay(10); HW_MBOX_EventAck(resources.dwMboxBase, MBOX_ARM2DSP, HW_MBOX_U1_DSP1, HW_MBOX_INT_NEW_MSG); } /* Enable the new message events on this IRQ line */ HW_MBOX_EventEnable(resources.dwMboxBase, MBOX_DSP2ARM, MBOX_ARM, HW_MBOX_INT_NEW_MSG); } return status; }