int rthal_arch_init(void) { #ifdef CONFIG_IPIPE_CORE int rc = wrap_select_timers(&rthal_supported_cpus); if (rc < 0) return rc; #else /* !I-pipe core */ #ifdef CONFIG_X86_LOCAL_APIC if (!boot_cpu_has(X86_FEATURE_APIC)) { printk("Xenomai: Local APIC absent or disabled!\n" " Disable APIC support or pass \"lapic=1\" as bootparam.\n"); rthal_smi_restore(); return -ENODEV; } #elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) && !defined(CONFIG_X86_TSC) && defined(CONFIG_VT) /* Prevent the speaker code from bugging our TSC emulation, also based on PIT channel 2. kd_mksound is exported by the Adeos patch. */ old_mksound = kd_mksound; kd_mksound = &dummy_mksound; #endif /* !CONFIG_X86_LOCAL_APIC && Linux < 2.6 && !CONFIG_X86_TSC && CONFIG_VT */ #ifdef CONFIG_X86_TSC if (!cpu_has_tsc) { printk("Xenomai: compiled for TSC, but CPU has no TSC\n" " Recompile the kernel selecting a CPU without " "TSC\n"); rthal_smi_restore(); return -ENODEV; } #endif /* X86_TSC */ #endif /* !I-pipe core */ if (rthal_cpufreq_arg == 0) #if defined(CONFIG_X86_TSC) || IPIPE_CORE_APIREV >= 2 /* FIXME: 4Ghz barrier is close... */ rthal_cpufreq_arg = rthal_get_cpufreq(); #else /* ! CONFIG_X86_TSC */ rthal_cpufreq_arg = CLOCK_TICK_RATE; rthal_setup_8254_tsc(); #endif /* CONFIG_X86_TSC */ if (rthal_clockfreq_arg == 0) rthal_clockfreq_arg = rthal_get_clockfreq(); #ifdef CONFIG_IPIPE_CORE if (rthal_timerfreq_arg == 0) rthal_timerfreq_arg = rthal_get_timerfreq(); #endif return 0; }
int rthal_arch_init(void) { if (rthal_cpufreq_arg == 0) rthal_cpufreq_arg = (unsigned long)rthal_get_cpufreq(); if (rthal_timerfreq_arg == 0) rthal_timerfreq_arg = (unsigned long)rthal_get_timerfreq(); if (rthal_clockfreq_arg == 0) rthal_clockfreq_arg = (unsigned long)rthal_get_clockfreq(); return 0; }
int rthal_arch_init(void) { if (rthal_cpufreq_arg == 0) rthal_cpufreq_arg = rthal_get_cpufreq(); if (rthal_timerfreq_arg == 0) rthal_timerfreq_arg = rthal_get_timerfreq(); if (rthal_clockfreq_arg == 0) rthal_clockfreq_arg = rthal_get_clockfreq(); xnarch_init_u32frac(&rthal_tsc_to_timer, rthal_timerfreq_arg, rthal_clockfreq_arg); return 0; }
int rthal_arch_init(void) { #ifdef CONFIG_ALTIVEC if (!cpu_has_feature(CPU_FTR_ALTIVEC)) { printk ("Xenomai: ALTIVEC support enabled in kernel but no hardware found.\n" " Disable CONFIG_ALTIVEC in the kernel configuration.\n"); return -ENODEV; } #endif /* CONFIG_ALTIVEC */ if (rthal_cpufreq_arg == 0) rthal_cpufreq_arg = (unsigned long)rthal_get_cpufreq(); if (rthal_timerfreq_arg == 0) rthal_timerfreq_arg = (unsigned long)rthal_get_timerfreq(); if (rthal_clockfreq_arg == 0) rthal_clockfreq_arg = (unsigned long)rthal_get_clockfreq(); return 0; }
int rthal_arch_init(void) { #ifdef CONFIG_IPIPE_CORE int rc = wrap_select_timers(&rthal_supported_cpus); if (rc < 0) return rc; #endif /* I-pipe core */ if (rthal_cpufreq_arg == 0) /* FIXME: 4Ghz barrier is close... */ rthal_cpufreq_arg = rthal_get_cpufreq(); if (rthal_clockfreq_arg == 0) rthal_clockfreq_arg = rthal_get_clockfreq(); #ifdef CONFIG_IPIPE_CORE if (rthal_timerfreq_arg == 0) rthal_timerfreq_arg = rthal_get_timerfreq(); #endif return 0; }
unsigned long rthal_timer_calibrate(void) { unsigned long flags, freq; u64 t, v; u32 d; int n; rthal_local_irq_save_hw(flags); rthal_read_tsc(t); barrier(); for (n = 1; n < 100; n++) rthal_read_tsc(v); rthal_local_irq_restore_hw(flags); d = (u32)(v - t); freq = rthal_get_clockfreq(); return ((1000000000 / freq) * (d / n)); }