summaryrefslogtreecommitdiff
path: root/minix/lib/libsys/arch/earm/tsc_util.c
blob: 4f973e9a16cc6f43bc832ee197c4c107782b4a9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

#include <stdio.h>
#include <time.h>
#include <sys/times.h>
#include <sys/types.h>
#include <minix/u64.h>
#include <minix/config.h>
#include <minix/const.h>
#include <minix/minlib.h>
#include <machine/archtypes.h>

#include "sysutil.h"

#ifndef CONFIG_MAX_CPUS
#define CONFIG_MAX_CPUS 1
#endif

#define MICROHZ		1000000		/* number of micros per second */
#define MICROSPERTICK(h)	(MICROHZ/(h))	/* number of micros per HZ tick */

static u32_t calib_hz = 600000000;

u32_t tsc_64_to_micros(u64_t tsc)
{
	u64_t tmp;

	tmp =  tsc / calib_hz;
	return (u32_t) tmp;
}

u32_t tsc_to_micros(u32_t low, u32_t high)
{
	return tsc_64_to_micros(make64(low, high));
}