From 38e953d913885b830f5f8f951afc0f1873d112d1 Mon Sep 17 00:00:00 2001 From: Sebastian Sumpf Date: Fri, 16 Mar 2012 14:47:41 +0100 Subject: [PATCH] Fiasco.OC: Set interrupt mode in IRQ session Set IRQ 0-15 to edget/high and 16-23 level low (x86 only). Fixes #153 --- base-foc/src/core/arm/platform_arm.cc | 2 ++ base-foc/src/core/include/platform.h | 5 +++++ base-foc/src/core/irq_session_component.cc | 4 ++++ base-foc/src/core/x86/platform_x86.cc | 12 ++++++++++++ 4 files changed, 23 insertions(+) diff --git a/base-foc/src/core/arm/platform_arm.cc b/base-foc/src/core/arm/platform_arm.cc index 9ef144fc4c..33877c19a7 100644 --- a/base-foc/src/core/arm/platform_arm.cc +++ b/base-foc/src/core/arm/platform_arm.cc @@ -14,3 +14,5 @@ #include void Genode::Platform::_setup_io_port_alloc() { } + +void Genode::Platform::setup_irq_mode(unsigned irq_number) { } diff --git a/base-foc/src/core/include/platform.h b/base-foc/src/core/include/platform.h index 74356efb0a..ae2b3b8875 100644 --- a/base-foc/src/core/include/platform.h +++ b/base-foc/src/core/include/platform.h @@ -125,6 +125,11 @@ namespace Genode { */ Core_pager *core_pager(); + /** + * Set interrupt mode (e.g., level or edge) + */ + static void setup_irq_mode(unsigned irq_number); + /** * Constructor */ diff --git a/base-foc/src/core/irq_session_component.cc b/base-foc/src/core/irq_session_component.cc index 54fe8226af..9f7353aa90 100644 --- a/base-foc/src/core/irq_session_component.cc +++ b/base-foc/src/core/irq_session_component.cc @@ -20,6 +20,7 @@ /* core includes */ #include #include +#include #include /* Fiasco includes */ @@ -122,6 +123,9 @@ Irq_session_component::Irq_session_component(Cap_session *cap_session, if (l4_error(l4_icu_bind(L4_BASE_ICU_CAP, irq_number, _irq.capability()))) PERR("Binding IRQ%ld to the ICU failed", irq_number); + /* set interrupt mode */ + Platform::setup_irq_mode(irq_number); + if (l4_error(l4_irq_attach(_irq.capability(), irq_number, Interrupt_handler::handler_cap()))) PERR("Error attaching to IRQ %ld", irq_number); diff --git a/base-foc/src/core/x86/platform_x86.cc b/base-foc/src/core/x86/platform_x86.cc index b9f94bc4f0..a788bedadc 100644 --- a/base-foc/src/core/x86/platform_x86.cc +++ b/base-foc/src/core/x86/platform_x86.cc @@ -21,6 +21,7 @@ /* Fiasco.OC includes */ namespace Fiasco { #include +#include } void Genode::Platform::_setup_io_port_alloc() @@ -42,3 +43,14 @@ void Genode::Platform::_setup_io_port_alloc() /* setup allocator */ _io_port_alloc.add_range(0, 0x10000); } + + +void Genode::Platform::setup_irq_mode(unsigned irq_number) +{ + using namespace Fiasco; + + /* set IRQ below 16 to edge/high and others to level/low */ + l4_umword_t mode = irq_number < 16 ? L4_IRQ_F_POS_EDGE : L4_IRQ_F_LEVEL_LOW; + if (l4_error(l4_icu_set_mode(L4_BASE_ICU_CAP, irq_number, mode))) + PERR("Setting mode for IRQ%u failed", irq_number); +}