u32_t kerninfo_magic;
u32_t minix_feature_flags; /* features in minix kernel */
u32_t ki_flags; /* what is present in this struct */
- u32_t minix_frclock;
+ u32_t minix_frclock_tcrr;
u32_t flags_unused3;
u32_t flags_unused4;
struct kinfo *kinfo;
struct kmessages *kmessages;
struct loadinfo *loadinfo;
struct minix_ipcvecs *minix_ipcvecs;
+ u64_t minix_arm_frclock_hz; /* minix_frclock_tcrr frequency */
} __packed;
#define MINIX_KIF_IPCVECS (1L << 0)
return OK;
}
else if (index == frclock_index) {
-#ifdef DM37XX
- minix_kerninfo.minix_frclock = addr;
-#endif
-#ifdef AM335X
- minix_kerninfo.minix_frclock = addr;
+#if defined(DM37XX)
+ minix_kerninfo.minix_frclock_tcrr = addr + OMAP3_TIMER_TCRR;
+ minix_kerninfo.minix_arm_frclock_hz = 1625000;
+#elif defined(AM335X)
+ minix_kerninfo.minix_frclock_tcrr = addr + AM335X_TIMER_TCRR;
+ minix_kerninfo.minix_arm_frclock_hz = 1500000;
+#else
+#error ARM: plese define either AM335X or DM37XX.
#endif
return OK;
#include <sys/types.h>
#include <assert.h>
-#ifdef DM37XX
-//keesj:todo we don't want to hardcode these values here but ratter
-//get them using a system call. the same applies for the time offset
-static u64_t calib_hz = 1625000, Hz;
-#endif
-#ifdef AM335X
-static u64_t calib_hz = 1500000, Hz;
-#endif
-
#define MICROHZ 1000000ULL /* number of micros per second */
#define MICROSPERTICK(h) (MICROHZ/(h)) /* number of micros per HZ tick */
+static u64_t Hz;
+
+extern struct minix_kerninfo *_minix_kerninfo;
+
int
micro_delay(u32_t micros)
{
/* Start of delay. */
read_frclock_64(&start);
- delta_end = (calib_hz * micros) / MICROHZ;
+ assert(_minix_kerninfo->minix_arm_frclock_hz);
+ delta_end = (_minix_kerninfo->minix_arm_frclock_hz * micros) / MICROHZ;
/* If we have to wait for at least one HZ tick, use the regular
* tickdelay first. Round downwards on purpose, so the average
u32_t frclock_64_to_micros(u64_t tsc)
{
- return (u32_t) tsc / (calib_hz / MICROHZ);
+ return (u32_t) tsc / (_minix_kerninfo->minix_arm_frclock_hz / MICROHZ);
}
void
read_frclock(u32_t *frclk)
{
- extern struct minix_kerninfo *_minix_kerninfo;
- volatile u32_t *frclock;
-
assert(frclk);
-#ifdef DM37XX
- frclock = (u32_t *)((u8_t *) _minix_kerninfo->minix_frclock + OMAP3_TIMER_TCRR);
-#endif
-#ifdef AM335X
- frclock = (u32_t *)((u8_t *) _minix_kerninfo->minix_frclock + AM335X_TIMER_TCRR);
-#endif
- *frclk = *frclock;
+ assert(_minix_kerninfo->minix_frclock_tcrr);
+ assert(_minix_kerninfo->minix_arm_frclock_hz);
+ *frclk = *(volatile u32_t *)((u8_t *) _minix_kerninfo->minix_frclock_tcrr);
}
u32_t