/* * ======== NTFY_Create ======== * Purpose: * Create an empty list of notifications. */ DSP_STATUS NTFY_Create(struct NTFY_OBJECT **phNtfy) { struct NTFY_OBJECT *pNtfy; DSP_STATUS status = DSP_SOK; DBC_Require(phNtfy != NULL); *phNtfy = NULL; MEM_AllocObject(pNtfy, struct NTFY_OBJECT, NTFY_SIGNATURE); if (pNtfy) { status = SYNC_InitializeDPCCS(&pNtfy->hSync); if (DSP_SUCCEEDED(status)) { pNtfy->notifyList = MEM_Calloc(sizeof(struct LST_LIST), MEM_NONPAGED); if (pNtfy->notifyList == NULL) { (void) SYNC_DeleteCS(pNtfy->hSync); MEM_FreeObject(pNtfy); status = DSP_EMEMORY; } else { INIT_LIST_HEAD(&pNtfy->notifyList->head); *phNtfy = pNtfy; } } } else { status = DSP_EMEMORY; } DBC_Ensure((DSP_FAILED(status) && *phNtfy == NULL) || (DSP_SUCCEEDED(status) && MEM_IsValidHandle((*phNtfy), NTFY_SIGNATURE))); return status; }
/* * ======== WMD_CHNL_Create ======== * Create a channel manager object, responsible for opening new channels * and closing old ones for a given board. */ DSP_STATUS WMD_CHNL_Create(OUT struct CHNL_MGR **phChnlMgr, struct DEV_OBJECT *hDevObject, IN CONST struct CHNL_MGRATTRS *pMgrAttrs) { DSP_STATUS status = DSP_SOK; struct CHNL_MGR *pChnlMgr = NULL; s32 cChannels; /* Check DBC requirements: */ DBC_Require(phChnlMgr != NULL); DBC_Require(pMgrAttrs != NULL); DBC_Require(pMgrAttrs->cChannels > 0); DBC_Require(pMgrAttrs->cChannels <= CHNL_MAXCHANNELS); DBC_Require(pMgrAttrs->uWordSize != 0); /* Allocate channel manager object: */ MEM_AllocObject(pChnlMgr, struct CHNL_MGR, CHNL_MGRSIGNATURE); if (pChnlMgr) { /* The cChannels attr must equal the # of supported * chnls for each transport(# chnls for PCPY = DDMA = * ZCPY): i.e. pMgrAttrs->cChannels = CHNL_MAXCHANNELS = * DDMA_MAXDDMACHNLS = DDMA_MAXZCPYCHNLS. */ DBC_Assert(pMgrAttrs->cChannels == CHNL_MAXCHANNELS); cChannels = CHNL_MAXCHANNELS + CHNL_MAXCHANNELS * CHNL_PCPY; /* Create array of channels: */ pChnlMgr->apChannel = MEM_Calloc( sizeof(struct CHNL_OBJECT *) * cChannels, MEM_NONPAGED); if (pChnlMgr->apChannel) { /* Initialize CHNL_MGR object: */ /* Shared memory driver. */ pChnlMgr->dwType = CHNL_TYPESM; pChnlMgr->uWordSize = pMgrAttrs->uWordSize; /* total # chnls supported */ pChnlMgr->cChannels = cChannels; pChnlMgr->cOpenChannels = 0; pChnlMgr->dwOutputMask = 0; pChnlMgr->dwLastOutput = 0; pChnlMgr->hDevObject = hDevObject; if (DSP_SUCCEEDED(status)) status = SYNC_InitializeDPCCS( &pChnlMgr->hCSObj); } else { status = DSP_EMEMORY; } } else { status = DSP_EMEMORY; } if (DSP_FAILED(status)) { WMD_CHNL_Destroy(pChnlMgr); *phChnlMgr = NULL; } else { /* Return channel manager object to caller... */ *phChnlMgr = pChnlMgr; } return status; }
/* * ======== 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; }
/* * ======== REG_Init ======== * Initialize the REG module's private state. */ bool REG_Init(void) { bool fInit; GT_create(®_debugMask, "RG"); /* RG for ReG */ fInit = regsupInit(); if (crefs == 0) SYNC_InitializeDPCCS(®lock); crefs++; GT_0trace(REG_debugMask, GT_5CLASS, "REG_Init\n"); return fInit; }