Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/acpica/acpi_hpet.c
Show All 23 Lines | |||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include "opt_acpi.h" | #include "opt_acpi.h" | ||||
#include "opt_compat.h" | |||||
#if defined(__amd64__) | #if defined(__amd64__) | ||||
#define DEV_APIC | #define DEV_APIC | ||||
#else | #else | ||||
#include "opt_apic.h" | #include "opt_apic.h" | ||||
#endif | #endif | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/conf.h> | #include <sys/conf.h> | ||||
#include <sys/bus.h> | #include <sys/bus.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/module.h> | #include <sys/module.h> | ||||
#include <sys/proc.h> | #include <sys/proc.h> | ||||
#include <sys/rman.h> | #include <sys/rman.h> | ||||
#include <sys/mman.h> | #include <sys/mman.h> | ||||
#include <sys/time.h> | #include <sys/time.h> | ||||
#include <sys/smp.h> | #include <sys/smp.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/timeet.h> | #include <sys/timeet.h> | ||||
#include <sys/timetc.h> | #include <sys/timetc.h> | ||||
#include <sys/vdso.h> | |||||
#include <contrib/dev/acpica/include/acpi.h> | #include <contrib/dev/acpica/include/acpi.h> | ||||
#include <contrib/dev/acpica/include/accommon.h> | #include <contrib/dev/acpica/include/accommon.h> | ||||
#include <dev/acpica/acpivar.h> | #include <dev/acpica/acpivar.h> | ||||
#include <dev/acpica/acpi_hpet.h> | #include <dev/acpica/acpi_hpet.h> | ||||
#ifdef DEV_APIC | #ifdef DEV_APIC | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | |||||
hpet_get_timecount(struct timecounter *tc) | hpet_get_timecount(struct timecounter *tc) | ||||
{ | { | ||||
struct hpet_softc *sc; | struct hpet_softc *sc; | ||||
sc = tc->tc_priv; | sc = tc->tc_priv; | ||||
return (bus_read_4(sc->mem_res, HPET_MAIN_COUNTER)); | return (bus_read_4(sc->mem_res, HPET_MAIN_COUNTER)); | ||||
} | } | ||||
uint32_t | |||||
hpet_vdso_timehands(struct vdso_timehands *vdso_th, struct timecounter *tc) | |||||
{ | |||||
struct hpet_softc *sc; | |||||
sc = tc->tc_priv; | |||||
vdso_th->th_algo = VDSO_TH_ALGO_X86_HPET; | |||||
vdso_th->th_x86_shift = 0; | |||||
vdso_th->th_x86_hpet_idx = device_get_unit(sc->dev); | |||||
bzero(vdso_th->th_res, sizeof(vdso_th->th_res)); | |||||
return (sc->mmap_allow != 0); | |||||
} | |||||
#ifdef COMPAT_FREEBSD32 | |||||
uint32_t | |||||
hpet_vdso_timehands32(struct vdso_timehands32 *vdso_th32, | |||||
struct timecounter *tc) | |||||
{ | |||||
struct hpet_softc *sc; | |||||
sc = tc->tc_priv; | |||||
vdso_th32->th_algo = VDSO_TH_ALGO_X86_HPET; | |||||
vdso_th32->th_x86_shift = 0; | |||||
vdso_th32->th_x86_hpet_idx = device_get_unit(sc->dev); | |||||
bzero(vdso_th32->th_res, sizeof(vdso_th32->th_res)); | |||||
return (sc->mmap_allow != 0); | |||||
} | |||||
#endif | |||||
static void | static void | ||||
hpet_enable(struct hpet_softc *sc) | hpet_enable(struct hpet_softc *sc) | ||||
{ | { | ||||
uint32_t val; | uint32_t val; | ||||
val = bus_read_4(sc->mem_res, HPET_CONFIG); | val = bus_read_4(sc->mem_res, HPET_CONFIG); | ||||
if (sc->legacy_route) | if (sc->legacy_route) | ||||
val |= HPET_CNF_LEG_RT; | val |= HPET_CNF_LEG_RT; | ||||
▲ Show 20 Lines • Show All 380 Lines • ▼ Show 20 Lines | hpet_attach(device_t dev) | ||||
/* Announce first HPET as timecounter. */ | /* Announce first HPET as timecounter. */ | ||||
if (device_get_unit(dev) == 0) { | if (device_get_unit(dev) == 0) { | ||||
sc->tc.tc_get_timecount = hpet_get_timecount, | sc->tc.tc_get_timecount = hpet_get_timecount, | ||||
sc->tc.tc_counter_mask = ~0u, | sc->tc.tc_counter_mask = ~0u, | ||||
sc->tc.tc_name = "HPET", | sc->tc.tc_name = "HPET", | ||||
sc->tc.tc_quality = 950, | sc->tc.tc_quality = 950, | ||||
sc->tc.tc_frequency = sc->freq; | sc->tc.tc_frequency = sc->freq; | ||||
sc->tc.tc_priv = sc; | sc->tc.tc_priv = sc; | ||||
sc->tc.tc_fill_vdso_timehands = hpet_vdso_timehands; | |||||
#ifdef COMPAT_FREEBSD32 | |||||
sc->tc.tc_fill_vdso_timehands32 = hpet_vdso_timehands32; | |||||
#endif | |||||
tc_init(&sc->tc); | tc_init(&sc->tc); | ||||
} | } | ||||
/* If not disabled - setup and announce event timers. */ | /* If not disabled - setup and announce event timers. */ | ||||
if (resource_int_value(device_get_name(dev), device_get_unit(dev), | if (resource_int_value(device_get_name(dev), device_get_unit(dev), | ||||
"clock", &i) == 0 && i == 0) | "clock", &i) == 0 && i == 0) | ||||
return (0); | return (0); | ||||
/* Check whether we can and want legacy routing. */ | /* Check whether we can and want legacy routing. */ | ||||
▲ Show 20 Lines • Show All 404 Lines • Show Last 20 Lines |