1.1 --- a/common.c Tue Sep 13 00:53:05 2022 +0200
1.2 +++ b/common.c Thu Sep 15 18:09:21 2022 +0200
1.3 @@ -112,6 +112,13 @@
1.4 return get_attribute_value(attr, "opcode");
1.5 }
1.6
1.7 +/* Return any opcode type attribute value. */
1.8 +
1.9 +char *get_opcode_type(struct attribute *attr)
1.10 +{
1.11 + return get_attribute_value(attr, "opcode_type");
1.12 +}
1.13 +
1.14 /* Return any protocol attribute value. */
1.15
1.16 char *get_protocol(struct attribute *attr)
2.1 --- a/common.h Tue Sep 13 00:53:05 2022 +0200
2.2 +++ b/common.h Thu Sep 15 18:09:21 2022 +0200
2.3 @@ -41,6 +41,7 @@
2.4
2.5 char *get_attribute_value(struct attribute *attr, const char *name);
2.6 char *get_opcode(struct attribute *attr);
2.7 +char *get_opcode_type(struct attribute *attr);
2.8 char *get_protocol(struct attribute *attr);
2.9 char *get_operation_wrapper_prefix(struct attribute *attr);
2.10 int have_attribute(struct attribute *attr, const char *name);
3.1 --- a/docs/idl.1 Tue Sep 13 00:53:05 2022 +0200
3.2 +++ b/docs/idl.1 Thu Sep 15 18:09:21 2022 +0200
3.3 @@ -1,4 +1,4 @@
3.4 -.TH IDL "1" "2020-04-20" "idl 0.1" "User Commands"
3.5 +.TH IDL "1" "2022-09-15" "idl 0.1" "User Commands"
3.6
3.7 .SH NAME
3.8 idl \- L4Re IDL parser and code generator
3.9 @@ -246,6 +246,9 @@
3.10 \fIopcode_value\fR as the message tag label when sending requests to the
3.11 interface. With a protocol, the \fIopcode_value\fR will be specified in the
3.12 first message word.
3.13 +.TP
3.14 +\fBopcode_type(\fIopcode_type_value\fB)\fR
3.15 +An explicit type for the opcode applying to the given operation.
3.16
3.17 .SH COMPLETION OPERATIONS
3.18 Operations can be annotated with the \fBcompletion\fR attribute, indicating
3.19 @@ -413,7 +416,7 @@
3.20 The project Web site: http://projects.boddie.org.uk/idl4re
3.21
3.22 .SH COPYRIGHT
3.23 -Copyright \(co 2019, 2020 Paul Boddie <paul@boddie.org.uk>
3.24 +Copyright \(co 2019, 2020, 2022 Paul Boddie <paul@boddie.org.uk>
3.25 .PP
3.26 This program is free software; you may redistribute it under the terms of
3.27 the GNU General Public License version 2 or (at your option) a later version.
4.1 --- a/structure.c Tue Sep 13 00:53:05 2022 +0200
4.2 +++ b/structure.c Thu Sep 15 18:09:21 2022 +0200
4.3 @@ -73,7 +73,8 @@
4.4 {
4.5 struct parameter *param = sig->parameters;
4.6 char *opname = get_operation_name(iface, sig),
4.7 - *protocol = get_protocol(iface->attributes);
4.8 + *protocol = get_protocol(iface->attributes),
4.9 + *opcode_type;
4.10 int input_words, input_items, output_words, output_items;
4.11
4.12 count_parameters(param, &input_words, &input_items, &output_words, &output_items);
4.13 @@ -90,8 +91,17 @@
4.14 fprintf(fp, structure_prologue, "in", opname);
4.15 if (protocol != NULL)
4.16 {
4.17 - fprintf(fp, structure_opcode_member, L4_OPCODE_TYPE);
4.18 - fprintf(fp, structure_opcode_padding_member, L4_OPCODE_PADDING_TYPE);
4.19 + opcode_type = get_opcode_type(sig->attributes);
4.20 +
4.21 + if (opcode_type != NULL)
4.22 + fprintf(fp, structure_opcode_member, opcode_type);
4.23 + else
4.24 + fprintf(fp, structure_opcode_member, L4_OPCODE_TYPE);
4.25 +
4.26 + /* Introduce opcode padding unless the opcode type is overridden. */
4.27 +
4.28 + if (opcode_type == NULL)
4.29 + fprintf(fp, structure_opcode_padding_member, L4_OPCODE_PADDING_TYPE);
4.30 }
4.31 write_declarations(param, IN_PARAMETER, WORD_CLASS, fp);
4.32 fputs(structure_epilogue, fp);