1 /* 2 * Interprocess communication abstractions. 3 * 4 * Copyright (C) 2018, 2019, 2021, 2023 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/sys/utcb.h> 23 24 #include "direct.h" 25 #include "util_ipc.h" 26 27 28 29 /* Direct operations. */ 30 31 /* Reserve the given number of slots from zero for incoming capabilities. */ 32 33 long ipc_expect_capabilities(int number) 34 { 35 return _expect_capabilities(l4_utcb_br(), number); 36 } 37 38 /* Reserve a slot for an incoming capability. */ 39 40 long ipc_expect_capability(int item) 41 { 42 return _expect_capability(l4_utcb_br(), item); 43 } 44 45 /* Export a capability at the given position in the message. */ 46 47 void ipc_export_capability(l4_msgtag_t tag, int item, l4_cap_idx_t ref) 48 { 49 _export_capability(tag, l4_utcb_mr(), item, ref); 50 } 51 52 /* Import the capability at the given item position, updating the buffer 53 registers for future capabilities. */ 54 55 long ipc_import_capability(l4_msgtag_t tag, int item, l4_cap_idx_t *ref) 56 { 57 int local; 58 long err = _import_capability(tag, l4_utcb_br(), l4_utcb_mr(), item, ref, &local); 59 60 if (err) 61 return err; 62 63 if (local) 64 return L4_EOK; 65 66 return ipc_expect_capability(item); 67 } 68 69 /* Import a dataspace, mapping it to an address, updating the buffer registers 70 for future capabilities. */ 71 72 long ipc_import_dataspace(l4_msgtag_t tag, int item, l4re_ds_t *mem, l4_addr_t *addr) 73 { 74 int local; 75 long err = _import_dataspace(tag, l4_utcb_br(), l4_utcb_mr(), item, mem, addr, &local); 76 77 if (err) 78 return err; 79 80 if (local) 81 return L4_EOK; 82 83 return ipc_expect_capability(item); 84 } 85 86 /* vim: tabstop=2 expandtab shiftwidth=2 87 */