- Handle ACPI_RESOURCE_TYPE_EXTENDED_IRQ and ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64
[reactos.git] / reactos / drivers / bus / acpi / buspdo.c
index 47a350c..6fe0f86 100644 (file)
@@ -623,6 +623,12 @@ Bus_PDO_QueryResources(
        {
                switch (resource->Type)
                {
        {
                switch (resource->Type)
                {
+                       case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
+                       {
+                               ACPI_RESOURCE_EXTENDED_IRQ *irq_data = (ACPI_RESOURCE_EXTENDED_IRQ*) &resource->Data;
+                               NumberOfResources += irq_data->InterruptCount;
+                               break;
+                       }
                        case ACPI_RESOURCE_TYPE_IRQ:
                        {
                                ACPI_RESOURCE_IRQ *irq_data = (ACPI_RESOURCE_IRQ*) &resource->Data;
                        case ACPI_RESOURCE_TYPE_IRQ:
                        {
                                ACPI_RESOURCE_IRQ *irq_data = (ACPI_RESOURCE_IRQ*) &resource->Data;
@@ -638,6 +644,7 @@ Bus_PDO_QueryResources(
                        case ACPI_RESOURCE_TYPE_ADDRESS16:
                        case ACPI_RESOURCE_TYPE_ADDRESS32:
                        case ACPI_RESOURCE_TYPE_ADDRESS64:
                        case ACPI_RESOURCE_TYPE_ADDRESS16:
                        case ACPI_RESOURCE_TYPE_ADDRESS32:
                        case ACPI_RESOURCE_TYPE_ADDRESS64:
+                       case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
                        case ACPI_RESOURCE_TYPE_MEMORY24:
                        case ACPI_RESOURCE_TYPE_MEMORY32:
                        case ACPI_RESOURCE_TYPE_IO:
                        case ACPI_RESOURCE_TYPE_MEMORY24:
                        case ACPI_RESOURCE_TYPE_MEMORY32:
                        case ACPI_RESOURCE_TYPE_IO:
@@ -676,6 +683,25 @@ Bus_PDO_QueryResources(
        {
                switch (resource->Type)
                {
        {
                switch (resource->Type)
                {
+                       case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
+                       {
+                               ACPI_RESOURCE_EXTENDED_IRQ *irq_data = (ACPI_RESOURCE_EXTENDED_IRQ*) &resource->Data;
+                               for (i = 0; i < irq_data->InterruptCount; i++)
+                               {
+                                       ResourceDescriptor->Type = CmResourceTypeInterrupt;
+
+                                       ResourceDescriptor->ShareDisposition =
+                                       (irq_data->Sharable == ACPI_SHARED ? CmResourceShareShared : CmResourceShareDeviceExclusive);
+                                       ResourceDescriptor->Flags =
+                                       (irq_data->Triggering == ACPI_LEVEL_SENSITIVE ? CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE : CM_RESOURCE_INTERRUPT_LATCHED);
+                                       ResourceDescriptor->u.Interrupt.Level = irq_data->Interrupts[i];
+                                       ResourceDescriptor->u.Interrupt.Vector = 0;
+                                       ResourceDescriptor->u.Interrupt.Affinity = (KAFFINITY)(-1);
+
+                                       ResourceDescriptor++;
+                               }
+                               break;
+                       }
                        case ACPI_RESOURCE_TYPE_IRQ:
                        {
                                ACPI_RESOURCE_IRQ *irq_data = (ACPI_RESOURCE_IRQ*) &resource->Data;
                        case ACPI_RESOURCE_TYPE_IRQ:
                        {
                                ACPI_RESOURCE_IRQ *irq_data = (ACPI_RESOURCE_IRQ*) &resource->Data;
@@ -865,6 +891,49 @@ Bus_PDO_QueryResources(
                                ResourceDescriptor++;
                                break;
                        }
                                ResourceDescriptor++;
                                break;
                        }
+                       case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
+                       {
+                               ACPI_RESOURCE_EXTENDED_ADDRESS64 *addr64_data = (ACPI_RESOURCE_EXTENDED_ADDRESS64*) &resource->Data;
+                               if (addr64_data->ResourceType == ACPI_BUS_NUMBER_RANGE)
+                               {
+                                       DPRINT1("64-bit bus address is not supported!\n");
+                                       ResourceDescriptor->Type = CmResourceTypeBusNumber;
+                                       ResourceDescriptor->ShareDisposition = CmResourceShareShared;
+                                       ResourceDescriptor->Flags = 0;
+                                       ResourceDescriptor->u.BusNumber.Start = (ULONG)addr64_data->Minimum;
+                                       ResourceDescriptor->u.BusNumber.Length = addr64_data->AddressLength;
+                               }
+                               else if (addr64_data->ResourceType == ACPI_IO_RANGE)
+                               {
+                                       ResourceDescriptor->Type = CmResourceTypePort;
+                                       ResourceDescriptor->ShareDisposition = CmResourceShareDeviceExclusive;
+                                       ResourceDescriptor->Flags = CM_RESOURCE_PORT_IO;
+                                       if (addr64_data->Decode == ACPI_POS_DECODE)
+                                               ResourceDescriptor->Flags |= CM_RESOURCE_PORT_POSITIVE_DECODE;
+                                       ResourceDescriptor->u.Port.Start.QuadPart = addr64_data->Minimum;
+                                       ResourceDescriptor->u.Port.Length = addr64_data->AddressLength;
+                               }
+                               else
+                               {
+                                       ResourceDescriptor->Type = CmResourceTypeMemory;
+                                       ResourceDescriptor->ShareDisposition = CmResourceShareDeviceExclusive;
+                                       ResourceDescriptor->Flags = 0;
+                                       if (addr64_data->Info.Mem.WriteProtect == ACPI_READ_ONLY_MEMORY)
+                                               ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_ONLY;
+                                       else
+                                               ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_WRITE;
+                                       switch (addr64_data->Info.Mem.Caching)
+                                       {
+                                               case ACPI_CACHABLE_MEMORY: ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_CACHEABLE; break;
+                                               case ACPI_WRITE_COMBINING_MEMORY: ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_COMBINEDWRITE; break;
+                                               case ACPI_PREFETCHABLE_MEMORY: ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_PREFETCHABLE; break;
+                                       }       
+                                       ResourceDescriptor->u.Memory.Start.QuadPart = addr64_data->Minimum;
+                                       ResourceDescriptor->u.Memory.Length = addr64_data->AddressLength;
+                               }
+                               ResourceDescriptor++;
+                               break;
+                       }
                        case ACPI_RESOURCE_TYPE_MEMORY24:
                        {
                                ACPI_RESOURCE_MEMORY24 *mem24_data = (ACPI_RESOURCE_MEMORY24*) &resource->Data;
                        case ACPI_RESOURCE_TYPE_MEMORY24:
                        {
                                ACPI_RESOURCE_MEMORY24 *mem24_data = (ACPI_RESOURCE_MEMORY24*) &resource->Data;
@@ -968,6 +1037,12 @@ Bus_PDO_QueryResourceRequirements(
        {
                switch (resource->Type)
                {
        {
                switch (resource->Type)
                {
+                       case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
+                       {
+                               ACPI_RESOURCE_EXTENDED_IRQ *irq_data = (ACPI_RESOURCE_EXTENDED_IRQ*) &resource->Data;
+                               NumberOfResources += irq_data->InterruptCount;
+                               break;
+                       }
                        case ACPI_RESOURCE_TYPE_IRQ:
                        {
                                ACPI_RESOURCE_IRQ *irq_data = (ACPI_RESOURCE_IRQ*) &resource->Data;
                        case ACPI_RESOURCE_TYPE_IRQ:
                        {
                                ACPI_RESOURCE_IRQ *irq_data = (ACPI_RESOURCE_IRQ*) &resource->Data;
@@ -983,6 +1058,7 @@ Bus_PDO_QueryResourceRequirements(
                        case ACPI_RESOURCE_TYPE_ADDRESS16:
                        case ACPI_RESOURCE_TYPE_ADDRESS32:
                        case ACPI_RESOURCE_TYPE_ADDRESS64:
                        case ACPI_RESOURCE_TYPE_ADDRESS16:
                        case ACPI_RESOURCE_TYPE_ADDRESS32:
                        case ACPI_RESOURCE_TYPE_ADDRESS64:
+                       case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
                        case ACPI_RESOURCE_TYPE_MEMORY24:
                        case ACPI_RESOURCE_TYPE_MEMORY32:
                        case ACPI_RESOURCE_TYPE_IO:
                        case ACPI_RESOURCE_TYPE_MEMORY24:
                        case ACPI_RESOURCE_TYPE_MEMORY32:
                        case ACPI_RESOURCE_TYPE_IO:
@@ -1021,6 +1097,22 @@ Bus_PDO_QueryResourceRequirements(
        {
                switch (resource->Type)
                {
        {
                switch (resource->Type)
                {
+                       case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
+                       {
+                               ACPI_RESOURCE_EXTENDED_IRQ *irq_data = (ACPI_RESOURCE_EXTENDED_IRQ*) &resource->Data;
+                               for (i = 0; i < irq_data->InterruptCount; i++)
+                               {
+                                       RequirementDescriptor->Option = CurrentRes ? 0 : IO_RESOURCE_PREFERRED;
+                                       RequirementDescriptor->Type = CmResourceTypeInterrupt;
+                                       RequirementDescriptor->ShareDisposition = (irq_data->Sharable == ACPI_SHARED ? CmResourceShareShared : CmResourceShareDeviceExclusive);
+                                       RequirementDescriptor->Flags =(irq_data->Triggering == ACPI_LEVEL_SENSITIVE ? CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE : CM_RESOURCE_INTERRUPT_LATCHED);
+                                       RequirementDescriptor->u.Interrupt.MinimumVector =
+                                       RequirementDescriptor->u.Interrupt.MaximumVector = irq_data->Interrupts[i];
+
+                                       RequirementDescriptor++;
+                               }
+                               break;
+                       }
                        case ACPI_RESOURCE_TYPE_IRQ:
                        {
                                ACPI_RESOURCE_IRQ *irq_data = (ACPI_RESOURCE_IRQ*) &resource->Data;
                        case ACPI_RESOURCE_TYPE_IRQ:
                        {
                                ACPI_RESOURCE_IRQ *irq_data = (ACPI_RESOURCE_IRQ*) &resource->Data;
@@ -1225,6 +1317,53 @@ Bus_PDO_QueryResourceRequirements(
                                RequirementDescriptor++;
                                break;
                        }
                                RequirementDescriptor++;
                                break;
                        }
+                       case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
+                       {
+                               ACPI_RESOURCE_EXTENDED_ADDRESS64 *addr64_data = (ACPI_RESOURCE_EXTENDED_ADDRESS64*) &resource->Data;
+                               RequirementDescriptor->Option = CurrentRes ? 0 : IO_RESOURCE_PREFERRED;
+                               if (addr64_data->ResourceType == ACPI_BUS_NUMBER_RANGE)
+                               {
+                                       DPRINT1("64-bit bus address is not supported!\n");
+                                       RequirementDescriptor->Type = CmResourceTypeBusNumber;
+                                       RequirementDescriptor->ShareDisposition = CmResourceShareShared;
+                                       RequirementDescriptor->Flags = 0;
+                                       RequirementDescriptor->u.BusNumber.MinBusNumber = (ULONG)addr64_data->Minimum;
+                                       RequirementDescriptor->u.BusNumber.MaxBusNumber = (ULONG)addr64_data->Maximum;
+                                       RequirementDescriptor->u.BusNumber.Length = addr64_data->AddressLength;
+                               }
+                               else if (addr64_data->ResourceType == ACPI_IO_RANGE)
+                               {
+                                       RequirementDescriptor->Type = CmResourceTypePort;
+                                       RequirementDescriptor->ShareDisposition = CmResourceShareDeviceExclusive;
+                                       RequirementDescriptor->Flags = CM_RESOURCE_PORT_IO;
+                                       if (addr64_data->Decode == ACPI_POS_DECODE)
+                                               RequirementDescriptor->Flags |= CM_RESOURCE_PORT_POSITIVE_DECODE;
+                                       RequirementDescriptor->u.Port.MinimumAddress.QuadPart = addr64_data->Minimum;
+                                       RequirementDescriptor->u.Port.MaximumAddress.QuadPart = addr64_data->Maximum;
+                                       RequirementDescriptor->u.Port.Length = addr64_data->AddressLength;
+                               }
+                               else
+                               {
+                                       RequirementDescriptor->Type = CmResourceTypeMemory;
+                                       RequirementDescriptor->ShareDisposition = CmResourceShareDeviceExclusive;
+                                       RequirementDescriptor->Flags = 0;
+                                       if (addr64_data->Info.Mem.WriteProtect == ACPI_READ_ONLY_MEMORY)
+                                               RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_ONLY;
+                                       else
+                                               RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_WRITE;
+                                       switch (addr64_data->Info.Mem.Caching)
+                                       {
+                                               case ACPI_CACHABLE_MEMORY: RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_CACHEABLE; break;
+                                               case ACPI_WRITE_COMBINING_MEMORY: RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_COMBINEDWRITE; break;
+                                               case ACPI_PREFETCHABLE_MEMORY: RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_PREFETCHABLE; break;
+                                       }       
+                                       RequirementDescriptor->u.Memory.MinimumAddress.QuadPart = addr64_data->Minimum;
+                                       RequirementDescriptor->u.Memory.MaximumAddress.QuadPart = addr64_data->Maximum;
+                                       RequirementDescriptor->u.Memory.Length = addr64_data->AddressLength;
+                               }
+                               RequirementDescriptor++;
+                               break;
+                       }
                        case ACPI_RESOURCE_TYPE_MEMORY24:
                        {
                                ACPI_RESOURCE_MEMORY24 *mem24_data = (ACPI_RESOURCE_MEMORY24*) &resource->Data;
                        case ACPI_RESOURCE_TYPE_MEMORY24:
                        {
                                ACPI_RESOURCE_MEMORY24 *mem24_data = (ACPI_RESOURCE_MEMORY24*) &resource->Data;