L4Re/departure

Change of libipc/include/ipc/message.h

181:49d8e9637cdb
libipc/include/ipc/message.h
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libipc/include/ipc/message.h	Wed Aug 25 01:28:08 2021 +0200
     1.3 @@ -0,0 +1,142 @@
     1.4 +/*
     1.5 + * Interprocess communication message abstraction.
     1.6 + *
     1.7 + * Copyright (C) 2018, 2019, 2021 Paul Boddie <paul@boddie.org.uk>
     1.8 + *
     1.9 + * This program is free software; you can redistribute it and/or
    1.10 + * modify it under the terms of the GNU General Public License as
    1.11 + * published by the Free Software Foundation; either version 2 of
    1.12 + * the License, or (at your option) any later version.
    1.13 + *
    1.14 + * This program is distributed in the hope that it will be useful,
    1.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.17 + * GNU General Public License for more details.
    1.18 + *
    1.19 + * You should have received a copy of the GNU General Public License
    1.20 + * along with this program; if not, write to the Free Software
    1.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
    1.22 + * Boston, MA  02110-1301, USA
    1.23 + */
    1.24 +
    1.25 +#pragma once
    1.26 +
    1.27 +#include <l4/re/c/dataspace.h>
    1.28 +#include <l4/sys/ipc.h>
    1.29 +#include <l4/sys/utcb.h>
    1.30 +#include <l4/sys/types.h>
    1.31 +
    1.32 +#include <sys/types.h>
    1.33 +
    1.34 +
    1.35 +
    1.36 +EXTERN_C_BEGIN
    1.37 +
    1.38 +/* Message abstraction. */
    1.39 +
    1.40 +typedef struct
    1.41 +{
    1.42 +  /* Common virtual registers. */
    1.43 +
    1.44 +  l4_buf_regs_t bregs;
    1.45 +  l4_msg_regs_t mregs;
    1.46 +
    1.47 +  /* Input details. */
    1.48 +
    1.49 +  l4_msgtag_t tag;
    1.50 +  unsigned int expected_items;
    1.51 +
    1.52 +  /* Output details. */
    1.53 +
    1.54 +  unsigned int words;
    1.55 +  unsigned int items;
    1.56 +
    1.57 +  /* Items transferred and not retained. */
    1.58 +
    1.59 +  unsigned int discarded_items;
    1.60 +  l4_cap_idx_t to_discard[L4_UTCB_GENERIC_DATA_SIZE];
    1.61 +
    1.62 +  /* Message label overriding. */
    1.63 +
    1.64 +  l4_umword_t new_label;
    1.65 +
    1.66 +  /* Server control. */
    1.67 +
    1.68 +  int terminating;
    1.69 +
    1.70 +} ipc_message_t;
    1.71 +
    1.72 +
    1.73 +
    1.74 +/* Special status codes. */
    1.75 +
    1.76 +#define IPC_MESSAGE_SENT      0x01d10000
    1.77 +
    1.78 +/* Capability annotations. */
    1.79 +
    1.80 +#define IPC_DISCARD_CAP_FLAG  (1 << (L4_CAP_SHIFT - 2))
    1.81 +#define discard_cap(x)        (x | IPC_DISCARD_CAP_FLAG)
    1.82 +
    1.83 +
    1.84 +
    1.85 +/* Message operations. */
    1.86 +
    1.87 +/* Lifecycle operations. */
    1.88 +
    1.89 +void ipc_message_new(ipc_message_t *msg);
    1.90 +long ipc_message_expect(ipc_message_t *msg, unsigned int expected_items);
    1.91 +void ipc_message_request(ipc_message_t *msg, int op, l4_cap_idx_t endpoint);
    1.92 +void ipc_message_send(ipc_message_t *msg, int op, l4_cap_idx_t endpoint);
    1.93 +void ipc_message_wait(ipc_message_t *msg, l4_umword_t *label);
    1.94 +void ipc_message_reply(ipc_message_t *msg);
    1.95 +void ipc_message_discard(ipc_message_t *msg);
    1.96 +void ipc_message_free(ipc_message_t *msg);
    1.97 +
    1.98 +/* Helper operations. */
    1.99 +
   1.100 +void ipc_message_open(ipc_message_t *msg);
   1.101 +void ipc_message_prepare(ipc_message_t *msg);
   1.102 +void ipc_message_preserve_buffer_registers(ipc_message_t *msg);
   1.103 +void ipc_message_preserve_message_registers(ipc_message_t *msg);
   1.104 +void ipc_message_reset(ipc_message_t *msg);
   1.105 +void ipc_message_restore_buffer_registers(ipc_message_t *msg);
   1.106 +void ipc_message_restore_message_registers(ipc_message_t *msg);
   1.107 +
   1.108 +/* Population operations. */
   1.109 +
   1.110 +void ipc_message_add_capability(ipc_message_t *msg, l4_cap_idx_t cap);
   1.111 +void ipc_message_add_data(ipc_message_t *msg, const char *value, size_t length);
   1.112 +void ipc_message_add_item(ipc_message_t *msg, l4_cap_idx_t cap);
   1.113 +void ipc_message_add_fpage(ipc_message_t *msg, l4_snd_fpage_t fpage);
   1.114 +void ipc_message_add_page(ipc_message_t *msg, l4_umword_t hot_spot, l4_fpage_t fpage);
   1.115 +void ipc_message_add_string(ipc_message_t *msg, const char *value);
   1.116 +void ipc_message_add_word(ipc_message_t *msg, l4_umword_t value);
   1.117 +void ipc_message_propagate_item(ipc_message_t *msg, l4_cap_idx_t cap);
   1.118 +void *ipc_message_reserve_data(ipc_message_t *msg, size_t length);
   1.119 +void *ipc_message_reserve_words(ipc_message_t *msg, size_t length);
   1.120 +void ipc_message_send_error(ipc_message_t *msg, long error);
   1.121 +
   1.122 +/* Access operations. */
   1.123 +
   1.124 +l4_umword_t ipc_message_get_word(ipc_message_t *msg, unsigned int word);
   1.125 +l4_umword_t *ipc_message_get_word_address(ipc_message_t *msg, unsigned int word);
   1.126 +unsigned int ipc_message_number_of_items(ipc_message_t *msg);
   1.127 +unsigned int ipc_message_number_of_words(ipc_message_t *msg);
   1.128 +
   1.129 +/* Supporting operations. */
   1.130 +
   1.131 +void ipc_message_discard_capability(ipc_message_t *msg, l4_cap_idx_t cap);
   1.132 +void ipc_message_discard_dataspace(ipc_message_t *msg, l4re_ds_t mem, l4_addr_t addr);
   1.133 +long ipc_message_expect_capabilities(ipc_message_t *msg, int number);
   1.134 +long ipc_message_expect_capability(ipc_message_t *msg, int item);
   1.135 +void ipc_message_export_capability(ipc_message_t *msg, int item, l4_cap_idx_t ref);
   1.136 +void ipc_message_export_fpage(ipc_message_t *msg, int item, l4_snd_fpage_t fpage);
   1.137 +void ipc_message_export_page(ipc_message_t *msg, int item, l4_umword_t hot_spot, l4_fpage_t fpage);
   1.138 +long ipc_message_import_capability(ipc_message_t *msg, int item, l4_cap_idx_t *ref);
   1.139 +long ipc_message_import_dataspace(ipc_message_t *msg, int item, l4re_ds_t *mem, l4_addr_t *addr);
   1.140 +long ipc_message_import_fpage(ipc_message_t *msg, int item, l4_snd_fpage_t *fpage);
   1.141 +void ipc_message_propagate_capability(ipc_message_t *msg, int item, l4_cap_idx_t ref);
   1.142 +l4_msgtag_t ipc_message_reply_tag(ipc_message_t *msg);
   1.143 +l4_msgtag_t ipc_message_request_tag(ipc_message_t *msg, int op);
   1.144 +
   1.145 +EXTERN_C_END