Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/acpi Move the GAS definition to the header so it can...
details: https://anonhg.NetBSD.org/src/rev/905b967b3f6e
branches: trunk
changeset: 756639:905b967b3f6e
user: jruoho <jruoho%NetBSD.org@localhost>
date: Tue Jul 27 05:11:32 2010 +0000
description:
Move the GAS definition to the header so it can be shared. Make a basic
sanity check before casting to the GAS. Rename the _CSD structure; the
optional "cross logical processor dependency information" is almost
identical in C, P, and T states. Add some comments to the header.
diffstat:
sys/dev/acpi/acpi_cpu.h | 70 ++++++++++++++++++++++++++---------------
sys/dev/acpi/acpi_cpu_cstate.c | 47 ++++++++++++----------------
2 files changed, 64 insertions(+), 53 deletions(-)
diffs (219 lines):
diff -r 06cb0dc1a62a -r 905b967b3f6e sys/dev/acpi/acpi_cpu.h
--- a/sys/dev/acpi/acpi_cpu.h Tue Jul 27 01:13:41 2010 +0000
+++ b/sys/dev/acpi/acpi_cpu.h Tue Jul 27 05:11:32 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu.h,v 1.5 2010/07/23 08:11:49 jruoho Exp $ */
+/* $NetBSD: acpi_cpu.h,v 1.6 2010/07/27 05:11:32 jruoho Exp $ */
/*-
* Copyright (c) 2010 Jukka Ruohonen <jruohonen%iki.fi@localhost>
@@ -52,11 +52,8 @@
#define ACPICPU_PDC_C_C2C3_FFH __BIT(9) /* SMP C2 and C2 native */
#define ACPICPU_PDC_P_HW __BIT(11) /* Px hardware coordination */
-/*
- * See ibid., table 4.
- */
-#define ACPICPU_PDC_GAS_HW __BIT(0) /* hw-coordinated state */
-#define ACPICPU_PDC_GAS_BM __BIT(1) /* bus master check required */
+#define ACPICPU_PDC_GAS_HW __BIT(0) /* HW-coordinated state */
+#define ACPICPU_PDC_GAS_BM __BIT(1) /* Bus master check required */
/*
* Notify values.
@@ -71,25 +68,32 @@
#define ACPICPU_C_C2_LATENCY_MAX 100 /* us */
#define ACPICPU_C_C3_LATENCY_MAX 1000 /* us */
-#define ACPICPU_C_CSD_SW_ALL 0xFC
-#define ACPICPU_C_CSD_SW_ANY 0xFD
-#define ACPICPU_C_CSD_HW_ALL 0xFE
-
#define ACPICPU_C_STATE_HALT 0x01
#define ACPICPU_C_STATE_FFH 0x02
#define ACPICPU_C_STATE_SYSIO 0x03
-#define ACPICPU_FLAG_C __BIT(0)
-#define ACPICPU_FLAG_P __BIT(1)
-#define ACPICPU_FLAG_T __BIT(2)
-#define ACPICPU_FLAG_C_CST __BIT(3)
-#define ACPICPU_FLAG_C_FADT __BIT(4)
-#define ACPICPU_FLAG_C_BM __BIT(5)
-#define ACPICPU_FLAG_C_BM_STS __BIT(6)
-#define ACPICPU_FLAG_C_ARB __BIT(7)
-#define ACPICPU_FLAG_C_NOC3 __BIT(8)
-#define ACPICPU_FLAG_C_MWAIT __BIT(9)
-#define ACPICPU_FLAG_C_C1E __BIT(10)
+/*
+ * Cross-CPU dependency coordination.
+ */
+#define ACPICPU_DEP_SW_ALL 0xFC
+#define ACPICPU_DEP_SW_ANY 0xFD
+#define ACPICPU_DEP_HW_ALL 0xFE
+
+/*
+ * Flags.
+ */
+#define ACPICPU_FLAG_C __BIT(0) /* C-states supported */
+#define ACPICPU_FLAG_P __BIT(1) /* P-states supported */
+#define ACPICPU_FLAG_T __BIT(2) /* T-states supported */
+
+#define ACPICPU_FLAG_C_CST __BIT(3) /* C-states with _CST */
+#define ACPICPU_FLAG_C_FADT __BIT(4) /* C-states with FADT */
+#define ACPICPU_FLAG_C_BM __BIT(5) /* Bus master control */
+#define ACPICPU_FLAG_C_BM_STS __BIT(6) /* Bus master check required */
+#define ACPICPU_FLAG_C_ARB __BIT(7) /* Bus master arbitration */
+#define ACPICPU_FLAG_C_NOC3 __BIT(8) /* C3 disabled (quirk) */
+#define ACPICPU_FLAG_C_MWAIT __BIT(9) /* MONITOR/MWAIT supported */
+#define ACPICPU_FLAG_C_C1E __BIT(10) /* AMD C1E detected */
struct acpicpu_cstate {
uint64_t cs_stat;
@@ -100,11 +104,11 @@
int cs_flags;
};
-struct acpicpu_csd {
- uint32_t csd_domain;
- uint32_t csd_coord;
- uint32_t csd_ncpu;
- uint32_t csd_index;
+struct acpicpu_dep {
+ uint32_t dep_domain;
+ uint32_t dep_coord;
+ uint32_t dep_ncpu;
+ uint32_t dep_index;
};
struct acpicpu_object {
@@ -126,6 +130,20 @@
uint32_t sc_flags;
};
+/*
+ * This is AML_RESOURCE_GENERIC_REGISTER,
+ * included here separately for convenience.
+ */
+struct acpicpu_reg {
+ uint8_t reg_desc;
+ uint16_t reg_reslen;
+ uint8_t reg_spaceid;
+ uint8_t reg_bitwidth;
+ uint8_t reg_bitoffset;
+ uint8_t reg_accesssize;
+ uint64_t reg_addr;
+} __packed;
+
void acpicpu_cstate_attach(device_t);
int acpicpu_cstate_detach(device_t);
int acpicpu_cstate_start(device_t);
diff -r 06cb0dc1a62a -r 905b967b3f6e sys/dev/acpi/acpi_cpu_cstate.c
--- a/sys/dev/acpi/acpi_cpu_cstate.c Tue Jul 27 01:13:41 2010 +0000
+++ b/sys/dev/acpi/acpi_cpu_cstate.c Tue Jul 27 05:11:32 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu_cstate.c,v 1.10 2010/07/25 17:44:01 jruoho Exp $ */
+/* $NetBSD: acpi_cpu_cstate.c,v 1.11 2010/07/27 05:11:33 jruoho Exp $ */
/*-
* Copyright (c) 2010 Jukka Ruohonen <jruohonen%iki.fi@localhost>
@@ -27,7 +27,7 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_cstate.c,v 1.10 2010/07/25 17:44:01 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_cstate.c,v 1.11 2010/07/27 05:11:33 jruoho Exp $");
#include <sys/param.h>
#include <sys/cpu.h>
@@ -49,26 +49,12 @@
#define _COMPONENT ACPI_BUS_COMPONENT
ACPI_MODULE_NAME ("acpi_cpu_cstate")
-/*
- * This is AML_RESOURCE_GENERIC_REGISTER,
- * included here separately for convenience.
- */
-struct acpicpu_reg {
- uint8_t reg_desc;
- uint16_t reg_reslen;
- uint8_t reg_spaceid;
- uint8_t reg_bitwidth;
- uint8_t reg_bitoffset;
- uint8_t reg_accesssize;
- uint64_t reg_addr;
-} __packed;
-
static void acpicpu_cstate_attach_print(struct acpicpu_softc *);
static ACPI_STATUS acpicpu_cstate_cst(struct acpicpu_softc *);
static ACPI_STATUS acpicpu_cstate_cst_add(struct acpicpu_softc *,
ACPI_OBJECT *);
static void acpicpu_cstate_cst_bios(void);
-static ACPI_STATUS acpicpu_cstate_csd(ACPI_HANDLE, struct acpicpu_csd *);
+static ACPI_STATUS acpicpu_cstate_csd(ACPI_HANDLE, struct acpicpu_dep *);
static void acpicpu_cstate_fadt(struct acpicpu_softc *);
static void acpicpu_cstate_quirks(struct acpicpu_softc *);
static int acpicpu_cstate_quirks_piix4(struct pci_attach_args *);
@@ -121,20 +107,20 @@
acpicpu_cstate_attach_print(struct acpicpu_softc *sc)
{
struct acpicpu_cstate *cs;
- struct acpicpu_csd csd;
+ struct acpicpu_dep dep;
const char *method;
ACPI_STATUS rv;
int i;
- (void)memset(&csd, 0, sizeof(struct acpicpu_csd));
+ (void)memset(&dep, 0, sizeof(struct acpicpu_dep));
- rv = acpicpu_cstate_csd(sc->sc_node->ad_handle, &csd);
+ rv = acpicpu_cstate_csd(sc->sc_node->ad_handle, &dep);
if (ACPI_SUCCESS(rv)) {
aprint_debug_dev(sc->sc_dev, "C%u: _CSD, "
"domain 0x%02x / 0x%02x, type 0x%02x\n",
- csd.csd_index, csd.csd_domain,
- csd.csd_ncpu, csd.csd_coord);
+ dep.dep_index, dep.dep_domain,
+ dep.dep_ncpu, dep.dep_coord);
}
aprint_debug_dev(sc->sc_dev, "Cx: %5s",
@@ -409,6 +395,13 @@
goto out;
}
+ CTASSERT(sizeof(struct acpicpu_reg) == 15);
+
+ if (obj->Buffer.Length < sizeof(struct acpicpu_reg)) {
+ rv = AE_LIMIT;
+ goto out;
+ }
+
reg = (struct acpicpu_reg *)obj->Buffer.Pointer;
switch (reg->reg_spaceid) {
@@ -512,7 +505,7 @@
}
static ACPI_STATUS
-acpicpu_cstate_csd(ACPI_HANDLE hdl, struct acpicpu_csd *csd)
+acpicpu_cstate_csd(ACPI_HANDLE hdl, struct acpicpu_dep *dep)
{
ACPI_OBJECT *elm, *obj;
ACPI_BUFFER buf;
@@ -558,10 +551,10 @@
goto out;
}
- csd->csd_domain = elm[2].Integer.Value;
- csd->csd_coord = elm[3].Integer.Value;
- csd->csd_ncpu = elm[4].Integer.Value;
- csd->csd_index = elm[5].Integer.Value;
+ dep->dep_domain = elm[2].Integer.Value;
+ dep->dep_coord = elm[3].Integer.Value;
+ dep->dep_ncpu = elm[4].Integer.Value;
+ dep->dep_index = elm[5].Integer.Value;
out:
if (buf.Pointer != NULL)
Home |
Main Index |
Thread Index |
Old Index