Author: ekohl
Date: Sun Dec 29 11:14:09 2013
New Revision: 61461
URL:
http://svn.reactos.org/svn/reactos?rev=61461&view=rev
Log:
[ACPI]
Take the processor information from HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0 and
pass it to the device manager.
CORE-5960 #comment Still WIP.
Modified:
trunk/reactos/drivers/bus/acpi/busmgr/bus.c
trunk/reactos/drivers/bus/acpi/buspdo.c
trunk/reactos/drivers/bus/acpi/include/acpisys.h
trunk/reactos/drivers/bus/acpi/main.c
Modified: trunk/reactos/drivers/bus/acpi/busmgr/bus.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/busmgr/bu…
==============================================================================
--- trunk/reactos/drivers/bus/acpi/busmgr/bus.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/bus/acpi/busmgr/bus.c [iso-8859-1] Sun Dec 29 11:14:09 2013
@@ -1287,7 +1287,7 @@
case ACPI_BUS_TYPE_PROCESSOR:
hid = ACPI_PROCESSOR_HID;
uid = static_uid_buffer;
- sprintf(uid, "%d", (ProcessorCount++));
+ sprintf(uid, "_%d", (ProcessorCount++));
break;
case ACPI_BUS_TYPE_SYSTEM:
hid = ACPI_SYSTEM_HID;
Modified: trunk/reactos/drivers/bus/acpi/buspdo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/buspdo.c?…
==============================================================================
--- trunk/reactos/drivers/bus/acpi/buspdo.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/bus/acpi/buspdo.c [iso-8859-1] Sun Dec 29 11:14:09 2013
@@ -406,7 +406,7 @@
PIRP Irp )
{
PIO_STACK_LOCATION stack;
- PWCHAR buffer;
+ PWCHAR buffer, src;
WCHAR temp[256];
ULONG length;
NTSTATUS status = STATUS_SUCCESS;
@@ -490,15 +490,45 @@
{
acpi_bus_get_device(DeviceData->AcpiHandle, &Device);
- length += swprintf(&temp[length],
- L"ACPI\\%hs",
- Device->pnp.hardware_id);
- length++;
-
- length += swprintf(&temp[length],
- L"*%hs",
- Device->pnp.hardware_id);
- length++;
+ DPRINT1("Device name: %s\n", Device->pnp.device_name);
+ DPRINT1("Hardware ID: %s\n", Device->pnp.hardware_id);
+
+ if (strcmp(Device->pnp.hardware_id, "Processor") == 0)
+ {
+/*
+ length += swprintf(&temp[length],
+ L"ACPI\\%s - %s",
+ ProcessorVendorIdentifier, ProcessorIdentifier);
+ length++;
+
+ length += swprintf(&temp[length],
+ L"*%s - %s",
+ ProcessorVendorIdentifier, ProcessorIdentifier);
+ length++;
+*/
+ length = ProcessorHardwareIds.Length / sizeof(WCHAR);
+ src = ProcessorHardwareIds.Buffer;
+ }
+ else
+ {
+ length += swprintf(&temp[length],
+ L"ACPI\\%hs",
+ Device->pnp.hardware_id);
+ length++;
+
+ length += swprintf(&temp[length],
+ L"*%hs",
+ Device->pnp.hardware_id);
+ length++;
+
+ temp[length] = UNICODE_NULL;
+
+ length++;
+
+ temp[length] = UNICODE_NULL;
+ src = temp;
+
+ }
}
else
{
@@ -509,13 +539,15 @@
length += swprintf(&temp[length],
L"*FixedButton");
length++;
+
+ temp[length] = UNICODE_NULL;
+
+ length++;
+
+ temp[length] = UNICODE_NULL;
+ src = temp;
}
- temp[length] = UNICODE_NULL;
-
- length++;
-
- temp[length] = UNICODE_NULL;
buffer = ExAllocatePoolWithTag (PagedPool, length * sizeof(WCHAR),
'IPCA');
@@ -524,9 +556,54 @@
break;
}
- RtlCopyMemory (buffer, temp, length * sizeof(WCHAR));
+ RtlCopyMemory (buffer, src, length * sizeof(WCHAR));
Irp->IoStatus.Information = (ULONG_PTR) buffer;
DPRINT("BusQueryHardwareIDs: %ls\n",buffer);
+ break;
+
+ case BusQueryCompatibleIDs:
+ length = 0;
+ status = STATUS_NOT_SUPPORTED;
+
+ /* See comment in BusQueryDeviceID case */
+ if (DeviceData->AcpiHandle)
+ {
+ acpi_bus_get_device(DeviceData->AcpiHandle, &Device);
+
+ if (strcmp(Device->pnp.hardware_id, "Processor") == 0)
+ {
+ DPRINT("Device name: %s\n", Device->pnp.device_name);
+ DPRINT("Hardware ID: %s\n", Device->pnp.hardware_id);
+
+ length += swprintf(&temp[length],
+ L"ACPI\\%hs",
+ Device->pnp.hardware_id);
+ length++;
+
+ length += swprintf(&temp[length],
+ L"*%hs",
+ Device->pnp.hardware_id);
+ length++;
+
+ temp[length] = UNICODE_NULL;
+
+ length++;
+
+ temp[length] = UNICODE_NULL;
+
+ buffer = ExAllocatePoolWithTag (PagedPool, length * sizeof(WCHAR),
'IPCA');
+ if (!buffer)
+ {
+ status = STATUS_INSUFFICIENT_RESOURCES;
+ break;
+ }
+
+ RtlCopyMemory (buffer, temp, length * sizeof(WCHAR));
+ Irp->IoStatus.Information = (ULONG_PTR) buffer;
+ DPRINT("BusQueryHardwareIDs: %ls\n",buffer);
+ status = STATUS_SUCCESS;
+ }
+ }
break;
default:
@@ -604,7 +681,12 @@
else if (wcsstr(DeviceData->HardwareIDs, L"ACPI_PWR") != 0)
Temp = L"ACPI Power Resource";
else if (wcsstr(DeviceData->HardwareIDs, L"Processor") != 0)
- Temp = L"Processor";
+ {
+ if (ProcessorNameString != NULL)
+ Temp = ProcessorNameString;
+ else
+ Temp = L"Processor";
+ }
else if (wcsstr(DeviceData->HardwareIDs, L"ThermalZone") != 0)
Temp = L"ACPI Thermal Zone";
else if (wcsstr(DeviceData->HardwareIDs, L"ACPI0002") != 0)
Modified: trunk/reactos/drivers/bus/acpi/include/acpisys.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/include/a…
==============================================================================
--- trunk/reactos/drivers/bus/acpi/include/acpisys.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/bus/acpi/include/acpisys.h [iso-8859-1] Sun Dec 29 11:14:09
2013
@@ -3,6 +3,10 @@
* FILE: acpi/ospm/include/acpisys.h
* PURPOSE: ACPI bus driver definitions
*/
+
+extern UNICODE_STRING ProcessorHardwareIds;
+extern LPWSTR ProcessorNameString;
+
typedef enum _DEVICE_PNP_STATE {
NotStarted = 0, // Not started yet
Modified: trunk/reactos/drivers/bus/acpi/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/main.c?re…
==============================================================================
--- trunk/reactos/drivers/bus/acpi/main.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/bus/acpi/main.c [iso-8859-1] Sun Dec 29 11:14:09 2013
@@ -27,6 +27,10 @@
extern struct acpi_device *sleep_button;
extern struct acpi_device *power_button;
+
+UNICODE_STRING ProcessorHardwareIds = {0, 0, NULL};
+LPWSTR ProcessorNameString = NULL;
+
NTSTATUS
NTAPI
@@ -332,6 +336,285 @@
return status;
}
+static
+NTSTATUS
+AcpiRegOpenKey(IN HANDLE ParentKeyHandle,
+ IN LPCWSTR KeyName,
+ IN ACCESS_MASK DesiredAccess,
+ OUT HANDLE KeyHandle)
+{
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ UNICODE_STRING Name;
+
+ RtlInitUnicodeString(&Name, KeyName);
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &Name,
+ OBJ_CASE_INSENSITIVE,
+ ParentKeyHandle,
+ NULL);
+
+ return ZwOpenKey(KeyHandle,
+ DesiredAccess,
+ &ObjectAttributes);
+}
+
+static
+NTSTATUS
+AcpiRegQueryValue(IN HANDLE KeyHandle,
+ IN LPWSTR ValueName,
+ OUT PULONG Type OPTIONAL,
+ OUT PVOID Data OPTIONAL,
+ IN OUT PULONG DataLength OPTIONAL)
+{
+ PKEY_VALUE_PARTIAL_INFORMATION ValueInfo;
+ UNICODE_STRING Name;
+ ULONG BufferLength = 0;
+ NTSTATUS Status;
+
+ RtlInitUnicodeString(&Name,
+ ValueName);
+
+ if (DataLength != NULL)
+ BufferLength = *DataLength;
+
+ BufferLength += FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data);
+
+ /* Allocate memory for the value */
+ ValueInfo = ExAllocatePoolWithTag(PagedPool, BufferLength, 'IPCA');
+ if (ValueInfo == NULL)
+ return STATUS_NO_MEMORY;
+
+ /* Query the value */
+ Status = ZwQueryValueKey(KeyHandle,
+ &Name,
+ KeyValuePartialInformation,
+ ValueInfo,
+ BufferLength,
+ &BufferLength);
+ if ((NT_SUCCESS(Status)) || (Status == STATUS_BUFFER_OVERFLOW))
+ {
+ if (Type != NULL)
+ *Type = ValueInfo->Type;
+
+ if (DataLength != NULL)
+ *DataLength = ValueInfo->DataLength;
+ }
+
+ /* Check if the caller wanted data back, and we got it */
+ if ((NT_SUCCESS(Status)) && (Data != NULL))
+ {
+ /* Copy it */
+ RtlMoveMemory(Data,
+ ValueInfo->Data,
+ ValueInfo->DataLength);
+
+ /* if the type is REG_SZ and data is not 0-terminated
+ * and there is enough space in the buffer NT appends a \0 */
+ if (((ValueInfo->Type == REG_SZ) || (ValueInfo->Type == REG_EXPAND_SZ) ||
(ValueInfo->Type == REG_MULTI_SZ)) &&
+ (ValueInfo->DataLength <= *DataLength - sizeof(WCHAR)))
+ {
+ WCHAR *ptr = (WCHAR *)((ULONG_PTR)Data + ValueInfo->DataLength);
+ if ((ptr > (WCHAR *)Data) && ptr[-1])
+ *ptr = 0;
+ }
+ }
+
+ /* Free the memory and return status */
+ ExFreePoolWithTag(ValueInfo, 'IPCA');
+
+ if ((Data == NULL) && (Status == STATUS_BUFFER_OVERFLOW))
+ Status = STATUS_SUCCESS;
+
+ return Status;
+}
+
+static
+NTSTATUS
+GetProcessorInformation(VOID)
+{
+ LPWSTR ProcessorIdentifier = NULL;
+ LPWSTR ProcessorVendorIdentifier = NULL;
+ LPWSTR HardwareIdsBuffer = NULL;
+ HANDLE ProcessorHandle = NULL;
+ ULONG Length, Level1Length = 0, Level2Length = 0, Level3Length = 0;
+ ULONG HardwareIdsLength = 0;
+ ULONG i;
+ PWCHAR Ptr;
+ NTSTATUS Status;
+
+ DPRINT1("GetProcessorInformation()\n");
+
+ Status = AcpiRegOpenKey(NULL,
+
L"\\Registry\\Machine\\Hardware\\Description\\System\\CentralProcessor\\0",
+ KEY_READ,
+ &ProcessorHandle);
+ if (!NT_SUCCESS(Status))
+ goto done;
+
+ AcpiRegQueryValue(ProcessorHandle,
+ L"Identifier",
+ NULL,
+ NULL,
+ &Length);
+
+ if (Length != 0)
+ {
+ ProcessorIdentifier = ExAllocatePoolWithTag(PagedPool, Length, 'IPCA');
+ if (ProcessorIdentifier == NULL)
+ {
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ goto done;
+ }
+
+ Status = AcpiRegQueryValue(ProcessorHandle,
+ L"Identifier",
+ NULL,
+ ProcessorIdentifier,
+ &Length);
+ if (!NT_SUCCESS(Status))
+ goto done;
+
+ Length = 0;
+ }
+
+ AcpiRegQueryValue(ProcessorHandle,
+ L"ProcessorNameString",
+ NULL,
+ NULL,
+ &Length);
+
+ if (Length != 0)
+ {
+ ProcessorNameString = ExAllocatePoolWithTag(PagedPool, Length, 'IPCA');
+ if (ProcessorNameString == NULL)
+ {
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ goto done;
+ }
+
+ Status = AcpiRegQueryValue(ProcessorHandle,
+ L"ProcessorNameString",
+ NULL,
+ ProcessorNameString,
+ &Length);
+ if (!NT_SUCCESS(Status))
+ goto done;
+
+ Length = 0;
+ }
+
+ AcpiRegQueryValue(ProcessorHandle,
+ L"VendorIdentifier",
+ NULL,
+ NULL,
+ &Length);
+
+ if (Length != 0)
+ {
+ ProcessorVendorIdentifier = ExAllocatePoolWithTag(PagedPool, Length,
'IPCA');
+ if (ProcessorVendorIdentifier == NULL)
+ {
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ goto done;
+ }
+
+ Status = AcpiRegQueryValue(ProcessorHandle,
+ L"VendorIdentifier",
+ NULL,
+ ProcessorVendorIdentifier,
+ &Length);
+ if (!NT_SUCCESS(Status))
+ goto done;
+
+ Length = 0;
+ }
+
+ for (i = 0; i < wcslen(ProcessorIdentifier); i++)
+ {
+ if (ProcessorIdentifier[i] == L' ')
+ ProcessorIdentifier[i] = L'_';
+ }
+
+ Ptr = wcsstr(ProcessorIdentifier, L"Stepping");
+ if (Ptr != NULL)
+ {
+ Ptr--;
+ Level1Length = (ULONG)(Ptr - ProcessorIdentifier);
+ }
+
+ Ptr = wcsstr(ProcessorIdentifier, L"Model");
+ if (Ptr != NULL)
+ {
+ Ptr--;
+ Level2Length = (ULONG)(Ptr - ProcessorIdentifier);
+ }
+
+ Ptr = wcsstr(ProcessorIdentifier, L"Family");
+ if (Ptr != NULL)
+ {
+ Ptr--;
+ Level3Length = (ULONG)(Ptr - ProcessorIdentifier);
+ }
+
+ HardwareIdsLength = 5 + wcslen(ProcessorVendorIdentifier) + 3 + Level1Length + 1 +
+ 1 + wcslen(ProcessorVendorIdentifier) + 3 + Level1Length + 1 +
+ 5 + wcslen(ProcessorVendorIdentifier) + 3 + Level2Length + 1 +
+ 1 + wcslen(ProcessorVendorIdentifier) + 3 + Level2Length + 1 +
+ 5 + wcslen(ProcessorVendorIdentifier) + 3 + Level3Length + 1 +
+ 1 + wcslen(ProcessorVendorIdentifier) + 3 + Level3Length + 1 +
+ 2;
+
+ HardwareIdsBuffer = ExAllocatePoolWithTag(PagedPool, HardwareIdsLength *
sizeof(WCHAR), 'IPCA');
+ if (HardwareIdsBuffer == NULL)
+ {
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ goto done;
+ }
+
+ Length = 0;
+ Length += swprintf(&HardwareIdsBuffer[Length], L"ACPI\\%s_-_%.*s",
ProcessorVendorIdentifier, Level1Length, ProcessorIdentifier);
+ Length++;
+
+ Length += swprintf(&HardwareIdsBuffer[Length], L"*%s_-_%.*s",
ProcessorVendorIdentifier, Level1Length, ProcessorIdentifier);
+ Length++;
+
+ Length += swprintf(&HardwareIdsBuffer[Length], L"ACPI\\%s_-_%.*s",
ProcessorVendorIdentifier, Level2Length, ProcessorIdentifier);
+ Length++;
+
+ Length += swprintf(&HardwareIdsBuffer[Length], L"*%s_-_%.*s",
ProcessorVendorIdentifier, Level2Length, ProcessorIdentifier);
+ Length++;
+
+ Length += swprintf(&HardwareIdsBuffer[Length], L"ACPI\\%s_-_%.*s",
ProcessorVendorIdentifier, Level3Length, ProcessorIdentifier);
+ Length++;
+
+ Length += swprintf(&HardwareIdsBuffer[Length], L"*%s_-_%.*s",
ProcessorVendorIdentifier, Level3Length, ProcessorIdentifier);
+ Length++;
+ HardwareIdsBuffer[Length] = UNICODE_NULL;
+
+ ProcessorHardwareIds.Length = HardwareIdsLength * sizeof(WCHAR);
+ ProcessorHardwareIds.MaximumLength = ProcessorHardwareIds.Length;
+ ProcessorHardwareIds.Buffer = HardwareIdsBuffer;
+
+done:
+ if (ProcessorHandle != NULL)
+ ZwClose(ProcessorHandle);
+
+ if (ProcessorIdentifier != NULL)
+ ExFreePoolWithTag(ProcessorIdentifier, 'IPCA');
+
+ if (ProcessorVendorIdentifier != NULL)
+ ExFreePoolWithTag(ProcessorVendorIdentifier, 'IPCA');
+
+ if (!NT_SUCCESS(Status))
+ {
+ if (HardwareIdsBuffer != NULL)
+ ExFreePoolWithTag(HardwareIdsBuffer, 'IPCA');
+ }
+
+ return Status;
+}
+
NTSTATUS
NTAPI
DriverEntry (
@@ -341,6 +624,8 @@
{
DPRINT("Driver Entry \n");
+ GetProcessorInformation();
+
//
// Set entry points into the driver
//