1*fe2bcea7Smilek7 /* 2*fe2bcea7Smilek7 * Copyright 2010, Clemens Zeidler, haiku@clemens-zeidler.de. 3*fe2bcea7Smilek7 * Distributed under the terms of the MIT License. 4*fe2bcea7Smilek7 */ 5*fe2bcea7Smilek7 #ifndef IRQ_ROUTING_TABLE_H 6*fe2bcea7Smilek7 #define IRQ_ROUTING_TABLE_H 7*fe2bcea7Smilek7 8*fe2bcea7Smilek7 9*fe2bcea7Smilek7 #include <ACPI.h> 10*fe2bcea7Smilek7 11*fe2bcea7Smilek7 12*fe2bcea7Smilek7 #include "util/Vector.h" 13*fe2bcea7Smilek7 14*fe2bcea7Smilek7 15*fe2bcea7Smilek7 struct irq_routing_entry { 16*fe2bcea7Smilek7 // ACPI specifics 17*fe2bcea7Smilek7 uint64 device_address; 18*fe2bcea7Smilek7 uint8 pin; 19*fe2bcea7Smilek7 20*fe2bcea7Smilek7 acpi_handle source; 21*fe2bcea7Smilek7 uint32 source_index; 22*fe2bcea7Smilek7 bool needs_configuration; 23*fe2bcea7Smilek7 24*fe2bcea7Smilek7 // PCI bus_manager connection 25*fe2bcea7Smilek7 uint8 pci_bus; 26*fe2bcea7Smilek7 uint8 pci_device; 27*fe2bcea7Smilek7 uint32 pci_function_mask; 28*fe2bcea7Smilek7 29*fe2bcea7Smilek7 // Distilled configuration info 30*fe2bcea7Smilek7 uint8 irq; // Global System Interrupt (GSI) 31*fe2bcea7Smilek7 uint8 bios_irq; // BIOS assigned original IRQ 32*fe2bcea7Smilek7 uint8 polarity; // B_{HIGH|LOW}_ACTIVE_POLARITY 33*fe2bcea7Smilek7 uint8 trigger_mode; // B_{LEVEL|EDGE}_TRIGGERED 34*fe2bcea7Smilek7 }; 35*fe2bcea7Smilek7 36*fe2bcea7Smilek7 37*fe2bcea7Smilek7 typedef Vector<irq_routing_entry> IRQRoutingTable; 38*fe2bcea7Smilek7 39*fe2bcea7Smilek7 40*fe2bcea7Smilek7 struct irq_descriptor { 41*fe2bcea7Smilek7 irq_descriptor(); 42*fe2bcea7Smilek7 43*fe2bcea7Smilek7 uint8 irq; 44*fe2bcea7Smilek7 bool shareable; 45*fe2bcea7Smilek7 // B_LOW_ACTIVE_POLARITY or B_HIGH_ACTIVE_POLARITY 46*fe2bcea7Smilek7 uint8 polarity; 47*fe2bcea7Smilek7 // B_LEVEL_TRIGGERED or B_EDGE_TRIGGERED 48*fe2bcea7Smilek7 uint8 trigger_mode; 49*fe2bcea7Smilek7 }; 50*fe2bcea7Smilek7 51*fe2bcea7Smilek7 52*fe2bcea7Smilek7 typedef Vector<irq_descriptor> irq_descriptor_list; 53*fe2bcea7Smilek7 54*fe2bcea7Smilek7 55*fe2bcea7Smilek7 struct pci_address { 56*fe2bcea7Smilek7 uint8 segment; 57*fe2bcea7Smilek7 uint8 bus; 58*fe2bcea7Smilek7 uint8 device; 59*fe2bcea7Smilek7 uint8 function; 60*fe2bcea7Smilek7 }; 61*fe2bcea7Smilek7 62*fe2bcea7Smilek7 63*fe2bcea7Smilek7 struct link_device { 64*fe2bcea7Smilek7 acpi_handle handle; 65*fe2bcea7Smilek7 irq_descriptor current_irq; 66*fe2bcea7Smilek7 Vector<irq_descriptor> possible_irqs; 67*fe2bcea7Smilek7 Vector<irq_routing_entry*> used_by; 68*fe2bcea7Smilek7 }; 69*fe2bcea7Smilek7 70*fe2bcea7Smilek7 71*fe2bcea7Smilek7 typedef bool (*interrupt_available_check_function)(int32 globalSystemInterrupt); 72*fe2bcea7Smilek7 73*fe2bcea7Smilek7 74*fe2bcea7Smilek7 void print_irq_descriptor(const irq_descriptor& descriptor); 75*fe2bcea7Smilek7 void print_irq_routing_table(const IRQRoutingTable& table); 76*fe2bcea7Smilek7 77*fe2bcea7Smilek7 78*fe2bcea7Smilek7 status_t prepare_irq_routing(acpi_module_info* acpi, IRQRoutingTable& table, 79*fe2bcea7Smilek7 interrupt_available_check_function checkFunction); 80*fe2bcea7Smilek7 status_t enable_irq_routing(acpi_module_info* acpi, 81*fe2bcea7Smilek7 IRQRoutingTable& routingTable); 82*fe2bcea7Smilek7 83*fe2bcea7Smilek7 status_t read_current_irq(acpi_module_info* acpi, acpi_handle device, 84*fe2bcea7Smilek7 irq_descriptor& descriptor); 85*fe2bcea7Smilek7 status_t read_possible_irqs(acpi_module_info* acpi, acpi_handle device, 86*fe2bcea7Smilek7 irq_descriptor_list& descriptorList); 87*fe2bcea7Smilek7 88*fe2bcea7Smilek7 status_t set_current_irq(acpi_module_info* acpi, acpi_handle device, 89*fe2bcea7Smilek7 const irq_descriptor& descriptor); 90*fe2bcea7Smilek7 91*fe2bcea7Smilek7 #endif // IRQ_ROUTING_TABLE_H 92