Enumerate all devices on the 'ACPI bus'.

svn path=/trunk/; revision=12361
This commit is contained in:
Eric Kohl 2004-12-27 14:24:00 +00:00
parent e81ecb35ce
commit 280e3627d8
7 changed files with 411 additions and 273 deletions

View file

@ -1,8 +1,9 @@
acpi.coff *.a
objects
*.d *.d
*.o *.o
*.sym *.sym
*.sys *.sys
*.map *.map
*.tmp *.tmp
acpi.coff
objects

View file

@ -1,4 +1,4 @@
/* $Id: acpienum.c,v 1.4 2003/11/14 17:13:23 weiden Exp $ /* $Id: acpienum.c,v 1.5 2004/12/27 14:24:00 ekohl Exp $
* *
* PROJECT: ReactOS ACPI bus driver * PROJECT: ReactOS ACPI bus driver
* FILE: acpi/ospm/acpienum.c * FILE: acpi/ospm/acpienum.c
@ -14,216 +14,175 @@
#include <debug.h> #include <debug.h>
void #ifndef NDEBUG
static void
bm_print1 ( bm_print1 (
BM_NODE *node, BM_NODE *node,
u32 flags) u32 flags)
{ {
ACPI_BUFFER buffer; ACPI_BUFFER buffer;
BM_DEVICE *device = NULL; BM_DEVICE *device = NULL;
char *type_string = NULL; char *type_string = NULL;
if (!node) { if (!node)
return; {
} return;
}
device = &(node->device); device = &(node->device);
if (flags & BM_PRINT_PRESENT) { if (flags & BM_PRINT_PRESENT)
if (!BM_DEVICE_PRESENT(device)) { {
return; if (!BM_DEVICE_PRESENT(device))
} {
} return;
}
}
buffer.length = 256; buffer.length = 256;
buffer.pointer = acpi_os_callocate(buffer.length); buffer.pointer = acpi_os_callocate(buffer.length);
if (!buffer.pointer) { if (!buffer.pointer)
return; {
} return;
}
acpi_get_name(device->acpi_handle, ACPI_FULL_PATHNAME, &buffer); acpi_get_name(device->acpi_handle, ACPI_FULL_PATHNAME, &buffer);
switch(device->id.type) { switch(device->id.type)
case BM_TYPE_SYSTEM: {
type_string = "System"; case BM_TYPE_SYSTEM:
break; type_string = "System";
case BM_TYPE_SCOPE: break;
type_string = "Scope";
break;
case BM_TYPE_PROCESSOR:
type_string = "Processor";
break;
case BM_TYPE_THERMAL_ZONE:
type_string = "ThermalZone";
break;
case BM_TYPE_POWER_RESOURCE:
type_string = "PowerResource";
break;
case BM_TYPE_FIXED_BUTTON:
type_string = "Button";
break;
case BM_TYPE_DEVICE:
type_string = "Device";
break;
default:
type_string = "Unknown";
break;
}
if (!(flags & BM_PRINT_GROUP)) { case BM_TYPE_SCOPE:
DbgPrint("+------------------------------------------------------------\n"); type_string = "Scope";
} break;
DbgPrint("%s[0x%02x] hid[%s] %s\n", type_string, device->handle, device->id.hid, buffer.pointer); case BM_TYPE_PROCESSOR:
DbgPrint(" acpi_handle[0x%08x] flags[0x%02x] status[0x%02x]\n", device->acpi_handle, device->flags, device->status); type_string = "Processor";
break;
if (flags & BM_PRINT_IDENTIFICATION) { case BM_TYPE_THERMAL_ZONE:
DbgPrint(" identification: uid[%s] adr[0x%08x]\n", device->id.uid, device->id.adr); type_string = "ThermalZone";
} break;
if (flags & BM_PRINT_LINKAGE) { case BM_TYPE_POWER_RESOURCE:
DbgPrint(" linkage: this[%p] parent[%p] next[%p]\n", node, node->parent, node->next); type_string = "PowerResource";
DbgPrint(" scope.head[%p] scope.tail[%p]\n", node->scope.head, node->scope.tail); break;
}
if (flags & BM_PRINT_POWER) { case BM_TYPE_FIXED_BUTTON:
DbgPrint(" power: state[D%d] flags[0x%08X]\n", device->power.state, device->power.flags); type_string = "Button";
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]); break;
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)) { case BM_TYPE_DEVICE:
DbgPrint("+------------------------------------------------------------\n"); type_string = "Device";
} break;
acpi_os_free(buffer.pointer); default:
type_string = "Unknown";
break;
}
return; 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;
} }
#endif
NTSTATUS NTSTATUS
ACPIEnumerateRootBusses( ACPIEnumerateDevices(PFDO_DEVICE_EXTENSION DeviceExtension)
PFDO_DEVICE_EXTENSION DeviceExtension)
{ {
BM_HANDLE_LIST HandleList; BM_HANDLE_LIST HandleList;
PACPI_DEVICE AcpiDevice; PACPI_DEVICE AcpiDevice;
ACPI_STATUS AcpiStatus; ACPI_STATUS AcpiStatus;
BM_DEVICE_ID Criteria; BM_DEVICE_ID Criteria;
BM_NODE *Node;
KIRQL OldIrql; KIRQL OldIrql;
ULONG i; ULONG i;
BM_NODE *Node;
ULONG j;
DPRINT("Called\n"); DPRINT("Called\n");
RtlZeroMemory(&Criteria, sizeof(BM_DEVICE_ID)); RtlZeroMemory(&Criteria, sizeof(BM_DEVICE_ID));
RtlMoveMemory(&Criteria.hid, PCI_ROOT_HID_STRING, sizeof(PCI_ROOT_HID_STRING));
AcpiStatus = bm_search(BM_HANDLE_ROOT, &Criteria, &HandleList);
if (ACPI_SUCCESS(AcpiStatus)) {
DPRINT("Got %d devices\n", HandleList.count);
for (i = 0; i < HandleList.count; i++) {
AcpiStatus = bm_get_node(HandleList.handles[i], 0, &Node);
if (ACPI_SUCCESS(AcpiStatus)) {
DPRINT("Got BM node information: (Node 0x%X)\n", Node);
bm_print1(Node, BM_PRINT_ALL - BM_PRINT_PRESENT);
#if 1
for (j=0; j < 4*1000;j++)
KeStallExecutionProcessor(1000);
#endif
} else {
DPRINT("Could not get BM node\n");
}
AcpiDevice = (PACPI_DEVICE)ExAllocatePool(
NonPagedPool, sizeof(ACPI_DEVICE));
if (!AcpiDevice) {
return STATUS_INSUFFICIENT_RESOURCES;
}
RtlZeroMemory(AcpiDevice, sizeof(ACPI_DEVICE));
AcpiDevice->Pdo = NULL;
AcpiDevice->BmHandle = HandleList.handles[i];
KeAcquireSpinLock(&DeviceExtension->DeviceListLock, &OldIrql);
InsertHeadList(&DeviceExtension->DeviceListHead,
&AcpiDevice->DeviceListEntry);
DeviceExtension->DeviceListCount++;
KeReleaseSpinLock(&DeviceExtension->DeviceListLock, OldIrql);
}
} else {
DPRINT("Got no devices (Status 0x%X)\n", AcpiStatus);
}
for (j=0; j < 4*10*1000;j++)
KeStallExecutionProcessor(1000);
return STATUS_SUCCESS;
}
NTSTATUS
ACPIEnumerateNamespace(
PFDO_DEVICE_EXTENSION DeviceExtension)
{
BM_HANDLE_LIST HandleList;
PACPI_DEVICE AcpiDevice;
ACPI_STATUS AcpiStatus;
BM_DEVICE_ID Criteria;
BM_NODE *Node;
KIRQL OldIrql;
ULONG i;
DPRINT("Called\n");
RtlZeroMemory(&Criteria, sizeof(BM_DEVICE_ID));
DbgPrint("Listing ACPI namespace\n");
Criteria.type = BM_TYPE_ALL; Criteria.type = BM_TYPE_ALL;
AcpiStatus = bm_search(BM_HANDLE_ROOT, &Criteria, &HandleList); AcpiStatus = bm_search(BM_HANDLE_ROOT, &Criteria, &HandleList);
if (ACPI_SUCCESS(AcpiStatus)) { if (ACPI_SUCCESS(AcpiStatus))
{
DPRINT("Got %d devices\n", HandleList.count); DPRINT("Got %d devices\n", HandleList.count);
for (i = 0; i < HandleList.count; i++) { for (i = 0; i < HandleList.count; i++)
{
AcpiStatus = bm_get_node(HandleList.handles[i], 0, &Node); AcpiStatus = bm_get_node(HandleList.handles[i], 0, &Node);
if (ACPI_SUCCESS(AcpiStatus)) { if (ACPI_SUCCESS(AcpiStatus))
{
DPRINT("Got BM node information: (Node 0x%X)\n", Node); DPRINT("Got BM node information: (Node 0x%X)\n", Node);
#if 0
{
ULONG j;
if ((Node->device.flags & BM_FLAGS_IDENTIFIABLE) &&
(Node->device.id.hid[0] != 0))
{
#ifndef NDEBUG
bm_print1(Node, BM_PRINT_ALL - BM_PRINT_PRESENT); bm_print1(Node, BM_PRINT_ALL - BM_PRINT_PRESENT);
for (j=0; j < 4*1000;j++)
KeStallExecutionProcessor(1000);
}
#endif #endif
} else {
AcpiDevice = (PACPI_DEVICE)ExAllocatePool(NonPagedPool,
sizeof(ACPI_DEVICE));
if (AcpiDevice == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
RtlZeroMemory(AcpiDevice, sizeof(ACPI_DEVICE));
AcpiDevice->Pdo = NULL;
AcpiDevice->BmHandle = HandleList.handles[i];
KeAcquireSpinLock(&DeviceExtension->DeviceListLock, &OldIrql);
InsertHeadList(&DeviceExtension->DeviceListHead,
&AcpiDevice->DeviceListEntry);
DeviceExtension->DeviceListCount++;
KeReleaseSpinLock(&DeviceExtension->DeviceListLock, OldIrql);
}
}
else
{
DPRINT("Could not get BM node\n"); DPRINT("Could not get BM node\n");
} }
AcpiDevice = (PACPI_DEVICE)ExAllocatePool(
NonPagedPool, sizeof(ACPI_DEVICE));
if (!AcpiDevice) {
return STATUS_INSUFFICIENT_RESOURCES;
}
RtlZeroMemory(AcpiDevice, sizeof(ACPI_DEVICE));
AcpiDevice->Pdo = NULL;
AcpiDevice->BmHandle = HandleList.handles[i];
KeAcquireSpinLock(&DeviceExtension->DeviceListLock, &OldIrql);
InsertHeadList(&DeviceExtension->DeviceListHead,
&AcpiDevice->DeviceListEntry);
DeviceExtension->DeviceListCount++;
KeReleaseSpinLock(&DeviceExtension->DeviceListLock, OldIrql);
} }
} else { }
else
{
DPRINT("Got no devices (Status 0x%X)\n", AcpiStatus); DPRINT("Got no devices (Status 0x%X)\n", AcpiStatus);
} }

View file

@ -1,4 +1,4 @@
/* $Id: acpisys.c,v 1.6 2004/12/25 00:44:49 greatlrd Exp $ /* $Id: acpisys.c,v 1.7 2004/12/27 14:24:00 ekohl Exp $
* *
* PROJECT: ReactOS ACPI bus driver * PROJECT: ReactOS ACPI bus driver
* FILE: acpi/ospm/acpisys.c * FILE: acpi/ospm/acpisys.c
@ -125,9 +125,15 @@ ACPIAddDevice(
DPRINT("Called\n"); DPRINT("Called\n");
Status = IoCreateDevice(DriverObject, sizeof(FDO_DEVICE_EXTENSION), Status = IoCreateDevice(DriverObject,
NULL, FILE_DEVICE_ACPI, FILE_DEVICE_SECURE_OPEN, TRUE, &Fdo); sizeof(FDO_DEVICE_EXTENSION),
if (!NT_SUCCESS(Status)) { NULL,
FILE_DEVICE_ACPI,
FILE_DEVICE_SECURE_OPEN,
TRUE,
&Fdo);
if (!NT_SUCCESS(Status))
{
DPRINT("IoCreateDevice() failed with status 0x%X\n", Status); DPRINT("IoCreateDevice() failed with status 0x%X\n", Status);
return Status; return Status;
} }

View file

@ -1,4 +1,4 @@
/* $Id: fdo.c,v 1.3 2003/11/14 17:13:23 weiden Exp $ /* $Id: fdo.c,v 1.4 2004/12/27 14:24:00 ekohl Exp $
* *
* PROJECT: ReactOS ACPI bus driver * PROJECT: ReactOS ACPI bus driver
* FILE: acpi/ospm/fdo.c * FILE: acpi/ospm/fdo.c
@ -14,11 +14,106 @@
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
FADT_DESCRIPTOR_REV2 acpi_fadt;
/*** PRIVATE *****************************************************************/ /*** PRIVATE *****************************************************************/
FADT_DESCRIPTOR_REV2 acpi_fadt;
NTSTATUS BOOLEAN
AcpiCreateUnicodeString(
PUNICODE_STRING Destination,
PWSTR Source,
POOL_TYPE PoolType)
{
ULONG Length;
if (!Source)
{
RtlInitUnicodeString(Destination, NULL);
return TRUE;
}
Length = (wcslen(Source) + 1) * sizeof(WCHAR);
Destination->Buffer = ExAllocatePool(PoolType, Length);
if (Destination->Buffer == NULL)
{
return FALSE;
}
RtlCopyMemory(Destination->Buffer, Source, Length);
Destination->MaximumLength = Length;
Destination->Length = Length - sizeof(WCHAR);
return TRUE;
}
BOOLEAN
AcpiCreateDeviceIDString(PUNICODE_STRING DeviceID,
BM_NODE *Node)
{
WCHAR Buffer[256];
swprintf(Buffer,
L"ACPI\\%S",
Node->device.id.hid);
if (!AcpiCreateUnicodeString(DeviceID, Buffer, PagedPool))
{
return FALSE;
}
return TRUE;
}
BOOLEAN
AcpiCreateHardwareIDsString(PUNICODE_STRING HardwareIDs,
BM_NODE *Node)
{
WCHAR Buffer[256];
ULONG Length;
ULONG Index;
Index = 0;
Index += swprintf(&Buffer[Index],
L"ACPI\\%S",
Node->device.id.hid);
Index++;
Index += swprintf(&Buffer[Index],
L"*%S",
Node->device.id.hid);
Index++;
Buffer[Index] = UNICODE_NULL;
Length = (Index + 1) * sizeof(WCHAR);
HardwareIDs->Buffer = ExAllocatePool(PagedPool, Length);
if (HardwareIDs->Buffer == NULL)
{
return FALSE;
}
HardwareIDs->Length = Length - sizeof(WCHAR);
HardwareIDs->MaximumLength = Length;
RtlCopyMemory(HardwareIDs->Buffer, Buffer, Length);
return TRUE;
}
BOOLEAN
AcpiCreateInstanceIDString(PUNICODE_STRING InstanceID,
BM_NODE *Node)
{
/* FIXME: Create unique instnce id. */
return AcpiCreateUnicodeString(InstanceID, L"0000", PagedPool);
}
static NTSTATUS
FdoQueryBusRelations( FdoQueryBusRelations(
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp, IN PIRP Irp,
@ -50,7 +145,8 @@ FdoQueryBusRelations(
i = 0; i = 0;
CurrentEntry = DeviceExtension->DeviceListHead.Flink; CurrentEntry = DeviceExtension->DeviceListHead.Flink;
while (CurrentEntry != &DeviceExtension->DeviceListHead) { while (CurrentEntry != &DeviceExtension->DeviceListHead)
{
Device = CONTAINING_RECORD(CurrentEntry, ACPI_DEVICE, DeviceListEntry); Device = CONTAINING_RECORD(CurrentEntry, ACPI_DEVICE, DeviceListEntry);
/* FIXME: For ACPI namespace devices on the motherboard create filter DOs /* FIXME: For ACPI namespace devices on the motherboard create filter DOs
@ -59,63 +155,75 @@ FdoQueryBusRelations(
/* FIXME: For other devices in ACPI namespace, but not on motherboard, /* FIXME: For other devices in ACPI namespace, but not on motherboard,
create PDOs */ create PDOs */
if (!Device->Pdo) { if (!Device->Pdo)
{
/* Create a physical device object for the /* Create a physical device object for the
device as it does not already have one */ device as it does not already have one */
Status = IoCreateDevice(DeviceObject->DriverObject, 0, Status = IoCreateDevice(DeviceObject->DriverObject,
NULL, FILE_DEVICE_CONTROLLER, 0, FALSE, &Device->Pdo); sizeof(PDO_DEVICE_EXTENSION),
if (!NT_SUCCESS(Status)) { NULL,
FILE_DEVICE_CONTROLLER,
FILE_AUTOGENERATED_DEVICE_NAME,
FALSE,
&Device->Pdo);
if (!NT_SUCCESS(Status))
{
DPRINT("IoCreateDevice() failed with status 0x%X\n", Status); DPRINT("IoCreateDevice() failed with status 0x%X\n", Status);
/* FIXME: Cleanup all new PDOs created in this call */ /* FIXME: Cleanup all new PDOs created in this call */
ExFreePool(Relations); ExFreePool(Relations);
return Status; return Status;
} }
PdoDeviceExtension = ExAllocatePool( PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)Device->Pdo->DeviceExtension;
NonPagedPool,
sizeof(PDO_DEVICE_EXTENSION));
if (!PdoDeviceExtension) {
/* FIXME: Cleanup all new PDOs created in this call */
ExFreePool(Relations);
}
RtlZeroMemory( RtlZeroMemory(PdoDeviceExtension, sizeof(PDO_DEVICE_EXTENSION));
PdoDeviceExtension,
sizeof(PDO_DEVICE_EXTENSION));
Device->Pdo->DeviceExtension = PdoDeviceExtension;
Device->Pdo->Flags |= DO_BUS_ENUMERATED_DEVICE; Device->Pdo->Flags |= DO_BUS_ENUMERATED_DEVICE;
Device->Pdo->Flags &= ~DO_DEVICE_INITIALIZING;
//Device->Pdo->Flags |= DO_POWER_PAGABLE;
PdoDeviceExtension->Common.DeviceObject = Device->Pdo; PdoDeviceExtension->Common.DeviceObject = Device->Pdo;
PdoDeviceExtension->Common.DevicePowerState = PowerDeviceD0; PdoDeviceExtension->Common.DevicePowerState = PowerDeviceD0;
PdoDeviceExtension->Common.Ldo = IoAttachDeviceToDeviceStack( // PdoDeviceExtension->Common.Ldo = IoAttachDeviceToDeviceStack(DeviceObject,
DeviceObject, // Device->Pdo);
Device->Pdo);
RtlInitUnicodeString(&PdoDeviceExtension->DeviceID, NULL);
RtlInitUnicodeString(&PdoDeviceExtension->InstanceID, NULL);
RtlInitUnicodeString(&PdoDeviceExtension->HardwareIDs, NULL); RtlInitUnicodeString(&PdoDeviceExtension->HardwareIDs, NULL);
RtlInitUnicodeString(&PdoDeviceExtension->CompatibleIDs, NULL);
AcpiStatus = bm_get_node(Device->BmHandle, 0, &Node); AcpiStatus = bm_get_node(Device->BmHandle, 0, &Node);
if (ACPI_SUCCESS(AcpiStatus)) { if (ACPI_SUCCESS(AcpiStatus))
if (Node->device.flags & BM_FLAGS_HAS_A_HID) { {
RtlInitAnsiString(&AnsiString, Node->device.id.hid); /* Add Device ID string */
Status = RtlAnsiStringToUnicodeString( if (!AcpiCreateDeviceIDString(&PdoDeviceExtension->DeviceID,
&PdoDeviceExtension->HardwareIDs, Node))
&AnsiString, {
TRUE); ASSERT(FALSE);
assert(NT_SUCCESS(Status)); // ErrorStatus = STATUS_INSUFFICIENT_RESOURCES;
// ErrorOccurred = TRUE;
// break;
} }
if (Node->device.flags & BM_FLAGS_HAS_A_CID) { if (!AcpiCreateInstanceIDString(&PdoDeviceExtension->InstanceID,
RtlInitAnsiString(&AnsiString, Node->device.id.cid); Node))
Status = RtlAnsiStringToUnicodeString( {
&PdoDeviceExtension->CompatibleIDs, ASSERT(FALSE);
&AnsiString, // ErrorStatus = STATUS_INSUFFICIENT_RESOURCES;
TRUE); // ErrorOccurred = TRUE;
assert(NT_SUCCESS(Status)); // break;
}
if (!AcpiCreateHardwareIDsString(&PdoDeviceExtension->HardwareIDs,
Node))
{
ASSERT(FALSE);
// ErrorStatus = STATUS_INSUFFICIENT_RESOURCES;
// ErrorOccurred = TRUE;
// break;
} }
} }
} }
@ -137,26 +245,28 @@ FdoQueryBusRelations(
} }
VOID ACPIPrintInfo( static VOID
PFDO_DEVICE_EXTENSION DeviceExtension) ACPIPrintInfo(
PFDO_DEVICE_EXTENSION DeviceExtension)
{ {
DbgPrint("ACPI: System firmware supports:\n"); DbgPrint("ACPI: System firmware supports:\n");
/* /*
* Print out basic system information * Print out basic system information
*/ */
DbgPrint("+------------------------------------------------------------\n"); DbgPrint("+------------------------------------------------------------\n");
DbgPrint("| Sx states: %cS0 %cS1 %cS2 %cS3 %cS4 %cS5\n", DbgPrint("| Sx states: %cS0 %cS1 %cS2 %cS3 %cS4 %cS5\n",
(DeviceExtension->SystemStates[0]?'+':'-'), (DeviceExtension->SystemStates[0]?'+':'-'),
(DeviceExtension->SystemStates[1]?'+':'-'), (DeviceExtension->SystemStates[1]?'+':'-'),
(DeviceExtension->SystemStates[2]?'+':'-'), (DeviceExtension->SystemStates[2]?'+':'-'),
(DeviceExtension->SystemStates[3]?'+':'-'), (DeviceExtension->SystemStates[3]?'+':'-'),
(DeviceExtension->SystemStates[4]?'+':'-'), (DeviceExtension->SystemStates[4]?'+':'-'),
(DeviceExtension->SystemStates[5]?'+':'-')); (DeviceExtension->SystemStates[5]?'+':'-'));
DbgPrint("+------------------------------------------------------------\n"); DbgPrint("+------------------------------------------------------------\n");
} }
NTSTATUS
static NTSTATUS
ACPIInitializeInternalDriver( ACPIInitializeInternalDriver(
PFDO_DEVICE_EXTENSION DeviceExtension, PFDO_DEVICE_EXTENSION DeviceExtension,
ACPI_DRIVER_FUNCTION Initialize, ACPI_DRIVER_FUNCTION Initialize,
@ -191,7 +301,7 @@ ACPIInitializeInternalDriver(
} }
NTSTATUS static NTSTATUS
ACPIInitializeInternalDrivers( ACPIInitializeInternalDrivers(
PFDO_DEVICE_EXTENSION DeviceExtension) PFDO_DEVICE_EXTENSION DeviceExtension)
{ {
@ -204,7 +314,7 @@ ACPIInitializeInternalDrivers(
} }
NTSTATUS static NTSTATUS
FdoStartDevice( FdoStartDevice(
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp) IN PIRP Irp)
@ -221,7 +331,7 @@ FdoStartDevice(
DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
assert(DeviceExtension->State == dsStopped); ASSERT(DeviceExtension->State == dsStopped);
AcpiStatus = acpi_initialize_subsystem(); AcpiStatus = acpi_initialize_subsystem();
if (!ACPI_SUCCESS(AcpiStatus)) { if (!ACPI_SUCCESS(AcpiStatus)) {
@ -233,30 +343,30 @@ FdoStartDevice(
if (!ACPI_SUCCESS(AcpiStatus)) { if (!ACPI_SUCCESS(AcpiStatus)) {
DPRINT("acpi_find_root_pointer() failed with status 0x%X\n", AcpiStatus); DPRINT("acpi_find_root_pointer() failed with status 0x%X\n", AcpiStatus);
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
/* From this point on, on error we must call acpi_terminate() */ /* From this point on, on error we must call acpi_terminate() */
AcpiStatus = acpi_load_tables(rsdp); AcpiStatus = acpi_load_tables(rsdp);
if (!ACPI_SUCCESS(AcpiStatus)) { if (!ACPI_SUCCESS(AcpiStatus)) {
DPRINT("acpi_load_tables() failed with status 0x%X\n", AcpiStatus); DPRINT("acpi_load_tables() failed with status 0x%X\n", AcpiStatus);
acpi_terminate(); acpi_terminate();
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
Buffer.length = sizeof(SysInfo); Buffer.length = sizeof(SysInfo);
Buffer.pointer = &SysInfo; Buffer.pointer = &SysInfo;
AcpiStatus = acpi_get_system_info(&Buffer); AcpiStatus = acpi_get_system_info(&Buffer);
if (!ACPI_SUCCESS(AcpiStatus)) { if (!ACPI_SUCCESS(AcpiStatus)) {
DPRINT("acpi_get_system_info() failed with status 0x%X\n", AcpiStatus); DPRINT("acpi_get_system_info() failed with status 0x%X\n", AcpiStatus);
acpi_terminate(); acpi_terminate();
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
DPRINT("ACPI CA Core Subsystem version 0x%X\n", SysInfo.acpi_ca_version); DPRINT("ACPI CA Core Subsystem version 0x%X\n", SysInfo.acpi_ca_version);
assert(SysInfo.num_table_types > ACPI_TABLE_FADT); ASSERT(SysInfo.num_table_types > ACPI_TABLE_FADT);
RtlMoveMemory(&acpi_fadt, RtlMoveMemory(&acpi_fadt,
&SysInfo.table_info[ACPI_TABLE_FADT], &SysInfo.table_info[ACPI_TABLE_FADT],
@ -272,21 +382,21 @@ FdoStartDevice(
DPRINT("ACPI CA Core Subsystem enabled\n"); DPRINT("ACPI CA Core Subsystem enabled\n");
/* /*
* Sx States: * Sx States:
* ---------- * ----------
* Figure out which Sx states are supported * Figure out which Sx states are supported
*/ */
for (i=0; i<=ACPI_S_STATES_MAX; i++) { for (i=0; i<=ACPI_S_STATES_MAX; i++) {
AcpiStatus = acpi_hw_obtain_sleep_type_register_data( AcpiStatus = acpi_hw_obtain_sleep_type_register_data(
i, i,
&TypeA, &TypeA,
&TypeB); &TypeB);
DPRINT("acpi_hw_obtain_sleep_type_register_data (%d) status 0x%X\n", DPRINT("acpi_hw_obtain_sleep_type_register_data (%d) status 0x%X\n",
i, AcpiStatus); i, AcpiStatus);
if (ACPI_SUCCESS(AcpiStatus)) { if (ACPI_SUCCESS(AcpiStatus)) {
DeviceExtension->SystemStates[i] = TRUE; DeviceExtension->SystemStates[i] = TRUE;
} }
} }
ACPIPrintInfo(DeviceExtension); ACPIPrintInfo(DeviceExtension);
@ -302,19 +412,17 @@ FdoStartDevice(
KeInitializeSpinLock(&DeviceExtension->DeviceListLock); KeInitializeSpinLock(&DeviceExtension->DeviceListLock);
DeviceExtension->DeviceListCount = 0; DeviceExtension->DeviceListCount = 0;
ACPIEnumerateNamespace(DeviceExtension); ACPIEnumerateDevices(DeviceExtension);
//ACPIEnumerateRootBusses(DeviceExtension);
ACPIInitializeInternalDrivers(DeviceExtension); ACPIInitializeInternalDrivers(DeviceExtension);
DeviceExtension->State = dsStarted; DeviceExtension->State = dsStarted;
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
NTSTATUS static NTSTATUS
FdoSetPower( FdoSetPower(
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp, IN PIRP Irp,

View file

@ -11,7 +11,8 @@
typedef ACPI_STATUS (*ACPI_DRIVER_FUNCTION)(VOID); typedef ACPI_STATUS (*ACPI_DRIVER_FUNCTION)(VOID);
typedef enum { typedef enum
{
dsStopped, dsStopped,
dsStarted, dsStarted,
dsPaused, dsPaused,
@ -34,17 +35,21 @@ typedef struct _COMMON_DEVICE_EXTENSION
PDEVICE_OBJECT Ldo; PDEVICE_OBJECT Ldo;
} COMMON_DEVICE_EXTENSION, *PCOMMON_DEVICE_EXTENSION; } COMMON_DEVICE_EXTENSION, *PCOMMON_DEVICE_EXTENSION;
/* Physical Device Object device extension for a child device */ /* Physical Device Object device extension for a child device */
typedef struct _PDO_DEVICE_EXTENSION typedef struct _PDO_DEVICE_EXTENSION
{ {
// Common device data // Common device data
COMMON_DEVICE_EXTENSION Common; COMMON_DEVICE_EXTENSION Common;
// Device ID
UNICODE_STRING DeviceID;
// Instance ID
UNICODE_STRING InstanceID;
// Hardware IDs // Hardware IDs
UNICODE_STRING HardwareIDs; UNICODE_STRING HardwareIDs;
// Compatible IDs
UNICODE_STRING CompatibleIDs;
} PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION; } PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION;
typedef struct _FDO_DEVICE_EXTENSION typedef struct _FDO_DEVICE_EXTENSION
{ {
// Common device data // Common device data
@ -82,11 +87,7 @@ typedef struct _ACPI_DEVICE
/* acpienum.c */ /* acpienum.c */
NTSTATUS NTSTATUS
ACPIEnumerateRootBusses( ACPIEnumerateDevices(
PFDO_DEVICE_EXTENSION DeviceExtension);
NTSTATUS
ACPIEnumerateNamespace(
PFDO_DEVICE_EXTENSION DeviceExtension); PFDO_DEVICE_EXTENSION DeviceExtension);

View file

@ -232,7 +232,7 @@ acpi_os_install_interrupt_handler(u32 irq, OSD_HANDLER handler, void *context)
Affinity, Affinity,
FALSE); FALSE);
if (!NT_SUCCESS(Status)) { if (!NT_SUCCESS(Status)) {
DPRINT("Could not connect to interrupt %d\n", Vector); DPRINT("Could not connect to interrupt %d\n", Vector);
return AE_ERROR; return AE_ERROR;
} }

View file

@ -1,4 +1,4 @@
/* $Id: pdo.c,v 1.2 2003/11/14 17:13:23 weiden Exp $ /* $Id: pdo.c,v 1.3 2004/12/27 14:24:00 ekohl Exp $
* *
* PROJECT: ReactOS ACPI bus driver * PROJECT: ReactOS ACPI bus driver
* FILE: acpi/ospm/pdo.c * FILE: acpi/ospm/pdo.c
@ -16,30 +16,90 @@
/*** PRIVATE *****************************************************************/ /*** PRIVATE *****************************************************************/
NTSTATUS static NTSTATUS
AcpiDuplicateUnicodeString(
PUNICODE_STRING Destination,
PUNICODE_STRING Source,
POOL_TYPE PoolType)
{
if (Source == NULL)
{
RtlInitUnicodeString(Destination, NULL);
return STATUS_SUCCESS;
}
Destination->Buffer = ExAllocatePool(PoolType, Source->MaximumLength);
if (Destination->Buffer == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
Destination->MaximumLength = Source->MaximumLength;
Destination->Length = Source->Length;
RtlCopyMemory(Destination->Buffer, Source->Buffer, Source->MaximumLength);
return STATUS_SUCCESS;
}
static NTSTATUS
PdoQueryId( PdoQueryId(
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp, IN PIRP Irp,
PIO_STACK_LOCATION IrpSp) PIO_STACK_LOCATION IrpSp)
{ {
PPDO_DEVICE_EXTENSION DeviceExtension; PPDO_DEVICE_EXTENSION DeviceExtension;
UNICODE_STRING String;
NTSTATUS Status; NTSTATUS Status;
DPRINT("Called\n"); DPRINT("Called\n");
DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension; DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
RtlInitUnicodeString(&String, NULL);
// Irp->IoStatus.Information = 0; // Irp->IoStatus.Information = 0;
switch (IrpSp->Parameters.QueryId.IdType) { switch (IrpSp->Parameters.QueryId.IdType)
{
case BusQueryDeviceID: case BusQueryDeviceID:
DPRINT("BusQueryDeviceID\n");
Status = AcpiDuplicateUnicodeString(&String,
&DeviceExtension->DeviceID,
PagedPool);
DPRINT("DeviceID: %S\n", String.Buffer);
Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
break; break;
case BusQueryHardwareIDs: case BusQueryHardwareIDs:
DPRINT("BusQueryHardwareIDs\n");
Status = AcpiDuplicateUnicodeString(&String,
&DeviceExtension->HardwareIDs,
PagedPool);
Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
break;
case BusQueryCompatibleIDs: case BusQueryCompatibleIDs:
DPRINT("BusQueryCompatibleIDs\n");
Status = STATUS_NOT_IMPLEMENTED;
break;
case BusQueryInstanceID: case BusQueryInstanceID:
DPRINT("BusQueryInstanceID\n");
Status = AcpiDuplicateUnicodeString(&String,
&DeviceExtension->InstanceID,
PagedPool);
DPRINT("InstanceID: %S\n", String.Buffer);
Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
break;
case BusQueryDeviceSerialNumber: case BusQueryDeviceSerialNumber:
DPRINT("BusQueryDeviceSerialNumber\n");
Status = STATUS_NOT_IMPLEMENTED;
break;
default: default:
DPRINT("Unknown id type: %lx\n", IrpSp->Parameters.QueryId.IdType);
Status = STATUS_NOT_IMPLEMENTED; Status = STATUS_NOT_IMPLEMENTED;
} }
@ -47,7 +107,7 @@ PdoQueryId(
} }
NTSTATUS static NTSTATUS
PdoSetPower( PdoSetPower(
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp, IN PIRP Irp,
@ -126,6 +186,9 @@ PdoPnpControl(
break; break;
case IRP_MN_QUERY_ID: case IRP_MN_QUERY_ID:
Status = PdoQueryId(DeviceObject,
Irp,
IrpSp);
break; break;
case IRP_MN_QUERY_PNP_DEVICE_STATE: case IRP_MN_QUERY_PNP_DEVICE_STATE: