1.1 --- a/libipc/lib/src/util_ipc.c Tue Mar 07 19:10:40 2023 +0100
1.2 +++ b/libipc/lib/src/util_ipc.c Thu Mar 09 19:27:22 2023 +0100
1.3 @@ -61,7 +61,7 @@
1.4 /* Indicate the expectation of a capability in return. */
1.5
1.6 bregs->bdr = 0;
1.7 - bregs->br[item] = L4_RCV_ITEM_SINGLE_CAP | future;
1.8 + bregs->br[item] = L4_RCV_ITEM_SINGLE_CAP | future | L4_RCV_ITEM_LOCAL_ID;
1.9
1.10 return L4_EOK;
1.11 }
1.12 @@ -126,7 +126,8 @@
1.13 /* Import from the message the capability at the given item position. */
1.14
1.15 long _import_capability(l4_msgtag_t tag, l4_buf_regs_t *bregs,
1.16 - l4_msg_regs_t *mregs, int item, l4_cap_idx_t *ref)
1.17 + l4_msg_regs_t *mregs, int item, l4_cap_idx_t *ref,
1.18 + int *local)
1.19 {
1.20 l4_snd_fpage_t fpage;
1.21 long err = _import_fpage(tag, bregs, mregs, item, &fpage);
1.22 @@ -134,15 +135,30 @@
1.23 if (err)
1.24 return err;
1.25
1.26 - /* Check for a received capability. */
1.27 + /* Check for a received capability and update the supplied capability
1.28 + index. */
1.29 +
1.30 + /* Inter-task capability transfer. */
1.31 +
1.32 + if ((fpage.snd_base & 0x3e) == 0x38)
1.33 + {
1.34 + *ref = bregs->br[item] & L4_CAP_MASK;
1.35 + *local = 0;
1.36 + }
1.37
1.38 - if ((fpage.snd_base & 0x3e) != 0x38)
1.39 + /* Local capability transfer. */
1.40 +
1.41 + else if ((fpage.snd_base & 0x3e) == 0x3e)
1.42 + {
1.43 + *ref = l4_fpage_obj(fpage.fpage);
1.44 + *local = 1;
1.45 + }
1.46 +
1.47 + /* Unsupported item. */
1.48 +
1.49 + else
1.50 return -L4_EIO;
1.51
1.52 - /* Update the supplied capability index. */
1.53 -
1.54 - *ref = bregs->br[item] & L4_CAP_MASK;
1.55 -
1.56 return L4_EOK;
1.57 }
1.58
1.59 @@ -150,18 +166,19 @@
1.60
1.61 long _import_dataspace(l4_msgtag_t tag, l4_buf_regs_t *bregs,
1.62 l4_msg_regs_t *mregs, int item, l4re_ds_t *mem,
1.63 - l4_addr_t *addr)
1.64 + l4_addr_t *addr, int *local)
1.65 {
1.66 long err;
1.67 unsigned long size;
1.68
1.69 *mem = ipc_cap_alloc();
1.70
1.71 - err = _import_capability(tag, bregs, mregs, item, mem);
1.72 + err = _import_capability(tag, bregs, mregs, item, mem, local);
1.73
1.74 if (err)
1.75 {
1.76 - ipc_cap_free_um(*mem);
1.77 + if (!*local)
1.78 + ipc_cap_free_um(*mem);
1.79 return err;
1.80 }
1.81