Ticket #5: acpi_routing_tables.patch

File acpi_routing_tables.patch, 4.2 KB (added by tqh, 9 years ago)

Current WIP, arch_int 682 for-loop always sets irq -1...

  • src/system/kernel/arch/x86/irq_routing_table.cpp

     
    1111#include <int.h>
    1212
    1313
    14 //#define TRACE_PRT
     14#define TRACE_PRT
    1515#ifdef TRACE_PRT
    1616#   define TRACE(x...) dprintf("IRQRoutingTable: "x)
    1717#else
     
    6767        dprintf("pin: %i\n", entry.pin);
    6868        dprintf("source: %x\n", int(entry.source));
    6969        dprintf("source index: %i\n", entry.source_index);
    70 
    71         dprintf("pci_bus: %i\n", entry.pci_bus);
    72         dprintf("pci_device: %i\n", entry.pci_device);
    7370    }
    7471}
    7572
    7673
    7774static status_t
    78 find_pci_device(pci_module_info *pci, irq_routing_entry* entry)
    79 {
    80     pci_info info;
    81     int pciN = 0;
    82     while ((*pci->get_nth_pci_info)(pciN, &info) == B_OK) {
    83         pciN ++;
    84 
    85         int16 deviceAddress = entry->device_address >> 16 & 0xFFFF;
    86         if (info.device == deviceAddress
    87             && info.u.h0.interrupt_pin == entry->pin + 1) {
    88             entry->pci_bus = info.bus;
    89             entry->pci_device = info.device;
    90             return B_OK;
    91         }
    92     }
    93 
    94     return B_ERROR;
    95 }
    96 
    97 
    98 static status_t
    9975read_device_irq_routing_table(pci_module_info *pci, acpi_module_info* acpi,
    10076    acpi_handle device, IRQRoutingTable* table)
    10177{
     
    10783        return status;
    10884
    10985    irq_routing_entry irqEntry;
    110     acpi_pci_routing_table* acpiTable
    111         = (acpi_pci_routing_table*)buffer.pointer;
     86    acpi_pci_routing_table* acpiTable = (acpi_pci_routing_table*)buffer.pointer;
    11287    while (acpiTable->length) {
    11388        irqEntry.device_address = acpiTable->address;
    11489        irqEntry.pin = acpiTable->pin;
    11590        acpi_handle source;
    116         if (acpi->get_handle(device, acpiTable->source, &source) != B_OK)
    117             continue;
     91        if (acpi->get_handle(device, acpiTable->source, &source) == B_OK) {
     92            irqEntry.source = source;
     93            irqEntry.source_index = acpiTable->sourceIndex;
     94            table->PushBack(irqEntry);         
     95        }
    11896        irqEntry.source = source;
    11997        irqEntry.source_index = acpiTable->sourceIndex;
    120 
    121         // connect to pci device
    122         if (find_pci_device(pci, &irqEntry) != B_OK) {
    123             TRACE("no pci dev found, device %x, pin %i\n",
    124                 irqEntry.device_address, irqEntry.pin);
    125             acpiTable = (acpi_pci_routing_table*)((uint8*)acpiTable
    126                 + acpiTable->length);
    127             continue;
    128         }
    129 
    13098        table->PushBack(irqEntry);
    13199        acpiTable = (acpi_pci_routing_table*)((uint8*)acpiTable
    132100            + acpiTable->length);
     
    153121        return status;
    154122    TRACE("Read root pci bus irq rooting table\n");
    155123    status = read_device_irq_routing_table(pci, acpi, rootPciHandle, table);
    156     if (status != B_OK)
    157         return status;
    158124
    159     TRACE("find p2p \n");
     125    TRACE("find routing tables \n");
    160126
    161127    char result[255];
    162128    result[0] = 0;
     
    170136
    171137        status = read_device_irq_routing_table(pci, acpi, brigde, table);
    172138        if (status == B_OK)
    173             TRACE("p2p found %s\n", result);
     139            TRACE("routing table found %s\n", result);
    174140    }
    175141
    176     return status;
     142    return table->Count() > 0 ? B_OK : B_ERROR;
    177143}
    178144
    179145
  • src/system/kernel/arch/x86/arch_int.cpp

     
    3939#include <stdio.h>
    4040
    4141
    42 //#define TRACE_ARCH_INT
     42#define TRACE_ARCH_INT
    4343#ifdef TRACE_ARCH_INT
    4444#   define TRACE(x) dprintf x
    4545#else
     
    590590    }
    591591
    592592// disable io apic for now
    593 return;
     593//return;
    594594
    595595    // load acpi module
    596596    status_t status;
     
    668668    // configure apic interrupts assume 1:1 mapping
    669669    for (int i = 0; i < table.Count(); i++) {
    670670        irq_routing_entry& entry = table.ElementAt(i);
     671        TRACE(("address: %x pin: %i source: %x source index: %i\n",
     672            entry.device_address, entry.pin, int(entry.source),
     673            entry.source_index));
     674
    671675        irq_descriptor irqDescriptor;
    672676        read_current_irq(acpiModule, entry.source, &irqDescriptor);
    673677        uint32 config = 0;
  • src/system/kernel/arch/x86/irq_routing_table.h

     
    1919
    2020    acpi_handle     source;
    2121    int             source_index;
    22 
    23     // pci busmanager connection
    24     uchar           pci_bus;
    25     uchar           pci_device;
    2622};
    2723
    2824