int main (int argc, char **args) { // add your dsplink init / LPM rest here: // put this between PROC_load and PROC_start in your dsplink init-code: NOTIFY_register (0, 0, 6, LogCallback, 0); for (;;) {} }
Void main(Int argc, Char *argv[]) { // create the semaphore dprint_sema = SEM_create (0, NULL); // connect with gpp: DSPLINK_init (); // register callback from the gpp side: NOTIFY_register (ID_GPP, 0, 6, dprint_callback, 0); // start task: TSK_create(TaskMain, NULL, &0); // task will start as soon as main ends! // don't call dprintf from here! }
Int Task_create (Task_TransferInfo ** infoPtr) { Int status = SYS_OK ; Task_TransferInfo * info = NULL ; /* Allocate Task_TransferInfo structure that will be initialized * and passed to other phases of the application */ if (status == SYS_OK) { *infoPtr = MEM_calloc (DSPLINK_SEGID, sizeof (Task_TransferInfo), 0) ; /* No alignment restriction */ if (*infoPtr == NULL) { status = SYS_EALLOC ; } else { info = *infoPtr ; } } /* Fill up the transfer info structure */ if (status == SYS_OK) { info->dataBuf = NULL ; /* Set through notification callback. */ info->bufferSize = MPCSXFER_BufferSize ; SEM_new (&(info->notifySemObj), 0) ; } /* * Register notification for the event callback to get control and data * buffer pointers from the GPP-side. */ if (status == SYS_OK) { status = NOTIFY_register (ID_GPP, MPCSXFER_IPS_ID, MPCSXFER_IPS_EVENTNO, (FnNotifyCbck) Task_notify, info) ; if (status != SYS_OK) { return status; } } /* * Send notification to the GPP-side that the application has completed its * setup and is ready for further execution. */ if (status == SYS_OK) { status = NOTIFY_notify (ID_GPP, MPCSXFER_IPS_ID, MPCSXFER_IPS_EVENTNO, (Uint32) 0) ; /* No payload to be sent. */ if (status != SYS_OK) { return status; } } /* * Wait for the event callback from the GPP-side to post the semaphore * indicating receipt of the data buffer pointer and image width and height. */ SEM_pend (&(info->notifySemObj), SYS_FOREVER) ; SEM_pend (&(info->notifySemObj), SYS_FOREVER) ; return status ; }
/** ============================================================================ * @func pool_notify_Create * * @desc This function allocates and initializes resources used by * this application. * * @modif None * ============================================================================ */ NORMAL_API DSP_STATUS pool_notify_Create (IN Char8 * dspExecutable, IN Char8 * strBufferSize, IN Uint8 processorId) { DSP_STATUS status = DSP_SOK ; Uint32 numArgs = NUM_ARGS ; Void * dspDataBuf = NULL ; Uint32 numBufs [NUM_BUF_SIZES] = {NUM_BUF_POOL0, } ; Uint32 size [NUM_BUF_SIZES] ; SMAPOOL_Attrs poolAttrs ; Char8 * args [NUM_ARGS] ; #ifdef DEBUG printf ("Entered pool_notify_Create ()\n") ; #endif sem_init(&sem,0,0); /* * Create and initialize the proc object. */ status = PROC_setup (NULL) ; /* * Attach the Dsp with which the transfers have to be done. */ if (DSP_SUCCEEDED (status)) { status = PROC_attach (processorId, NULL) ; if (DSP_FAILED (status)) { printf ("PROC_attach () failed. Status = [0x%x]\n", (int)status) ; } } else { printf ("PROC_setup () failed. Status = [0x%x]\n", (int)status) ; } /* * Open the pool. */ if (DSP_SUCCEEDED (status)) { size [0] = pool_notify_BufferSize ; poolAttrs.bufSizes = (Uint32 *) &size ; poolAttrs.numBuffers = (Uint32 *) &numBufs ; poolAttrs.numBufPools = NUM_BUF_SIZES ; poolAttrs.exactMatchReq = TRUE ; status = POOL_open (POOL_makePoolId(processorId, SAMPLE_POOL_ID), &poolAttrs) ; if (DSP_FAILED (status)) { printf ("POOL_open () failed. Status = [0x%x]\n", (int)status) ; } } /* * Allocate the data buffer to be used for the application. */ if (DSP_SUCCEEDED (status)) { status = POOL_alloc (POOL_makePoolId(processorId, SAMPLE_POOL_ID), (Void **) &pool_notify_DataBuf, pool_notify_BufferSize) ; /* Get the translated DSP address to be sent to the DSP. */ if (DSP_SUCCEEDED (status)) { status = POOL_translateAddr ( POOL_makePoolId(processorId, SAMPLE_POOL_ID), &dspDataBuf, AddrType_Dsp, (Void *) pool_notify_DataBuf, AddrType_Usr) ; if (DSP_FAILED (status)) { printf ("POOL_translateAddr () DataBuf failed." " Status = [0x%x]\n", (int)status) ; } } else { printf ("POOL_alloc () DataBuf failed. Status = [0x%x]\n", (int)status) ; } } /* * Register for notification that the DSP-side application setup is * complete. */ if (DSP_SUCCEEDED (status)) { status = NOTIFY_register (processorId, pool_notify_IPS_ID, pool_notify_IPS_EVENTNO, (FnNotifyCbck) pool_notify_Notify, 0/* vladms XFER_SemPtr*/) ; if (DSP_FAILED (status)) { printf ("NOTIFY_register () failed Status = [0x%x]\n", (int)status) ; } } /* * Load the executable on the DSP. */ if (DSP_SUCCEEDED (status)) { args [0] = strBufferSize ; { status = PROC_load (processorId, dspExecutable, numArgs, args) ; } if (DSP_FAILED (status)) { printf ("PROC_load () failed. Status = [0x%x]\n", (int)status) ; } } /* * Start execution on DSP. */ if (DSP_SUCCEEDED (status)) { status = PROC_start (processorId) ; if (DSP_FAILED (status)) { printf ("PROC_start () failed. Status = [0x%x]\n", (int)status) ; } } /* * Wait for the DSP-side application to indicate that it has completed its * setup. The DSP-side application sends notification of the IPS event * when it is ready to proceed with further execution of the application. */ if (DSP_SUCCEEDED (status)) { // wait for initialization sem_wait(&sem); } /* * Send notifications to the DSP with information about the address of the * control structure and data buffer to be used by the application. * */ status = NOTIFY_notify (processorId, pool_notify_IPS_ID, pool_notify_IPS_EVENTNO, (Uint32) dspDataBuf); if (DSP_FAILED (status)) { printf ("NOTIFY_notify () DataBuf failed." " Status = [0x%x]\n", (int)status) ; } status = NOTIFY_notify (processorId, pool_notify_IPS_ID, pool_notify_IPS_EVENTNO, (Uint32) pool_notify_BufferSize); if (DSP_FAILED (status)) { printf ("NOTIFY_notify () DataBuf failed." " Status = [0x%x]\n", (int)status) ; } #ifdef DEBUG printf ("Leaving pool_notify_Create ()\n") ; #endif return status ; }