Deleted Added
full compact
acpi_powerres.c (133622) acpi_powerres.c (134908)
1/*-
2 * Copyright (c) 2001 Michael Smith
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001 Michael Smith
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/dev/acpica/acpi_powerres.c 133622 2004-08-13 06:22:10Z njl $");
28__FBSDID("$FreeBSD: head/sys/dev/acpica/acpi_powerres.c 134908 2004-09-07 16:58:12Z njl $");
29
30#include "opt_acpi.h"
31#include <sys/param.h>
32#include <sys/kernel.h>
33#include <sys/malloc.h>
34#include <sys/bus.h>
35
36#include "acpi.h"

--- 20 unchanged lines hidden (view full) ---

57
58/* Hooks for the ACPI CA debugging infrastructure */
59#define _COMPONENT ACPI_POWERRES
60ACPI_MODULE_NAME("POWERRES")
61
62/* Return values from _STA on a power resource */
63#define ACPI_PWR_OFF 0
64#define ACPI_PWR_ON 1
29
30#include "opt_acpi.h"
31#include <sys/param.h>
32#include <sys/kernel.h>
33#include <sys/malloc.h>
34#include <sys/bus.h>
35
36#include "acpi.h"

--- 20 unchanged lines hidden (view full) ---

57
58/* Hooks for the ACPI CA debugging infrastructure */
59#define _COMPONENT ACPI_POWERRES
60ACPI_MODULE_NAME("POWERRES")
61
62/* Return values from _STA on a power resource */
63#define ACPI_PWR_OFF 0
64#define ACPI_PWR_ON 1
65#define ACPI_PWR_UNK (-1)
65
66/* A relationship between a power resource and a consumer. */
67struct acpi_powerreference {
68 struct acpi_powerconsumer *ar_consumer;
69 struct acpi_powerresource *ar_resource;
70 TAILQ_ENTRY(acpi_powerreference) ar_rlink; /* link on resource list */
71 TAILQ_ENTRY(acpi_powerreference) ar_clink; /* link on consumer */
72};

--- 9 unchanged lines hidden (view full) ---

82
83/* A power resource. */
84struct acpi_powerresource {
85 TAILQ_ENTRY(acpi_powerresource) ap_link;
86 TAILQ_HEAD(,acpi_powerreference) ap_references;
87 ACPI_HANDLE ap_resource;
88 ACPI_INTEGER ap_systemlevel;
89 ACPI_INTEGER ap_order;
66
67/* A relationship between a power resource and a consumer. */
68struct acpi_powerreference {
69 struct acpi_powerconsumer *ar_consumer;
70 struct acpi_powerresource *ar_resource;
71 TAILQ_ENTRY(acpi_powerreference) ar_rlink; /* link on resource list */
72 TAILQ_ENTRY(acpi_powerreference) ar_clink; /* link on consumer */
73};

--- 9 unchanged lines hidden (view full) ---

83
84/* A power resource. */
85struct acpi_powerresource {
86 TAILQ_ENTRY(acpi_powerresource) ap_link;
87 TAILQ_HEAD(,acpi_powerreference) ap_references;
88 ACPI_HANDLE ap_resource;
89 ACPI_INTEGER ap_systemlevel;
90 ACPI_INTEGER ap_order;
91 int ap_state;
90};
91
92static TAILQ_HEAD(acpi_powerresource_list, acpi_powerresource)
93 acpi_powerresources;
94static TAILQ_HEAD(acpi_powerconsumer_list, acpi_powerconsumer)
95 acpi_powerconsumers;
96ACPI_SERIAL_DECL(powerres, "ACPI power resources");
97

--- 66 unchanged lines hidden (view full) ---

164 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
165 "questionable power resource object %s\n",
166 acpi_name(res)));
167 status = AE_TYPE;
168 goto out;
169 }
170 rp->ap_systemlevel = obj->PowerResource.SystemLevel;
171 rp->ap_order = obj->PowerResource.ResourceOrder;
92};
93
94static TAILQ_HEAD(acpi_powerresource_list, acpi_powerresource)
95 acpi_powerresources;
96static TAILQ_HEAD(acpi_powerconsumer_list, acpi_powerconsumer)
97 acpi_powerconsumers;
98ACPI_SERIAL_DECL(powerres, "ACPI power resources");
99

--- 66 unchanged lines hidden (view full) ---

166 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
167 "questionable power resource object %s\n",
168 acpi_name(res)));
169 status = AE_TYPE;
170 goto out;
171 }
172 rp->ap_systemlevel = obj->PowerResource.SystemLevel;
173 rp->ap_order = obj->PowerResource.ResourceOrder;
174 rp->ap_state = ACPI_PWR_UNK;
172
173 /* Sort the resource into the list */
174 status = AE_OK;
175 srp = TAILQ_FIRST(&acpi_powerresources);
176 if (srp == NULL || rp->ap_order < srp->ap_order) {
177 TAILQ_INSERT_HEAD(&acpi_powerresources, rp, ap_link);
178 goto done;
179 }

--- 455 unchanged lines hidden (view full) ---

635 continue;
636 }
637
638 /* We could cache this if we trusted it not to change under us */
639 status = acpi_GetInteger(rp->ap_resource, "_STA", &cur);
640 if (ACPI_FAILURE(status)) {
641 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "can't get status of %s - %d\n",
642 acpi_name(rp->ap_resource), status));
175
176 /* Sort the resource into the list */
177 status = AE_OK;
178 srp = TAILQ_FIRST(&acpi_powerresources);
179 if (srp == NULL || rp->ap_order < srp->ap_order) {
180 TAILQ_INSERT_HEAD(&acpi_powerresources, rp, ap_link);
181 goto done;
182 }

--- 455 unchanged lines hidden (view full) ---

638 continue;
639 }
640
641 /* We could cache this if we trusted it not to change under us */
642 status = acpi_GetInteger(rp->ap_resource, "_STA", &cur);
643 if (ACPI_FAILURE(status)) {
644 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "can't get status of %s - %d\n",
645 acpi_name(rp->ap_resource), status));
643
644 /* XXX is this correct? Always switch if in doubt? */
645 continue;
646 /* XXX is this correct? Always switch if in doubt? */
647 continue;
646 }
648 } else if (rp->ap_state == ACPI_PWR_UNK)
649 rp->ap_state = cur;
647
648 /*
649 * Switch if required. Note that we ignore the result of the switch
650 * effort; we don't know what to do if it fails, so checking wouldn't
651 * help much.
652 */
650
651 /*
652 * Switch if required. Note that we ignore the result of the switch
653 * effort; we don't know what to do if it fails, so checking wouldn't
654 * help much.
655 */
653 if (cur != ACPI_PWR_ON) {
656 if (rp->ap_state != ACPI_PWR_ON) {
654 status = AcpiEvaluateObject(rp->ap_resource, "_ON", NULL, NULL);
655 if (ACPI_FAILURE(status)) {
656 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
657 "failed to switch %s on - %s\n",
658 acpi_name(rp->ap_resource),
659 AcpiFormatException(status)));
660 } else {
657 status = AcpiEvaluateObject(rp->ap_resource, "_ON", NULL, NULL);
658 if (ACPI_FAILURE(status)) {
659 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
660 "failed to switch %s on - %s\n",
661 acpi_name(rp->ap_resource),
662 AcpiFormatException(status)));
663 } else {
664 rp->ap_state = ACPI_PWR_ON;
661 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "switched %s on\n",
662 acpi_name(rp->ap_resource)));
663 }
664 } else {
665 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "%s is already on\n",
666 acpi_name(rp->ap_resource)));
667 }
668 }

--- 11 unchanged lines hidden (view full) ---

680
681 /* We could cache this if we trusted it not to change under us */
682 status = acpi_GetInteger(rp->ap_resource, "_STA", &cur);
683 if (ACPI_FAILURE(status)) {
684 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "can't get status of %s - %d\n",
685 acpi_name(rp->ap_resource), status));
686 /* XXX is this correct? Always switch if in doubt? */
687 continue;
665 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "switched %s on\n",
666 acpi_name(rp->ap_resource)));
667 }
668 } else {
669 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "%s is already on\n",
670 acpi_name(rp->ap_resource)));
671 }
672 }

--- 11 unchanged lines hidden (view full) ---

684
685 /* We could cache this if we trusted it not to change under us */
686 status = acpi_GetInteger(rp->ap_resource, "_STA", &cur);
687 if (ACPI_FAILURE(status)) {
688 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "can't get status of %s - %d\n",
689 acpi_name(rp->ap_resource), status));
690 /* XXX is this correct? Always switch if in doubt? */
691 continue;
688 }
692 } else if (rp->ap_state == ACPI_PWR_UNK)
693 rp->ap_state = cur;
689
690 /*
691 * Switch if required. Note that we ignore the result of the switch
692 * effort; we don't know what to do if it fails, so checking wouldn't
693 * help much.
694 */
694
695 /*
696 * Switch if required. Note that we ignore the result of the switch
697 * effort; we don't know what to do if it fails, so checking wouldn't
698 * help much.
699 */
695 if (cur != ACPI_PWR_OFF) {
700 if (rp->ap_state != ACPI_PWR_OFF) {
696 status = AcpiEvaluateObject(rp->ap_resource, "_OFF", NULL, NULL);
697 if (ACPI_FAILURE(status)) {
698 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
699 "failed to switch %s off - %s\n",
700 acpi_name(rp->ap_resource),
701 AcpiFormatException(status)));
702 } else {
701 status = AcpiEvaluateObject(rp->ap_resource, "_OFF", NULL, NULL);
702 if (ACPI_FAILURE(status)) {
703 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
704 "failed to switch %s off - %s\n",
705 acpi_name(rp->ap_resource),
706 AcpiFormatException(status)));
707 } else {
708 rp->ap_state = ACPI_PWR_OFF;
703 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "switched %s off\n",
704 acpi_name(rp->ap_resource)));
705 }
706 } else {
707 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "%s is already off\n",
708 acpi_name(rp->ap_resource)));
709 }
710 }

--- 41 unchanged lines hidden ---
709 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "switched %s off\n",
710 acpi_name(rp->ap_resource)));
711 }
712 } else {
713 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "%s is already off\n",
714 acpi_name(rp->ap_resource)));
715 }
716 }

--- 41 unchanged lines hidden ---