Exemplo n.º 1
0
void init_cycle_clock(void)
{
  static int init_done = 0;
  int i;
  long long val = 0;

  if(init_done) return;
  init_done = 1;

#ifdef USE_PERFCTR
  init_perfctr();
#endif
  
  // collect some samples
  for(i=0; i<10; i++) {
    val += timing_loop();
  }
  val = val / 10;

  ticks_per_second      = val * 1e3;
  ticks_per_millisecond = val * 1e0;
  ticks_per_microsecond = val / 1e3;
  ticks_per_nanosecond  = val / 1e6;

  GET_REAL_CPU_TICKS( real_start_ticks );
  GET_CPU_TICKS( virtual_start_ticks );
}
Exemplo n.º 2
0
Arquivo: timer.c Projeto: mrd/terrier
void timer_init(void)
{
  int i;
#ifdef USE_VMM
  if(vmm_map_region(&l4wakeup_region) != OK) {
    early_panic("Unable to map L4 wakeup registers.");
    return;
  }
  if(vmm_map_region(&l4perip_region) != OK) {
    early_panic("Unable to map L4 peripheral registers.");
    return;
  }
#ifdef OMAP3530
  if(vmm_map_region(&l4core_region) != OK) {
    early_panic("Unable to map L4 core registers.");
    return;
  }
#endif
#ifdef OMAP4460
  if(vmm_map_region(&l4abe_region) != OK) {
    early_panic("Unable to map L4 ABE registers.");
    return;
  }
#endif
#endif

#ifdef OMAP3530
  /* For some reason, this is defaulting to SYS_CLK on my board, even
   * though the manual says otherwise. Set it to 32K_FCLK, div-by-1. */
  *CM_CLKSEL_WKUP = (*CM_CLKSEL_WKUP & (~0x7)) | 0x2;
#endif
#ifdef OMAP4460
  DLOG(1, "CM_WKUP_GPTIMER1_CLKCTRL=%#x (%s)\n", *CM_WKUP_GPTIMER1_CLKCTRL, GETBITS(*CM_WKUP_GPTIMER1_CLKCTRL, 24, 1) ? "32kHz" : "SYS_CLK");
#endif

#ifdef OMAP4460
  GBLTIMER = (void *) (arm_config_base_address() + 0x200);
  PVTTIMER = (void *) (arm_config_base_address() + 0x600);
  WATCHDOG = (void *) (arm_config_base_address() + 0x620);
#ifdef USE_VMM
  timer_region.pstart = ((u32) PVTTIMER) & 0xFFF00000;
  timer_region.vstart = (void *) (((u32) PVTTIMER) & 0xFFF00000);
  /* ensure mapping of private/global timers */
  if(vmm_map_region(&timer_region) != OK) {
    early_panic("Unable to map private/global timers.");
    return;
  }
#endif
  PVTTIMER->control = 0;
  WATCHDOG->control = 0;
  GBLTIMER->control = 0;
#endif

  for(i=0;i<NUM_TIMERS;i++) {
    intc_set_irq_handler(GPTIMER_BASE_IRQ + i, timer_irq_handler);
    intc_unmask_irq(GPTIMER_BASE_IRQ + i);
    DLOG(1, "gptimer[%d] revision=%#x TCLR=%#x\n", i+1, gptimer[i+1]->TIDR, gptimer[i+1]->TCLR);
  }

  /* OMAP4460 TRM p892 */
  DLOG(1, "*CM_CLKMODE_DPLL_PER=%#x\n", *((u32 *) 0x4A008140));
  /* OMAP4460 TRM p895 */
  DLOG(1, "*CM_CLKSEL_DPLL_PER=%#x\n", *((u32 *) 0x4A00814C));

  timing_loop();
}
Exemplo n.º 3
0
int
main(int argc, char *argv[])
{
	long rate, payloadsize, port;
	char *dummy;
	struct _a a;	/* arguments */
	struct addrinfo hints, *res, *ressave;

	bzero(&a, sizeof(a));

	if (argc != 6)
		usage();

	memset(&hints, 0, sizeof(hints));
	hints.ai_family = AF_UNSPEC;

	if (getaddrinfo(argv[1], NULL, &hints, &res) != 0) {
		fprintf(stderr, "Couldn't resolv %s\n", argv[1]);
		return (-1);
	}
	ressave = res;
	while (res) {
		if (res->ai_family == AF_INET) {
			memcpy(&a.sin, res->ai_addr, res->ai_addrlen);
			a.ipv6 = 0;
			break;
		} else if (res->ai_family == AF_INET6) {
			memcpy(&a.sin6, res->ai_addr, res->ai_addrlen);
			a.ipv6 = 1;
			break;
		} 
		res = res->ai_next;
	}
	if (!res) {
		fprintf(stderr, "Couldn't resolv %s\n", argv[1]);
		exit(1);
	}
	freeaddrinfo(ressave);

	port = strtoul(argv[2], &dummy, 10);
	if (port < 1 || port > 65535)
		usage();
	if (*dummy != '\0' && *dummy != '-')
		usage();
	if (a.ipv6)
		a.sin6.sin6_port = htons(port);
	else
		a.sin.sin_port = htons(port);
	a.port = a.port_max = port;
	if (*dummy == '-') {	/* set high port */
		port = strtoul(dummy + 1, &dummy, 10);
		if (port < a.port || port > 65535)
			usage();
		a.port_max = port;
	}

	payloadsize = strtoul(argv[3], &dummy, 10);
	if (payloadsize < 0 || *dummy != '\0')
		usage();
	if (payloadsize > 32768) {
		fprintf(stderr, "payloadsize > 32768\n");
		return (-1);
	}
	a.packet_len = payloadsize;

	/*
	 * Specify an arbitrary limit.  It's exactly that, not selected by
	 * any particular strategy.  '0' is a special value meaning "blast",
	 * and avoids the cost of a timing loop.
	 */
	rate = strtoul(argv[4], &dummy, 10);
	if (rate < 0 || *dummy != '\0')
		usage();
	if (rate > MAX_RATE) {
		fprintf(stderr, "packet rate at most %d\n", MAX_RATE);
		return (-1);
	}

	a.duration = strtoul(argv[5], &dummy, 10);
	if (a.duration < 0 || *dummy != '\0')
		usage();

	a.packet = malloc(payloadsize);
	if (a.packet == NULL) {
		perror("malloc");
		return (-1);
	}
	bzero(a.packet, payloadsize);
	if (rate == 0) {
		a.interval.tv_sec = 0;
		a.interval.tv_nsec = 0;
	} else if (rate == 1) {
		a.interval.tv_sec = 1;
		a.interval.tv_nsec = 0;
	} else {
		a.interval.tv_sec = 0;
		a.interval.tv_nsec = ((1 * 1000000000) / rate);
	}

	printf("Sending packet of payload size %ld every %jd.%09lds for %ld "
	    "seconds\n", payloadsize, (intmax_t)a.interval.tv_sec,
	    a.interval.tv_nsec, a.duration);

	if (a.ipv6)
		a.s = socket(PF_INET6, SOCK_DGRAM, 0);
	else
		a.s = socket(PF_INET, SOCK_DGRAM, 0);
	if (a.s == -1) {
		perror("socket");
		return (-1);
	}

	return (timing_loop(&a));
}