1.1 --- a/common.c Fri Nov 01 17:20:36 2019 +0100
1.2 +++ b/common.c Fri Nov 01 19:07:32 2019 +0100
1.3 @@ -145,8 +145,7 @@
1.4 and items. */
1.5
1.6 void count_parameters(struct parameter *param, int *input_words,
1.7 - int *input_items, int *output_words,
1.8 - int *output_items)
1.9 + int *input_items, int *output_words, int *output_items)
1.10 {
1.11 for (*input_words = 0, *input_items = 0, *output_words = 0, *output_items = 0;
1.12 param != NULL;
1.13 @@ -154,12 +153,12 @@
1.14 {
1.15 if (param->specifier & IN_PARAMETER)
1.16 {
1.17 - if (param->item) (*input_items)++;
1.18 + if (param->cls & ITEM_CLASS) (*input_items)++;
1.19 else (*input_words)++;
1.20 }
1.21 else
1.22 {
1.23 - if (param->item) (*output_items)++;
1.24 + if (param->cls & ITEM_CLASS) (*output_items)++;
1.25 else (*output_words)++;
1.26 }
1.27 }
2.1 --- a/idl.y Fri Nov 01 17:20:36 2019 +0100
2.2 +++ b/idl.y Fri Nov 01 19:07:32 2019 +0100
2.3 @@ -190,9 +190,9 @@
2.4 ;
2.5
2.6 parameter : specifier item identifiers
2.7 - { $$.specifier = $1; $$.item = $2; $$.identifiers = copy_identifier($3); }
2.8 + { $$.specifier = $1; $$.cls = $2; $$.identifiers = copy_identifier($3); }
2.9 | specifier identifiers
2.10 - { $$.specifier = $1; $$.item = 0; $$.identifiers = copy_identifier($2); }
2.11 + { $$.specifier = $1; $$.cls = WORD_CLASS; $$.identifiers = copy_identifier($2); }
2.12 ;
2.13
2.14 specifier : IN | INOUT | OUT ;
3.1 --- a/program.c Fri Nov 01 17:20:36 2019 +0100
3.2 +++ b/program.c Fri Nov 01 19:07:32 2019 +0100
3.3 @@ -150,7 +150,7 @@
3.4
3.5 for (; param != NULL; param = param->tail)
3.6 {
3.7 - if ((param->specifier & direction) && !param->item)
3.8 + if ((param->specifier & direction) && (param->cls & WORD_CLASS))
3.9 {
3.10 name = get_parameter_name(param->identifiers);
3.11
3.12 @@ -177,10 +177,10 @@
3.13
3.14 for (index = 0; param != NULL; param = param->tail)
3.15 {
3.16 - if ((param->specifier & direction) && param->item)
3.17 + if ((param->specifier & direction) && (param->cls & ITEM_CLASS))
3.18 {
3.19 name = get_parameter_name(param->identifiers);
3.20 - type = param->item == FPAGE_ITEM ? "page" : "capability";
3.21 + type = param->cls == FPAGE_ITEM ? "page" : "capability";
3.22
3.23 fprintf(fp, " ipc_message_import_%s(%smsg, %d, %s);\n",
3.24 type, addr, index, name);
3.25 @@ -199,7 +199,7 @@
3.26
3.27 for (; param != NULL; param = param->tail)
3.28 {
3.29 - if ((param->specifier & direction) && !param->item)
3.30 + if ((param->specifier & direction) && (param->cls & WORD_CLASS))
3.31 {
3.32 name = get_parameter_name(param->identifiers);
3.33 deref = dereference_name(param, direction);
3.34 @@ -226,10 +226,10 @@
3.35
3.36 for (; param != NULL; param = param->tail)
3.37 {
3.38 - if ((param->specifier & direction) && param->item)
3.39 + if ((param->specifier & direction) && (param->cls & ITEM_CLASS))
3.40 {
3.41 name = get_parameter_name(param->identifiers);
3.42 - type = param->item == FPAGE_ITEM ? "page" : "item";
3.43 + type = param->cls == FPAGE_ITEM ? "page" : "item";
3.44 deref = dereference_name(param, direction);
3.45
3.46 fprintf(fp, " ipc_message_add_%s(%smsg, %s%s);\n",
3.47 @@ -857,7 +857,7 @@
3.48
3.49 /* Generate variable declarations. */
3.50
3.51 - write_variables(param, fp);
3.52 + write_declarations(param, ANY_PARAMETER, ANY_CLASS, fp);
3.53
3.54 /* Generate types parameterised with the qualified operation name. */
3.55
3.56 @@ -953,14 +953,14 @@
3.57 if (input_words)
3.58 {
3.59 fprintf(fp, "\nstruct in_words_%s\n{\n", opname);
3.60 - write_structure_members(param, IN_PARAMETER, fp);
3.61 + write_declarations(param, IN_PARAMETER, WORD_CLASS, fp);
3.62 fprintf(fp, "};\n");
3.63 }
3.64
3.65 if (output_words)
3.66 {
3.67 fprintf(fp, "\nstruct out_words_%s\n{\n", opname);
3.68 - write_structure_members(param, OUT_PARAMETER, fp);
3.69 + write_declarations(param, OUT_PARAMETER, WORD_CLASS, fp);
3.70 fprintf(fp, "};\n");
3.71 }
3.72
3.73 @@ -1004,9 +1004,9 @@
3.74 {
3.75 /* Items must have their type identifiers restored. */
3.76
3.77 - if (param->item)
3.78 + if (param->cls & ITEM_CLASS)
3.79 {
3.80 - type = param->item == FPAGE_ITEM ? L4_FPAGE_TYPE : L4_CAP_TYPE;
3.81 + type = param->cls == FPAGE_ITEM ? L4_FPAGE_TYPE : L4_CAP_TYPE;
3.82 fprintf(fp, " %s", type);
3.83 }
3.84
3.85 @@ -1018,26 +1018,15 @@
3.86 }
3.87 }
3.88
3.89 -/* Generate variable declarations for parameters. */
3.90 +/* Write structure members for word data structures or variable declarations for
3.91 + parameters. */
3.92
3.93 -void write_variables(struct parameter *param, FILE *fp)
3.94 +void write_declarations(struct parameter *param, enum specifier direction,
3.95 + enum parameter_class cls, FILE *fp)
3.96 {
3.97 for (; param != NULL; param = param->tail)
3.98 {
3.99 - fputs(" ", fp);
3.100 - write_parameter(param, fp, STRUCTURE_ROLE);
3.101 - fputs(";\n", fp);
3.102 - }
3.103 -}
3.104 -
3.105 -/* Write structure members for word data. */
3.106 -
3.107 -void write_structure_members(struct parameter *param,
3.108 - enum specifier direction, FILE *fp)
3.109 -{
3.110 - for (; param != NULL; param = param->tail)
3.111 - {
3.112 - if ((param->specifier & direction) && !param->item)
3.113 + if ((param->specifier & direction) && (param->cls & cls))
3.114 {
3.115 fputs(" ", fp);
3.116 write_parameter(param, fp, STRUCTURE_ROLE);
4.1 --- a/program.h Fri Nov 01 17:20:36 2019 +0100
4.2 +++ b/program.h Fri Nov 01 19:07:32 2019 +0100
4.3 @@ -27,6 +27,8 @@
4.4 #define L4_CAP_TYPE "l4_cap_idx_t"
4.5 #define L4_FPAGE_TYPE "l4_fpage_t"
4.6
4.7 +/* Output role of a parameter. */
4.8 +
4.9 enum parameter_role
4.10 {
4.11 SIGNATURE_ROLE,
4.12 @@ -89,18 +91,16 @@
4.13 void write_structures(struct signature *sig, FILE *fp, struct interface *iface);
4.14 void write_structure(struct signature *sig, FILE *fp, struct interface *iface);
4.15
4.16 -void write_structure_members(struct parameter *param,
4.17 - enum specifier direction, FILE *fp);
4.18 +/* Parameter lists. */
4.19 +
4.20 +void write_parameters(struct parameter *param, FILE *fp, enum parameter_role role);
4.21 +void write_parameter(struct parameter *param, FILE *fp, enum parameter_role role);
4.22
4.23 /* Operation codes. */
4.24
4.25 void write_opcodes(struct signature *sig, FILE *fp, const char *name);
4.26
4.27 -/* Parameter lists. */
4.28 +/* Structure members and variable lists. */
4.29
4.30 -void write_parameters(struct parameter *param, FILE *fp, enum parameter_role role);
4.31 -void write_parameter(struct parameter *param, FILE *fp, enum parameter_role role);
4.32 -
4.33 -/* Variable lists for parameters. */
4.34 -
4.35 -void write_variables(struct parameter *param, FILE *fp);
4.36 +void write_declarations(struct parameter *param, enum specifier direction,
4.37 + enum parameter_class cls, FILE *fp);
5.1 --- a/summary.c Fri Nov 01 17:20:36 2019 +0100
5.2 +++ b/summary.c Fri Nov 01 19:07:32 2019 +0100
5.3 @@ -85,9 +85,9 @@
5.4
5.5 /* Items must have their type identifiers restored. */
5.6
5.7 - if (param->item)
5.8 + if (param->cls & ITEM_CLASS)
5.9 {
5.10 - type = param->item == FPAGE_ITEM ? "fpage" : "cap";
5.11 + type = param->cls == FPAGE_ITEM ? "fpage" : "cap";
5.12 printf(" %s", type);
5.13 }
5.14
6.1 --- a/types.h Fri Nov 01 17:20:36 2019 +0100
6.2 +++ b/types.h Fri Nov 01 19:07:32 2019 +0100
6.3 @@ -28,14 +28,18 @@
6.4 IN_PARAMETER = 1,
6.5 OUT_PARAMETER = 2,
6.6 INOUT_PARAMETER = 3,
6.7 + ANY_PARAMETER = 3,
6.8 };
6.9
6.10 -/* Item values. */
6.11 +/* Data class of a parameter. */
6.12
6.13 -enum item
6.14 +enum parameter_class
6.15 {
6.16 - CAP_ITEM = 1,
6.17 - FPAGE_ITEM = 2,
6.18 + WORD_CLASS = 1,
6.19 + CAP_ITEM = 2,
6.20 + FPAGE_ITEM = 4,
6.21 + ITEM_CLASS = 6, /* all item values combined */
6.22 + ANY_CLASS = 7, /* WORD_CLASS | ITEM_CLASS */
6.23 };
6.24
6.25 /* Include declarations. */
6.26 @@ -58,8 +62,8 @@
6.27
6.28 struct parameter
6.29 {
6.30 - int specifier;
6.31 - int item;
6.32 + enum specifier specifier;
6.33 + enum parameter_class cls;
6.34 struct identifier *identifiers;
6.35 struct parameter *tail;
6.36 };