Deleted Added
sdiff udiff text old ( 78689 ) new ( 78915 )
full compact
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 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 78689 2001-06-24 02:37:38Z iwasaki $
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>

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

702 device_printf(sc->acpi_dev, MSGFORMAT, "sleep");
703 }
704 }
705
706 first_time = 0;
707}
708
709/*
710 * Match a HID string against a device
711 */
712BOOLEAN
713acpi_MatchHid(device_t dev, char *hid)
714{
715 ACPI_HANDLE h;
716 ACPI_DEVICE_INFO devinfo;
717 ACPI_STATUS error;

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

723 if ((error = AcpiGetObjectInfo(h, &devinfo)) != AE_OK)
724 return(FALSE);
725 if ((devinfo.Valid & ACPI_VALID_HID) && !strcmp(hid, devinfo.HardwareId))
726 return(TRUE);
727 return(FALSE);
728}
729
730/*
731 * Perform the tedious double-get procedure required for fetching something into
732 * an ACPI_BUFFER that has not been initialised.
733 */
734ACPI_STATUS
735acpi_GetIntoBuffer(ACPI_HANDLE handle, ACPI_STATUS (*func)(ACPI_HANDLE, ACPI_BUFFER *), ACPI_BUFFER *buf)
736{
737 ACPI_STATUS status;
738
739 buf->Length = 0;
740 buf->Pointer = NULL;
741
742 if ((status = func(handle, buf)) != AE_BUFFER_OVERFLOW)
743 return(status);
744 if ((buf->Pointer = AcpiOsCallocate(buf->Length)) == NULL)
745 return(AE_NO_MEMORY);
746 return(func(handle, buf));
747}
748
749/*
750 * Allocate a buffer with a preset data size.
751 */
752ACPI_BUFFER *
753acpi_AllocBuffer(int size)
754{
755 ACPI_BUFFER *buf;
756
757 if ((buf = malloc(size + sizeof(*buf), M_ACPIDEV, M_NOWAIT)) == NULL)
758 return(NULL);
759 buf->Length = size;
760 buf->Pointer = (void *)(buf + 1);
761 return(buf);
762}
763
764static ACPI_STATUS __inline
765acpi_wakeup(UINT8 state)
766{
767 UINT16 Count;
768 ACPI_STATUS Status;
769 ACPI_OBJECT_LIST Arg_list;
770 ACPI_OBJECT Arg;
771 ACPI_OBJECT Objects[3]; /* package plus 2 number objects */

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

948 status = AE_OK;
949 }
950 if (status == AE_OK)
951 sc->acpi_enabled = 0;
952 return_ACPI_STATUS(status);
953}
954
955/*
956 * Returns true if the device is actually present and should
957 * be attached to. This requires the present, enabled, UI-visible
958 * and diagnostics-passed bits to be set.
959 */
960BOOLEAN
961acpi_DeviceIsPresent(device_t dev)
962{
963 ACPI_HANDLE h;
964 ACPI_DEVICE_INFO devinfo;
965 ACPI_STATUS error;
966
967 if ((h = acpi_get_handle(dev)) == NULL)
968 return(FALSE);
969 if ((error = AcpiGetObjectInfo(h, &devinfo)) != AE_OK)
970 return(FALSE);
971 if ((devinfo.Valid & ACPI_VALID_HID) && (devinfo.CurrentStatus & 0xf))
972 return(TRUE);
973 return(FALSE);
974}
975
976/*
977 * Evaluate a path that should return an integer.
978 */
979ACPI_STATUS
980acpi_EvaluateInteger(ACPI_HANDLE handle, char *path, int *number)
981{
982 ACPI_STATUS error;
983 ACPI_BUFFER buf;
984 ACPI_OBJECT param;
985
986 if (handle == NULL)
987 handle = ACPI_ROOT_OBJECT;
988 buf.Pointer = &param;
989 buf.Length = sizeof(param);
990 if ((error = AcpiEvaluateObject(handle, path, NULL, &buf)) == AE_OK) {
991 if (param.Type == ACPI_TYPE_INTEGER) {
992 *number = param.Integer.Value;
993 } else {
994 error = AE_TYPE;
995 }
996 }
997 return(error);
998}
999
1000/*
1001 * ACPI Event Handlers
1002 */
1003
1004/* System Event Handlers (registered by EVENTHANDLER_REGISTER) */
1005
1006static void
1007acpi_system_eventhandler_sleep(void *arg, int state)
1008{

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

1342 */
1343struct debugtag
1344{
1345 char *name;
1346 UINT32 value;
1347};
1348
1349static struct debugtag dbg_layer[] = {
1350 {"GLOBAL", 0x00000001},
1351 {"COMMON", 0x00000002},
1352 {"PARSER", 0x00000004},
1353 {"DISPATCHER", 0x00000008},
1354 {"INTERPRETER", 0x00000010},
1355 {"NAMESPACE", 0x00000020},
1356 {"RESOURCE_MANAGER", 0x00000040},
1357 {"TABLE_MANAGER", 0x00000080},
1358 {"EVENT_HANDLING", 0x00000100},
1359 {"HARDWARE", 0x00000200},
1360 {"MISCELLANEOUS", 0x00000400},
1361 {"OS_DEPENDENT", 0x00000800},
1362 {"BUS_MANAGER", 0x00001000},
1363 {"PROCESSOR_CONTROL", 0x00002000},
1364 {"SYSTEM_CONTROL", 0x00004000},
1365 {"THERMAL_CONTROL", 0x00008000},
1366 {"POWER_CONTROL", 0x00010000},
1367 {"EMBEDDED_CONTROLLER", 0x00020000},
1368 {"BATTERY", 0x00040000},
1369 {"DEBUGGER", 0x00100000},
1370 {"ALL_COMPONENTS", 0x001FFFFF},
1371 {NULL, 0}
1372};
1373
1374static struct debugtag dbg_level[] = {
1375 {"ACPI_OK", 0x00000001},
1376 {"ACPI_INFO", 0x00000002},
1377 {"ACPI_WARN", 0x00000004},
1378 {"ACPI_ERROR", 0x00000008},
1379 {"ACPI_FATAL", 0x00000010},
1380 {"ACPI_DEBUG_OBJECT", 0x00000020},
1381 {"ACPI_ALL", 0x0000003F},
1382 {"TRACE_PARSE", 0x00000100},
1383 {"TRACE_DISPATCH", 0x00000200},
1384 {"TRACE_LOAD", 0x00000400},
1385 {"TRACE_EXEC", 0x00000800},
1386 {"TRACE_NAMES", 0x00001000},
1387 {"TRACE_OPREGION", 0x00002000},
1388 {"TRACE_BFIELD", 0x00004000},
1389 {"TRACE_TRASH", 0x00008000},
1390 {"TRACE_TABLES", 0x00010000},
1391 {"TRACE_FUNCTIONS", 0x00020000},
1392 {"TRACE_VALUES", 0x00040000},
1393 {"TRACE_OBJECTS", 0x00080000},
1394 {"TRACE_ALLOCATIONS", 0x00100000},
1395 {"TRACE_RESOURCES", 0x00200000},
1396 {"TRACE_IO", 0x00400000},
1397 {"TRACE_INTERRUPTS", 0x00800000},
1398 {"TRACE_USER_REQUESTS", 0x01000000},
1399 {"TRACE_PACKAGE", 0x02000000},
1400 {"TRACE_MUTEX", 0x04000000},
1401 {"TRACE_ALL", 0x0FFFFF00},
1402 {"VERBOSE_AML_DISASSEMBLE", 0x10000000},
1403 {"VERBOSE_INFO", 0x20000000},
1404 {"VERBOSE_TABLES", 0x40000000},
1405 {"VERBOSE_EVENTS", 0x80000000},
1406 {"VERBOSE_ALL", 0xF0000000},
1407 {NULL, 0}
1408};
1409
1410static void
1411acpi_parse_debug(char *cp, struct debugtag *tag, UINT32 *flag)
1412{
1413 char *ep;
1414 int i, l;

--- 248 unchanged lines hidden ---