From 15800ce78a5e881250ab1d9caa522d3f6d1f9eb5 Mon Sep 17 00:00:00 2001 From: Andrew Boie Date: Mon, 28 Mar 2016 14:49:37 -0700 Subject: [PATCH] nanokernel: deprecate dynamic IRQs We have not found any use-cases for dynamic IRQs where a static IRQ did not also suffice. Deprecate so that we can eventually remove from Zephyr and nontrivially decrease the complexity of the kernel. Change-Id: I509655371773aeaca7d01134dd850eb4cd95f387 Signed-off-by: Andrew Boie --- doc/board/frdm_k64f.rst | 2 +- .../nanokernel/nanokernel_interrupts.rst | 84 +------------------ include/irq.h | 24 +++++- .../footprint/microkernel/float/arm.conf | 1 - .../footprint/microkernel/max/arm.conf | 1 - .../microkernel/src/microkernel_footprint.c | 4 - .../footprint/nanokernel/max/arc.conf | 1 - .../footprint/nanokernel/max/arm.conf | 1 - .../footprint/nanokernel/max/x86.conf | 1 - .../nanokernel/src/nanokernel_footprint.c | 5 -- tests/benchmark/object_footprint/Kconfig | 4 - tests/benchmark/object_footprint/prj10.conf | 2 - tests/benchmark/object_footprint/prj11.conf | 2 - .../object_footprint/src/nanokernel_objects.c | 6 -- 14 files changed, 26 insertions(+), 112 deletions(-) diff --git a/doc/board/frdm_k64f.rst b/doc/board/frdm_k64f.rst index d54f3cee514..0e468b5d25a 100644 --- a/doc/board/frdm_k64f.rst +++ b/doc/board/frdm_k64f.rst @@ -277,7 +277,7 @@ For example, if 3 bits are implemented, use 1, 2, and 3, not 0x20h, 0x40h, and 0x60h. Interrupt priority is set using the *prio* parameter of -:c:macro:`IRQ_CONNECT()` or :c:func:`irq_connect_dynamic()`. +:c:macro:`IRQ_CONNECT()`. The range of available priorities is different if using Zero Latency Interrupts (ZLI) or not. diff --git a/doc/kernel/nanokernel/nanokernel_interrupts.rst b/doc/kernel/nanokernel/nanokernel_interrupts.rst index 27aa605a8dd..a29ab6d9279 100644 --- a/doc/kernel/nanokernel/nanokernel_interrupts.rst +++ b/doc/kernel/nanokernel/nanokernel_interrupts.rst @@ -25,9 +25,6 @@ Each ISR has the following properties: An :abbr:`IDT (Interrupt Descriptor Table)` is used to associate a given interrupt source with a given ISR. Only a single ISR can be associated with a specific IRQ at any given time. -An ISR can be incorporated into the IDT when the Zephyr project is built -(a "static ISR") or bound to the IDT when the system is up and running -(a "dynamic ISR"). Multiple ISRs can utilize the same function to process interrupts, allowing a single function to service a device that generates @@ -66,27 +63,10 @@ response, and which can be done quickly and without blocking. Installing an ISR ***************** -Use one of the following procedures to install an ISR: - -* `Installing a Static ISR`_ -* `Installing a Dynamic ISR`_ - -Installing a Static ISR -======================= - -Use a static ISR to register an interrupt handler when the interrupt -parameters are known during the build time and the device is always -present in the system. - -.. note:: - - There is no API method to uninstall a static ISR; however, it is - possible to replace it by installing a dynamic ISR. - -Prerequisites -------------- - -* Ensure that the platform used by the project supports static ISRs. +It's important to note that IRQ_CONNECT() is not a C function and does +some inline assembly magic behind the scenes. All its arguments must be known +at build time. Drivers that have multiple instances may need to define +per-instance config functions to configure the interrupt for that instance. Example ------- @@ -112,51 +92,6 @@ Example ... } -Installing a Dynamic ISR -======================== - -Use a dynamic ISR to register an interrupt handler when the interrupt -parameters can be found out only at runtime, or when a device is not always -present in the system. - -Prerequisites -------------- - -* Ensure that the platform used by the project supports dynamic ISRs. - -* (x86 only) Set the :option:`NUM_DYNAMIC_STUBS` configuration option - to specify the maximum number of dynamic ISRs allowed in the project. - -* (ARC & ARM only) Enable the :option:`SW_ISR_TABLE_DYNAMIC` so that - interrupts may be connected at runtime. - -Example -------- - -This is an example of a dynamic interrupt for x86: - -.. code-block:: c - - #define MY_DEV_IRQ 24 /* device uses IRQ 24 */ - #define MY_DEV_PRIO 2 /* device uses interrupt priority 2 */ - #define MY_ISR_ARG 17 /* argument passed to my_isr() */ - /* IRQ flags. Interrupt is triggered by low level signal */ - #define MY_IRQ_FLAGS (IOAPIC_LEVEL | IOAPIC_LOW) - - void my_isr(void *arg) - { - ... /* ISR code */ - } - - void my_isr_installer(void) - { - ... - irq_connect_dynamic(MY_DEV_IRQ, MY_DEV_PRIO, my_isr, MY_ISR_ARG, - MY_IRQ_FLAGS); - ... - irq_enable(MY_DEV_IRQ); - ... - } Working with Interrupts *********************** @@ -221,22 +156,11 @@ Additional intermediate context switches may be required to execute any currently executing fiber or any higher-priority tasks that are scheduled to run. -IDT Security -============ - -Ideally, the IDT memory area should be protected against accidental -modification, in the same way that text and read-only data areas -are protected. If no dynamic interrupts are in use, i.e. -:option:`NUM_DYNAMIC_STUBS` is 0, the IDT will be located in ROM. - APIs **** These are the interrupt-related Application Program Interfaces. -:c:func:`irq_connect_dynamic()` - Registers a dynamic ISR with the IDT and interrupt controller. - :c:func:`irq_enable()` Enables interrupts from a specific IRQ. diff --git a/include/irq.h b/include/irq.h index 62e00855313..e380fe63aad 100644 --- a/include/irq.h +++ b/include/irq.h @@ -24,6 +24,11 @@ /* Pull in the arch-specific implementations */ #include +#ifndef _ASMLANGUAGE + +#ifdef __cplusplus +extern "C" { +#endif /** * Configure a static interrupt. * @@ -52,9 +57,18 @@ * * @return The vector assigned to this interrupt */ -#define irq_connect_dynamic(irq_p, priority_p, isr_p, isr_param_p, flags_p) \ - _arch_irq_connect_dynamic(irq_p, priority_p, isr_p, isr_param_p, \ - flags_p) +extern int _arch_irq_connect_dynamic(unsigned int irq, unsigned int priority, + void (*routine)(void *parameter), void *parameter, + uint32_t flags); + +static inline int __attribute__((deprecated)) +irq_connect_dynamic(unsigned int irq, unsigned int priority, + void (*routine)(void *parameter), void *parameter, + uint32_t flags) +{ + return _arch_irq_connect_dynamic(irq, priority, routine, parameter, flags); +} + /** @@ -122,5 +136,9 @@ */ #define irq_disable(irq) _arch_irq_disable(irq) +#ifdef __cplusplus +} +#endif +#endif /* ASMLANGUAGE */ #endif /* _IRQ_H_ */ diff --git a/tests/benchmark/footprint/microkernel/float/arm.conf b/tests/benchmark/footprint/microkernel/float/arm.conf index 732a483d85b..b9753cf52f8 100644 --- a/tests/benchmark/footprint/microkernel/float/arm.conf +++ b/tests/benchmark/footprint/microkernel/float/arm.conf @@ -11,4 +11,3 @@ CONFIG_MICROKERNEL_SERVER_STACK_SIZE=4096 CONFIG_SYS_POWER_MANAGEMENT=y CONFIG_NUM_IRQS=43 -CONFIG_SW_ISR_TABLE_DYNAMIC=y diff --git a/tests/benchmark/footprint/microkernel/max/arm.conf b/tests/benchmark/footprint/microkernel/max/arm.conf index eb5d5dda968..0f78db6e8ed 100644 --- a/tests/benchmark/footprint/microkernel/max/arm.conf +++ b/tests/benchmark/footprint/microkernel/max/arm.conf @@ -9,4 +9,3 @@ CONFIG_NUM_TIMER_PACKETS=16 CONFIG_MICROKERNEL_SERVER_STACK_SIZE=4096 CONFIG_SYS_POWER_MANAGEMENT=y CONFIG_NUM_IRQS=43 -CONFIG_SW_ISR_TABLE_DYNAMIC=y diff --git a/tests/benchmark/footprint/microkernel/src/microkernel_footprint.c b/tests/benchmark/footprint/microkernel/src/microkernel_footprint.c index 6ce40b05945..ce2f100ec76 100644 --- a/tests/benchmark/footprint/microkernel/src/microkernel_footprint.c +++ b/tests/benchmark/footprint/microkernel/src/microkernel_footprint.c @@ -117,10 +117,6 @@ void dummyIsr(void *unused) */ void fgTaskEntry(void) { -#ifdef TEST_max - /* dynamically link in dummy ISR */ - irq_connect_dynamic(IRQ_LINE, IRQ_PRIORITY, dummyIsr, (void *) 0, 0); -#endif /* TEST_max */ #ifdef TEST_reg IRQ_CONNECT(IRQ_LINE, IRQ_PRIORITY, dummyIsr, NULL, 0); #endif diff --git a/tests/benchmark/footprint/nanokernel/max/arc.conf b/tests/benchmark/footprint/nanokernel/max/arc.conf index d2018f27e65..c808d0d63b4 100644 --- a/tests/benchmark/footprint/nanokernel/max/arc.conf +++ b/tests/benchmark/footprint/nanokernel/max/arc.conf @@ -1,3 +1,2 @@ CONFIG_SERIAL=n CONFIG_IPM=n -CONFIG_SW_ISR_TABLE_DYNAMIC=y diff --git a/tests/benchmark/footprint/nanokernel/max/arm.conf b/tests/benchmark/footprint/nanokernel/max/arm.conf index 7f94948912c..d8c7611af7d 100644 --- a/tests/benchmark/footprint/nanokernel/max/arm.conf +++ b/tests/benchmark/footprint/nanokernel/max/arm.conf @@ -2,4 +2,3 @@ CONFIG_PRINTK=y CONFIG_STDOUT_CONSOLE=y CONFIG_NUM_IRQS=43 CONFIG_FAULT_DUMP=2 -CONFIG_SW_ISR_TABLE_DYNAMIC=y diff --git a/tests/benchmark/footprint/nanokernel/max/x86.conf b/tests/benchmark/footprint/nanokernel/max/x86.conf index a3e6c5e4928..ceb5a268584 100644 --- a/tests/benchmark/footprint/nanokernel/max/x86.conf +++ b/tests/benchmark/footprint/nanokernel/max/x86.conf @@ -1,4 +1,3 @@ CONFIG_PRINTK=y CONFIG_STDOUT_CONSOLE=y CONFIG_IDT_NUM_VECTORS=256 -CONFIG_NUM_DYNAMIC_STUBS=2 diff --git a/tests/benchmark/footprint/nanokernel/src/nanokernel_footprint.c b/tests/benchmark/footprint/nanokernel/src/nanokernel_footprint.c index 892486ec7ca..15311547336 100644 --- a/tests/benchmark/footprint/nanokernel/src/nanokernel_footprint.c +++ b/tests/benchmark/footprint/nanokernel/src/nanokernel_footprint.c @@ -120,11 +120,6 @@ static void fiberEntry(int message, int arg1) void main(void) { -#ifdef TEST_max - /* dynamically link in dummy ISR */ - irq_connect_dynamic(IRQ_LINE, IRQ_PRIORITY, dummyIsr, - (void *) 0, 0); -#endif /* TEST_max */ #ifdef TEST_reg IRQ_CONNECT(IRQ_LINE, IRQ_PRIORITY, dummyIsr, NULL, 0); #endif diff --git a/tests/benchmark/object_footprint/Kconfig b/tests/benchmark/object_footprint/Kconfig index df33d3881ec..47d1552e852 100644 --- a/tests/benchmark/object_footprint/Kconfig +++ b/tests/benchmark/object_footprint/Kconfig @@ -51,7 +51,3 @@ config STATIC_ISR bool "static isr" default y -config DYNAMIC_ISR - bool "dynamic isr" - default n - diff --git a/tests/benchmark/object_footprint/prj10.conf b/tests/benchmark/object_footprint/prj10.conf index 2c5cd4dadb6..00a7caf442b 100644 --- a/tests/benchmark/object_footprint/prj10.conf +++ b/tests/benchmark/object_footprint/prj10.conf @@ -14,7 +14,5 @@ CONFIG_OBJECTS_LIFO=y CONFIG_OBJECTS_FIFO=y CONFIG_OBJECTS_STACK=y CONFIG_STATIC_ISR=n -CONFIG_DYNAMIC_ISR=y -CONFIG_NUM_DYNAMIC_STUBS=2 #CONFIG_TOOLCHAIN_VARIANT="iamcu" CONFIG_KERNEL_BIN_NAME="prj10" diff --git a/tests/benchmark/object_footprint/prj11.conf b/tests/benchmark/object_footprint/prj11.conf index d5283e86a43..6eacacca75f 100644 --- a/tests/benchmark/object_footprint/prj11.conf +++ b/tests/benchmark/object_footprint/prj11.conf @@ -14,7 +14,5 @@ CONFIG_OBJECTS_LIFO=y CONFIG_OBJECTS_FIFO=y CONFIG_OBJECTS_STACK=y CONFIG_STATIC_ISR=n -CONFIG_DYNAMIC_ISR=y -CONFIG_NUM_DYNAMIC_STUBS=2 CONFIG_NANO_TIMEOUTS=y CONFIG_KERNEL_BIN_NAME="prj11" diff --git a/tests/benchmark/object_footprint/src/nanokernel_objects.c b/tests/benchmark/object_footprint/src/nanokernel_objects.c index 6b317a9fdec..1bba2b602a6 100644 --- a/tests/benchmark/object_footprint/src/nanokernel_objects.c +++ b/tests/benchmark/object_footprint/src/nanokernel_objects.c @@ -115,12 +115,6 @@ void main(void) IRQ_CONNECT(IRQ_LINE, IRQ_PRIORITY, dummyIsr, NULL, 0); #endif -#ifdef CONFIG_DYNAMIC_ISR - /* dynamically link in dummy ISR */ - irq_connect_dynamic(IRQ_LINE, IRQ_PRIORITY, dummyIsr, - (void *) 0, 0); -#endif - #ifdef CONFIG_OBJECTS_FIBER /* start a trivial fiber */ task_fiber_start(pStack, FIBER_STACK_SIZE, fiberEntry, (int) MESSAGE,