2005-01-06 13:58:04 +00:00
|
|
|
/* $Id$
|
2001-05-01 23:00:05 +00:00
|
|
|
*
|
|
|
|
* PROJECT: ReactOS ACPI bus driver
|
|
|
|
* FILE: acpi/ospm/acpienum.c
|
|
|
|
* PURPOSE: ACPI namespace enumerator
|
|
|
|
* PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
|
|
|
|
* UPDATE HISTORY:
|
|
|
|
* 01-05-2001 CSH Created
|
|
|
|
*/
|
2006-01-09 00:41:48 +00:00
|
|
|
#include <acpi.h>
|
2001-05-01 23:00:05 +00:00
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
|
2004-12-27 14:24:00 +00:00
|
|
|
#ifndef NDEBUG
|
|
|
|
static void
|
2001-05-05 19:15:44 +00:00
|
|
|
bm_print1 (
|
2004-12-27 14:24:00 +00:00
|
|
|
BM_NODE *node,
|
|
|
|
u32 flags)
|
2001-05-01 23:00:05 +00:00
|
|
|
{
|
2004-12-27 14:24:00 +00:00
|
|
|
ACPI_BUFFER buffer;
|
|
|
|
BM_DEVICE *device = NULL;
|
|
|
|
char *type_string = NULL;
|
2001-05-05 19:15:44 +00:00
|
|
|
|
2004-12-27 14:24:00 +00:00
|
|
|
if (!node)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2001-05-05 19:15:44 +00:00
|
|
|
|
2004-12-27 14:24:00 +00:00
|
|
|
device = &(node->device);
|
2001-05-05 19:15:44 +00:00
|
|
|
|
2004-12-27 14:24:00 +00:00
|
|
|
if (flags & BM_PRINT_PRESENT)
|
|
|
|
{
|
|
|
|
if (!BM_DEVICE_PRESENT(device))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2001-05-05 19:15:44 +00:00
|
|
|
|
2004-12-27 14:24:00 +00:00
|
|
|
buffer.length = 256;
|
|
|
|
buffer.pointer = acpi_os_callocate(buffer.length);
|
|
|
|
if (!buffer.pointer)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2001-05-05 19:15:44 +00:00
|
|
|
|
2004-12-27 14:24:00 +00:00
|
|
|
acpi_get_name(device->acpi_handle, ACPI_FULL_PATHNAME, &buffer);
|
2001-05-05 19:15:44 +00:00
|
|
|
|
2004-12-27 14:24:00 +00:00
|
|
|
switch(device->id.type)
|
|
|
|
{
|
|
|
|
case BM_TYPE_SYSTEM:
|
|
|
|
type_string = "System";
|
|
|
|
break;
|
2001-05-05 19:15:44 +00:00
|
|
|
|
2004-12-27 14:24:00 +00:00
|
|
|
case BM_TYPE_SCOPE:
|
|
|
|
type_string = "Scope";
|
|
|
|
break;
|
2001-05-05 19:15:44 +00:00
|
|
|
|
2004-12-27 14:24:00 +00:00
|
|
|
case BM_TYPE_PROCESSOR:
|
|
|
|
type_string = "Processor";
|
|
|
|
break;
|
2001-05-05 19:15:44 +00:00
|
|
|
|
2004-12-27 14:24:00 +00:00
|
|
|
case BM_TYPE_THERMAL_ZONE:
|
|
|
|
type_string = "ThermalZone";
|
|
|
|
break;
|
2001-05-05 19:15:44 +00:00
|
|
|
|
2004-12-27 14:24:00 +00:00
|
|
|
case BM_TYPE_POWER_RESOURCE:
|
|
|
|
type_string = "PowerResource";
|
|
|
|
break;
|
2001-08-23 17:32:04 +00:00
|
|
|
|
2004-12-27 14:24:00 +00:00
|
|
|
case BM_TYPE_FIXED_BUTTON:
|
|
|
|
type_string = "Button";
|
|
|
|
break;
|
2001-05-01 23:00:05 +00:00
|
|
|
|
2004-12-27 14:24:00 +00:00
|
|
|
case BM_TYPE_DEVICE:
|
|
|
|
type_string = "Device";
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
type_string = "Unknown";
|
|
|
|
break;
|
2001-05-01 23:00:05 +00:00
|
|
|
}
|
2001-05-05 19:15:44 +00:00
|
|
|
|
2004-12-27 14:24:00 +00:00
|
|
|
if (!(flags & BM_PRINT_GROUP))
|
|
|
|
{
|
|
|
|
DbgPrint("+------------------------------------------------------------\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
DbgPrint("%s[0x%02x] hid[%s] %s\n", type_string, device->handle, device->id.hid, buffer.pointer);
|
|
|
|
DbgPrint(" acpi_handle[0x%08x] flags[0x%02x] status[0x%02x]\n", device->acpi_handle, device->flags, device->status);
|
|
|
|
|
|
|
|
if (flags & BM_PRINT_IDENTIFICATION)
|
|
|
|
{
|
|
|
|
DbgPrint(" identification: uid[%s] adr[0x%08x]\n", device->id.uid, device->id.adr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & BM_PRINT_LINKAGE)
|
|
|
|
{
|
|
|
|
DbgPrint(" linkage: this[%p] parent[%p] next[%p]\n", node, node->parent, node->next);
|
|
|
|
DbgPrint(" scope.head[%p] scope.tail[%p]\n", node->scope.head, node->scope.tail);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & BM_PRINT_POWER)
|
|
|
|
{
|
|
|
|
DbgPrint(" power: state[D%d] flags[0x%08X]\n", device->power.state, device->power.flags);
|
|
|
|
DbgPrint(" S0[0x%02x] S1[0x%02x] S2[0x%02x]\n", device->power.dx_supported[0], device->power.dx_supported[1], device->power.dx_supported[2]);
|
|
|
|
DbgPrint(" S3[0x%02x] S4[0x%02x] S5[0x%02x]\n", device->power.dx_supported[3], device->power.dx_supported[4], device->power.dx_supported[5]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(flags & BM_PRINT_GROUP))
|
|
|
|
{
|
|
|
|
DbgPrint("+------------------------------------------------------------\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
acpi_os_free(buffer.pointer);
|
|
|
|
|
|
|
|
return;
|
2001-05-01 23:00:05 +00:00
|
|
|
}
|
2004-12-27 14:24:00 +00:00
|
|
|
#endif
|
2001-05-01 23:00:05 +00:00
|
|
|
|
2001-05-05 19:15:44 +00:00
|
|
|
|
2001-05-01 23:00:05 +00:00
|
|
|
NTSTATUS
|
2004-12-27 14:24:00 +00:00
|
|
|
ACPIEnumerateDevices(PFDO_DEVICE_EXTENSION DeviceExtension)
|
2001-05-01 23:00:05 +00:00
|
|
|
{
|
2001-08-23 17:32:04 +00:00
|
|
|
BM_HANDLE_LIST HandleList;
|
|
|
|
PACPI_DEVICE AcpiDevice;
|
2001-05-05 19:15:44 +00:00
|
|
|
ACPI_STATUS AcpiStatus;
|
2004-12-27 14:24:00 +00:00
|
|
|
BM_DEVICE_ID Criteria;
|
2001-05-05 19:15:44 +00:00
|
|
|
BM_NODE *Node;
|
2001-08-23 17:32:04 +00:00
|
|
|
KIRQL OldIrql;
|
|
|
|
ULONG i;
|
2001-05-01 23:00:05 +00:00
|
|
|
|
2001-05-05 19:15:44 +00:00
|
|
|
DPRINT("Called\n");
|
2001-05-01 23:00:05 +00:00
|
|
|
|
2004-12-27 14:24:00 +00:00
|
|
|
RtlZeroMemory(&Criteria, sizeof(BM_DEVICE_ID));
|
2001-05-05 19:15:44 +00:00
|
|
|
Criteria.type = BM_TYPE_ALL;
|
|
|
|
|
|
|
|
AcpiStatus = bm_search(BM_HANDLE_ROOT, &Criteria, &HandleList);
|
2004-12-27 14:24:00 +00:00
|
|
|
if (ACPI_SUCCESS(AcpiStatus))
|
|
|
|
{
|
2001-05-05 19:15:44 +00:00
|
|
|
DPRINT("Got %d devices\n", HandleList.count);
|
|
|
|
|
2004-12-27 14:24:00 +00:00
|
|
|
for (i = 0; i < HandleList.count; i++)
|
|
|
|
{
|
2001-05-05 19:15:44 +00:00
|
|
|
AcpiStatus = bm_get_node(HandleList.handles[i], 0, &Node);
|
2004-12-27 14:24:00 +00:00
|
|
|
if (ACPI_SUCCESS(AcpiStatus))
|
|
|
|
{
|
2001-05-05 19:15:44 +00:00
|
|
|
DPRINT("Got BM node information: (Node 0x%X)\n", Node);
|
2001-08-23 17:32:04 +00:00
|
|
|
|
2004-12-27 14:24:00 +00:00
|
|
|
if ((Node->device.flags & BM_FLAGS_IDENTIFIABLE) &&
|
|
|
|
(Node->device.id.hid[0] != 0))
|
|
|
|
{
|
|
|
|
#ifndef NDEBUG
|
2001-08-23 17:32:04 +00:00
|
|
|
bm_print1(Node, BM_PRINT_ALL - BM_PRINT_PRESENT);
|
2001-05-05 19:15:44 +00:00
|
|
|
#endif
|
2001-08-23 17:32:04 +00:00
|
|
|
|
2004-12-27 14:24:00 +00:00
|
|
|
AcpiDevice = (PACPI_DEVICE)ExAllocatePool(NonPagedPool,
|
|
|
|
sizeof(ACPI_DEVICE));
|
|
|
|
if (AcpiDevice == NULL)
|
|
|
|
{
|
|
|
|
return STATUS_INSUFFICIENT_RESOURCES;
|
|
|
|
}
|
2001-08-23 17:32:04 +00:00
|
|
|
|
2004-12-27 14:24:00 +00:00
|
|
|
RtlZeroMemory(AcpiDevice, sizeof(ACPI_DEVICE));
|
2001-08-23 17:32:04 +00:00
|
|
|
|
2004-12-27 14:24:00 +00:00
|
|
|
AcpiDevice->Pdo = NULL;
|
|
|
|
AcpiDevice->BmHandle = HandleList.handles[i];
|
2001-08-23 17:32:04 +00:00
|
|
|
|
2004-12-27 14:24:00 +00:00
|
|
|
KeAcquireSpinLock(&DeviceExtension->DeviceListLock, &OldIrql);
|
|
|
|
InsertHeadList(&DeviceExtension->DeviceListHead,
|
|
|
|
&AcpiDevice->DeviceListEntry);
|
|
|
|
DeviceExtension->DeviceListCount++;
|
|
|
|
KeReleaseSpinLock(&DeviceExtension->DeviceListLock, OldIrql);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DPRINT("Could not get BM node\n");
|
|
|
|
}
|
2001-05-05 19:15:44 +00:00
|
|
|
}
|
2004-12-27 14:24:00 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-05-05 19:15:44 +00:00
|
|
|
DPRINT("Got no devices (Status 0x%X)\n", AcpiStatus);
|
|
|
|
}
|
2001-05-01 23:00:05 +00:00
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|