Changeset View
Changeset View
Standalone View
Standalone View
sys/powerpc/powerpc/clock.c
Show First 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | |||||
#include <machine/intr_machdep.h> | #include <machine/intr_machdep.h> | ||||
#endif | #endif | ||||
#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 uint64_t ps_per_tick = 80000; | 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 struct intr_event *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; | ||||
static uint32_t decr_vdso_timehands(struct vdso_timehands *vdso_th, | static uint32_t decr_vdso_timehands(struct vdso_timehands *vdso_th, | ||||
struct timecounter *tc); | struct timecounter *tc); | ||||
#ifdef COMPAT_FREEBSD32 | #ifdef COMPAT_FREEBSD32 | ||||
Show All 27 Lines | |||||
{ | { | ||||
struct decr_state *s = DPCPU_PTR(decr_state); | struct decr_state *s = DPCPU_PTR(decr_state); | ||||
int nticks = 0; | int nticks = 0; | ||||
int32_t val; | int32_t val; | ||||
if (!initialized) | if (!initialized) | ||||
return; | return; | ||||
(*decr_counts[curcpu])++; | decr_counts[curcpu]->ie_intrcnt++; | ||||
#ifdef BOOKE | #ifdef BOOKE | ||||
/* | /* | ||||
* Interrupt handler must reset DIS to avoid getting another | * Interrupt handler must reset DIS to avoid getting another | ||||
* interrupt once EE is enabled. | * interrupt once EE is enabled. | ||||
*/ | */ | ||||
mtspr(SPR_TSR, TSR_DIS); | mtspr(SPR_TSR, TSR_DIS); | ||||
#endif | #endif | ||||
Show All 33 Lines | |||||
/* | /* | ||||
* BSP early initialization. | * BSP early initialization. | ||||
*/ | */ | ||||
void | void | ||||
decr_init(void) | decr_init(void) | ||||
{ | { | ||||
struct cpuref cpu; | struct cpuref cpu; | ||||
char buf[32]; | int error; | ||||
/* | /* | ||||
* 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); | ||||
ps_per_tick = 1000000000000 / ticks_per_sec; | ps_per_tick = 1000000000000 / ticks_per_sec; | ||||
set_cputicker(mftb, ticks_per_sec, false); | set_cputicker(mftb, ticks_per_sec, false); | ||||
snprintf(buf, sizeof(buf), "cpu%d:decrementer", curcpu); | error = intr_event_create(decr_counts + curcpu, NULL, 0, NULL, NULL, | ||||
intrcnt_add(buf, &decr_counts[curcpu]); | NULL, NULL, "cpu%d:decrementer", curcpu); | ||||
if (error != 0) | |||||
panic("%s(): intr_event_create() failed, return=%d", __func__, | |||||
error); | |||||
decr_et_stop(NULL); | decr_et_stop(NULL); | ||||
initialized = 1; | initialized = 1; | ||||
} | } | ||||
#ifdef SMP | #ifdef SMP | ||||
/* | /* | ||||
* AP early initialization. | * AP early initialization. | ||||
*/ | */ | ||||
void | void | ||||
decr_ap_init(void) | decr_ap_init(void) | ||||
{ | { | ||||
char buf[32]; | char buf[32]; | ||||
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); | ||||
ehem_freebsd_m5p.com: This has me worried, why is this array being initialized **twice**? This uses the safer… | |||||
} | } | ||||
#endif | #endif | ||||
/* | /* | ||||
* Final initialization. | * Final initialization. | ||||
*/ | */ | ||||
void | void | ||||
decr_tc_init(void) | decr_tc_init(void) | ||||
▲ Show 20 Lines • Show All 127 Lines • Show Last 20 Lines |
This has me worried, why is this array being initialized twice? This uses the safer approach, but I'm unable to test this so someone else needs to verify.