/*-------------------------------------------------------------------------*/ void * tcfg_cpy_event_op_ctrl(void *dest, uint8 group, size_t destBytes) { int srcBytes; int copy_bytes; memset(dest, 0, destBytes); if (bTracerInitialized) { srcBytes = sizeof(tracer_config.event_op_ctrl); if (srcBytes < (group * destBytes)) { // Request ID range starts beyond target's range. return dest; } if (srcBytes < ((group + 1) * destBytes)) { // Request ID range extends beyond target's range. copy_bytes = srcBytes - (group * destBytes); } else { copy_bytes = destBytes; } memscpy(dest, destBytes, &(tracer_config.event_op_ctrl[ (group * destBytes) / sizeof(event_op_ctrl_t)]), copy_bytes); } return dest; }
/*============================================================================= FUNCTION UTIMER_QDI_REMOTE_HANDLER DESCRIPTION Timer Expire function to push timer cb details into corresponding process pipe. DEPENDENCIES None RETURN VALUE SIDE EFFECTS None =============================================================================*/ void utimer_qdi_remote_handler(uint32 process_idx, utimer_ptr_type timer, utimer_notify_type cb_type, utimer_osal_notify_obj_ptr sigs_func_addr, utimer_osal_notify_data sigs_mask_data, utimer_timetick_type run_time_ms) { qurt_pipe_data_t data1 = 0; qurt_pipe_data_t data2 = 0; qurt_pipe_data_t data3 = 0; qurt_pipe_data_t *ptr = 0; utimer_cb_info temp_cb; static uint32 sequence = 0; if(process_idx >= UTIMER_MAX_CLIENTS) ERR_FATAL("ProcessIdx %d >= %d func 0x%x", process_idx, UTIMER_MAX_CLIENTS, sigs_func_addr); UTIMER_QDI_LOCK(); if(utimer_clients[process_idx].opener_allocated == FALSE) { UTIMER_QDI_FREE(); /* Process got cleared or deleted, ignoring the timers related to that process */ return; } UTIMER_QDI_FREE(); temp_cb.timer = timer; temp_cb.seq = sequence++; /* Just dummy */ temp_cb.cb_type = cb_type; temp_cb.sig_func_addr = (uint32)sigs_func_addr; temp_cb.mask_data1 = (uint32)sigs_mask_data; temp_cb.data2 = (uint32)run_time_ms; ptr = (qurt_pipe_data_t *)&temp_cb; memscpy(&data1, sizeof(data1), (void *)ptr, sizeof(data1)); memscpy(&data2, sizeof(data2), (void *)(++ptr), sizeof(data2)); memscpy(&data3, sizeof(data3), (void *)(++ptr), sizeof(data3)); /* Todo: Need to see if there is a way, where i can figure out pipe is not full */ qurt_pipe_send((qurt_pipe_t *)&utimer_clients[process_idx].pipe, data1); /* As first data is successfully sent, data2 should be able to send */ qurt_pipe_send((qurt_pipe_t *)&utimer_clients[process_idx].pipe, data2); /* As first data is successfully sent, data3 should be able to send */ qurt_pipe_send((qurt_pipe_t *)&utimer_clients[process_idx].pipe, data3); return; } /* utimer_qdi_remote_handler */
/*-------------------------------------------------------------------------*/ void * tcfg_cpy_event_tag(void * dest, size_t destBytes) { char tag[] = EVENT_TABLE_TAG; // from autogenerated tracer_event_ids.h size_t tagBytes = sizeof(tag) - 1; //tag size without null terminator size_t copyBytes; if (tagBytes < destBytes) { memset(dest, '\0', destBytes); copyBytes = tagBytes; } else { copyBytes = destBytes; } //copy last copyBytes chars memscpy(dest, destBytes, &tag[tagBytes-copyBytes], copyBytes); return dest; }
/*-------------------------------------------------------------------------*/ void * tcfg_cpy_entity_op_ctrl(void *dest, size_t destBytes) { size_t srcBytes; if (bTracerInitialized) { srcBytes = sizeof(tracer_config.entity_op_ctrl); if (srcBytes < destBytes) { memset(dest, 0, destBytes); } // Truncates if doesn't fit. memscpy (dest, destBytes, tracer_config.entity_op_ctrl, srcBytes); } else { memset(dest, 0, destBytes); } return dest; }
void LAMP_SetState(const LampState* state) { // AJ_InfoPrintf(("\n%s\n", __func__)); int32_t diff = memcmp(state, &TheLampState, sizeof(LampState)); if (diff) { // AJ_InfoPrintf(("\n%s: Calling into NVRAM\n", __func__)); // AJ_NV_DATASET* id = AJ_NVRAM_Open(LAMP_STATE_FD, "w", sizeof(LampState)); memscpy((void*)(&TheLampState), sizeof(LampState), (const void*)(state), sizeof(LampState)); /* if (id != NULL) { AJ_NVRAM_Write(&TheLampState, sizeof(LampState), id); AJ_NVRAM_Close(id); }*/ } // this will cause the signal org.allseen.LSF.LampService.LampStateChanged // to be sent if there is a current session. LAMP_SendStateChangedSignal(); }
/** * This function does the logging for algo tuning variables * * @param[in] log_buffer Ptr to the buffer to be logged. * @param[in] log_size logging size in bytes * @param[in] client_handle_ptr client handle pointer * */ ADSPResult algo_data_log_now(algo_data_logging_t *algo_data_logging_ptr, int8_t *log_buffer, uint32_t log_size, uint32_t client_handle) { uint32_t log_buf_size; uint32_t log_size_used = 0; int8_t *log_buf_ptr = NULL; algo_log_client_info_t *algo_log_client_info_ptr = NULL; if(NULL == (algo_log_client_info_ptr = algo_find_client_info(algo_data_logging_ptr, client_handle))) { MSG_1(MSG_SSID_QDSP6, DBG_ERROR_PRIO, "Algo Log: algo client is not found 0x%lx", client_handle); return ADSP_EFAILED; } /* Validate the log size */ if(log_size != algo_log_client_info_ptr->log_size) { MSG_2(MSG_SSID_QDSP6, DBG_ERROR_PRIO, "Algo Log: log size registered %ld is different from log size %ld being logged", algo_log_client_info_ptr->log_size, log_size); return ADSP_EFAILED; } if(NULL != algo_log_client_info_ptr->log_buf_ptr) { log_buf_size = algo_log_client_info_ptr->log_buf_size; log_size_used = algo_log_client_info_ptr->log_size_used; log_buf_ptr = algo_log_client_info_ptr->log_buf_ptr; if((log_size_used + log_size) <= log_buf_size) { //dest buffer will have the free space of (log_buf_size-log_size_used) memscpy(log_buf_ptr + (log_size_used), (log_buf_size - log_size_used), log_buffer, log_size); /* Update used log buffer size */ algo_log_client_info_ptr->log_size_used += log_size; /* If all the log buffer size has been used, do commit the log buffer. */ if(algo_log_client_info_ptr->log_size_used >= (log_buf_size)) { algo_log_commit_buf(algo_log_client_info_ptr); } } else { algo_log_commit_buf(algo_log_client_info_ptr); //dest buffer will have the free space of (log_buf_size-log_size_used) /* algo_log_client_info_ptr->log_size_used is reset to 0 inside commit func */ memscpy(log_buf_ptr, log_buf_size, log_buffer, log_size); /* Update used log buffer size */ algo_log_client_info_ptr->log_size_used += log_size; } } return ADSP_EOK; }
void LAMP_GetState(LampState* state) { memscpy((void*)(state), sizeof(LampState), (const void*)(&TheLampState), sizeof(LampState)); }