Esempio n. 1
0
void mc146818_device::set_base_datetime()
{
	system_time systime;
	system_time::full_time current_time;

	machine().base_datetime(systime);

	current_time = (m_use_utc) ? systime.utc_time: systime.local_time;

//  logerror("mc146818_set_base_datetime %02d/%02d/%02d %02d:%02d:%02d\n",
//          current_time.year % 100, current_time.month + 1, current_time.mday,
//          current_time.hour,current_time.minute, current_time.second);

	set_seconds(current_time.second);
	set_minutes(current_time.minute);
	set_hours(current_time.hour);
	set_dayofweek(current_time.weekday + 1);
	set_dayofmonth(current_time.mday);
	set_month(current_time.month + 1);

	if(m_binyear)
		set_year((current_time.year - m_epoch) % (m_data[REG_B] & REG_B_DM ? 0x100 : 100)); // pcd actually depends on this
	else
		set_year((current_time.year - m_epoch) % 100);

	if (m_century_index >= 0)
		m_data[m_century_index] = to_ram(current_time.year / 100);
}
Esempio n. 2
0
int main(int argc, char** argv){
    struct timeval tv;

    if(argc > 4 || parseargs(argc, argv) == 0)
      return -1;

    /* This starts the xuartctl daemon TODO - Should we start it */
    /*  printf("Starting xuartctl...");*/
    /*  fflush(stdout);*/
    /*  system("xuartctl -d -p 0 -o 8n1 -s 9600");*/
    /*  printf("done\n");*/

    printf("Starting gps with device %s\n", gps_device);
    uart_init( 0, stderr, gps_device);

    original_tries = tries;
    for(;!is_gps_ready(); tries--)
      {
        if(tries <= 0)
          {
            fprintf(stderr, "Number of tries limit of %u was reached. Returning error -1\n", original_tries);
            return -1;
          }
        sleep(1);
      }

    printf("GPS is ready. Reading value and setting it in kernel.\n");
    switch(getGPStimeUTC(&tv)){
      case 1:
        fprintf(stderr, "Unable to read time from GPS (Error 1)\n");
        return -1;
      case 2:
        fprintf(stderr, "An error occured while waiting for a time reply (Error 2)\n");
        return -1;
    }


    printf("GPS returned with UNIX seconds: %ld\n", tv.tv_sec);
    // set miavita time
    set_seconds((uint64_t) tv.tv_sec); /* Set's the seconds in the miavia counter in the kernel cat ts7500_kernel/ipc/miavita_syscall.c:sys_miavitasetseconds */
    printf("Seconds set in the miavita kernel variable: %lu\n", get_mean_value());

    printf("Now I'm going to set the current date to the OS\n");
    printf("Time at before setting:\n");
    print_time();

    // set system time
    time_t seconds_time = (time_t) tv.tv_sec;
    stime(&seconds_time);

    sleep(2);
    printf("Time at after setting:\n");
    print_time();

    printf("Program finished without errors.\n");
    return 0;
}
//##############################################################################
//##############################################################################
void
BerkeleyDB::add_new_range_version()
{
    RANGE_LOG_FUNCTION();
    this->init_info();
    auto lock = info_->write_lock(record_type::GRAPH_META, "graph_list");

    std::string buf = info_->get_record(record_type::GRAPH_META,
            "range_changelist");
    ChangeList changes;
    if(!buf.empty()) {
        changes.ParseFromString(buf);
    }

    std::unordered_map<std::string, uint64_t> vermap;
    for (auto &gname : listGraphInstances()) {
        auto ginst = getGraphInstance(gname);
        vermap[gname] = ginst->version();
    }

    ChangeList_Change *c = changes.add_change();

    for(auto &verinfo : vermap) {
        auto item = c->add_items();
        item->set_key(verinfo.first);
        item->set_version(verinfo.second);
    }

    struct timeval cur_time;
    gettimeofday(&cur_time, NULL);

    auto ts = c->mutable_timestamp();
    ts->set_seconds(cur_time.tv_sec);
    ts->set_msec(cur_time.tv_usec / 1000);

    changes.set_current_version(changes.current_version() + 1);
    info_->commit_record(std::make_tuple(record_type::GRAPH_META, "range_changelist", 0, changes.SerializeAsString()));
}
Esempio n. 4
0
void mc146818_device::set_base_datetime()
{
	system_time systime;
	system_time::full_time current_time;

	machine().base_datetime(systime);

	current_time = (m_use_utc) ? systime.utc_time: systime.local_time;

//  logerror("mc146818_set_base_datetime %02d/%02d/%02d %02d:%02d:%02d\n",
//          current_time.year % 100, current_time.month + 1, current_time.mday,
//          current_time.hour,current_time.minute, current_time.second);

	set_seconds(current_time.second);
	set_minutes(current_time.minute);
	set_hours(current_time.hour);
	set_dayofweek(current_time.weekday + 1);
	set_dayofmonth(current_time.mday);
	set_month(current_time.month + 1);
	set_year(current_time.year % 100);

	if (m_century_index >= 0)
		m_data[m_century_index] = to_ram(current_time.year / 100);
}
Esempio n. 5
0
void mc146818_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
	switch (id)
	{
	case TIMER_PERIODIC:
		m_data[REG_C] |= REG_C_PF;
		update_irq();
		break;

	case TIMER_CLOCK:
		if (!(m_data[REG_B] & REG_B_SET))
		{
			/// TODO: find out how the real chip deals with updates when binary/bcd values are already outside the normal range
			int seconds = get_seconds() + 1;
			if (seconds < 60)
			{
				set_seconds(seconds);
			}
			else
			{
				set_seconds(0);

				int minutes = get_minutes() + 1;
				if (minutes < 60)
				{
					set_minutes(minutes);
				}
				else
				{
					set_minutes(0);

					int hours = get_hours() + 1;
					if (hours < 24)
					{
						set_hours(hours);
					}
					else
					{
						set_hours(0);

						int dayofweek = get_dayofweek() + 1;
						if (dayofweek <= 7)
						{
							set_dayofweek(dayofweek);
						}
						else
						{
							set_dayofweek(1);
						}

						int dayofmonth = get_dayofmonth() + 1;
						if (dayofmonth <= gregorian_days_in_month(get_month(), get_year() + 2000))
						{
							set_dayofmonth(dayofmonth);
						}
						else
						{
							set_dayofmonth(1);

							int month = get_month() + 1;
							if (month <= 12)
							{
								set_month(month);
							}
							else
							{
								set_month(1);

								set_year((get_year() + 1) % 100);
							}
						}
					}
				}
			}

			if ((m_data[REG_ALARM_SECONDS] == m_data[REG_SECONDS] || (m_data[REG_ALARM_SECONDS] & ALARM_DONTCARE) == ALARM_DONTCARE) &&
				(m_data[REG_ALARM_MINUTES] == m_data[REG_MINUTES] || (m_data[REG_ALARM_MINUTES] & ALARM_DONTCARE) == ALARM_DONTCARE) &&
				(m_data[REG_ALARM_HOURS] == m_data[REG_HOURS] || (m_data[REG_ALARM_HOURS] & ALARM_DONTCARE) == ALARM_DONTCARE))
			{
				// set the alarm interrupt flag AF
				m_data[REG_C] |= REG_C_AF;
			}

			// set the update-ended interrupt Flag UF
			m_data[REG_C] |=  REG_C_UF;
			update_irq();

			m_last_refresh = machine().time();
		}
		break;
	}
}