1.1 --- a/client.c Thu Mar 23 00:32:22 2023 +0100
1.2 +++ b/client.c Sun Jan 14 23:22:03 2024 +0100
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * Client code generation.
1.6 *
1.7 - * Copyright (C) 2019, 2020, 2021, 2022, 2023 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2019-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 @@ -89,13 +89,6 @@
1.13
1.14 fprintf(fp, "\n ipc_message_new(&msg);\n");
1.15
1.16 - /* Generate expected output item requirements. */
1.17 -
1.18 - if (output_items)
1.19 - fprintf(fp, " err = ipc_message_expect(&msg, %d);\n"
1.20 - " if (err)\n"
1.21 - " return err;\n", output_items);
1.22 -
1.23 /* Populate input parameters in the message. Dereference function parameters
1.24 acting as "inout" parameters. */
1.25
1.26 @@ -114,9 +107,9 @@
1.27 WORD_CLASS, fp);
1.28 }
1.29
1.30 - /* Do the same for items. */
1.31 + /* Do the same for items, also preparing to receive output items. */
1.32
1.33 - if (input_items)
1.34 + if (input_items | output_items)
1.35 {
1.36 fputs("\n", fp);
1.37 write_message_access(param, CLIENT_ROLE, GENERAL_FUNCTION_ROLE, IN_PARAMETER,
2.1 --- a/common.c Thu Mar 23 00:32:22 2023 +0100
2.2 +++ b/common.c Sun Jan 14 23:22:03 2024 +0100
2.3 @@ -1,7 +1,7 @@
2.4 /*
2.5 * Common routines.
2.6 *
2.7 - * Copyright (C) 2019, 2020, 2022 Paul Boddie <paul@boddie.org.uk>
2.8 + * Copyright (C) 2019, 2020, 2022, 2024 Paul Boddie <paul@boddie.org.uk>
2.9 *
2.10 * This program is free software; you can redistribute it and/or
2.11 * modify it under the terms of the GNU General Public License as
2.12 @@ -430,25 +430,24 @@
2.13 char *item_type_name(struct parameter *param, enum component_role component,
2.14 int writing)
2.15 {
2.16 - if (param->cls == FPAGE_ITEM)
2.17 - {
2.18 - /* Permit the specification of receive window flexpage items. */
2.19 + /* Permit the specification of receive window flexpage items or the
2.20 + expectation of a capability. */
2.21 +
2.22 + int receiving = specify_receive_item(param, component, writing);
2.23
2.24 - if (specify_receive_fpage(param, component, writing))
2.25 - return "receive_fpage";
2.26 - else
2.27 - return "fpage";
2.28 - }
2.29 + if (param->cls == FPAGE_ITEM)
2.30 + return receiving ? "receive_fpage" : "fpage";
2.31 else
2.32 - return "capability";
2.33 + return receiving ? "receive_capability" : "capability";
2.34 }
2.35
2.36 -/* Return whether the parameter involves a receive window flexpage. */
2.37 +/* Return whether the parameter involves a receive window flexpage or the
2.38 + expectation of a capability. */
2.39
2.40 -int specify_receive_fpage(struct parameter *param,
2.41 - enum component_role component, int writing)
2.42 +int specify_receive_item(struct parameter *param,
2.43 + enum component_role component, int writing)
2.44 {
2.45 - return (param->cls == FPAGE_ITEM) &&
2.46 + return (param->cls & ITEM_CLASS) &&
2.47 (component == CLIENT_ROLE) &&
2.48 !(param->specifier & IN_PARAMETER) &&
2.49 (param->specifier & OUT_PARAMETER) &&
3.1 --- a/common.h Thu Mar 23 00:32:22 2023 +0100
3.2 +++ b/common.h Sun Jan 14 23:22:03 2024 +0100
3.3 @@ -1,7 +1,7 @@
3.4 /*
3.5 * Common routines.
3.6 *
3.7 - * Copyright (C) 2019, 2020, 2022 Paul Boddie <paul@boddie.org.uk>
3.8 + * Copyright (C) 2019, 2020, 2022, 2024 Paul Boddie <paul@boddie.org.uk>
3.9 *
3.10 * This program is free software; you can redistribute it and/or
3.11 * modify it under the terms of the GNU General Public License as
3.12 @@ -91,7 +91,7 @@
3.13
3.14 char *access_name(struct parameter *param, enum component_role component, int writing);
3.15 char *item_type_name(struct parameter *param, enum component_role component, int writing);
3.16 -int specify_receive_fpage(struct parameter *param, enum component_role component, int writing);
3.17 +int specify_receive_item(struct parameter *param, enum component_role component, int writing);
3.18 char *reference_message(enum component_role component, enum function_role function);
3.19 char *structure_prefix(enum specifier direction);
3.20 int writing_to_message(enum component_role component, enum specifier direction);
4.1 --- a/message.c Thu Mar 23 00:32:22 2023 +0100
4.2 +++ b/message.c Sun Jan 14 23:22:03 2024 +0100
4.3 @@ -1,7 +1,7 @@
4.4 /*
4.5 * Generation of message structure access operations.
4.6 *
4.7 - * Copyright (C) 2019, 2022 Paul Boddie <paul@boddie.org.uk>
4.8 + * Copyright (C) 2019, 2022, 2024 Paul Boddie <paul@boddie.org.uk>
4.9 *
4.10 * This program is free software; you can redistribute it and/or
4.11 * modify it under the terms of the GNU General Public License as
4.12 @@ -79,12 +79,13 @@
4.13
4.14 for (index = 0; param != NULL; param = param->tail)
4.15 {
4.16 - /* Permit the specification of receive window flexpage input items for
4.17 - "out fpage" parameters. */
4.18 + /* Permit the specification of receive window flexpage and returned
4.19 + capability items for "out fpage" and "out cap" parameters, even when
4.20 + processing inputs to an operation. */
4.21
4.22 if ((param->cls & cls) &&
4.23 ((param->specifier & direction) ||
4.24 - specify_receive_fpage(param, component, writing)))
4.25 + specify_receive_item(param, component, writing)))
4.26 {
4.27 name = get_parameter_name(param->identifiers);
4.28 access = access_name(param, component, writing);
4.29 @@ -109,8 +110,17 @@
4.30 fprintf(fp, " ipc_message_add_%s(%smsg, %s%s);\n",
4.31 suffix, addr, access, name);
4.32 else
4.33 - fprintf(fp, " ipc_message_import_%s(%smsg, %d, %s%s);\n",
4.34 - suffix, addr, index, access, name);
4.35 + {
4.36 + /* For servers, update the buffer registers for future capabilities,
4.37 + allocating new capability slots. */
4.38 +
4.39 + if (component == SERVER_ROLE)
4.40 + fprintf(fp, " ipc_message_import_and_expect_%s(%smsg, %d, %s%s);\n",
4.41 + suffix, addr, index, access, name);
4.42 + else
4.43 + fprintf(fp, " ipc_message_import_%s(%smsg, %d, %s%s);\n",
4.44 + suffix, addr, index, access, name);
4.45 + }
4.46 index++;
4.47 break;
4.48