1 /* 2 * Interrupt request handling. 3 * 4 * Copyright (C) 2018, 2019, 2021 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA 20 */ 21 22 #include <l4/re/env.h> 23 #include <l4/sys/factory.h> 24 #include <l4/sys/irq.h> 25 #include <l4/sys/rcv_endpoint.h> 26 27 #include "cap_alloc.h" 28 #include "irq.h" 29 30 31 32 /* IRQ operations. */ 33 34 /* Create an interrupt request object. */ 35 36 long ipc_create_irq(l4_cap_idx_t *irq) 37 { 38 long err; 39 40 *irq = ipc_cap_alloc(); 41 42 if (l4_is_invalid_cap(*irq)) 43 return -L4_ENOENT; 44 45 err = l4_error(l4_factory_create_irq(l4re_env()->factory, *irq)); 46 47 if (err) 48 { 49 ipc_cap_free_um(*irq); 50 return err; 51 } 52 53 return L4_EOK; 54 } 55 56 /* Initialise an interrupt request object for subsequent notifications. */ 57 58 l4_msgtag_t ipc_init_irq(l4_cap_idx_t irq) 59 { 60 return l4_irq_unmask(irq); 61 } 62 63 /* Prepare a thread to receive IRQ object notifications. */ 64 65 long ipc_bind_irq(l4_cap_idx_t irq, l4_umword_t id, l4_cap_idx_t thread) 66 { 67 long err = l4_error(l4_rcv_ep_bind_thread(irq, thread, id)); 68 69 if (err) 70 return err; 71 72 return L4_EOK; 73 }