/*! * @brief Function to destroy the DM8168DUCATIPWR module. * * Once this function is called, other DM8168DUCATIPWR module APIs, except * for the DM8168DUCATIPWR_getConfig API cannot be called anymore. * * @sa DM8168DUCATIPWR_setup * GateMutex_delete */ Int DM8168DUCATIPWR_destroy (Void) { Int status = PWRMGR_SUCCESS; UInt16 i; IArg key; GT_0trace (curTrace, GT_ENTER, "DM8168DUCATIPWR_destroy"); GT_assert (curTrace, (DM8168DUCATIPWR_state.refCount != 0)); #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) if (DM8168DUCATIPWR_state.refCount == 0) { status = DM8168DUCATIPWR_E_INVALIDSTATE; GT_setFailureReason (curTrace, GT_4CLASS, "DM8168DUCATIPWR_destroy", status, "Module was not initialized!"); } else { #endif /* !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */ key = Gate_enterSystem(); DM8168DUCATIPWR_state.refCount--; Gate_leaveSystem(key); if (DM8168DUCATIPWR_state.refCount == 0) { /* Temporarily increment refCount here. */ key = Gate_enterSystem(); DM8168DUCATIPWR_state.refCount = 1; Gate_leaveSystem(key); /* Check if any DM8168DUCATIPWR instances have not been deleted so far. If not, * delete them. */ for (i = 0 ; i < MultiProc_MAXPROCESSORS ; i++) { GT_assert (curTrace, (DM8168DUCATIPWR_state.pwrHandles [i] == NULL)); if (DM8168DUCATIPWR_state.pwrHandles [i] != NULL) { DM8168DUCATIPWR_delete (&(DM8168DUCATIPWR_state.pwrHandles [i])); } } /* restore refCount here. */ key = Gate_enterSystem(); DM8168DUCATIPWR_state.refCount = 0; Gate_leaveSystem(key); if (DM8168DUCATIPWR_state.gateHandle != NULL) { GateMutex_delete ((GateMutex_Handle *) &(DM8168DUCATIPWR_state.gateHandle)); } DM8168DUCATIPWR_state.isSetup = FALSE; } #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) } #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */ GT_1trace (curTrace, GT_LEAVE, "DM8168DUCATIPWR_destroy", status); /*! @retval PWRMGR_SUCCESS Operation successful */ return (status); }
Void ListTest(Void) { List_Params listParams; List_Handle listHandle; List_Elem *elem; ListNode *node; UInt32 i, value; Bool failed = FALSE; IGateProvider_Handle gateHandle; List_Params_init(&listParams); gateHandle = (IGateProvider_Handle) GateMutex_create(); if(gateHandle == NULL) { Osal_printf("ListTest: GateMutex_create failed.\n"); goto exit; } listParams.gateHandle = gateHandle; listHandle = List_create(&listParams); if(listHandle == NULL) { Osal_printf("ListTest: List_create failed.\n"); goto gateExit; } node = Memory_alloc(NULL, LIST_SIZE * sizeof(ListNode), 0); if(node == NULL) { Osal_printf("ListTest: Memory_alloc failed.\n"); goto listExit; } // Put some nodes into the list for(i = 0; i < LIST_SIZE; i++) { node[i].value = i; List_put(listHandle, (List_Elem *)&node[i]); } // Traverse the list for(i = 0, elem = List_next(listHandle, NULL); elem != NULL && !failed; i++, elem = List_next(listHandle, elem)) { value = ((ListNode *)elem)->value; // Check against expected value if(value != i) { Osal_printf("ListTest: data mismatch, expected " "0x%x, actual 0x%x\n", i, i, value); failed = TRUE; } } // Remove nodes for(i = 0; i < LIST_SIZE && !List_empty(listHandle); i++) { // Get first element and put it back to test List_get and List_putHead elem = List_get(listHandle); List_putHead(listHandle, elem); // Now remove it permanently to test List_remove if(elem != NULL) { List_remove(listHandle, elem); } } // Did we remove the expected number of nodes? if(i != LIST_SIZE) { Osal_printf("ListTest: removed %d node(s), expected %d\n", i, LIST_SIZE); failed = TRUE; } if(!List_empty(listHandle)) { Osal_printf("ListTest: list not empty!\n"); failed = TRUE; } if(failed) Osal_printf("ListTest: FAILED!\n"); else Osal_printf("ListTest: PASSED!\n"); listExit: List_delete(&listHandle); gateExit: GateMutex_delete((GateMutex_Handle *)&gateHandle); exit: return; }
/** * \brief delete mutex object * * Deletes the specified mutex. * All threads suspended waiting for the mutex are resumed and given a TX_DELETED return status * * \param[in] p_handle Handle to a mutex control block * * \return e_SUCCESS on success, e_FAILURE on error * * \sa OS_mutex_create, OS_mutex_lock, OS_mutex_unlock * \note * * \warning */ e_ret_status OS_mutex_delete(handle p_handle) { GateMutex_delete((GateMutex_Handle *)p_handle); return e_SUCCESS; }