3 * PROJECT: ReactOS ACPI bus driver
4 * FILE: acpi/ospm/acpienum.c
5 * PURPOSE: ACPI namespace enumerator
6 * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
8 * 01-05-2001 CSH Created
24 BM_DEVICE
*device
= NULL
;
25 char *type_string
= NULL
;
32 device
= &(node
->device
);
34 if (flags
& BM_PRINT_PRESENT
)
36 if (!BM_DEVICE_PRESENT(device
))
43 buffer
.pointer
= acpi_os_callocate(buffer
.length
);
49 acpi_get_name(device
->acpi_handle
, ACPI_FULL_PATHNAME
, &buffer
);
51 switch(device
->id
.type
)
54 type_string
= "System";
58 type_string
= "Scope";
61 case BM_TYPE_PROCESSOR
:
62 type_string
= "Processor";
65 case BM_TYPE_THERMAL_ZONE
:
66 type_string
= "ThermalZone";
69 case BM_TYPE_POWER_RESOURCE
:
70 type_string
= "PowerResource";
73 case BM_TYPE_FIXED_BUTTON
:
74 type_string
= "Button";
78 type_string
= "Device";
82 type_string
= "Unknown";
86 if (!(flags
& BM_PRINT_GROUP
))
88 DbgPrint("+------------------------------------------------------------\n");
91 DbgPrint("%s[0x%02x] hid[%s] %s\n", type_string
, device
->handle
, device
->id
.hid
, buffer
.pointer
);
92 DbgPrint(" acpi_handle[0x%08x] flags[0x%02x] status[0x%02x]\n", device
->acpi_handle
, device
->flags
, device
->status
);
94 if (flags
& BM_PRINT_IDENTIFICATION
)
96 DbgPrint(" identification: uid[%s] adr[0x%08x]\n", device
->id
.uid
, device
->id
.adr
);
99 if (flags
& BM_PRINT_LINKAGE
)
101 DbgPrint(" linkage: this[%p] parent[%p] next[%p]\n", node
, node
->parent
, node
->next
);
102 DbgPrint(" scope.head[%p] scope.tail[%p]\n", node
->scope
.head
, node
->scope
.tail
);
105 if (flags
& BM_PRINT_POWER
)
107 DbgPrint(" power: state[D%d] flags[0x%08X]\n", device
->power
.state
, device
->power
.flags
);
108 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]);
109 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]);
112 if (!(flags
& BM_PRINT_GROUP
))
114 DbgPrint("+------------------------------------------------------------\n");
117 acpi_os_free(buffer
.pointer
);
125 ACPIEnumerateDevices(PFDO_DEVICE_EXTENSION DeviceExtension
)
127 BM_HANDLE_LIST HandleList
;
128 PACPI_DEVICE AcpiDevice
;
129 ACPI_STATUS AcpiStatus
;
130 BM_DEVICE_ID Criteria
;
137 RtlZeroMemory(&Criteria
, sizeof(BM_DEVICE_ID
));
138 Criteria
.type
= BM_TYPE_ALL
;
140 AcpiStatus
= bm_search(BM_HANDLE_ROOT
, &Criteria
, &HandleList
);
141 if (ACPI_SUCCESS(AcpiStatus
))
143 DPRINT("Got %d devices\n", HandleList
.count
);
145 for (i
= 0; i
< HandleList
.count
; i
++)
147 AcpiStatus
= bm_get_node(HandleList
.handles
[i
], 0, &Node
);
148 if (ACPI_SUCCESS(AcpiStatus
))
150 DPRINT("Got BM node information: (Node 0x%X)\n", Node
);
152 if ((Node
->device
.flags
& BM_FLAGS_IDENTIFIABLE
) &&
153 (Node
->device
.id
.hid
[0] != 0))
156 bm_print1(Node
, BM_PRINT_ALL
- BM_PRINT_PRESENT
);
159 AcpiDevice
= (PACPI_DEVICE
)ExAllocatePool(NonPagedPool
,
160 sizeof(ACPI_DEVICE
));
161 if (AcpiDevice
== NULL
)
163 return STATUS_INSUFFICIENT_RESOURCES
;
166 RtlZeroMemory(AcpiDevice
, sizeof(ACPI_DEVICE
));
168 AcpiDevice
->Pdo
= NULL
;
169 AcpiDevice
->BmHandle
= HandleList
.handles
[i
];
171 KeAcquireSpinLock(&DeviceExtension
->DeviceListLock
, &OldIrql
);
172 InsertHeadList(&DeviceExtension
->DeviceListHead
,
173 &AcpiDevice
->DeviceListEntry
);
174 DeviceExtension
->DeviceListCount
++;
175 KeReleaseSpinLock(&DeviceExtension
->DeviceListLock
, OldIrql
);
180 DPRINT("Could not get BM node\n");
186 DPRINT("Got no devices (Status 0x%X)\n", AcpiStatus
);
189 return STATUS_SUCCESS
;