Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | /* * Copyright (c) 2014 Wind River Systems, Inc. * * SPDX-License-Identifier: Apache-2.0 */ /** * @file * @brief ARCv2 interrupt management * * * Interrupt management: * * - enabling/disabling * * An IRQ number passed to the @a irq parameters found in this file is a * number from 16 to last IRQ number on the platform. */ #include <kernel.h> #include <arch/cpu.h> #include <sys/__assert.h> #include <toolchain.h> #include <linker/sections.h> #include <sw_isr_table.h> #include <irq.h> #include <sys/printk.h> /* * @brief Enable an interrupt line * * Clear possible pending interrupts on the line, and enable the interrupt * line. After this call, the CPU will receive interrupts for the specified * @a irq. * * @return N/A */ void z_arch_irq_enable(unsigned int irq) { unsigned int key = irq_lock(); z_arc_v2_irq_unit_int_enable(irq); irq_unlock(key); } /* * @brief Disable an interrupt line * * Disable an interrupt line. After this call, the CPU will stop receiving * interrupts for the specified @a irq. * * @return N/A */ void z_arch_irq_disable(unsigned int irq) { unsigned int key = irq_lock(); z_arc_v2_irq_unit_int_disable(irq); irq_unlock(key); } /* * @internal * * @brief Set an interrupt's priority * * Lower values take priority over higher values. Special case priorities are * expressed via mutually exclusive flags. * The priority is verified if ASSERT_ON is enabled; max priority level * depends on CONFIG_NUM_IRQ_PRIO_LEVELS. * * @return N/A */ void z_irq_priority_set(unsigned int irq, unsigned int prio, u32_t flags) { ARG_UNUSED(flags); unsigned int key = irq_lock(); __ASSERT(prio < CONFIG_NUM_IRQ_PRIO_LEVELS, "invalid priority %d for irq %d", prio, irq); /* 0 -> CONFIG_NUM_IRQ_PRIO_LEVELS allocted to secure world * left prio levels allocated to normal world */ #if defined(CONFIG_ARC_SECURE_FIRMWARE) prio = prio < ARC_N_IRQ_START_LEVEL ? prio : (ARC_N_IRQ_START_LEVEL - 1); #elif defined(CONFIG_ARC_NORMAL_FIRMWARE) prio = prio < ARC_N_IRQ_START_LEVEL ? ARC_N_IRQ_START_LEVEL : prio; #endif z_arc_v2_irq_unit_prio_set(irq, prio); irq_unlock(key); } /* * @brief Spurious interrupt handler * * Installed in all dynamic interrupt slots at boot time. Throws an error if * called. * * @return N/A */ void z_irq_spurious(void *unused) { ARG_UNUSED(unused); z_fatal_error(K_ERR_SPURIOUS_IRQ, NULL); } #ifdef CONFIG_DYNAMIC_INTERRUPTS int z_arch_irq_connect_dynamic(unsigned int irq, unsigned int priority, void (*routine)(void *parameter), void *parameter, u32_t flags) { z_isr_install(irq, routine, parameter); z_irq_priority_set(irq, priority, flags); return irq; } #endif /* CONFIG_DYNAMIC_INTERRUPTS */ |