Changeset View
Changeset View
Standalone View
Standalone View
head/sys/powerpc/powerpc/clock.c
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | |||||
#include <machine/intr_machdep.h> | #include <machine/intr_machdep.h> | ||||
#include <machine/md_var.h> | #include <machine/md_var.h> | ||||
#include <machine/smp.h> | #include <machine/smp.h> | ||||
/* | /* | ||||
* Initially we assume a processor with a bus frequency of 12.5 MHz. | * Initially we assume a processor with a bus frequency of 12.5 MHz. | ||||
*/ | */ | ||||
static int initialized = 0; | static int initialized = 0; | ||||
static u_long ns_per_tick = 80; | static uint64_t ps_per_tick = 80000; | ||||
static u_long ticks_per_sec = 12500000; | static u_long ticks_per_sec = 12500000; | ||||
static u_long *decr_counts[MAXCPU]; | static u_long *decr_counts[MAXCPU]; | ||||
static int decr_et_start(struct eventtimer *et, | static int decr_et_start(struct eventtimer *et, | ||||
sbintime_t first, sbintime_t period); | sbintime_t first, sbintime_t period); | ||||
static int decr_et_stop(struct eventtimer *et); | static int decr_et_stop(struct eventtimer *et); | ||||
static timecounter_get_t decr_get_timecount; | static timecounter_get_t decr_get_timecount; | ||||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | decr_init(void) | ||||
/* | /* | ||||
* Check the BSP's timebase frequency. Sometimes we can't find the BSP, | * Check the BSP's timebase frequency. Sometimes we can't find the BSP, | ||||
* so fall back to the first CPU in this case. | * so fall back to the first CPU in this case. | ||||
*/ | */ | ||||
if (platform_smp_get_bsp(&cpu) != 0) | if (platform_smp_get_bsp(&cpu) != 0) | ||||
platform_smp_first_cpu(&cpu); | platform_smp_first_cpu(&cpu); | ||||
ticks_per_sec = platform_timebase_freq(&cpu); | ticks_per_sec = platform_timebase_freq(&cpu); | ||||
ns_per_tick = 1000000000 / ticks_per_sec; | ps_per_tick = 1000000000000 / ticks_per_sec; | ||||
set_cputicker(mftb, ticks_per_sec, 0); | set_cputicker(mftb, ticks_per_sec, 0); | ||||
snprintf(buf, sizeof(buf), "cpu%d:decrementer", curcpu); | snprintf(buf, sizeof(buf), "cpu%d:decrementer", curcpu); | ||||
intrcnt_add(buf, &decr_counts[curcpu]); | intrcnt_add(buf, &decr_counts[curcpu]); | ||||
decr_et_stop(NULL); | decr_et_stop(NULL); | ||||
initialized = 1; | initialized = 1; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
void | void | ||||
DELAY(int n) | DELAY(int n) | ||||
{ | { | ||||
u_quad_t tb, ttb; | u_quad_t tb, ttb; | ||||
TSENTER(); | TSENTER(); | ||||
tb = mftb(); | tb = mftb(); | ||||
ttb = tb + howmany(n * 1000, ns_per_tick); | ttb = tb + howmany((uint64_t)n * 1000000, ps_per_tick); | ||||
while (tb < ttb) | while (tb < ttb) | ||||
tb = mftb(); | tb = mftb(); | ||||
TSEXIT(); | TSEXIT(); | ||||
} | } | ||||