const char * yard_ice_get_prompt(void) { int status; status = target_status(); return (char * )prompt_tab[status + 4]; }
/* * Read the specified status registers and return their values. * * status: array of id-value pairs. Each <id> specifies a status register, * i.e, one of MSM_RPM_STATUS_ID_xxxx. Upon return, each <value> will * contain the value of the status register. * count: number of id-value pairs in the array * * Return value: * 0: success * -EBUSY: RPM is updating the status page; values across different registers * may not be consistent * -EINVAL: invalid id in <status> array * -ENODEV: RPM driver not initialized */ int msm_rpm_get_status(struct msm_rpm_iv_pair *status, int count) { uint32_t seq_begin; uint32_t seq_end; int rc; int i; seq_begin = msm_rpm_read(MSM_RPM_PAGE_STATUS, target_status(MSM_RPM_STATUS_ID_SEQUENCE)); for (i = 0; i < count; i++) { int target_status_id; if (status[i].id >= MSM_RPM_STATUS_ID_LAST) { pr_err("%s(): Status ID beyond limits\n", __func__); rc = -EINVAL; goto get_status_exit; } target_status_id = target_status(status[i].id); if (target_status_id >= MSM_RPM_STATUS_ID_LAST) { pr_err("%s(): Status id %d not defined for target\n", __func__, target_status_id); rc = -EINVAL; goto get_status_exit; } status[i].value = msm_rpm_read(MSM_RPM_PAGE_STATUS, target_status_id); } seq_end = msm_rpm_read(MSM_RPM_PAGE_STATUS, target_status(MSM_RPM_STATUS_ID_SEQUENCE)); rc = (seq_begin != seq_end || (seq_begin & 0x01)) ? -EBUSY : 0; get_status_exit: return rc; }
int __init msm_rpm_init(struct msm_rpm_platform_data *data) { int rc; memcpy(&msm_rpm_data, data, sizeof(struct msm_rpm_platform_data)); msm_rpm_sel_mask_size = msm_rpm_data.sel_last / 32 + 1; BUG_ON(SEL_MASK_SIZE < msm_rpm_sel_mask_size); fw_major = msm_rpm_read(MSM_RPM_PAGE_STATUS, target_status(MSM_RPM_STATUS_ID_VERSION_MAJOR)); fw_minor = msm_rpm_read(MSM_RPM_PAGE_STATUS, target_status(MSM_RPM_STATUS_ID_VERSION_MINOR)); fw_build = msm_rpm_read(MSM_RPM_PAGE_STATUS, target_status(MSM_RPM_STATUS_ID_VERSION_BUILD)); pr_info("%s: RPM firmware %u.%u.%u\n", __func__, fw_major, fw_minor, fw_build); if (fw_major != msm_rpm_data.ver[0]) { pr_err("%s: RPM version %u.%u.%u incompatible with " "this driver version %u.%u.%u\n", __func__, fw_major, fw_minor, fw_build, msm_rpm_data.ver[0], msm_rpm_data.ver[1], msm_rpm_data.ver[2]); return -EFAULT; } msm_rpm_write(MSM_RPM_PAGE_CTRL, target_ctrl(MSM_RPM_CTRL_VERSION_MAJOR), msm_rpm_data.ver[0]); msm_rpm_write(MSM_RPM_PAGE_CTRL, target_ctrl(MSM_RPM_CTRL_VERSION_MINOR), msm_rpm_data.ver[1]); msm_rpm_write(MSM_RPM_PAGE_CTRL, target_ctrl(MSM_RPM_CTRL_VERSION_BUILD), msm_rpm_data.ver[2]); rc = request_irq(data->irq_ack, msm_rpm_ack_interrupt, IRQF_TRIGGER_RISING | IRQF_NO_SUSPEND, "rpm_drv", msm_rpm_ack_interrupt); if (rc) { pr_err("%s: failed to request irq %d: %d\n", __func__, data->irq_ack, rc); return rc; } rc = irq_set_irq_wake(data->irq_ack, 1); if (rc) { pr_err("%s: failed to set wakeup irq %u: %d\n", __func__, data->irq_ack, rc); return rc; } rc = request_irq(data->irq_err, msm_rpm_err_interrupt, IRQF_TRIGGER_RISING, "rpm_err", NULL); if (rc) { pr_err("%s: failed to request error interrupt: %d\n", __func__, rc); return rc; } rc = request_irq(data->irq_wakeup, msm_pm_rpm_wakeup_interrupt, IRQF_TRIGGER_RISING, "pm_drv", msm_pm_rpm_wakeup_interrupt); if (rc) { pr_err("%s: failed to request irq %u: %d\n", __func__, data->irq_wakeup, rc); return rc; } rc = irq_set_irq_wake(data->irq_wakeup, 1); if (rc) { pr_err("%s: failed to set wakeup irq %u: %d\n", __func__, data->irq_wakeup, rc); return rc; } msm_rpm_populate_map(data); return platform_driver_register(&msm_rpm_platform_driver); }
static int rsp_last_signal(struct gdb_rspd * gdb, struct tcp_pcb * tp, char * pkt, int len) { int state; state = target_status(); if (state < DBG_ST_CONNECTED) { DCC_LOG(LOG_WARNING, "target not connected!"); return rsp_error(tp, state); } if (state != DBG_ST_HALTED) { DCC_LOG(LOG_TRACE, "running"); if ((state = target_halt(0)) < 0) { DCC_LOG(LOG_WARNING, "target_halt() failed!"); rsp_msg(tp, pkt, "YARD-ICE: halt fail\n"); return rsp_error(tp, 1); } if ((state = target_halt_wait(500)) == ERR_TIMEOUT) { DCC_LOG(LOG_TRACE, "timeout..."); rsp_msg(tp, pkt, "YARD-ICE: target_halt failed!"); return rsp_error(tp, 1); } } if (state == DBG_ST_HALTED) { DCC_LOG(LOG_TRACE, "halted"); thinkos_flag_clr(gdb->run_flag); return rsp_signal(tp, pkt, SIGTRAP); } switch (state) { case DBG_ST_ERROR: rsp_msg(tp, pkt, "YARD-ICE: error state\n"); break; case DBG_ST_OUTOFSYNC: DCC_LOG(LOG_TRACE, "out of sync"); rsp_msg(tp, pkt, "YARD-ICE: Out of sync\n"); break; case DBG_ST_BUSY: DCC_LOG(LOG_TRACE, "busy..."); rsp_msg(tp, pkt, "YARD-ICE: busy ... \n"); break; case DBG_ST_UNDEF: rsp_msg(tp, pkt, "YARD-ICE: undefined state\n"); break; case DBG_ST_UNCONNECTED: DCC_LOG(LOG_TRACE, "unconnected"); rsp_msg(tp, pkt, "YARD-ICE: unconnected ?\n"); break; case DBG_ST_CONNECTED: DCC_LOG(LOG_TRACE, "connected"); rsp_msg(tp, pkt, "YARD-ICE: connected (busy)\n"); break; case DBG_ST_RUNNING: DCC_LOG(LOG_TRACE, "running"); rsp_msg(tp, pkt, "YARD-ICE: running\n"); thinkos_flag_set(gdb->run_flag); break; default: DCC_LOG1(LOG_WARNING, "unknown state: %d", state); rsp_msg(tp, pkt, "YARD-ICE: unknown state, bailing out!\n"); return -1; } return rsp_error(tp, 1); }
Result NaiveSolver::SolveNonMILP(const Scenario &scen) { nlog.Reset(); Result r(scen.phone_count); // Create global required data info. typedef std::vector<std::vector<double> > DataInfo_t; DataInfo_t phone_datas(scen.phone_count, std::vector<double>(scen.target_count, 0.0)); // Create target status. // False: not uploaded yet. True: uploaded. std::vector<bool> target_status(scen.target_count, false); std::vector<double> data_remain(scen.target_count, 1.0); // Copy phones upload limits. std::vector<double> upload_limits(scen.phone_count, 0.0); for (int i = 0; i < scen.phone_count; ++i) { upload_limits[i] = scen.phones[i].upload_limit_; } // Simulate walk. nlog << "\n"; nlog << "*********************************************\n"; nlog << "Start simulated walk: \n"; nlog << "*********************************************\n"; for (int t = 0; t < scen.running_time; ++t) { nlog << "\n"; nlog << "*********************************************\n"; nlog << "Time: " << t << ":\n"; const ThreeDimVector<int> &am = scen.adj_mats; const ThreeDimVector<double> &dm = scen.data_mats; for (int i = 0; i < scen.phone_count; ++i) { DataInfo_t &di = phone_datas; // Check if we can sense any target. for (int j = 0; j < scen.target_count; ++j) { // Target j's id in adj mat is phone count + j if (am(t, i, scen.phone_count + j) == 1 && target_status[j] == false) { if (di[i][j] < data_remain[j]) { // Target j is not fully uploaded and we do not // have full data in data storage. // Sense the target and save the data. nlog << "Phone " << i << " sense target " << j << ".\n"; double sensing_cost = scen.phones[i].costs_.sensing_cost; r.AddCost(i, sensing_cost, Cost::SENSING); di[i][j] = data_remain[j]; } } } bool empty_storage = true; for (int j = 0; j < scen.target_count; ++j) { if (di[i][j] > 0) { empty_storage = false; break; } } // Check if we have data that can be transferred. if (!empty_storage) { // There is data can be transferred. // Check if we can upload the data we have. for (int j = 0; j < scen.target_count; ++j) { assert(di[i][j] >= 0.0); if (di[i][j] == 0.0) continue; if (upload_limits[i] == 0.0) break; double upload_amount; if (di[i][j] > upload_limits[i]) { // Only be able to upload part of the data. upload_amount = upload_limits[i]; upload_limits[i] = 0.0; } else { // Can upload all the data. // The corresponding target data is uploaded. upload_amount = di[i][j]; upload_limits[i] -= di[i][j]; } nlog << "Phone " << i << " uploads part of target " << j << ", upload amount: " << upload_amount << ".\n"; assert(di[i][j] <= data_remain[j]); // Update global required data info. for (int k = 0; k < scen.phone_count; ++k) { if (di[k][j] > 0) { di[k][j] = (di[k][j] > upload_amount) ? (di[k][j] - upload_amount) : 0.0; } } data_remain[j] -= upload_amount; if (data_remain[j] == 0.0) { target_status[j] = true; } double upload_cost = scen.phones[i].costs_.upload_cost * upload_amount; r.AddCost(i, upload_cost, Cost::UPLOAD); } // We may have uploaded all the data. empty_storage = true; for (int j = 0; j < scen.target_count; ++j) { if (di[i][j] > 0) { empty_storage = false; break; } } if (empty_storage) { continue; } // Check if there is an available neighbor. double amount_transferred = 0.0; for (int j = 0; j < scen.phone_count; ++j) { if (i != j && am(t, i, j) == 1) { for (int k = 0; k < scen.target_count; ++k) { // Search on phone j to see if phone j already // has the data. Only transfer the data phone j // does not have. if (di[i][k] > di[j][k]) { double data_transferred = di[i][k] - di[j][k]; double comm_cost1 = scen.phones[i].costs_.transfer_cost * data_transferred; double comm_cost2 = scen.phones[j].costs_.transfer_cost * data_transferred; di[j][k] = di[i][k]; amount_transferred += data_transferred; r.AddCost(i, comm_cost1, Cost::COMM); r.AddCost(j, comm_cost2, Cost::COMM); nlog << "Phone " << i << " copy data of target " << k << " to phone " << j << ", transfer amount: " << data_transferred << ".\n"; } } // break; // allow only one transfer. } } // End of for (int j } // End of if (!di.empty()) } // End of for (int i // Check if all target datas are uploaded bool all_upload = true; for (int i = 0; i < scen.target_count; ++i) { if (target_status[i] == false) { all_upload = false; break; } } if (all_upload == true) { break; nlog << "All set. Exit loop.\n"; } } // End of for (int t // Check if all target datas are uploaded bool all_upload = true; for (int i = 0; i < scen.target_count; ++i) { if (target_status[i] == false) { all_upload = false; break; } } if (!all_upload) { r.is_valid = false; // infeasible r.is_optimal = false; } else { r.is_valid = true; // valid r.is_optimal = true; } return r; }
Result NaiveSolver::SolveMILP(const Scenario &scen) { nlog.Reset(); Result r(scen.phone_count); // Create global required data info. // (i, j): celluar tower's knowledge on how much more data // of target j sensed by phone i has yet to be uploaded. // Initialized with 1.0: all need to be uploaded. DataInfo data_required; for (int i = 0; i < scen.phone_count; ++i) { for (int j = 0; j < scen.target_count; ++j) { data_required[std::make_pair(i, j)] = 1.0; } } // Create target status. // False: not uploaded yet. True: uploaded. std::vector<bool> target_status(scen.target_count, false); // Create phone data matrix // Each phone has a data info matrix indicating // how much sensing data (associated with phones) it currently has. std::vector<DataInfo> phone_datas(scen.phone_count); // Copy phones upload limits. std::vector<double> upload_limits(scen.phone_count, 0.0); for (int i = 0; i < scen.phone_count; ++i) { upload_limits[i] = scen.phones[i].upload_limit_; } // Simulate walk. nlog << "\n"; nlog << "*********************************************\n"; nlog << "Start simulated walk: \n"; nlog << "*********************************************\n"; for (int t = 0; t < scen.running_time; ++t) { nlog << "\n"; nlog << "*********************************************\n"; nlog << "Time: " << t << ":\n"; const ThreeDimVector<int> &am = scen.adj_mats; const ThreeDimVector<double> &dm = scen.data_mats; for (int i = 0; i < scen.phone_count; ++i) { DataInfo &di = phone_datas[i]; // Update data storage as all or part of targets' data // may have been uploaded. //nlog << "Phone " << i << " update data storage...\n"; if (!di.empty()) { for (DataInfo::iterator it = di.begin(); it != di.end();) { int tid = (*it).first.second; if (target_status[tid] == true) { di.erase(it++); } else { double data = (*it).second; std::pair<int, int> phone_target = (*it).first; if (data > data_required[phone_target]) { (*it).second = data_required[phone_target]; } ++it; } } } // Check if we can sense any target. for (int j = 0; j < scen.target_count; ++j) { // Target j's id in adj mat is phone count + j if (am(t, i, scen.phone_count + j) == 1 && target_status[j] == false) { DataInfo::iterator find_it = di.find(std::make_pair(i, j)); if (find_it == di.end()) { // Target j is not fully uploaded and is not // in data storage. // Sense the target and save the data. nlog << "Phone " << i << " sense target " << j << ".\n"; double sensing_cost = scen.phones[i].costs_.sensing_cost; r.AddCost(i, sensing_cost, Cost::SENSING); di[std::make_pair(i, j)] = data_required[std::make_pair(i, j)]; } } } // Check if we have data that can be transferred. if (!di.empty()) { // There is data can be transferred. // Check if we can upload the data we have. for (DataInfo::iterator it = di.begin(); upload_limits[i] > 0 && it != di.end();) { // Data amount is (*it).second if ((*it).second > upload_limits[i]) { // Only be able to upload part of the data. nlog << "Phone " << i << " uploads part of target " << (*it).first.second << ", upload amount: " << upload_limits[i] << ".\n"; (*it).second -= upload_limits[i]; double upload_cost = scen.phones[i].costs_.upload_cost * upload_limits[i]; r.AddCost(i, upload_cost, Cost::UPLOAD); // Update global required data info. if ((*it).second < data_required[(*it).first]) { data_required[(*it).first] = (*it).second; } // Upload limit is used up. upload_limits[i] = 0.0; break; } else { // Can upload all the data. // The corresponding target data is uploaded. nlog << "Phone " << i << " uploads all of (" << (*it).first.first << "," << (*it).first.second << "), upload amount: " << (*it).second << ".\n"; int tid = (*it).first.second; target_status[tid] = true; // Remove this data from storage. upload_limits[i] -= (*it).second; double upload_cost = scen.phones[i].costs_.upload_cost * (*it).second; r.AddCost(i, upload_cost, Cost::UPLOAD); di.erase(it++); } } // We may have uploaded all the data. if (di.empty()) { continue; } // Check if there is an available neighbor. double amount_transferred = 0.0; for (int j = 0; j < scen.phone_count; ++j) { if (i != j && am(t, i, j) == 1) { for (DataInfo::iterator it = di.begin(); it != di.end() && amount_transferred < dm(t, i, j); ++it) { // Search on phone j to see if phone j already // has the data. Only transfer the data phone j // does not have. DataInfo::iterator find_it = phone_datas[j].find((*it).first); if (find_it == phone_datas[j].end()) { // Assume all the data for current target can be // transferred. (all dm[i][j] >= 1.0) nlog << "Phone " << i << " copy all of (" << (*it).first.first << "," << (*it).first.second << ") to phone " << j << ", transfer amount: " << data_required[(*it).first] << ".\n"; double data_transferred = data_required[(*it).first]; double comm_cost1 = scen.phones[i].costs_.transfer_cost * data_transferred; double comm_cost2 = scen.phones[j].costs_.transfer_cost * data_transferred; phone_datas[j][(*it).first] = data_transferred; amount_transferred += data_transferred; r.AddCost(i, comm_cost1, Cost::COMM); r.AddCost(j, comm_cost2, Cost::COMM); } } // break; // allow only one transfer. } } // End of for (int j } // End of if (!di.empty()) } // End of for (int i // Check if all target datas are uploaded bool all_upload = true; for (int i = 0; i < scen.target_count; ++i) { if (target_status[i] == false) { all_upload = false; break; } } if (all_upload == true) { break; nlog << "All set. Exit loop.\n"; } } // End of for (int t // Check if all target datas are uploaded bool all_upload = true; for (int i = 0; i < scen.target_count; ++i) { if (target_status[i] == false) { all_upload = false; break; } } if (!all_upload) { r.is_valid = false; // infeasible r.is_optimal = false; } else { r.is_valid = true; // valid r.is_optimal = true; } return r; }
int __init msm_rpm_init(struct msm_rpm_platform_data *data) { int rc; memcpy(&msm_rpm_data, data, sizeof(struct msm_rpm_platform_data)); msm_rpm_stat_data = (stats_blob *)msm_rpm_data.reg_base_addrs[MSM_RPM_PAGE_STAT]; msm_rpm_sel_mask_size = msm_rpm_data.sel_last / 32 + 1; BUG_ON(SEL_MASK_SIZE < msm_rpm_sel_mask_size); #ifndef CONFIG_ARCH_MSM8X60 if ((get_radio_flag() & KERNEL_FLAG_APPSBARK) && msm_rpm_stat_data) msm_rpm_stat_data->rpm_debug_mode |= RPM_DEBUG_RAM_DUMP; if ((get_kernel_flag() & KERNEL_FLAG_PM_MONITOR) && msm_rpm_stat_data) msm_rpm_stat_data->rpm_debug_mode |= RPM_DEBUG_POWER_MEASUREMENT; if ((get_kernel_flag() & KERNEL_FLAG_RPM_DISABLE_WATCHDOG) && msm_rpm_stat_data) msm_rpm_stat_data->rpm_debug_mode |= RPM_DEBUG_DISABLE_WATCHDOG; #endif fw_major = msm_rpm_read(MSM_RPM_PAGE_STATUS, target_status(MSM_RPM_STATUS_ID_VERSION_MAJOR)); fw_minor = msm_rpm_read(MSM_RPM_PAGE_STATUS, target_status(MSM_RPM_STATUS_ID_VERSION_MINOR)); fw_build = msm_rpm_read(MSM_RPM_PAGE_STATUS, target_status(MSM_RPM_STATUS_ID_VERSION_BUILD)); /*pr_info("%s: RPM firmware %u.%u.%u\n", __func__, fw_major, fw_minor, fw_build);*/ if (fw_major != msm_rpm_data.ver[0]) { /*pr_err("%s: RPM version %u.%u.%u incompatible with " "this driver version %u.%u.%u\n", __func__, fw_major, fw_minor, fw_build, msm_rpm_data.ver[0], msm_rpm_data.ver[1], msm_rpm_data.ver[2]);*/ return -EFAULT; } msm_rpm_write(MSM_RPM_PAGE_CTRL, target_ctrl(MSM_RPM_CTRL_VERSION_MAJOR), msm_rpm_data.ver[0]); msm_rpm_write(MSM_RPM_PAGE_CTRL, target_ctrl(MSM_RPM_CTRL_VERSION_MINOR), msm_rpm_data.ver[1]); msm_rpm_write(MSM_RPM_PAGE_CTRL, target_ctrl(MSM_RPM_CTRL_VERSION_BUILD), msm_rpm_data.ver[2]); rc = request_irq(data->irq_ack, msm_rpm_ack_interrupt, IRQF_TRIGGER_RISING | IRQF_NO_SUSPEND, "rpm_drv", msm_rpm_ack_interrupt); if (rc) { /*pr_err("%s: failed to request irq %d: %d\n", __func__, data->irq_ack, rc);*/ return rc; } rc = irq_set_irq_wake(data->irq_ack, 1); if (rc) { /*pr_err("%s: failed to set wakeup irq %u: %d\n", __func__, data->irq_ack, rc);*/ return rc; } rc = request_irq(data->irq_err, msm_rpm_err_interrupt, IRQF_TRIGGER_RISING, "rpm_err", NULL); if (rc) { /*pr_err("%s: failed to request error interrupt: %d\n", __func__, rc);*/ return rc; } rc = request_irq(data->irq_wakeup, msm_pm_rpm_wakeup_interrupt, IRQF_TRIGGER_RISING, "pm_drv", msm_pm_rpm_wakeup_interrupt); if (rc) { /*pr_err("%s: failed to request irq %u: %d\n", __func__, data->irq_wakeup, rc);*/ return rc; } rc = irq_set_irq_wake(data->irq_wakeup, 1); if (rc) { /*pr_err("%s: failed to set wakeup irq %u: %d\n", __func__, data->irq_wakeup, rc);*/ return rc; } msm_rpm_populate_map(data); msm_rpm_print_sleep_tick(); return platform_driver_register(&msm_rpm_platform_driver); }