20 #include "pedigree/kernel/Log.h" 21 #include "pedigree/kernel/machine/Device.h" 22 #include "pedigree/kernel/machine/openfirmware/Device.h" 23 #include "pedigree/kernel/panic.h" 24 #include "pedigree/kernel/processor/Processor.h" 25 #include "pedigree/kernel/processor/types.h" 28 size_t resolveInterruptNumber(
Device *pDev)
32 uint32_t interrupt_specifier;
36 ofDev.getProperty(
"interrupts", reinterpret_cast<OFParam>(buf), 8);
39 return static_cast<size_t>(-1);
41 interrupt_specifier = buf[0];
44 uint32_t unit_address =
45 reinterpret_cast<uint32_t
>(ofDev.getProperty(
"reg"));
51 ofDev.getProperty(
"name", type);
54 if (ofDev.propertyExists(
"interrupt-parent"))
56 this_node = ofDev.getProperty(
"interrupt-parent");
60 this_node = pDev->
getParent()->getOFHandle();
62 while (this_node != 0)
65 OFHandle parent_node = 0;
68 if (dev.propertyExists(
"interrupt-controller"))
70 if (dev.propertyExists(
"interrupt-parent"))
72 parent_node = dev.getProperty(
"interrupt-parent");
74 reinterpret_cast<uint32_t
>(dev.getProperty(
"reg"));
77 reinterpret_cast<uint32_t
>(dev.getProperty(
"interrupts"));
78 this_node = parent_node;
82 return interrupt_specifier;
86 else if (dev.propertyExists(
"interrupt-map"))
89 size_t mapLength = dev.getPropertyLength(
"interrupt-map");
90 uint32_t *map =
new uint32_t[mapLength / 4];
92 "interrupt-map", reinterpret_cast<OFParam>(map), mapLength);
94 uint32_t address_cells = 0;
95 if (dev.propertyExists(
"#address-cells"))
97 address_cells =
reinterpret_cast<uint32_t
>(
98 dev.getProperty(
"#address-cells"));
102 if (dev.propertyExists(
"interrupt-map-mask"))
104 size_t maskLength = dev.getPropertyLength(
"interrupt-map-mask");
105 uint32_t *mask =
new uint32_t[maskLength / 4];
107 "interrupt-map-mask", reinterpret_cast<OFParam>(mask),
110 unit_address &= mask[0];
111 interrupt_specifier &= mask[address_cells];
117 while (i < (mapLength / 4))
120 if (map[i] == 0 || map[i] == 1)
122 if (address_cells > 0)
124 if (map[i] != unit_address)
138 if (map[i] != interrupt_specifier)
150 parent_node =
reinterpret_cast<OFHandle
>(map[i++]);
151 interrupt_specifier = map[i++];
153 this_node = parent_node;
157 if (parent_node == 0)
164 else if (dev.propertyExists(
"interrupt-parent"))
166 this_node = dev.getProperty(
"interrupt-parent");
171 this_node = dev.getParent();
173 return static_cast<size_t>(-1);
176 return interrupt_specifier;
void EXPORTED_PUBLIC panic(const char *msg) NORETURN
Device * getParent() const