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