1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (c) 2016-2019, Linaro Limited 4 */ 5 #ifndef __KERNEL_INTERRUPT_H 6 #define __KERNEL_INTERRUPT_H 7 8 #include <types_ext.h> 9 #include <sys/queue.h> 10 11 #define ITRF_TRIGGER_LEVEL (1 << 0) 12 13 struct itr_chip { 14 const struct itr_ops *ops; 15 }; 16 17 struct itr_ops { 18 void (*add)(struct itr_chip *chip, size_t it, uint32_t flags); 19 void (*enable)(struct itr_chip *chip, size_t it); 20 void (*disable)(struct itr_chip *chip, size_t it); 21 void (*raise_pi)(struct itr_chip *chip, size_t it); 22 void (*raise_sgi)(struct itr_chip *chip, size_t it, 23 uint8_t cpu_mask); 24 void (*set_affinity)(struct itr_chip *chip, size_t it, 25 uint8_t cpu_mask); 26 }; 27 28 enum itr_return { 29 ITRR_NONE, 30 ITRR_HANDLED, 31 }; 32 33 struct itr_handler { 34 size_t it; 35 uint32_t flags; 36 enum itr_return (*handler)(struct itr_handler *h); 37 void *data; 38 SLIST_ENTRY(itr_handler) link; 39 }; 40 41 void itr_init(struct itr_chip *data); 42 void itr_handle(size_t it); 43 44 void itr_add(struct itr_handler *handler); 45 void itr_enable(size_t it); 46 void itr_disable(size_t it); 47 /* raise the Peripheral Interrupt corresponding to the interrupt ID */ 48 void itr_raise_pi(size_t it); 49 /* 50 * raise the Software Generated Interrupt corresponding to the interrupt ID, 51 * the cpu_mask represents which cpu interface to forward. 52 */ 53 void itr_raise_sgi(size_t it, uint8_t cpu_mask); 54 /* 55 * let corresponding interrupt forward to the cpu interface 56 * according to the cpu_mask. 57 */ 58 void itr_set_affinity(size_t it, uint8_t cpu_mask); 59 60 /* 61 * __weak overridable function which is called when a secure interrupt is 62 * received. The default function calls panic() immediately, platforms which 63 * expects to receive secure interrupts should override this function. 64 */ 65 void itr_core_handler(void); 66 67 #endif /*__KERNEL_INTERRUPT_H*/ 68