[BUS][ACPI] Silence DPRINT1 in the special case of IOCTL_BATTERY_QUERY_TAG (#427)
[reactos.git] / drivers / bus / acpi / main.c
index b2da79c..d9dc256 100644 (file)
@@ -22,6 +22,7 @@ extern struct acpi_device *sleep_button;
 extern struct acpi_device *power_button;
 
 UNICODE_STRING ProcessorHardwareIds = {0, 0, NULL};
+LPWSTR ProcessorIdString = NULL;
 LPWSTR ProcessorNameString = NULL;
 
 
@@ -36,8 +37,8 @@ Bus_AddDevice(
     NTSTATUS            status;
     PDEVICE_OBJECT      deviceObject = NULL;
     PFDO_DEVICE_DATA    deviceData = NULL;
-    PWCHAR              deviceName = NULL;
 #ifndef NDEBUG
+    PWCHAR              deviceName = NULL;
     ULONG               nameLength;
 #endif
 
@@ -123,8 +124,7 @@ Bus_AddDevice(
         goto End;
     }
 
-    deviceName = ExAllocatePoolWithTag (NonPagedPool,
-                            nameLength, 'IPCA');
+    deviceName = ExAllocatePoolWithTag(NonPagedPool, nameLength, 'MpcA');
 
     if (NULL == deviceName) {
         DPRINT1("AddDevice: no memory to alloc for deviceName(0x%x)\n", nameLength);
@@ -159,9 +159,11 @@ Bus_AddDevice(
     deviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
 
 End:
+#ifndef NDEBUG
     if (deviceName){
-        ExFreePoolWithTag(deviceName, 'IPCA');
+        ExFreePoolWithTag(deviceName, 'MpcA');
     }
+#endif
     if (!NT_SUCCESS(status) && deviceObject){
         if (deviceData && deviceData->NextLowerDriver){
             IoDetachDevice (deviceData->NextLowerDriver);
@@ -270,23 +272,23 @@ ACPIDispatchDeviceControl(
                    */
                   if (power_button)
                   {
-                      DPRINT1("Fixed power button reported to power manager\n");
+                      DPRINT("Fixed power button reported to power manager\n");
                       Caps |= SYS_BUTTON_POWER;
                   }
                   if (sleep_button)
                   {
-                      DPRINT1("Fixed sleep button reported to power manager\n");
+                      DPRINT("Fixed sleep button reported to power manager\n");
                       Caps |= SYS_BUTTON_SLEEP;
                   }
               }
               else if (wcsstr(((PPDO_DEVICE_DATA)commonData)->HardwareIDs, L"PNP0C0C"))
               {
-                  DPRINT1("Control method power button reported to power manager\n");
+                  DPRINT("Control method power button reported to power manager\n");
                   Caps |= SYS_BUTTON_POWER;
               }
               else if (wcsstr(((PPDO_DEVICE_DATA)commonData)->HardwareIDs, L"PNP0C0E"))
               {
-                  DPRINT1("Control method sleep reported to power manager\n");
+                  DPRINT("Control method sleep reported to power manager\n");
                   Caps |= SYS_BUTTON_SLEEP;
               }
               else
@@ -309,6 +311,10 @@ ACPIDispatchDeviceControl(
 
               status = STATUS_PENDING;
               break;
+           
+           case IOCTL_BATTERY_QUERY_TAG:
+              DPRINT("IOCTL_BATTERY_QUERY_TAG is not supported!\n");
+              break;
 
            default:
               DPRINT1("Unsupported IOCTL: %x\n", irpStack->Parameters.DeviceIoControl.IoControlCode);
@@ -376,7 +382,7 @@ AcpiRegQueryValue(IN HANDLE KeyHandle,
         BufferLength += FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data);
 
         /* Allocate memory for the value */
-        ValueInfo = ExAllocatePoolWithTag(PagedPool, BufferLength, 'IPCA');
+        ValueInfo = ExAllocatePoolWithTag(PagedPool, BufferLength, 'MpcA');
         if (ValueInfo == NULL)
             return STATUS_NO_MEMORY;
     }
@@ -436,7 +442,7 @@ AcpiRegQueryValue(IN HANDLE KeyHandle,
     /* Free the memory and return status */
     if (ValueInfo != NULL)
     {
-        ExFreePoolWithTag(ValueInfo, 'IPCA');
+        ExFreePoolWithTag(ValueInfo, 'MpcA');
     }
 
     return Status;
@@ -450,14 +456,14 @@ GetProcessorInformation(VOID)
     LPWSTR ProcessorVendorIdentifier = NULL;
     LPWSTR HardwareIdsBuffer = NULL;
     HANDLE ProcessorHandle = NULL;
-    ULONG Length, Level1Length = 0, Level2Length = 0, Level3Length = 0;
+    ULONG Length = 0, Level1Length = 0, Level2Length = 0, Level3Length = 0;
     SIZE_T HardwareIdsLength = 0;
     SIZE_T VendorIdentifierLength;
     ULONG i;
     PWCHAR Ptr;
     NTSTATUS Status;
 
-    DPRINT1("GetProcessorInformation()\n");
+    DPRINT("GetProcessorInformation()\n");
 
     /* Open the key for CPU 0 */
     Status = AcpiRegOpenKey(NULL,
@@ -465,7 +471,10 @@ GetProcessorInformation(VOID)
                             KEY_READ,
                             &ProcessorHandle);
     if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("Failed to open CentralProcessor registry key: 0x%lx\n", Status);
         goto done;
+    }
 
     /* Query the processor identifier length */
     Status = AcpiRegQueryValue(ProcessorHandle,
@@ -474,16 +483,20 @@ GetProcessorInformation(VOID)
                                NULL,
                                &Length);
     if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("Failed to query Identifier value: 0x%lx\n", Status);
         goto done;
+    }
 
     /* Remember the length as fallback for level 1-3 length */
     Level1Length = Level2Length = Level3Length = Length;
 
     /* Allocate a buffer large enough to be zero terminated */
     Length += sizeof(UNICODE_NULL);
-    ProcessorIdentifier = ExAllocatePoolWithTag(PagedPool, Length, 'IPCA');
+    ProcessorIdentifier = ExAllocatePoolWithTag(PagedPool, Length, 'IpcA');
     if (ProcessorIdentifier == NULL)
     {
+        DPRINT1("Failed to allocate 0x%lx bytes\n", Length);
         Status = STATUS_INSUFFICIENT_RESOURCES;
         goto done;
     }
@@ -495,7 +508,10 @@ GetProcessorInformation(VOID)
                                ProcessorIdentifier,
                                &Length);
     if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("Failed to query Identifier value: 0x%lx\n", Status);
         goto done;
+    }
 
     /* Query the processor name length */
     Length = 0;
@@ -505,13 +521,17 @@ GetProcessorInformation(VOID)
                                NULL,
                                &Length);
     if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("Failed to query ProcessorNameString value: 0x%lx\n", Status);
         goto done;
+    }
 
     /* Allocate a buffer large enough to be zero terminated */
     Length += sizeof(UNICODE_NULL);
-    ProcessorNameString = ExAllocatePoolWithTag(PagedPool, Length, 'IPCA');
+    ProcessorNameString = ExAllocatePoolWithTag(PagedPool, Length, 'IpcA');
     if (ProcessorNameString == NULL)
     {
+        DPRINT1("Failed to allocate 0x%lx bytes\n", Length);
         Status = STATUS_INSUFFICIENT_RESOURCES;
         goto done;
     }
@@ -523,7 +543,10 @@ GetProcessorInformation(VOID)
                                ProcessorNameString,
                                &Length);
     if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("Failed to query ProcessorNameString value: 0x%lx\n", Status);
         goto done;
+    }
 
     /* Query the vendor identifier length */
     Length = 0;
@@ -533,13 +556,17 @@ GetProcessorInformation(VOID)
                                NULL,
                                &Length);
     if (!NT_SUCCESS(Status) || (Length == 0))
+    {
+        DPRINT1("Failed to query VendorIdentifier value: 0x%lx\n", Status);
         goto done;
+    }
 
     /* Allocate a buffer large enough to be zero terminated */
     Length += sizeof(UNICODE_NULL);
-    ProcessorVendorIdentifier = ExAllocatePoolWithTag(PagedPool, Length, 'IPCA');
+    ProcessorVendorIdentifier = ExAllocatePoolWithTag(PagedPool, Length, 'IpcA');
     if (ProcessorVendorIdentifier == NULL)
     {
+        DPRINT1("Failed to allocate 0x%lx bytes\n", Length);
         Status = STATUS_INSUFFICIENT_RESOURCES;
         goto done;
     }
@@ -551,7 +578,10 @@ GetProcessorInformation(VOID)
                                ProcessorVendorIdentifier,
                                &Length);
     if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("Failed to query VendorIdentifier value: 0x%lx\n", Status);
         goto done;
+    }
 
     /* Change spaces to underscores */
     for (i = 0; i < wcslen(ProcessorIdentifier); i++)
@@ -593,7 +623,7 @@ GetProcessorInformation(VOID)
                          1) * sizeof(WCHAR);
 
     /* Allocate a buffer to the data */
-    HardwareIdsBuffer = ExAllocatePoolWithTag(PagedPool, HardwareIdsLength, 'IPCA');
+    HardwareIdsBuffer = ExAllocatePoolWithTag(PagedPool, HardwareIdsLength, 'IpcA');
     if (HardwareIdsBuffer == NULL)
     {
         Status = STATUS_INSUFFICIENT_RESOURCES;
@@ -627,20 +657,29 @@ GetProcessorInformation(VOID)
     ProcessorHardwareIds.MaximumLength = ProcessorHardwareIds.Length;
     ProcessorHardwareIds.Buffer = HardwareIdsBuffer;
 
+    Length = (5 + VendorIdentifierLength + 3 + Level1Length + 1) * sizeof(WCHAR);
+    ProcessorIdString = ExAllocatePoolWithTag(PagedPool, Length, 'IpcA');
+    if (ProcessorIdString != NULL)
+    {
+        Length = swprintf(ProcessorIdString, L"ACPI\\%s_-_%.*s", ProcessorVendorIdentifier, Level1Length, ProcessorIdentifier);
+        ProcessorIdString[Length++] = UNICODE_NULL;
+        DPRINT("ProcessorIdString: %S\n", ProcessorIdString);
+    }
+
 done:
     if (ProcessorHandle != NULL)
         ZwClose(ProcessorHandle);
 
     if (ProcessorIdentifier != NULL)
-        ExFreePoolWithTag(ProcessorIdentifier, 'IPCA');
+        ExFreePoolWithTag(ProcessorIdentifier, 'IpcA');
 
     if (ProcessorVendorIdentifier != NULL)
-        ExFreePoolWithTag(ProcessorVendorIdentifier, 'IPCA');
+        ExFreePoolWithTag(ProcessorVendorIdentifier, 'IpcA');
 
     if (!NT_SUCCESS(Status))
     {
         if (HardwareIdsBuffer != NULL)
-            ExFreePoolWithTag(HardwareIdsBuffer, 'IPCA');
+            ExFreePoolWithTag(HardwareIdsBuffer, 'IpcA');
     }
 
     return Status;