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
objects
*.a
*.d
*.o
*.sym
*.sys
*.map
*.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
* FILE: acpi/ospm/acpienum.c
@ -14,216 +14,175 @@
#include <debug.h>
void
#ifndef NDEBUG
static void
bm_print1 (
BM_NODE *node,
u32 flags)
BM_NODE *node,
u32 flags)
{
ACPI_BUFFER buffer;
BM_DEVICE *device = NULL;
char *type_string = NULL;
ACPI_BUFFER buffer;
BM_DEVICE *device = NULL;
char *type_string = NULL;
if (!node) {
return;
}
if (!node)
{
return;
}
device = &(node->device);
device = &(node->device);
if (flags & BM_PRINT_PRESENT) {
if (!BM_DEVICE_PRESENT(device)) {
return;
}
}
if (flags & BM_PRINT_PRESENT)
{
if (!BM_DEVICE_PRESENT(device))
{
return;
}
}
buffer.length = 256;
buffer.pointer = acpi_os_callocate(buffer.length);
if (!buffer.pointer) {
return;
}
buffer.length = 256;
buffer.pointer = acpi_os_callocate(buffer.length);
if (!buffer.pointer)
{
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) {
case BM_TYPE_SYSTEM:
type_string = "System";
break;
case BM_TYPE_SCOPE:
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;
}
switch(device->id.type)
{
case BM_TYPE_SYSTEM:
type_string = "System";
break;
if (!(flags & BM_PRINT_GROUP)) {
DbgPrint("+------------------------------------------------------------\n");
}
case BM_TYPE_SCOPE:
type_string = "Scope";
break;
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);
case BM_TYPE_PROCESSOR:
type_string = "Processor";
break;
if (flags & BM_PRINT_IDENTIFICATION) {
DbgPrint(" identification: uid[%s] adr[0x%08x]\n", device->id.uid, device->id.adr);
}
case BM_TYPE_THERMAL_ZONE:
type_string = "ThermalZone";
break;
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);
}
case BM_TYPE_POWER_RESOURCE:
type_string = "PowerResource";
break;
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]);
}
case BM_TYPE_FIXED_BUTTON:
type_string = "Button";
break;
if (!(flags & BM_PRINT_GROUP)) {
DbgPrint("+------------------------------------------------------------\n");
}
case BM_TYPE_DEVICE:
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
ACPIEnumerateRootBusses(
PFDO_DEVICE_EXTENSION DeviceExtension)
ACPIEnumerateDevices(PFDO_DEVICE_EXTENSION DeviceExtension)
{
BM_HANDLE_LIST HandleList;
PACPI_DEVICE AcpiDevice;
ACPI_STATUS AcpiStatus;
BM_DEVICE_ID Criteria;
BM_DEVICE_ID Criteria;
BM_NODE *Node;
KIRQL OldIrql;
ULONG i;
BM_NODE *Node;
ULONG j;
DPRINT("Called\n");
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;
AcpiStatus = bm_search(BM_HANDLE_ROOT, &Criteria, &HandleList);
if (ACPI_SUCCESS(AcpiStatus)) {
if (ACPI_SUCCESS(AcpiStatus))
{
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);
if (ACPI_SUCCESS(AcpiStatus)) {
if (ACPI_SUCCESS(AcpiStatus))
{
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);
for (j=0; j < 4*1000;j++)
KeStallExecutionProcessor(1000);
}
#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");
}
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);
}

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
* FILE: acpi/ospm/acpisys.c
@ -125,9 +125,15 @@ ACPIAddDevice(
DPRINT("Called\n");
Status = IoCreateDevice(DriverObject, sizeof(FDO_DEVICE_EXTENSION),
NULL, FILE_DEVICE_ACPI, FILE_DEVICE_SECURE_OPEN, TRUE, &Fdo);
if (!NT_SUCCESS(Status)) {
Status = IoCreateDevice(DriverObject,
sizeof(FDO_DEVICE_EXTENSION),
NULL,
FILE_DEVICE_ACPI,
FILE_DEVICE_SECURE_OPEN,
TRUE,
&Fdo);
if (!NT_SUCCESS(Status))
{
DPRINT("IoCreateDevice() failed with status 0x%X\n", 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
* FILE: acpi/ospm/fdo.c
@ -14,11 +14,106 @@
#define NDEBUG
#include <debug.h>
FADT_DESCRIPTOR_REV2 acpi_fadt;
/*** 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(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
@ -50,7 +145,8 @@ FdoQueryBusRelations(
i = 0;
CurrentEntry = DeviceExtension->DeviceListHead.Flink;
while (CurrentEntry != &DeviceExtension->DeviceListHead) {
while (CurrentEntry != &DeviceExtension->DeviceListHead)
{
Device = CONTAINING_RECORD(CurrentEntry, ACPI_DEVICE, DeviceListEntry);
/* 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,
create PDOs */
if (!Device->Pdo) {
if (!Device->Pdo)
{
/* Create a physical device object for the
device as it does not already have one */
Status = IoCreateDevice(DeviceObject->DriverObject, 0,
NULL, FILE_DEVICE_CONTROLLER, 0, FALSE, &Device->Pdo);
if (!NT_SUCCESS(Status)) {
Status = IoCreateDevice(DeviceObject->DriverObject,
sizeof(PDO_DEVICE_EXTENSION),
NULL,
FILE_DEVICE_CONTROLLER,
FILE_AUTOGENERATED_DEVICE_NAME,
FALSE,
&Device->Pdo);
if (!NT_SUCCESS(Status))
{
DPRINT("IoCreateDevice() failed with status 0x%X\n", Status);
/* FIXME: Cleanup all new PDOs created in this call */
ExFreePool(Relations);
return Status;
}
PdoDeviceExtension = ExAllocatePool(
NonPagedPool,
sizeof(PDO_DEVICE_EXTENSION));
if (!PdoDeviceExtension) {
/* FIXME: Cleanup all new PDOs created in this call */
ExFreePool(Relations);
}
PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)Device->Pdo->DeviceExtension;
RtlZeroMemory(
PdoDeviceExtension,
sizeof(PDO_DEVICE_EXTENSION));
Device->Pdo->DeviceExtension = PdoDeviceExtension;
RtlZeroMemory(PdoDeviceExtension, sizeof(PDO_DEVICE_EXTENSION));
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.DevicePowerState = PowerDeviceD0;
PdoDeviceExtension->Common.Ldo = IoAttachDeviceToDeviceStack(
DeviceObject,
Device->Pdo);
// PdoDeviceExtension->Common.Ldo = IoAttachDeviceToDeviceStack(DeviceObject,
// Device->Pdo);
RtlInitUnicodeString(&PdoDeviceExtension->DeviceID, NULL);
RtlInitUnicodeString(&PdoDeviceExtension->InstanceID, NULL);
RtlInitUnicodeString(&PdoDeviceExtension->HardwareIDs, NULL);
RtlInitUnicodeString(&PdoDeviceExtension->CompatibleIDs, NULL);
AcpiStatus = bm_get_node(Device->BmHandle, 0, &Node);
if (ACPI_SUCCESS(AcpiStatus)) {
if (Node->device.flags & BM_FLAGS_HAS_A_HID) {
RtlInitAnsiString(&AnsiString, Node->device.id.hid);
Status = RtlAnsiStringToUnicodeString(
&PdoDeviceExtension->HardwareIDs,
&AnsiString,
TRUE);
assert(NT_SUCCESS(Status));
if (ACPI_SUCCESS(AcpiStatus))
{
/* Add Device ID string */
if (!AcpiCreateDeviceIDString(&PdoDeviceExtension->DeviceID,
Node))
{
ASSERT(FALSE);
// ErrorStatus = STATUS_INSUFFICIENT_RESOURCES;
// ErrorOccurred = TRUE;
// break;
}
if (Node->device.flags & BM_FLAGS_HAS_A_CID) {
RtlInitAnsiString(&AnsiString, Node->device.id.cid);
Status = RtlAnsiStringToUnicodeString(
&PdoDeviceExtension->CompatibleIDs,
&AnsiString,
TRUE);
assert(NT_SUCCESS(Status));
if (!AcpiCreateInstanceIDString(&PdoDeviceExtension->InstanceID,
Node))
{
ASSERT(FALSE);
// ErrorStatus = STATUS_INSUFFICIENT_RESOURCES;
// ErrorOccurred = TRUE;
// break;
}
if (!AcpiCreateHardwareIDsString(&PdoDeviceExtension->HardwareIDs,
Node))
{
ASSERT(FALSE);
// ErrorStatus = STATUS_INSUFFICIENT_RESOURCES;
// ErrorOccurred = TRUE;
// break;
}
}
}
@ -137,26 +245,28 @@ FdoQueryBusRelations(
}
VOID ACPIPrintInfo(
PFDO_DEVICE_EXTENSION DeviceExtension)
static VOID
ACPIPrintInfo(
PFDO_DEVICE_EXTENSION DeviceExtension)
{
DbgPrint("ACPI: System firmware supports:\n");
/*
* Print out basic system information
*/
DbgPrint("+------------------------------------------------------------\n");
DbgPrint("| Sx states: %cS0 %cS1 %cS2 %cS3 %cS4 %cS5\n",
(DeviceExtension->SystemStates[0]?'+':'-'),
(DeviceExtension->SystemStates[1]?'+':'-'),
(DeviceExtension->SystemStates[2]?'+':'-'),
(DeviceExtension->SystemStates[3]?'+':'-'),
(DeviceExtension->SystemStates[4]?'+':'-'),
(DeviceExtension->SystemStates[5]?'+':'-'));
DbgPrint("+------------------------------------------------------------\n");
/*
* Print out basic system information
*/
DbgPrint("+------------------------------------------------------------\n");
DbgPrint("| Sx states: %cS0 %cS1 %cS2 %cS3 %cS4 %cS5\n",
(DeviceExtension->SystemStates[0]?'+':'-'),
(DeviceExtension->SystemStates[1]?'+':'-'),
(DeviceExtension->SystemStates[2]?'+':'-'),
(DeviceExtension->SystemStates[3]?'+':'-'),
(DeviceExtension->SystemStates[4]?'+':'-'),
(DeviceExtension->SystemStates[5]?'+':'-'));
DbgPrint("+------------------------------------------------------------\n");
}
NTSTATUS
static NTSTATUS
ACPIInitializeInternalDriver(
PFDO_DEVICE_EXTENSION DeviceExtension,
ACPI_DRIVER_FUNCTION Initialize,
@ -191,7 +301,7 @@ ACPIInitializeInternalDriver(
}
NTSTATUS
static NTSTATUS
ACPIInitializeInternalDrivers(
PFDO_DEVICE_EXTENSION DeviceExtension)
{
@ -204,7 +314,7 @@ ACPIInitializeInternalDrivers(
}
NTSTATUS
static NTSTATUS
FdoStartDevice(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
@ -221,7 +331,7 @@ FdoStartDevice(
DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
assert(DeviceExtension->State == dsStopped);
ASSERT(DeviceExtension->State == dsStopped);
AcpiStatus = acpi_initialize_subsystem();
if (!ACPI_SUCCESS(AcpiStatus)) {
@ -233,30 +343,30 @@ FdoStartDevice(
if (!ACPI_SUCCESS(AcpiStatus)) {
DPRINT("acpi_find_root_pointer() failed with status 0x%X\n", AcpiStatus);
return STATUS_UNSUCCESSFUL;
}
}
/* From this point on, on error we must call acpi_terminate() */
AcpiStatus = acpi_load_tables(rsdp);
if (!ACPI_SUCCESS(AcpiStatus)) {
DPRINT("acpi_load_tables() failed with status 0x%X\n", AcpiStatus);
acpi_terminate();
return STATUS_UNSUCCESSFUL;
}
if (!ACPI_SUCCESS(AcpiStatus)) {
DPRINT("acpi_load_tables() failed with status 0x%X\n", AcpiStatus);
acpi_terminate();
return STATUS_UNSUCCESSFUL;
}
Buffer.length = sizeof(SysInfo);
Buffer.pointer = &SysInfo;
Buffer.length = sizeof(SysInfo);
Buffer.pointer = &SysInfo;
AcpiStatus = acpi_get_system_info(&Buffer);
if (!ACPI_SUCCESS(AcpiStatus)) {
DPRINT("acpi_get_system_info() failed with status 0x%X\n", AcpiStatus);
acpi_terminate();
return STATUS_UNSUCCESSFUL;
}
if (!ACPI_SUCCESS(AcpiStatus)) {
DPRINT("acpi_get_system_info() failed with status 0x%X\n", AcpiStatus);
acpi_terminate();
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,
&SysInfo.table_info[ACPI_TABLE_FADT],
@ -272,21 +382,21 @@ FdoStartDevice(
DPRINT("ACPI CA Core Subsystem enabled\n");
/*
* Sx States:
* ----------
* Figure out which Sx states are supported
*/
for (i=0; i<=ACPI_S_STATES_MAX; i++) {
AcpiStatus = acpi_hw_obtain_sleep_type_register_data(
* Sx States:
* ----------
* Figure out which Sx states are supported
*/
for (i=0; i<=ACPI_S_STATES_MAX; i++) {
AcpiStatus = acpi_hw_obtain_sleep_type_register_data(
i,
&TypeA,
&TypeB);
DPRINT("acpi_hw_obtain_sleep_type_register_data (%d) status 0x%X\n",
i, AcpiStatus);
if (ACPI_SUCCESS(AcpiStatus)) {
DeviceExtension->SystemStates[i] = TRUE;
}
}
DeviceExtension->SystemStates[i] = TRUE;
}
}
ACPIPrintInfo(DeviceExtension);
@ -302,19 +412,17 @@ FdoStartDevice(
KeInitializeSpinLock(&DeviceExtension->DeviceListLock);
DeviceExtension->DeviceListCount = 0;
ACPIEnumerateNamespace(DeviceExtension);
//ACPIEnumerateRootBusses(DeviceExtension);
ACPIEnumerateDevices(DeviceExtension);
ACPIInitializeInternalDrivers(DeviceExtension);
DeviceExtension->State = dsStarted;
return STATUS_SUCCESS;
return STATUS_SUCCESS;
}
NTSTATUS
static NTSTATUS
FdoSetPower(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,

View file

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

View file

@ -232,7 +232,7 @@ acpi_os_install_interrupt_handler(u32 irq, OSD_HANDLER handler, void *context)
Affinity,
FALSE);
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;
}

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
* FILE: acpi/ospm/pdo.c
@ -16,30 +16,90 @@
/*** 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(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
PIO_STACK_LOCATION IrpSp)
{
PPDO_DEVICE_EXTENSION DeviceExtension;
UNICODE_STRING String;
NTSTATUS Status;
DPRINT("Called\n");
DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
RtlInitUnicodeString(&String, NULL);
// Irp->IoStatus.Information = 0;
switch (IrpSp->Parameters.QueryId.IdType) {
switch (IrpSp->Parameters.QueryId.IdType)
{
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;
case BusQueryHardwareIDs:
DPRINT("BusQueryHardwareIDs\n");
Status = AcpiDuplicateUnicodeString(&String,
&DeviceExtension->HardwareIDs,
PagedPool);
Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
break;
case BusQueryCompatibleIDs:
DPRINT("BusQueryCompatibleIDs\n");
Status = STATUS_NOT_IMPLEMENTED;
break;
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:
DPRINT("BusQueryDeviceSerialNumber\n");
Status = STATUS_NOT_IMPLEMENTED;
break;
default:
DPRINT("Unknown id type: %lx\n", IrpSp->Parameters.QueryId.IdType);
Status = STATUS_NOT_IMPLEMENTED;
}
@ -47,7 +107,7 @@ PdoQueryId(
}
NTSTATUS
static NTSTATUS
PdoSetPower(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
@ -126,6 +186,9 @@ PdoPnpControl(
break;
case IRP_MN_QUERY_ID:
Status = PdoQueryId(DeviceObject,
Irp,
IrpSp);
break;
case IRP_MN_QUERY_PNP_DEVICE_STATE: