1.1 --- a/examples/dataspace.idl Sun Apr 26 22:59:15 2020 +0200
1.2 +++ b/examples/dataspace.idl Sat Jul 04 23:24:20 2020 +0200
1.3 @@ -7,7 +7,9 @@
1.4 {
1.5 /* Map memory within a dataspace. */
1.6
1.7 - [opcode(0)] void map(in unsigned long offset, in l4_addr_t hot_spot,
1.8 + [opcode(0),
1.9 + completion,
1.10 + sync ] void map(in unsigned long offset, in l4_addr_t hot_spot,
1.11 in unsigned long flags, out fpage region);
1.12
1.13 /* Clear a dataspace. */
2.1 --- a/server.c Sun Apr 26 22:59:15 2020 +0200
2.2 +++ b/server.c Sat Jul 04 23:24:20 2020 +0200
2.3 @@ -1,7 +1,7 @@
2.4 /*
2.5 * Server code generation.
2.6 *
2.7 - * Copyright (C) 2019 Paul Boddie <paul@boddie.org.uk>
2.8 + * Copyright (C) 2019, 2020 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 @@ -88,13 +88,21 @@
2.13 {
2.14 char *opname = get_operation_name(iface, sig);
2.15
2.16 - /* Generate a signature featuring an initiator reference and only "out" and
2.17 - "inout" parameters. */
2.18 + /* Generate a signature featuring an initiator reference (for non-synchronous
2.19 + completions) and only "out" and "inout" parameters. */
2.20 +
2.21 + int synchronous = have_attribute(sig->attributes, "sync");
2.22
2.23 - fprintf(fp, server_completion_function_signature_prologue, opname, iface->name);
2.24 + char *prologue = synchronous ?
2.25 + server_completion_synchronous_function_signature_prologue :
2.26 + server_completion_function_signature_prologue;
2.27 +
2.28 + fprintf(fp, prologue, opname, iface->name);
2.29 +
2.30 + /* Continue from the initial endpoint parameter if not synchronous. */
2.31
2.32 write_parameters(sig->parameters, fp, SIGNATURE_ROLE, COMPLETION_ROLE,
2.33 - OUT_PARAMETER, 1);
2.34 + OUT_PARAMETER, !synchronous);
2.35
2.36 fputs(")", fp);
2.37 fputs(get_signature_terminator(role), fp);
2.38 @@ -250,10 +258,16 @@
2.39
2.40 write_output_initialisation(param, fp, opname, output_words, output_items, COMPLETION_ROLE);
2.41
2.42 - /* Send the response.
2.43 + /* Send a plain reply for synchronous completions. */
2.44 +
2.45 + if (have_attribute(sig->attributes, "sync"))
2.46 + fputs(server_completion_synchronous_function_body_epilogue, fp);
2.47 +
2.48 + /* Send a response as a new message to the given endpoint.
2.49 NOTE: The label 0 is employed but an error condition could be communicated. */
2.50
2.51 - fprintf(fp, server_completion_function_body_epilogue, "0", "_endp");
2.52 + else
2.53 + fprintf(fp, server_completion_function_body_epilogue, "0", "_endp");
2.54
2.55 /* Free allocated strings. */
2.56
3.1 --- a/templates.h Sun Apr 26 22:59:15 2020 +0200
3.2 +++ b/templates.h Sat Jul 04 23:24:20 2020 +0200
3.3 @@ -195,6 +195,9 @@
3.4 #define server_completion_function_signature_prologue \
3.5 "\nlong complete_%s(l4_cap_idx_t _endp"
3.6
3.7 +#define server_completion_synchronous_function_signature_prologue \
3.8 +"\nlong complete_%s("
3.9 +
3.10 #define server_completion_function_body_prologue \
3.11 " ipc_message_t msg;\n"
3.12
3.13 @@ -202,6 +205,10 @@
3.14 "\n ipc_message_send(&msg, %s, %s);\n\n" \
3.15 " return l4_error(msg.tag);\n"
3.16
3.17 +#define server_completion_synchronous_function_body_epilogue \
3.18 +"\n ipc_message_reply(&msg);\n\n" \
3.19 + " return l4_error(msg.tag);\n"
3.20 +
3.21 #define server_initiation_function_body_epilogue \
3.22 "\n ipc_message_prepare(msg);\n\n" \
3.23 " return L4_EOK;\n"