//---------------------------------------------------------------------------- int tn_fmem_get_ipolling(TN_FMP * fmp,void ** p_data) { TN_INTSAVE_DATA_INT int rc; void * ptr; #if TN_CHECK_PARAM if(fmp == NULL || p_data == NULL) return TERR_WRONG_PARAM; if(fmp->id_fmp != TN_ID_FSMEMORYPOOL) return TERR_NOEXS; #endif TN_CHECK_INT_CONTEXT tn_idisable_interrupt(); ptr = fm_get(fmp); if(ptr != NULL) //-- Get memory { *p_data = ptr; rc = TERR_NO_ERR; } else rc = TERR_TIMEOUT; tn_ienable_interrupt(); return rc; }
/** * * @param fmp * @param p_data * @param timeout * * @return TN_RETVAL */ TN_RETVAL tnnc_fmem_get (TN_FMP_S *fmp, void ** p_data, TN_TIMEOUT timeout) { TN_UWORD tn_save_status_reg TN_UNUSED; /* for SR save */ TN_RETVAL rc; void *ptr; /* Not check parameter error if (fmp == TN_NULL || p_data == TN_NULL || timeout == 0) return TERR_WRONG_PARAM; */ if (fmp->id_fmp != TN_ID_FSMEMORYPOOL) return TERR_NOEXS; if (tn_is_non_task_context()) { return TERR_WCONTEXT; } tn_disable_interrupt(); ptr = fm_get(fmp); if (ptr != TN_NULL) { *p_data = ptr; rc = TERR_NO_ERR; } else { task_curr_to_wait_action(&(fmp->wait_queue), TSK_WAIT_REASON_WFIXMEM,timeout); tn_enable_interrupt(); tn_switch_context(); /* When return to this point,in data_elem have to be valid value */ *p_data = tn_curr_run_task->data_elem; return tn_curr_run_task->task_wait_rc; } tn_enable_interrupt(); return rc; }
//---------------------------------------------------------------------------- int tn_fmem_get(TN_FMP * fmp, void ** p_data, unsigned long timeout) { TN_INTSAVE_DATA int rc; void * ptr; #if TN_CHECK_PARAM if(fmp == NULL || p_data == NULL || timeout == 0) return TERR_WRONG_PARAM; if(fmp->id_fmp != TN_ID_FSMEMORYPOOL) return TERR_NOEXS; #endif TN_CHECK_NON_INT_CONTEXT tn_disable_interrupt(); ptr = fm_get(fmp); if(ptr != NULL) //-- Get memory { *p_data = ptr; rc = TERR_NO_ERR; } else { task_curr_to_wait_action(&(fmp->wait_queue), TSK_WAIT_REASON_WFIXMEM, timeout); tn_enable_interrupt(); tn_switch_context(); //-- When returns to this point, in the 'data_elem' have to be valid value *p_data = tn_curr_run_task->data_elem; //-- Return to caller return tn_curr_run_task->task_wait_rc; } tn_enable_interrupt(); return rc; }
/** * * @param fmp * @param p_data * * @return TN_RETVAL */ TN_RETVAL tnnc_fmem_get_polling (TN_FMP_S *fmp, void **p_data) { TN_UWORD tn_save_status_reg TN_UNUSED; /* for SR save */ TN_RETVAL rc; void *ptr; /* Not check parameter error if (fmp == TN_NULL || p_data == TN_NULL) return TERR_WRONG_PARAM; */ if (fmp->id_fmp != TN_ID_FSMEMORYPOOL) return TERR_NOEXS; if (tn_is_non_task_context()) { return TERR_WCONTEXT; } tn_disable_interrupt(); ptr = fm_get(fmp); if (ptr != TN_NULL) { /* Get memory */ *p_data = ptr; rc = TERR_NO_ERR; } else { rc = TERR_TIMEOUT; } tn_enable_interrupt(); return rc; }