acpi.c (81092) | acpi.c (82372) |
---|---|
1/*- 2 * Copyright (c) 2000 Takanori Watanabe <takawata@jp.freebsd.org> 3 * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@jp.freebsd.org> 4 * Copyright (c) 2000, 2001 Michael Smith 5 * Copyright (c) 2000 BSDi 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * | 1/*- 2 * Copyright (c) 2000 Takanori Watanabe <takawata@jp.freebsd.org> 3 * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@jp.freebsd.org> 4 * Copyright (c) 2000, 2001 Michael Smith 5 * Copyright (c) 2000 BSDi 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * |
29 * $FreeBSD: head/sys/dev/acpica/acpi.c 81092 2001-08-03 08:38:11Z msmith $ | 29 * $FreeBSD: head/sys/dev/acpica/acpi.c 82372 2001-08-26 22:50:15Z msmith $ |
30 */ 31 32#include "opt_acpi.h" 33#include <sys/param.h> 34#include <sys/kernel.h> 35#include <sys/proc.h> 36#include <sys/lock.h> 37#include <sys/malloc.h> --- 569 unchanged lines hidden (view full) --- 607 int i; 608 609 FUNCTION_TRACE(__func__); 610 ACPI_ASSERTLOCK; 611 612 /* 613 * Create any static children by calling device identify methods. 614 */ | 30 */ 31 32#include "opt_acpi.h" 33#include <sys/param.h> 34#include <sys/kernel.h> 35#include <sys/proc.h> 36#include <sys/lock.h> 37#include <sys/malloc.h> --- 569 unchanged lines hidden (view full) --- 607 int i; 608 609 FUNCTION_TRACE(__func__); 610 ACPI_ASSERTLOCK; 611 612 /* 613 * Create any static children by calling device identify methods. 614 */ |
615 DEBUG_PRINT(TRACE_OBJECTS, ("device identify routines\n")); | 615 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "device identify routines\n")); |
616 bus_generic_probe(bus); 617 618 /* 619 * Scan the namespace and insert placeholders for all the devices that 620 * we find. 621 * 622 * Note that we use AcpiWalkNamespace rather than AcpiGetDevices because 623 * we want to create nodes for all devices, not just those that are currently 624 * present. (This assumes that we don't want to create/remove devices as they 625 * appear, which might be smarter.) 626 */ | 616 bus_generic_probe(bus); 617 618 /* 619 * Scan the namespace and insert placeholders for all the devices that 620 * we find. 621 * 622 * Note that we use AcpiWalkNamespace rather than AcpiGetDevices because 623 * we want to create nodes for all devices, not just those that are currently 624 * present. (This assumes that we don't want to create/remove devices as they 625 * appear, which might be smarter.) 626 */ |
627 DEBUG_PRINT(TRACE_OBJECTS, ("namespace scan\n")); | 627 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "namespace scan\n")); |
628 for (i = 0; scopes[i] != NULL; i++) 629 if ((AcpiGetHandle(ACPI_ROOT_OBJECT, scopes[i], &parent)) == AE_OK) 630 AcpiWalkNamespace(ACPI_TYPE_ANY, parent, 100, acpi_probe_child, bus, NULL); 631 632 /* 633 * Scan all of the child devices we have created and let them probe/attach. 634 */ | 628 for (i = 0; scopes[i] != NULL; i++) 629 if ((AcpiGetHandle(ACPI_ROOT_OBJECT, scopes[i], &parent)) == AE_OK) 630 AcpiWalkNamespace(ACPI_TYPE_ANY, parent, 100, acpi_probe_child, bus, NULL); 631 632 /* 633 * Scan all of the child devices we have created and let them probe/attach. 634 */ |
635 DEBUG_PRINT(TRACE_OBJECTS, ("first bus_generic_attach\n")); | 635 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "first bus_generic_attach\n")); |
636 bus_generic_attach(bus); 637 638 /* 639 * Some of these children may have attached others as part of their attach 640 * process (eg. the root PCI bus driver), so rescan. 641 */ | 636 bus_generic_attach(bus); 637 638 /* 639 * Some of these children may have attached others as part of their attach 640 * process (eg. the root PCI bus driver), so rescan. 641 */ |
642 DEBUG_PRINT(TRACE_OBJECTS, ("second bus_generic_attach\n")); | 642 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "second bus_generic_attach\n")); |
643 bus_generic_attach(bus); 644 645 return_VOID; 646} 647 648/* 649 * Evaluate a child device and determine whether we might attach a device to 650 * it. --- 19 unchanged lines hidden (view full) --- 670 case ACPI_TYPE_THERMAL: 671 case ACPI_TYPE_POWER: 672 if (acpi_disabled("children")) 673 break; 674 /* 675 * Create a placeholder device for this node. Sort the placeholder 676 * so that the probe/attach passes will run breadth-first. 677 */ | 643 bus_generic_attach(bus); 644 645 return_VOID; 646} 647 648/* 649 * Evaluate a child device and determine whether we might attach a device to 650 * it. --- 19 unchanged lines hidden (view full) --- 670 case ACPI_TYPE_THERMAL: 671 case ACPI_TYPE_POWER: 672 if (acpi_disabled("children")) 673 break; 674 /* 675 * Create a placeholder device for this node. Sort the placeholder 676 * so that the probe/attach passes will run breadth-first. 677 */ |
678 DEBUG_PRINT(TRACE_OBJECTS, ("scanning '%s'\n", acpi_name(handle))) | 678 ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "scanning '%s'\n", acpi_name(handle))); |
679 child = BUS_ADD_CHILD(bus, level * 10, NULL, -1); 680 acpi_set_handle(child, handle); 681 DEBUG_EXEC(device_probe_and_attach(child)); 682 break; 683 } 684 } 685 return_ACPI_STATUS(AE_OK); 686} --- 418 unchanged lines hidden (view full) --- 1105 /* Check result code for _WAK */ 1106 if (Objects[0].Type != ACPI_TYPE_PACKAGE || 1107 Objects[1].Type != ACPI_TYPE_INTEGER || 1108 Objects[2].Type != ACPI_TYPE_INTEGER) { 1109 /* 1110 * In many BIOSes, _WAK doesn't return a result code. 1111 * We don't need to worry about it too much :-). 1112 */ | 679 child = BUS_ADD_CHILD(bus, level * 10, NULL, -1); 680 acpi_set_handle(child, handle); 681 DEBUG_EXEC(device_probe_and_attach(child)); 682 break; 683 } 684 } 685 return_ACPI_STATUS(AE_OK); 686} --- 418 unchanged lines hidden (view full) --- 1105 /* Check result code for _WAK */ 1106 if (Objects[0].Type != ACPI_TYPE_PACKAGE || 1107 Objects[1].Type != ACPI_TYPE_INTEGER || 1108 Objects[2].Type != ACPI_TYPE_INTEGER) { 1109 /* 1110 * In many BIOSes, _WAK doesn't return a result code. 1111 * We don't need to worry about it too much :-). 1112 */ |
1113 DEBUG_PRINT(ACPI_INFO, 1114 ("acpi_wakeup: _WAK result code is corrupted, " 1115 "but should be OK.\n")); | 1113 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 1114 "acpi_wakeup: _WAK result code is corrupted, " 1115 "but should be OK.\n")); |
1116 } else { 1117 /* evaluate status code */ 1118 switch (Objects[1].Integer.Value) { 1119 case 0x00000001: | 1116 } else { 1117 /* evaluate status code */ 1118 switch (Objects[1].Integer.Value) { 1119 case 0x00000001: |
1120 DEBUG_PRINT(ACPI_ERROR, 1121 ("acpi_wakeup: Wake was signaled " 1122 "but failed due to lack of power.\n")); | 1120 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1121 "acpi_wakeup: Wake was signaled " 1122 "but failed due to lack of power.\n")); |
1123 Status = AE_ERROR; 1124 break; 1125 1126 case 0x00000002: | 1123 Status = AE_ERROR; 1124 break; 1125 1126 case 0x00000002: |
1127 DEBUG_PRINT(ACPI_ERROR, 1128 ("acpi_wakeup: Wake was signaled " 1129 "but failed due to thermal condition.\n")); | 1127 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1128 "acpi_wakeup: Wake was signaled " 1129 "but failed due to thermal condition.\n")); |
1130 Status = AE_ERROR; 1131 break; 1132 } 1133 /* evaluate PSS code */ 1134 if (Objects[2].Integer.Value == 0) { | 1130 Status = AE_ERROR; 1131 break; 1132 } 1133 /* evaluate PSS code */ 1134 if (Objects[2].Integer.Value == 0) { |
1135 DEBUG_PRINT(ACPI_ERROR, 1136 ("acpi_wakeup: The targeted S-state " 1137 "was not entered because of too much current " 1138 "being drawn from the power supply.\n")); | 1135 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1136 "acpi_wakeup: The targeted S-state " 1137 "was not entered because of too much current " 1138 "being drawn from the power supply.\n")); |
1139 Status = AE_ERROR; 1140 } 1141 } 1142 return_ACPI_STATUS(Status); 1143} 1144 1145/* 1146 * Set the system sleep state --- 264 unchanged lines hidden (view full) --- 1411 for (;;) { 1412 while ((*cp != 0) && isspace(*cp)) 1413 cp++; 1414 if (*cp == 0) 1415 break; 1416 len = 0; 1417 while ((cp[len] != 0) && !isspace(cp[len])) 1418 len++; | 1139 Status = AE_ERROR; 1140 } 1141 } 1142 return_ACPI_STATUS(Status); 1143} 1144 1145/* 1146 * Set the system sleep state --- 264 unchanged lines hidden (view full) --- 1411 for (;;) { 1412 while ((*cp != 0) && isspace(*cp)) 1413 cp++; 1414 if (*cp == 0) 1415 break; 1416 len = 0; 1417 while ((cp[len] != 0) && !isspace(cp[len])) 1418 len++; |
1419 if (!strncmp(cp, np, len)) { 1420 DEBUG_PRINT(TRACE_OBJECTS, ("avoiding '%s'\n", np)); | 1419 if (!strncmp(cp, np, len)) |
1421 return(1); | 1420 return(1); |
1422 } | |
1423 cp += len; 1424 } 1425 return(0); 1426} 1427 1428/* 1429 * Debugging/bug-avoidance. Disable ACPI subsystem components. 1430 */ --- 12 unchanged lines hidden (view full) --- 1443 for (;;) { 1444 while ((*cp != 0) && isspace(*cp)) 1445 cp++; 1446 if (*cp == 0) 1447 break; 1448 len = 0; 1449 while ((cp[len] != 0) && !isspace(cp[len])) 1450 len++; | 1421 cp += len; 1422 } 1423 return(0); 1424} 1425 1426/* 1427 * Debugging/bug-avoidance. Disable ACPI subsystem components. 1428 */ --- 12 unchanged lines hidden (view full) --- 1441 for (;;) { 1442 while ((*cp != 0) && isspace(*cp)) 1443 cp++; 1444 if (*cp == 0) 1445 break; 1446 len = 0; 1447 while ((cp[len] != 0) && !isspace(cp[len])) 1448 len++; |
1451 if (!strncmp(cp, subsys, len)) { 1452 DEBUG_PRINT(TRACE_OBJECTS, ("disabled '%s'\n", subsys)); | 1449 if (!strncmp(cp, subsys, len)) |
1453 return(1); | 1450 return(1); |
1454 } | |
1455 cp += len; 1456 } 1457 return(0); 1458} 1459 1460/* 1461 * Control interface. 1462 * --- 177 unchanged lines hidden (view full) --- 1640 {"ACPI_HARDWARE", ACPI_HARDWARE}, 1641 {"ACPI_EVENTS", ACPI_EVENTS}, 1642 {"ACPI_TABLES", ACPI_TABLES}, 1643 {"ACPI_NAMESPACE", ACPI_NAMESPACE}, 1644 {"ACPI_PARSER", ACPI_PARSER}, 1645 {"ACPI_DISPATCHER", ACPI_DISPATCHER}, 1646 {"ACPI_EXECUTER", ACPI_EXECUTER}, 1647 {"ACPI_RESOURCES", ACPI_RESOURCES}, | 1451 cp += len; 1452 } 1453 return(0); 1454} 1455 1456/* 1457 * Control interface. 1458 * --- 177 unchanged lines hidden (view full) --- 1636 {"ACPI_HARDWARE", ACPI_HARDWARE}, 1637 {"ACPI_EVENTS", ACPI_EVENTS}, 1638 {"ACPI_TABLES", ACPI_TABLES}, 1639 {"ACPI_NAMESPACE", ACPI_NAMESPACE}, 1640 {"ACPI_PARSER", ACPI_PARSER}, 1641 {"ACPI_DISPATCHER", ACPI_DISPATCHER}, 1642 {"ACPI_EXECUTER", ACPI_EXECUTER}, 1643 {"ACPI_RESOURCES", ACPI_RESOURCES}, |
1648 {"ACPI_POWER", ACPI_POWER}, | 1644 {"ACPI_DEBUGGER", ACPI_DEBUGGER}, 1645 {"ACPI_OS_SERVICES", ACPI_OS_SERVICES}, 1646 |
1649 {"ACPI_BUS", ACPI_BUS}, | 1647 {"ACPI_BUS", ACPI_BUS}, |
1648 {"ACPI_SYSTEM", ACPI_SYSTEM}, |
|
1650 {"ACPI_POWER", ACPI_POWER}, 1651 {"ACPI_EC", ACPI_EC}, | 1649 {"ACPI_POWER", ACPI_POWER}, 1650 {"ACPI_EC", ACPI_EC}, |
1652 {"ACPI_PROCESSOR", ACPI_PROCESSOR}, | |
1653 {"ACPI_AC_ADAPTER", ACPI_AC_ADAPTER}, 1654 {"ACPI_BATTERY", ACPI_BATTERY}, 1655 {"ACPI_BUTTON", ACPI_BUTTON}, | 1651 {"ACPI_AC_ADAPTER", ACPI_AC_ADAPTER}, 1652 {"ACPI_BATTERY", ACPI_BATTERY}, 1653 {"ACPI_BUTTON", ACPI_BUTTON}, |
1656 {"ACPI_SYSTEM", ACPI_SYSTEM}, | 1654 {"ACPI_PROCESSOR", ACPI_PROCESSOR}, |
1657 {"ACPI_THERMAL", ACPI_THERMAL}, | 1655 {"ACPI_THERMAL", ACPI_THERMAL}, |
1658 {"ACPI_DEBUGGER", ACPI_DEBUGGER}, 1659 {"ACPI_OS_SERVICES", ACPI_OS_SERVICES}, | 1656 {"ACPI_FAN", ACPI_FAN}, 1657 |
1660 {"ACPI_ALL_COMPONENTS", ACPI_ALL_COMPONENTS}, 1661 {NULL, 0} 1662}; 1663 1664static struct debugtag dbg_level[] = { | 1658 {"ACPI_ALL_COMPONENTS", ACPI_ALL_COMPONENTS}, 1659 {NULL, 0} 1660}; 1661 1662static struct debugtag dbg_level[] = { |
1665 {"ACPI_OK", ACPI_OK}, 1666 {"ACPI_INFO", ACPI_INFO}, 1667 {"ACPI_WARN", ACPI_WARN}, 1668 {"ACPI_ERROR", ACPI_ERROR}, 1669 {"ACPI_FATAL", ACPI_FATAL}, 1670 {"ACPI_DEBUG_OBJECT", ACPI_DEBUG_OBJECT}, 1671 {"ACPI_ALL", ACPI_ALL}, 1672 {"TRACE_THREADS", TRACE_THREADS}, 1673 {"TRACE_PARSE", TRACE_PARSE}, 1674 {"TRACE_DISPATCH", TRACE_DISPATCH}, 1675 {"TRACE_LOAD", TRACE_LOAD}, 1676 {"TRACE_EXEC", TRACE_EXEC}, 1677 {"TRACE_NAMES", TRACE_NAMES}, 1678 {"TRACE_OPREGION", TRACE_OPREGION}, 1679 {"TRACE_BFIELD", TRACE_BFIELD}, 1680 {"TRACE_TRASH", TRACE_TRASH}, 1681 {"TRACE_TABLES", TRACE_TABLES}, 1682 {"TRACE_FUNCTIONS", TRACE_FUNCTIONS}, 1683 {"TRACE_VALUES", TRACE_VALUES}, 1684 {"TRACE_OBJECTS", TRACE_OBJECTS}, 1685 {"TRACE_ALLOCATIONS", TRACE_ALLOCATIONS}, 1686 {"TRACE_RESOURCES", TRACE_RESOURCES}, 1687 {"TRACE_IO", TRACE_IO}, 1688 {"TRACE_INTERRUPTS", TRACE_INTERRUPTS}, 1689 {"TRACE_USER_REQUESTS", TRACE_USER_REQUESTS}, 1690 {"TRACE_PACKAGE", TRACE_PACKAGE}, 1691 {"TRACE_MUTEX", TRACE_MUTEX}, 1692 {"TRACE_INIT", TRACE_INIT}, 1693 {"TRACE_ALL", TRACE_ALL}, 1694 {"VERBOSE_AML_DISASSEMBLE", VERBOSE_AML_DISASSEMBLE}, 1695 {"VERBOSE_INFO", VERBOSE_INFO}, 1696 {"VERBOSE_TABLES", VERBOSE_TABLES}, 1697 {"VERBOSE_EVENTS", VERBOSE_EVENTS}, 1698 {"VERBOSE_ALL", VERBOSE_ALL}, | 1663 {"ACPI_LV_OK", ACPI_LV_OK}, 1664 {"ACPI_LV_INFO", ACPI_LV_INFO}, 1665 {"ACPI_LV_WARN", ACPI_LV_WARN}, 1666 {"ACPI_LV_ERROR", ACPI_LV_ERROR}, 1667 {"ACPI_LV_FATAL", ACPI_LV_FATAL}, 1668 {"ACPI_LV_DEBUG_OBJECT", ACPI_LV_DEBUG_OBJECT}, 1669 {"ACPI_LV_ALL_EXCEPTIONS", ACPI_LV_ALL_EXCEPTIONS}, 1670 {"ACPI_LV_THREADS", ACPI_LV_THREADS}, 1671 {"ACPI_LV_PARSE", ACPI_LV_PARSE}, 1672 {"ACPI_LV_DISPATCH", ACPI_LV_DISPATCH}, 1673 {"ACPI_LV_LOAD", ACPI_LV_LOAD}, 1674 {"ACPI_LV_EXEC", ACPI_LV_EXEC}, 1675 {"ACPI_LV_NAMES", ACPI_LV_NAMES}, 1676 {"ACPI_LV_OPREGION", ACPI_LV_OPREGION}, 1677 {"ACPI_LV_BFIELD", ACPI_LV_BFIELD}, 1678 {"ACPI_LV_TRASH", ACPI_LV_TRASH}, 1679 {"ACPI_LV_TABLES", ACPI_LV_TABLES}, 1680 {"ACPI_LV_FUNCTIONS", ACPI_LV_FUNCTIONS}, 1681 {"ACPI_LV_VALUES", ACPI_LV_VALUES}, 1682 {"ACPI_LV_OBJECTS", ACPI_LV_OBJECTS}, 1683 {"ACPI_LV_ALLOCATIONS", ACPI_LV_ALLOCATIONS}, 1684 {"ACPI_LV_RESOURCES", ACPI_LV_RESOURCES}, 1685 {"ACPI_LV_IO", ACPI_LV_IO}, 1686 {"ACPI_LV_INTERRUPTS", ACPI_LV_INTERRUPTS}, 1687 {"ACPI_LV_USER_REQUESTS", ACPI_LV_USER_REQUESTS}, 1688 {"ACPI_LV_PACKAGE", ACPI_LV_PACKAGE}, 1689 {"ACPI_LV_MUTEX", ACPI_LV_MUTEX}, 1690 {"ACPI_LV_INIT", ACPI_LV_INIT}, 1691 {"ACPI_LV_ALL", ACPI_LV_ALL}, 1692 {"ACPI_DB_AML_DISASSEMBLE", ACPI_DB_AML_DISASSEMBLE}, 1693 {"ACPI_DB_VERBOSE_INFO", ACPI_DB_VERBOSE_INFO}, 1694 {"ACPI_DB_FULL_TABLES", ACPI_DB_FULL_TABLES}, 1695 {"ACPI_DB_EVENTS", ACPI_DB_EVENTS}, 1696 {"ACPI_DB_VERBOSE", ACPI_DB_VERBOSE}, |
1699 {NULL, 0} 1700}; 1701 1702static void 1703acpi_parse_debug(char *cp, struct debugtag *tag, UINT32 *flag) 1704{ 1705 char *ep; 1706 int i, l; --- 49 unchanged lines hidden --- | 1697 {NULL, 0} 1698}; 1699 1700static void 1701acpi_parse_debug(char *cp, struct debugtag *tag, UINT32 *flag) 1702{ 1703 char *ep; 1704 int i, l; --- 49 unchanged lines hidden --- |