Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 1908 → Rev 1909

/trunk/kernel/genarch/src/ofw/ebus.c
39,6 → 39,7
#include <arch/memstr.h>
#include <func.h>
#include <panic.h>
#include <debug.h>
#include <macros.h>
 
bool ofw_ebus_apply_ranges(ofw_tree_node_t *node, ofw_ebus_reg_t *reg, uintptr_t *pa)
73,5 → 74,51
return false;
}
 
bool ofw_ebus_map_interrupts(ofw_tree_node_t *node, ofw_ebus_reg_t *reg, uint32_t interrupt, int *ino)
{
ofw_tree_property_t *prop;
ofw_tree_node_t *controller;
prop = ofw_tree_getprop(node, "interrupt-map");
if (!prop || !prop->value)
return false;
 
ofw_ebus_intr_map_t *intr_map = prop->value;
count_t count = prop->size / sizeof(ofw_ebus_intr_map_t);
ASSERT(count);
prop = ofw_tree_getprop(node, "interrupt-map-mask");
if (!prop || !prop->value)
return false;
ofw_ebus_intr_mask_t *intr_mask = prop->value;
ASSERT(prop->size == sizeof(ofw_ebus_intr_mask_t));
uint32_t space = reg->space & intr_mask->space_mask;
uint32_t addr = reg->addr & intr_mask->addr_mask;
uint32_t intr = interrupt & intr_mask->intr_mask;
int i;
for (i = 0; i < count; i++) {
if ((intr_map[i].space == space) && (intr_map[i].addr == addr)
&& (intr_map[i].intr == intr))
goto found;
}
return false;
 
found:
/*
* We found the device that functions as an interrupt controller
* for the interrupt. We also found mapping from interrupt to INO.
*/
 
controller = ofw_tree_find_node_by_handle(ofw_tree_lookup("/"), intr_map[i].controller_handle);
*ino = intr_map[i].controller_ino;
return true;
}
 
/** @}
*/