Пример #1
0
int gettimeofday(struct timeval *tv, struct timezone *tz)
{
	unsigned int tbu;
	unsigned int tbl;

	unsigned long long tb;

	static unsigned long long starttb;

	gettb(tbu, tbl);

	tb = (((unsigned long long)tbu)<<32)|tbl;

	if (tv)
	{
		tv->tv_sec = tb/TBFREQ;
		tv->tv_usec = ((tb%TBFREQ)/6075)*100;
	}

	return 0;
}
Пример #2
0
void net_init(void) {
	memset(&ipaddr, 0, sizeof(ipaddr));
	memset(&netmask, 0, sizeof(ipaddr));
	memset(&gw, 0, sizeof(ipaddr));

	printf("Initializing network...\n");
	lwip_init();
	printf("lwIP Initialized\n");
	netif_add(&eth, &ipaddr, &netmask, &gw, NULL, gelicif_init, ethernet_input);
	netif_set_default(&eth);
	netif_set_up(&eth);
	printf("Ethernet interface initialized\n");
	printf("Starting DHCP\n");
	dhcp_start(&eth);

	u64 now = gettb();
#if LWIP_TCP
	last_tcp_time = now;
#endif
	last_arp_time = last_dhcp_coarse_time = last_dhcp_fine_time = now;
}
Пример #3
0
double Sys_DoubleTime()
{
	unsigned int tbu;
	unsigned int tbl;

	unsigned long long tb;

	double time;

	static unsigned long long starttb;

	gettb(tbu, tbl);

	tb = (((unsigned long long)tbu)<<32)|tbl;

	if (starttb == 0)
		starttb = tb;

	time = (tb-starttb)/TBFREQ;
	time+= ((double)((tb-starttb)%TBFREQ))/TBFREQ;

	return time;
}
Пример #4
0
void net_poll(void) {

	u64 now = gettb();

	gelicif_input(&eth);
	if ((now - last_arp_time) >= (ARP_TMR_INTERVAL*TICKS_PER_MS)) {
		etharp_tmr();
		last_arp_time = now;
	}
#if LWIP_TCP
	if ((now - last_tcp_time) >= (TCP_TMR_INTERVAL*TICKS_PER_MS)) {
		tcp_tmr();
		last_tcp_time = now;
	}
#endif
	if ((now - last_dhcp_coarse_time) >= (DHCP_COARSE_TIMER_SECS*TICKS_PER_SEC)) {
		dhcp_coarse_tmr();
		last_dhcp_coarse_time = now;
	}
	if ((now - last_dhcp_fine_time) >= (DHCP_FINE_TIMER_MSECS*TICKS_PER_MS)) {
		dhcp_fine_tmr();
		last_dhcp_fine_time = now;
	}
}