int vol_rglr_vt1185m_set_output_vol (unsigned char vol_sel, unsigned char vol_idx) { unsigned char i; unsigned char i2c_addr; unsigned char sensor_num = 0; unsigned char vid_code = 0; unsigned int microV; int ret = E_OK; const vol_table_entry* vtbl_ptr; sdr_threshold_t thr; thr.flag = (SDR_THR_UPPER_NON_RECOV | SDR_THR_UPPER_CRITICAL | SDR_THR_UPPER_NON_CRITICAL | SDR_THR_LOWER_NON_CRITICAL | SDR_THR_LOWER_CRITICAL | SDR_THR_LOWER_NON_RECOV); if (vol_sel == VT1185M_VOL_SEL_CORE) { i2c_addr = VT1185M_I2C_ADDR_CORE; vtbl_ptr = vol_table_core; sdr_find_sensor_num_by_readfunc (sensor_power1014_get_vdd_core, &sensor_num); } else { i2c_addr = VT1185M_I2C_ADDR_DDR3; vtbl_ptr = vol_table_ddr3; sdr_find_sensor_num_by_readfunc (sensor_power1014_get_vdd_ddr3, &sensor_num); } for (i = 0; vtbl_ptr[i].vol_idx != 0xFF; i++) { if (vol_idx == vtbl_ptr[i].vol_idx) { vid_code = vtbl_ptr[i].vid; microV = VID_VOLTAGE_BASE - (vid_code - VID_BASE) * VID_VOLTAGE_STEP; thr.unr = (unsigned char)((microV / VOLTAGE_SENSOR_STEP) + (microV / 10 / VOLTAGE_SENSOR_STEP)); thr.unc = (unsigned char)((microV / VOLTAGE_SENSOR_STEP) + (microV / 20 / VOLTAGE_SENSOR_STEP)); thr.ucr = (thr.unr + thr.unc) / 2 + 1; thr.lnc = (unsigned char)((microV / VOLTAGE_SENSOR_STEP) - (microV / 20 / VOLTAGE_SENSOR_STEP)) - 1; thr.lnr = (unsigned char)((microV / VOLTAGE_SENSOR_STEP) - (microV / 10 / VOLTAGE_SENSOR_STEP)) - 1; thr.lcr = (thr.lnr + thr.lnc) / 2; break; } } if (vid_code) ret = vol_rglr_vt1185m_set_voltage_by_vid (i2c_addr, vid_code); if (ret) ERROR_PRINTF((DEBUG_UART, "ERR: Set Voltage Failed: %d(1:Core, 2:DDR3) to %d\n", vol_sel, vol_idx)); if (vid_code /*&& !ret*/) // Sometimes return != E_OK but still take effect?? ret = sdr_set_threshold (sensor_num, &thr); return ret; }
/* When the first mythread_create call is invoked, we create the tcb corresponding to main and idle threads. The following function adds the tcb for main thread in front of the queue. */ static int __mythread_add_main_tcb() { DEBUG_PRINTF("add_main_tcb: Creating node for Main thread \n"); main_tcb = (mythread_private_t *) malloc(sizeof(mythread_private_t)); if (main_tcb == NULL) { ERROR_PRINTF("add_main_tcb: Error allocating memory for main node\n"); return -ENOMEM; } main_tcb->start_func = NULL; main_tcb->args = NULL; main_tcb->state = READY; main_tcb->returnValue = NULL; main_tcb->blockedForJoin = NULL; /* Get the main's tid and put it in its corresponding tcb. */ main_tcb->tid = __mythread_gettid(); /* Initialize futex to zero */ futex_init(&main_tcb->sched_futex, 1); /* Put it in the Queue of thread blocks */ mythread_q_add(main_tcb); return 0; }
// ============================================================================ /// Enumerates the INSTRUCTION (Opcode and Uop) operation type const char* get_enum_instruction_operation_char(instruction_operation_t type) { switch (type) { // ==================================================================== /// INTEGERS case INSTRUCTION_OPERATION_INT_ALU: return "OP_IN_ALU"; break; case INSTRUCTION_OPERATION_INT_MUL: return "OP_IN_MUL"; break; case INSTRUCTION_OPERATION_INT_DIV: return "OP_IN_DIV"; break; // ==================================================================== /// FLOAT POINT case INSTRUCTION_OPERATION_FP_ALU: return "OP_FP_ALU"; break; case INSTRUCTION_OPERATION_FP_MUL: return "OP_FP_MUL"; break; case INSTRUCTION_OPERATION_FP_DIV: return "OP_FP_DIV"; break; // ==================================================================== /// BRANCHES case INSTRUCTION_OPERATION_BRANCH: return "OP_BRANCH"; break; // ==================================================================== /// MEMORY OPERATIONS case INSTRUCTION_OPERATION_MEM_LOAD: return "OP_LOAD "; break; case INSTRUCTION_OPERATION_MEM_STORE: return "OP_STORE "; break; // ==================================================================== /// NOP or NOT IDENTIFIED case INSTRUCTION_OPERATION_NOP: return "OP_NOP "; break; case INSTRUCTION_OPERATION_OTHER: return "OP_OTHER "; break; // ==================================================================== /// SYNCHRONIZATION case INSTRUCTION_OPERATION_BARRIER: return "OP_BARRIER"; break; // ==================================================================== /// HMC case INSTRUCTION_OPERATION_HMC_ALU: return "OP_HMC_ALU"; break; case INSTRUCTION_OPERATION_HMC_ALUR: return "OP_HMC_ALUR"; break; }; ERROR_PRINTF("Wrong INSTRUCTION_OPERATION\n"); return "FAIL"; };
// ============================================================================ /// Enumerates the directory coherence protocol const char *get_enum_coherence_protocol_char(coherence_protocol_t type) { switch (type) { case COHERENCE_PROTOCOL_MOESI: return "MOESI"; break; }; ERROR_PRINTF("Wrong COHERENCE_PROTOCOL\n"); return "FAIL"; };
/** * Write multiple bytes to file or socket. * * @param file or socket descriptor * @param buffer to be written * @param number of bytes to write * @return number of bytes written (-2: error, -1: socket would have blocked, -3 EPIPE error) */ EXTERNAL int sysWriteBytes(int fd, char *buf, int cnt) { SYS_START(); TRACE_PRINTF("%s: sysWriteBytes %d %p %d\n", Me, fd, buf, cnt); #ifdef RVM_FOR_HARMONY return hyfile_write(fd, buf, cnt); #else while(1) { int rc = write(fd, buf, cnt); if (rc >= 0) return rc; int err = errno; if (err == EAGAIN) { TRACE_PRINTF("%s: write on %d would have blocked: needs retry\n", Me, fd); return -1; } else if (err == EINTR) { // interrupted by signal; try again } else if (err == EPIPE) { TRACE_PRINTF("%s: write on %d with nobody to read it\n", Me, fd); return -3; } else { ERROR_PRINTF("%s: write error %d (%s) on %d\n", Me, err, strerror( err ), fd); return -2; } } #endif // RVM_FOR_HARMONY }
// ============================================================================ /// Enumerates the policies to set the priority during the Row Buffer access const char *get_enum_request_priority_char(request_priority_t type) { switch (type) { case REQUEST_PRIORITY_ROW_BUFFER_HITS_FIRST: return "ROW_BUFFER_HITS_FIRST"; break; case REQUEST_PRIORITY_FIRST_COME_FIRST_SERVE: return "FIRST_COME_FIRST_SERVE"; break; }; ERROR_PRINTF("Wrong MEMORY_CONTROLLER REQUEST_PRIORITY\n"); return "FAIL"; };
// ============================================================================ /// Enumerates the policies to control the page (row buffer) inside the memory controller const char *get_enum_page_policy_char(page_policy_t type) { switch (type) { case PAGE_POLICY_OPEN_ROW: return "PAGE_POLICY_OPEN_ROW"; break; case PAGE_POLICY_CLOSE_ROW: return "PAGE_POLICY_CLOSE_ROW"; break; }; ERROR_PRINTF("Wrong MEMORY_CONTROLLER PAGE_POLICY\n"); return "FAIL"; };
// ============================================================================ /// Enumerates the way to treat memory dependencies. const char *get_enum_disambiguation_char(disambiguation_t type) { switch (type) { case DISAMBIGUATION_HASHED: return "HASHED"; break; case DISAMBIGUATION_DISABLE: return "DISABLE"; break; }; ERROR_PRINTF("Wrong SELECTION\n"); return "FAIL"; };
// ============================================================================ /// Enumerates the policies to give privilege of some operations over others const char *get_enum_write_priority_char(write_priority_t type) { switch (type) { case WRITE_PRIORITY_SERVICE_AT_NO_READ: return "SERVICE_AT_NO_READ"; break; case WRITE_PRIORITY_DRAIN_WHEN_FULL: return "DRAIN_WHEN_FULL"; break; }; ERROR_PRINTF("Wrong WRITE_PRIORITY\n"); return "FAIL"; };
// ============================================================================ /// Enumerates the prefetcher full buffer policy const char *get_enum_full_buffer_char(full_buffer_t type) { switch (type) { case FULL_BUFFER_OVERRIDE: return "FULL_BUFFER_OVERRIDE"; break; case FULL_BUFFER_STOP: return "FULL_BUFFER_STOP"; break; }; ERROR_PRINTF("Wrong FULL_BUFFER\n"); return "FAIL"; };
// ============================================================================ /// Enumerates the prefetcher type const char *get_enum_prefetch_policy_char(prefetch_policy_t type) { switch (type) { case PREFETCHER_STRIDE: return "STRIDE"; break; case PREFETCHER_STREAM: return "STREAM"; break; case PREFETCHER_DISABLE: return "DISABLE"; break; }; ERROR_PRINTF("Wrong PREFETCH_POLICY\n"); return "FAIL"; };
// ============================================================================ /// Enumerates the directory inclusiveness protocol const char *get_enum_inclusiveness_char(inclusiveness_t type) { switch (type) { case INCLUSIVENESS_NON_INCLUSIVE: return "NON_INCLUSIVE"; break; case INCLUSIVENESS_INCLUSIVE_LLC: return "INCLUSIVE_LLC"; break; case INCLUSIVENESS_INCLUSIVE_ALL: return "INCLUSIVE_ALL"; break; }; ERROR_PRINTF("Wrong INCLUSIVENESS\n"); return "FAIL"; };
// ============================================================================ /// Enumerates the routing algorithm const char *get_enum_routing_algorithm_char(routing_algorithm_t type) { switch (type) { case ROUTING_ALGORITHM_XY: return "XY"; break; case ROUTING_ALGORITHM_ODD_EVEN: return "ODD_EVEN"; break; case ROUTING_ALGORITHM_FLOYD_WARSHALL: return "FLOYD_WARSHALL"; break; }; ERROR_PRINTF("Wrong ROUTING_ALGORITHM\n"); return "FAIL"; };
// ============================================================================ /// Enumerates the selection policy to pick a sender or next to be treated. const char *get_enum_selection_char(selection_t type) { switch (type) { case SELECTION_RANDOM: return "RANDOM"; break; case SELECTION_ROUND_ROBIN: return "ROUND_ROBIN"; break; case SELECTION_BUFFER_LEVEL: return "BUFFER_LEVEL"; break; }; ERROR_PRINTF("Wrong SELECTION\n"); return "FAIL"; };
// ============================================================================ /// Enumerates the directory line lock status const char *get_enum_lock_char(lock_t type) { switch (type) { case LOCK_FREE: return "UNLOCK"; break; case LOCK_READ: return "LOCK_R"; break; case LOCK_WRITE: return "LOCK_W"; break; }; ERROR_PRINTF("Wrong LOCK\n"); return "FAIL"; };
// ============================================================================ /// Enumarates the data and instruction ports inside the processor const char *get_enum_processor_port_char(processor_port_t type) { switch (type) { case PROCESSOR_PORT_DATA_CACHE: return "DATA_PORT "; break; case PROCESSOR_PORT_INST_CACHE: return "INST_PORT "; break; case PROCESSOR_PORT_NUMBER: return "TOTAL_PORTS"; break; }; ERROR_PRINTF("Wrong PROCESSOR_PORT\n"); return "FAIL"; };
// ============================================================================ /// Enumerates the memory cache address mask const char *get_enum_cache_mask_char(cache_mask_t type) { switch (type) { case CACHE_MASK_TAG_INDEX_OFFSET: return "TAG_INDEX_OFFSET"; break; case CACHE_MASK_TAG_INDEX_BANK_OFFSET: return "TAG_INDEX_BANK_OFFSET"; break; case CACHE_MASK_TAG_BANK_INDEX_OFFSET: return "TAG_BANK_INDEX_OFFSET"; break; }; ERROR_PRINTF("Wrong CACHE_MASK\n"); return "FAIL"; };
/********************************************************************************** * Function : static rt_err_t ammeter_645_proxy(enum ammeter_uart_e Collector_port, enum ammeter_uart_e ammeter_port, rt_uint32_t format_time_out, rt_uint32_t byte_time_out) * Description: 接收采集器的数据发送到电表,并把电表返回的数据发送到采集器 * Arguments : (1)Collector_port:连接采集器的端口。(2)ammeter_port:连接电表的端口。 * (3)format_time_out:帧间隔超时时间(ms)。(4)byte_time_out:字节间隔超时时间(ms)。 * Return : RT_EOK *************************************************************************************/ static rt_err_t ammeter_645_proxy(enum ammeter_uart_e Collector_port, enum ammeter_uart_e ammeter_port, rt_uint32_t format_time_out, rt_uint32_t byte_time_out) { rt_err_t ret = RT_EOK; rt_uint8_t recv_buf[256] = {'\0'}; rt_uint32_t recv_len = 0; if (RT_EOK == recv_data_from_485(Collector_port, recv_buf, &recv_len, RT_WAITING_FOREVER, byte_time_out)) { #if DEBUG rt_uint32_t k = 0; printf_syn("\nrecv_len = %d\n", recv_len); printf_syn("recv buf: "); for (k= 0; k < recv_len; k++) { printf_syn("%x ", recv_buf[k]); } printf_syn("\n\n"); #endif ret = ammeter_mutex_take(ammeter_port, 1000); if(ret != RT_EOK) { ERROR_PRINTF(("ERROR: func:%s, line(%d)\n", __FUNCTION__, __LINE__)); return RT_ERROR; } send_data_by_485(get_485_port_from_ammeter_uart(ammeter_port), recv_buf, recv_len); rt_memset(recv_buf, 0, sizeof(recv_buf)); recv_len = 0; ret = recv_data_from_485(ammeter_port, recv_buf, &recv_len, format_time_out, byte_time_out); if(RT_EOK != ammeter_mutex_release(ammeter_port)) { ERROR_PRINTF(("ERROR: func:%s, line(%d)\n", __FUNCTION__, __LINE__)); return RT_ERROR; } if(ret == RT_EOK) { send_data_by_485(get_485_port_from_ammeter_uart(Collector_port), recv_buf, recv_len); } else { ERROR_PRINTF(("ERROR: func:%s, line(%d)\n", __FUNCTION__, __LINE__)); } } return RT_EOK; }
// ============================================================================ /// Enumerates the line usage predictor type const char *get_enum_line_usage_predictor_policy_char(line_usage_predictor_policy_t type) { switch (type) { case LINE_USAGE_PREDICTOR_POLICY_DISABLE: return "DISABLE"; break; case LINE_USAGE_PREDICTOR_POLICY_DEWP: return "DEWP"; break; case LINE_USAGE_PREDICTOR_POLICY_DEWP_ORACLE: return "DEWP_ORACLE"; break; case LINE_USAGE_PREDICTOR_POLICY_SKEWED: return "SKEWED"; break; }; ERROR_PRINTF("Wrong LINE_USAGE_PREDICTOR_POLICY\n"); return "FAIL"; };
// ============================================================================ /// Enumerates the prefetcher stride state const char *get_enum_prefetch_stride_state_char(prefetch_stride_state_t type) { switch (type) { case PREFETCHER_STRIDE_STATE_INIT: return "INIT"; break; case PREFETCHER_STRIDE_STATE_TRANSIENT: return "TRANSIENT"; break; case PREFETCHER_STRIDE_STATE_STEADY: return "STEADY"; break; case PREFETCHER_STRIDE_STATE_NO_PRED: return "NO_PRED"; break; }; ERROR_PRINTF("Wrong PREFETCHER_STRIDE_STATE\n"); return "FAIL"; };
// ============================================================================ /// Enumerates the prefetcher stream state const char *get_enum_prefetch_stream_state_char(prefetch_stream_state_t type) { switch (type) { case PREFETCHER_STREAM_STATE_INVALID: return "INVALID"; break; case PREFETCHER_STREAM_STATE_ALLOCATED: return "ALLOCATED"; break; case PREFETCHER_STREAM_STATE_TRAINING: return "TRAINING"; break; case PREFETCHER_STREAM_STATE_MONITOR_AND_REQUEST: return "MONITOR_AND_REQUEST"; break; }; ERROR_PRINTF("Wrong PREFETCHER_STREAM_STATE\n"); return "FAIL"; };
// ============================================================================ /// Enumerates the coherence protocol status const char *get_enum_protocol_status_char(protocol_status_t type) { switch (type) { case PROTOCOL_STATUS_M: return "MODF"; break; case PROTOCOL_STATUS_O: return "OWNR"; break; case PROTOCOL_STATUS_E: return "EXCL"; break; case PROTOCOL_STATUS_S: return "SHRD"; break; case PROTOCOL_STATUS_I: return "INVD"; break; }; ERROR_PRINTF("Wrong PROTOCOL_STATUS\n"); return "FAIL"; };
// ============================================================================ /// Enumerates the package status when it arrives on the components const char *get_enum_package_state_char(package_state_t type) { switch (type) { case PACKAGE_STATE_FREE: return "FREE "; break; case PACKAGE_STATE_UNTREATED: return "UNTD "; break; case PACKAGE_STATE_READY: return "READY"; break; case PACKAGE_STATE_WAIT: return "WAIT "; break; case PACKAGE_STATE_TRANSMIT: return "XMIT "; break; }; ERROR_PRINTF("Wrong PACKAGE_STATE\n"); return "FAIL"; };
// ============================================================================ /// Enumerates the valid sub-block type const char *get_enum_line_prediction_t_char(line_prediction_t type) { switch (type) { case LINE_PREDICTION_TURNOFF: return "DISABLE"; break; case LINE_PREDICTION_NORMAL: return "NORMAL"; break; case LINE_PREDICTION_LEARN: return "LEARN"; break; case LINE_PREDICTION_WRONG_FIRST: return "WRONG"; break; case LINE_PREDICTION_WRITEBACK: return "WRITEBACK"; break; }; ERROR_PRINTF("Wrong LINE_PREDICTION\n"); return "FAIL"; };
// ============================================================================ /// Enumerates the synchronization type required by the dynamic trace. const char *get_enum_sync_char(sync_t type) { switch (type) { case SYNC_BARRIER: return "BARRIER"; break; case SYNC_WAIT_CRITICAL_START: return "WAIT_CRITICAL_START"; break; case SYNC_CRITICAL_START: return "CRITICAL_START"; break; case SYNC_CRITICAL_END: return "CRITICAL_END"; break; case SYNC_FREE: return "SYNC_FREE"; break; }; ERROR_PRINTF("Wrong SYNC\n"); return "FAIL"; };
// ============================================================================ /// Enumerates the cache replacement policy const char *get_enum_replacement_char(replacement_t type) { switch (type) { case REPLACEMENT_LRU: return "LRU"; break; case REPLACEMENT_DEAD_OR_LRU: return "DEAR_OR_LRU"; break; case REPLACEMENT_INVALID_OR_LRU: return "INVALID_OR_LRU"; break; case REPLACEMENT_RANDOM: return "RANDOM"; break; case REPLACEMENT_FIFO: return "FIFO"; break; case REPLACEMENT_LRF: return "LRF"; break; }; ERROR_PRINTF("Wrong REPLACEMENT\n"); return "FAIL"; };
// ============================================================================ /// Enumerates the memory controller commands to the DRAM const char *get_enum_memory_controller_command_char(memory_controller_command_t type) { switch (type) { case MEMORY_CONTROLLER_COMMAND_PRECHARGE: return "PRECHARGE"; break; case MEMORY_CONTROLLER_COMMAND_ROW_ACCESS: return "ROW_ACCESS"; break; case MEMORY_CONTROLLER_COMMAND_COLUMN_READ: return "COLUMN_READ"; break; case MEMORY_CONTROLLER_COMMAND_COLUMN_WRITE: return "COLUMN_WRITE"; break; case MEMORY_CONTROLLER_COMMAND_NUMBER: return "NUMBER"; break; }; ERROR_PRINTF("Wrong MEMORY_CONTROLLER_COMMAND\n"); return "FAIL"; };
// ============================================================================ /// Enumerates the processor stages, used to indicate when the branch will be solved const char *get_enum_processor_stage_char(processor_stage_t type) { switch (type) { case PROCESSOR_STAGE_FETCH: return "FETCH "; break; case PROCESSOR_STAGE_DECODE: return "DECODE "; break; case PROCESSOR_STAGE_RENAME: return "RENAME "; break; case PROCESSOR_STAGE_DISPATCH: return "DISPATCH "; break; case PROCESSOR_STAGE_EXECUTION: return "EXECUTION"; break; case PROCESSOR_STAGE_COMMIT: return "COMMIT "; break; }; ERROR_PRINTF("Wrong PROCESSOR_STAGE\n"); return "FAIL"; };
// ============================================================================ /// Enumerates the main memory address mask const char *get_enum_memory_controller_mask_char(memory_controller_mask_t type) { switch (type) { case MEMORY_CONTROLLER_MASK_ROW_BANK_COLROW_COLBYTE: return "ROW_BANK_COLROW_COLBYTE"; break; case MEMORY_CONTROLLER_MASK_ROW_BANK_CHANNEL_COLROW_COLBYTE: return "ROW_BANK_CHANNEL_COLROW_COLBYTE"; break; case MEMORY_CONTROLLER_MASK_ROW_BANK_CHANNEL_CTRL_COLROW_COLBYTE: return "ROW_BANK_CHANNEL_CTRL_COLROW_COLBYTE"; break; case MEMORY_CONTROLLER_MASK_ROW_BANK_COLROW_CHANNEL_COLBYTE: return "ROW_BANK_COLROW_CHANNEL_COLBYTE"; break; case MEMORY_CONTROLLER_MASK_ROW_BANK_COLROW_CTRL_CHANNEL_COLBYTE: return "ROW_BANK_COLROW_CTRL_CHANNEL_COLBYTE"; break; case MEMORY_CONTROLLER_MASK_ROW_CTRL_BANK_COLROW_COLBYTE: return "ROW_CTRL_BANK_COLROW_COLBYTE,"; break; case MEMORY_CONTROLLER_MASK_ROW_COLROW_BANK_CHANNEL_COLBYTE: return "ROW_COLROW_BANK_CHANNEL_COLBYTE"; break; }; ERROR_PRINTF("Wrong MEMORY_CONTROLLER_MASK\n"); return "FAIL"; };
/********************************************************************************** * Function : static void ammeter_645_proxy_thread_entry(void* parameter) * Description: 透传数据线程入口函数 * Arguments : void * Return : void *************************************************************************************/ static void ammeter_645_proxy_thread_entry(void* parameter) { int ret = RT_ERROR; while (1) { ret = ammeter_645_proxy(AMMETER_UART3, AMMETER_UART1, 500, 100); if(ret != RT_EOK) { ERROR_PRINTF(("ERROR: func:%s, line(%d)\n", __FUNCTION__, __LINE__)); return; } } return; }