Provide MD wrappers for match and attach.

This commit is contained in:
jruoho 2011-02-27 18:32:53 +00:00
parent c5d6c4cef0
commit cd966b244a
3 changed files with 77 additions and 48 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: acpi_cpu_md.c,v 1.47 2011/02/27 17:27:28 jruoho Exp $ */
/* $NetBSD: acpi_cpu_md.c,v 1.48 2011/02/27 18:32:54 jruoho Exp $ */
/*-
* Copyright (c) 2010, 2011 Jukka Ruohonen <jruohonen@iki.fi>
@ -27,10 +27,11 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.47 2011/02/27 17:27:28 jruoho Exp $");
__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.48 2011/02/27 18:32:54 jruoho Exp $");
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/device.h>
#include <sys/kcore.h>
#include <sys/sysctl.h>
#include <sys/xcall.h>
@ -118,6 +119,25 @@ extern struct acpicpu_softc **acpicpu_sc;
static bool acpicpu_pstate_status = false;
static struct sysctllog *acpicpu_log = NULL;
struct cpu_info *
acpicpu_md_match(device_t parent, cfdata_t match, void *aux)
{
struct cpufeature_attach_args *cfaa = aux;
if (strcmp(cfaa->name, "frequency") != 0)
return NULL;
return cfaa->ci;
}
struct cpu_info *
acpicpu_md_attach(device_t parent, device_t self, void *aux)
{
struct cpufeature_attach_args *cfaa = aux;
return cfaa->ci;
}
uint32_t
acpicpu_md_cap(void)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: acpi_cpu.c,v 1.30 2011/02/27 17:10:33 jruoho Exp $ */
/* $NetBSD: acpi_cpu.c,v 1.31 2011/02/27 18:32:53 jruoho Exp $ */
/*-
* Copyright (c) 2010, 2011 Jukka Ruohonen <jruohonen@iki.fi>
@ -27,7 +27,7 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: acpi_cpu.c,v 1.30 2011/02/27 17:10:33 jruoho Exp $");
__KERNEL_RCSID(0, "$NetBSD: acpi_cpu.c,v 1.31 2011/02/27 18:32:53 jruoho Exp $");
#include <sys/param.h>
#include <sys/cpu.h>
@ -85,26 +85,32 @@ CFATTACH_DECL_NEW(acpicpu, sizeof(struct acpicpu_softc),
static int
acpicpu_match(device_t parent, cfdata_t match, void *aux)
{
struct cpufeature_attach_args *cfaa = aux;
struct cpu_info *ci;
if (acpi_softc == NULL)
return 0;
if (strcmp(cfaa->name, "frequency") != 0)
ci = acpicpu_md_match(parent, match, aux);
if (ci == NULL)
return 0;
return acpicpu_find(cfaa->ci, NULL);
return acpicpu_find(ci, NULL);
}
static void
acpicpu_attach(device_t parent, device_t self, void *aux)
{
struct acpicpu_softc *sc = device_private(self);
struct cpufeature_attach_args *cfaa = aux;
struct cpu_info *ci = cfaa->ci;
struct cpu_info *ci;
cpuid_t id;
int rv;
ci = acpicpu_md_attach(parent, self, aux);
if (ci == NULL)
return;
sc->sc_ci = ci;
sc->sc_dev = self;
sc->sc_cold = true;
@ -409,7 +415,7 @@ out:
if (ptr != NULL)
*ptr = ad;
return 10; /* Beat est(4) and powernow(4). */
return 10;
}
static uint32_t

View File

@ -1,4 +1,4 @@
/* $NetBSD: acpi_cpu.h,v 1.33 2011/02/25 20:59:37 jruoho Exp $ */
/* $NetBSD: acpi_cpu.h,v 1.34 2011/02/27 18:32:53 jruoho Exp $ */
/*-
* Copyright (c) 2010, 2011 Jukka Ruohonen <jruohonen@iki.fi>
@ -230,45 +230,48 @@ struct acpicpu_softc {
bool sc_cold;
};
void acpicpu_cstate_attach(device_t);
int acpicpu_cstate_detach(device_t);
void acpicpu_cstate_start(device_t);
bool acpicpu_cstate_suspend(device_t);
bool acpicpu_cstate_resume(device_t);
void acpicpu_cstate_callback(void *);
void acpicpu_cstate_idle(void);
void acpicpu_cstate_attach(device_t);
int acpicpu_cstate_detach(device_t);
void acpicpu_cstate_start(device_t);
bool acpicpu_cstate_suspend(device_t);
bool acpicpu_cstate_resume(device_t);
void acpicpu_cstate_callback(void *);
void acpicpu_cstate_idle(void);
void acpicpu_pstate_attach(device_t);
int acpicpu_pstate_detach(device_t);
void acpicpu_pstate_start(device_t);
bool acpicpu_pstate_suspend(device_t);
bool acpicpu_pstate_resume(device_t);
void acpicpu_pstate_callback(void *);
int acpicpu_pstate_get(struct acpicpu_softc *, uint32_t *);
int acpicpu_pstate_set(struct acpicpu_softc *, uint32_t);
void acpicpu_pstate_attach(device_t);
int acpicpu_pstate_detach(device_t);
void acpicpu_pstate_start(device_t);
bool acpicpu_pstate_suspend(device_t);
bool acpicpu_pstate_resume(device_t);
void acpicpu_pstate_callback(void *);
int acpicpu_pstate_get(struct acpicpu_softc *, uint32_t *);
int acpicpu_pstate_set(struct acpicpu_softc *, uint32_t);
void acpicpu_tstate_attach(device_t);
int acpicpu_tstate_detach(device_t);
void acpicpu_tstate_start(device_t);
bool acpicpu_tstate_suspend(device_t);
bool acpicpu_tstate_resume(device_t);
void acpicpu_tstate_callback(void *);
int acpicpu_tstate_get(struct acpicpu_softc *, uint32_t *);
int acpicpu_tstate_set(struct acpicpu_softc *, uint32_t);
void acpicpu_tstate_attach(device_t);
int acpicpu_tstate_detach(device_t);
void acpicpu_tstate_start(device_t);
bool acpicpu_tstate_suspend(device_t);
bool acpicpu_tstate_resume(device_t);
void acpicpu_tstate_callback(void *);
int acpicpu_tstate_get(struct acpicpu_softc *, uint32_t *);
int acpicpu_tstate_set(struct acpicpu_softc *, uint32_t);
uint32_t acpicpu_md_cap(void);
uint32_t acpicpu_md_flags(void);
void acpicpu_md_quirk_c1e(void);
int acpicpu_md_cstate_start(struct acpicpu_softc *);
int acpicpu_md_cstate_stop(void);
void acpicpu_md_cstate_enter(int, int);
int acpicpu_md_pstate_start(struct acpicpu_softc *);
int acpicpu_md_pstate_stop(void);
int acpicpu_md_pstate_pss(struct acpicpu_softc *);
uint8_t acpicpu_md_pstate_percent(struct acpicpu_softc *);
int acpicpu_md_pstate_get(struct acpicpu_softc *, uint32_t *);
int acpicpu_md_pstate_set(struct acpicpu_pstate *);
int acpicpu_md_tstate_get(struct acpicpu_softc *, uint32_t *);
int acpicpu_md_tstate_set(struct acpicpu_tstate *);
struct cpu_info *acpicpu_md_match(device_t, cfdata_t, void *);
struct cpu_info *acpicpu_md_attach(device_t, device_t, void *);
uint32_t acpicpu_md_cap(void);
uint32_t acpicpu_md_flags(void);
void acpicpu_md_quirk_c1e(void);
int acpicpu_md_cstate_start(struct acpicpu_softc *);
int acpicpu_md_cstate_stop(void);
void acpicpu_md_cstate_enter(int, int);
int acpicpu_md_pstate_start(struct acpicpu_softc *);
int acpicpu_md_pstate_stop(void);
int acpicpu_md_pstate_pss(struct acpicpu_softc *);
uint8_t acpicpu_md_pstate_percent(struct acpicpu_softc *);
int acpicpu_md_pstate_get(struct acpicpu_softc *, uint32_t *);
int acpicpu_md_pstate_set(struct acpicpu_pstate *);
int acpicpu_md_tstate_get(struct acpicpu_softc *, uint32_t *);
int acpicpu_md_tstate_set(struct acpicpu_tstate *);
#endif /* !_SYS_DEV_ACPI_ACPI_CPU_H */