Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/dev/acpi/acpi.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/dev/acpi/acpi.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.251.2.3 retrieving revision 1.252 diff -u -p -r1.251.2.3 -r1.252 --- src/sys/dev/acpi/acpi.c 2014/05/22 11:40:19 1.251.2.3 +++ src/sys/dev/acpi/acpi.c 2011/11/14 02:44:59 1.252 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi.c,v 1.251.2.3 2014/05/22 11:40:19 yamt Exp $ */ +/* $NetBSD: acpi.c,v 1.252 2011/11/14 02:44:59 jmcneill Exp $ */ /*- * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc. @@ -100,7 +100,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.251.2.3 2014/05/22 11:40:19 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.252 2011/11/14 02:44:59 jmcneill Exp $"); #include "opt_acpi.h" #include "opt_pcifixup.h" @@ -190,7 +190,6 @@ static bool acpi_suspend(device_t, cons static bool acpi_resume(device_t, const pmf_qual_t *); static void acpi_build_tree(struct acpi_softc *); -static void acpi_config_tree(struct acpi_softc *); static ACPI_STATUS acpi_make_devnode(ACPI_HANDLE, uint32_t, void *, void **); static ACPI_STATUS acpi_make_devnode_post(ACPI_HANDLE, uint32_t, @@ -463,8 +462,20 @@ acpi_attach(device_t parent, device_t se /* * Bring ACPICA on-line. */ +#define ACPI_ENABLE_PHASE1 \ + (ACPI_NO_HANDLER_INIT | ACPI_NO_EVENT_INIT) +#define ACPI_ENABLE_PHASE2 \ + (ACPI_NO_HARDWARE_INIT | ACPI_NO_ACPI_ENABLE | \ + ACPI_NO_ADDRESS_SPACE_INIT) - rv = AcpiEnableSubsystem(ACPI_FULL_INITIALIZATION); + rv = AcpiEnableSubsystem(ACPI_ENABLE_PHASE1); + + if (ACPI_FAILURE(rv)) + goto fail; + + acpi_md_callback(); + + rv = AcpiEnableSubsystem(ACPI_ENABLE_PHASE2); if (ACPI_FAILURE(rv)) goto fail; @@ -480,13 +491,6 @@ acpi_attach(device_t parent, device_t se goto fail; /* - * Scan the namespace and build our device tree. - */ - acpi_build_tree(sc); - - acpi_md_callback(sc); - - /* * Early initialization of the _PDC control method * that may load additional SSDT tables dynamically. */ @@ -520,7 +524,11 @@ acpi_attach(device_t parent, device_t se acpi_register_fixed_button(sc, ACPI_EVENT_SLEEP_BUTTON); acpitimer_init(sc); - acpi_config_tree(sc); + + /* + * Scan the namespace and build our device tree. + */ + acpi_build_tree(sc); acpi_sleep_init(sc); #ifdef ACPI_DEBUG @@ -658,15 +666,6 @@ acpi_build_tree(struct acpi_softc *sc) * Scan the internal namespace. */ (void)acpi_pcidev_scan(sc->sc_root); -} - -static void -acpi_config_tree(struct acpi_softc *sc) -{ - - /* - * Configure all everything found "at acpi?". - */ (void)acpi_rescan(sc->sc_dev, NULL, NULL); /* @@ -709,7 +708,7 @@ acpi_make_devnode(ACPI_HANDLE handle, ui case ACPI_TYPE_THERMAL: case ACPI_TYPE_POWER: - ad = kmem_zalloc(sizeof(*ad), KM_SLEEP); + ad = kmem_zalloc(sizeof(*ad), KM_NOSLEEP); if (ad == NULL) return AE_NO_MEMORY; @@ -1296,6 +1295,7 @@ acpi_enter_sleep_state(int state) { struct acpi_softc *sc = acpi_softc; ACPI_STATUS rv; + int err; if (acpi_softc == NULL) return; @@ -1402,7 +1402,7 @@ acpi_enter_sleep_state(int state) } else { - (void)acpi_md_sleep(state); + err = acpi_md_sleep(state); if (state == ACPI_STATE_S4) AcpiEnable(); @@ -1455,14 +1455,22 @@ acpi_enter_sleep_state(int state) */ SYSCTL_SETUP(sysctl_acpi_setup, "sysctl hw.acpi subtree setup") { - const struct sysctlnode *rnode, *snode; + const struct sysctlnode *mnode, *rnode, *snode; int err; err = sysctl_createv(clog, 0, NULL, &rnode, + CTLFLAG_PERMANENT, CTLTYPE_NODE, "hw", + NULL, NULL, 0, NULL, 0, + CTL_HW, CTL_EOL); + + if (err != 0) + return; + + err = sysctl_createv(clog, 0, &rnode, &rnode, CTLFLAG_PERMANENT, CTLTYPE_NODE, "acpi", SYSCTL_DESCR("ACPI subsystem parameters"), NULL, 0, NULL, 0, - CTL_HW, CTL_CREATE, CTL_EOL); + CTL_CREATE, CTL_EOL); if (err != 0) return; @@ -1494,6 +1502,24 @@ SYSCTL_SETUP(sysctl_acpi_setup, "sysctl sysctl_hw_acpi_sleepstates, 0, NULL, 0, CTL_CREATE, CTL_EOL); + /* + * For the time being, machdep.sleep_state + * is provided for backwards compatibility. + */ + err = sysctl_createv(NULL, 0, NULL, &mnode, + CTLFLAG_PERMANENT, CTLTYPE_NODE, "machdep", + NULL, NULL, 0, NULL, 0, + CTL_MACHDEP, CTL_EOL); + + if (err == 0) { + + (void)sysctl_createv(NULL, 0, &mnode, NULL, + CTLFLAG_PERMANENT | CTLFLAG_READWRITE, CTLTYPE_INT, + "sleep_state", SYSCTL_DESCR("System sleep state"), + sysctl_hw_acpi_sleepstate, 0, NULL, 0, + CTL_CREATE, CTL_EOL); + } + err = sysctl_createv(clog, 0, &rnode, &rnode, CTLFLAG_PERMANENT, CTLTYPE_NODE, "stat", SYSCTL_DESCR("ACPI statistics"), @@ -1845,9 +1871,7 @@ acpi_allocate_resources(ACPI_HANDLE hand ACPI_BUFFER bufp, bufc, bufn; ACPI_RESOURCE *resp, *resc, *resn; ACPI_RESOURCE_IRQ *irq; -#if 0 ACPI_RESOURCE_EXTENDED_IRQ *xirq; -#endif ACPI_STATUS rv; uint delta; @@ -1885,8 +1909,8 @@ acpi_allocate_resources(ACPI_HANDLE hand case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: memcpy(&resn->Data, &resp->Data, sizeof(ACPI_RESOURCE_EXTENDED_IRQ)); -#if 0 xirq = (ACPI_RESOURCE_EXTENDED_IRQ *)&resn->Data; +#if 0 /* * XXX: Not duplicating the interrupt logic above * because its not clear what it accomplishes.