1.1 --- a/libipc/include/ipc/message.h Sun Jan 14 00:45:39 2024 +0100
1.2 +++ b/libipc/include/ipc/message.h Sun Jan 14 23:17:58 2024 +0100
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * Interprocess communication message abstraction.
1.6 *
1.7 - * Copyright (C) 2018, 2019, 2021, 2022 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2018, 2019, 2021, 2022, 2024 Paul Boddie <paul@boddie.org.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or
1.11 * modify it under the terms of the GNU General Public License as
1.12 @@ -113,6 +113,7 @@
1.13 void ipc_message_add_item(ipc_message_t *msg, l4_cap_idx_t cap);
1.14 void ipc_message_add_fpage(ipc_message_t *msg, l4_snd_fpage_t fpage);
1.15 void ipc_message_add_page(ipc_message_t *msg, l4_umword_t hot_spot, l4_fpage_t fpage);
1.16 +void ipc_message_add_receive_capability(ipc_message_t *msg, l4_cap_idx_t /* cap */);
1.17 void ipc_message_add_receive_fpage(ipc_message_t *msg, l4_snd_fpage_t fpage);
1.18 void ipc_message_add_string(ipc_message_t *msg, const char *value);
1.19 void ipc_message_add_word(ipc_message_t *msg, l4_umword_t value);
1.20 @@ -137,6 +138,8 @@
1.21 void ipc_message_export_capability(ipc_message_t *msg, int item, l4_cap_idx_t ref);
1.22 void ipc_message_export_fpage(ipc_message_t *msg, int item, l4_snd_fpage_t fpage);
1.23 void ipc_message_export_page(ipc_message_t *msg, int item, l4_umword_t hot_spot, l4_fpage_t fpage);
1.24 +long ipc_message_import_and_expect_capability(ipc_message_t *msg, int item, l4_cap_idx_t *ref);
1.25 +long ipc_message_import_and_expect_dataspace(ipc_message_t *msg, int item, l4re_ds_t *mem, l4_addr_t *addr);
1.26 long ipc_message_import_capability(ipc_message_t *msg, int item, l4_cap_idx_t *ref);
1.27 long ipc_message_import_dataspace(ipc_message_t *msg, int item, l4re_ds_t *mem, l4_addr_t *addr);
1.28 long ipc_message_import_fpage(ipc_message_t *msg, int item, l4_snd_fpage_t *fpage);
2.1 --- a/libipc/lib/src/message.c Sun Jan 14 00:45:39 2024 +0100
2.2 +++ b/libipc/lib/src/message.c Sun Jan 14 23:17:58 2024 +0100
2.3 @@ -50,7 +50,9 @@
2.4 ipc_cap_free_um(msg->to_discard[i]);
2.5 }
2.6
2.7 -/* Initialise a message structure with the given number of expected items. */
2.8 +/* Initialise a message structure with the given number of expected items. This
2.9 + function is primarily for the use of servers needing to reserve items that
2.10 + might be sent in messages from clients. */
2.11
2.12 long ipc_message_expect(ipc_message_t *msg, unsigned int expected_items)
2.13 {
2.14 @@ -271,6 +273,15 @@
2.15 ipc_message_export_fpage(msg, msg->items++, fpage);
2.16 }
2.17
2.18 +/* Add the expectation of a capability. Note that a capability is accepted as a
2.19 + parameter but ignored, this being for the convenience of code generation. */
2.20 +
2.21 +void ipc_message_add_receive_capability(ipc_message_t *msg, l4_cap_idx_t cap)
2.22 +{
2.23 + (void) cap;
2.24 + return _expect_capability(&msg->bregs, msg->receive_items++);
2.25 +}
2.26 +
2.27 /* Add a receive window flexpage item to the message. */
2.28
2.29 void ipc_message_add_receive_fpage(ipc_message_t *msg, l4_snd_fpage_t fpage)
2.30 @@ -486,7 +497,7 @@
2.31 /* Import from the message the capability at the given item position, updating
2.32 the buffer registers for future capabilities. */
2.33
2.34 -long ipc_message_import_capability(ipc_message_t *msg, int item, l4_cap_idx_t *ref)
2.35 +long ipc_message_import_and_expect_capability(ipc_message_t *msg, int item, l4_cap_idx_t *ref)
2.36 {
2.37 long err;
2.38 int local;
2.39 @@ -504,7 +515,7 @@
2.40 /* Import from the message a dataspace, mapping it to an address, updating the
2.41 buffer registers for future capabilities. */
2.42
2.43 -long ipc_message_import_dataspace(ipc_message_t *msg, int item, l4re_ds_t *mem, l4_addr_t *addr)
2.44 +long ipc_message_import_and_expect_dataspace(ipc_message_t *msg, int item, l4re_ds_t *mem, l4_addr_t *addr)
2.45 {
2.46 long err;
2.47 int local;
2.48 @@ -519,6 +530,24 @@
2.49 return ipc_message_expect_capability(msg, item);
2.50 }
2.51
2.52 +/* Import from the message the capability at the given item position. */
2.53 +
2.54 +long ipc_message_import_capability(ipc_message_t *msg, int item, l4_cap_idx_t *ref)
2.55 +{
2.56 + int local;
2.57 +
2.58 + return _import_capability(msg->tag, &msg->bregs, &msg->mregs, item, ref, &local);
2.59 +}
2.60 +
2.61 +/* Import from the message a dataspace, mapping it to an address. */
2.62 +
2.63 +long ipc_message_import_dataspace(ipc_message_t *msg, int item, l4re_ds_t *mem, l4_addr_t *addr)
2.64 +{
2.65 + int local;
2.66 +
2.67 + return _import_dataspace(msg->tag, &msg->bregs, &msg->mregs, item, mem, addr, &local);
2.68 +}
2.69 +
2.70 /* Import from the message the flexpage at the given item position. */
2.71
2.72 long ipc_message_import_fpage(ipc_message_t *msg, int item, l4_snd_fpage_t *fpage)