/trunk/kernel/genarch/include/ofw/ofw_tree.h |
---|
49,6 → 49,12 |
unsigned properties; /**< Number of properties. */ |
ofw_tree_property_t *property; |
/** |
* Pointer to a structure representing respective device. |
* Its semantics is device dependent. |
*/ |
void *device; |
}; |
/** Memory representation of OpenFirmware device tree node property. */ |
104,8 → 110,24 |
} __attribute__ ((packed)); |
typedef struct ofw_ebus_range ofw_ebus_range_t; |
struct ofw_ebus_intr_map { |
uint32_t space; |
uint32_t addr; |
uint32_t intr; |
uint32_t controller_handle; |
uint32_t controller_ino; |
} __attribute__ ((packed)); |
typedef struct ofw_ebus_intr_map ofw_ebus_intr_map_t; |
struct ofw_ebus_intr_mask { |
uint32_t space_mask; |
uint32_t addr_mask; |
uint32_t intr_mask; |
} __attribute__ ((packed)); |
typedef struct ofw_ebus_intr_mask ofw_ebus_intr_mask_t; |
struct ofw_pci_reg { |
uint32_t space; /* needs to masked to obtain pure space id */ |
uint32_t space; /* needs to be masked to obtain pure space id */ |
uint64_t addr; /* group phys.mid and phys.lo together */ |
uint64_t size; |
} __attribute__ ((packed)); |
143,4 → 165,7 |
extern bool ofw_pci_reg_absolutize(ofw_tree_node_t *node, ofw_pci_reg_t *reg, ofw_pci_reg_t *out); |
extern bool ofw_fhc_map_interrupts(ofw_tree_node_t *node, ofw_fhc_reg_t *reg, uint32_t interrupt, int *ino); |
extern bool ofw_ebus_map_interrupts(ofw_tree_node_t *node, ofw_ebus_reg_t *reg, uint32_t interrupt, int *ino); |
#endif |
/trunk/kernel/genarch/src/kbd/z8530.c |
---|
38,7 → 38,6 |
#include <genarch/kbd/key.h> |
#include <genarch/kbd/scanc.h> |
#include <genarch/kbd/scanc_sun.h> |
#include <arch/drivers/fhc.h> |
#include <arch/drivers/z8530.h> |
#include <arch/interrupt.h> |
#include <arch/drivers/kbd.h> |
106,14 → 105,6 |
z8530_write_a(WR3, WR3_RX8BITSCH | WR3_RX_ENABLE); |
z8530_write_a(WR9, WR9_MIE); /* Master Interrupt Enable. */ |
/* |
* We need to initialize the FireHose Controller, |
* to which is this z8530 attached. Otherwise |
* interrupts generated by the z8530 would not |
* be forwarded to the CPU. |
*/ |
fhc_init(); |
} |
/** Process z8530 interrupt. |
/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; |
} |
/** @} |
*/ |
/trunk/kernel/genarch/src/ofw/fhc.c |
---|
36,6 → 36,7 |
*/ |
#include <genarch/ofw/ofw_tree.h> |
#include <arch/drivers/fhc.h> |
#include <arch/memstr.h> |
#include <func.h> |
#include <panic.h> |
108,5 → 109,25 |
return false; |
} |
bool ofw_fhc_map_interrupts(ofw_tree_node_t *node, ofw_fhc_reg_t *reg, uint32_t interrupt, int *ino) |
{ |
fhc_t *fhc = NULL; |
if (!node->device) { |
fhc = fhc_init(node); |
if (!fhc) |
return false; |
node->device = fhc; |
central_fhc = fhc; |
} |
/* |
* The interrupt controller for the interrupt is the FHC itself. |
*/ |
fhc_enable_interrupt(fhc, interrupt); |
*ino = interrupt; |
return true; |
} |
/** @} |
*/ |