1/* 2 * Copyright 2019, Data61 3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO) 4 * ABN 41 687 119 230. 5 * 6 * This software may be distributed and modified according to the terms of 7 * the BSD 2-Clause license. Note that NO WARRANTY is provided. 8 * See "LICENSE_BSD2.txt" for details. 9 * 10 * @TAG(DATA61_BSD) 11 */ 12 13#pragma once 14 15#include <platsupport/irq.h> 16#include <platsupport/io.h> 17#include <stdint.h> 18#include <stdbool.h> 19#include <sel4/sel4.h> 20#include <utils/attribute.h> 21 22/* 23 * This struct describes the interrupts that were allocated by CAmkES. 24 * 25 * Pointers to instances of this struct is intended to be located inside an ELF 26 * section. 27 */ 28struct allocated_irq { 29 seL4_CPtr irq_handler; 30 ps_irq_t irq; 31 bool is_allocated; 32 irq_callback_fn_t callback_fn; 33 void *callback_data; 34}; 35typedef struct allocated_irq allocated_irq_t; 36 37 38struct global_notification_irq_handler { 39 seL4_Word badge; 40 ps_irq_acknowledge_fn_t ack_fun; 41 allocated_irq_t *allocated_ref; 42}; 43typedef struct global_notification_irq_handler global_notification_irq_handler_t; 44 45/* 46 * NOTE: This implementation of the platsuport IRQ interface is not thread-safe. 47 */ 48 49/* 50 * Initialises the IRQ interface. The number of interrupts that can be 51 * registered is the number of interrupts allocated by CAmkES. 52 * 53 * @param irq_ops Interface to fill in 54 * @param malloc_ops Malloc interface that is used to allocate memory for the IRQ interface 55 * @param max_ntfn_ids Maximum number of notifications that can be provided 56 * 57 * @return 0 on success, otherwise an error code 58 */ 59int camkes_irq_ops(ps_irq_ops_t *irq_ops); 60 61 62/* Event handler function for processing notification received on global_endpoint connector 63 * notification object. 64 * 65 * @param badge Badge received from reading notification object. Badge is bitwise compared 66 * against badge values registered by global_notification_irq_handler_t entry. 67 * 68 * @return 0 on success, otherwise an error code 69 */ 70int camkes_handle_global_endpoint_irq(seL4_Word badge); 71