inline void msm5832_device::advance_minutes() { int minutes = read_counter(REGISTER_MI1); int hours = read_counter(REGISTER_H1); int days = read_counter(REGISTER_D1); int month = read_counter(REGISTER_MO1); int year = read_counter(REGISTER_Y1); int day_of_week = m_reg[REGISTER_W]; minutes++; if (minutes > 59) { minutes = 0; hours++; } if (hours > 23) { hours = 0; days++; day_of_week++; } if (day_of_week > 6) { day_of_week++; } if (days > DAYS_PER_MONTH[month - 1]) { days = 1; month++; } if (month > 12) { month = 1; year++; } if (year > 99) { year = 0; } write_counter(REGISTER_MI1, minutes); write_counter(REGISTER_H1, hours); write_counter(REGISTER_D1, days); write_counter(REGISTER_MO1, month); write_counter(REGISTER_Y1, year); m_reg[REGISTER_W] = day_of_week; }
inline void msm5832_device::advance_seconds() { int seconds = read_counter(REGISTER_S1); seconds++; if (seconds > 59) { seconds = 0; advance_minutes(); } write_counter(REGISTER_S1, seconds); }
void msm58321_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) { write_counter(REGISTER_Y1, year); write_counter(REGISTER_MO1, month); write_counter(REGISTER_D1, day); m_reg[REGISTER_W] = day_of_week; write_counter(REGISTER_H1, hour); write_counter(REGISTER_MI1, minute); write_counter(REGISTER_S1, second); }
/* * Multiple writes with same key must be processed in the same order as * they were initiated by client. * * Following test checks this mechanics by calling write_cas() with data containing * counter that is incremented after every write_cas() and checking that previosly stored * counter is one unit less than current counter. Also this test writes multiple different * keys (with repetitions) in different order, thereby modelling real workload case. */ static void test_write_order_execution(session &sess) { const int num_write_repetitions = 5; const int num_different_keys = 10; std::vector<std::pair<key, int>> keys; for (int i = 0; i < num_different_keys; ++i) { key id(std::to_string(static_cast<unsigned long long>(i))); for (int j = 0; j < num_write_repetitions; ++j) { keys.push_back(std::make_pair(id, i)); } } std::unique_ptr<async_write_result[]> results(new async_write_result[keys.size()]); dnet_id old_csum; const int num_iterations = 30; for (int i = 0; i < num_iterations; ++i) { // every key is associated with counter, which is initialized by zero std::vector<int> write_counter(num_different_keys, 0); std::random_shuffle(keys.begin(), keys.end()); for (size_t j = 0; j < keys.size(); ++j) { // increment counter associated with key identified by key_id const int key_id = keys[j].second; const int new_value = write_counter[key_id]++; if (new_value > 0) { const int prev_value = new_value - 1; memset(&old_csum, 0, sizeof(old_csum)); sess.transform(std::to_string(static_cast<unsigned long long>(prev_value)), old_csum); results[j] = std::move(sess.write_cas(keys[j].first, std::to_string(static_cast<unsigned long long>(new_value)), old_csum, 0)); } else { // first write results[j] = std::move(sess.write_data(keys[j].first, std::to_string(static_cast<unsigned long long>(new_value)), 0)); } } for (size_t j = 0; j < keys.size(); ++j) { results[j].wait(); const int err = results[j].error().code(); BOOST_REQUIRE_MESSAGE(err == 0, "write_cas() failed (err=" + std::to_string(static_cast<unsigned long long>(err)) + "): " "multiple consecutive writes are executed out-of-order " "or overlapped. Oplock mechanism of backend's request queue is broken."); } } }
void msm5832_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) { if (LOG) logerror("MSM5832 Clock Update: %d.%d.%d %d %d:%d:%d\n", year, month, day, day_of_week, hour, minute, second); write_counter(REGISTER_Y1, year); write_counter(REGISTER_MO1, month); write_counter(REGISTER_D1, day); m_reg[REGISTER_W] = day_of_week-1; write_counter(REGISTER_H1, hour); write_counter(REGISTER_MI1, minute); write_counter(REGISTER_S1, second); }
void hd64610_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) { write_counter(REG_SECOND, second); write_counter(REG_MINUTE, minute); write_counter(REG_HOUR, hour); write_counter(REG_DAY, day); write_counter(REG_MONTH, month); write_counter(REG_YEAR, year); m_regs[REG_DAY_OF_THE_WEEK] = day_of_week; check_alarm(); set_irq_line(); }
void rp5c01_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) { m_reg[MODE01][REGISTER_LEAP_YEAR] = year % 4; write_counter(REGISTER_1_YEAR, year); write_counter(REGISTER_1_MONTH, month); write_counter(REGISTER_1_DAY, day); m_reg[MODE00][REGISTER_DAY_OF_THE_WEEK] = day_of_week; write_counter(REGISTER_1_HOUR, hour); write_counter(REGISTER_1_MINUTE, minute); write_counter(REGISTER_1_SECOND, second); check_alarm(); set_alarm_line(); }