psa_sim_serialise.pl now creates the updated .h file
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
diff --git a/tests/psa-client-server/psasim/src/psa_sim_serialise.h b/tests/psa-client-server/psasim/src/psa_sim_serialise.h
index 7a5881e..4ec7ec0 100644
--- a/tests/psa-client-server/psasim/src/psa_sim_serialise.h
+++ b/tests/psa-client-server/psasim/src/psa_sim_serialise.h
@@ -409,12 +409,44 @@
size_t *remaining,
psa_hash_operation_t *value);
-size_t psasim_server_serialise_psa_hash_operation_t_needs(psa_hash_operation_t *operation);
+/** Return how much buffer space is needed by \c psasim_server_serialise_psa_hash_operation_t()
+ * to serialise a `psa_hash_operation_t`.
+ *
+ * \param value The value that will be serialised into the buffer
+ * (needed in case some serialisations are value-
+ * dependent).
+ *
+ * \return The number of bytes needed in the buffer by
+ * \c psasim_serialise_psa_hash_operation_t() to serialise
+ * the given value.
+ */
+size_t psasim_server_serialise_psa_hash_operation_t_needs(psa_hash_operation_t *value);
+/** Serialise a `psa_hash_operation_t` into a buffer on the server side.
+ *
+ * \param pos[in,out] Pointer to a `uint8_t *` holding current position
+ * in the buffer.
+ * \param remaining[in,out] Pointer to a `size_t` holding number of bytes
+ * remaining in the buffer.
+ * \param value The value to serialise into the buffer.
+ *
+ * \return \c 1 on success ("okay"), \c 0 on error.
+ */
int psasim_server_serialise_psa_hash_operation_t(uint8_t **pos,
size_t *remaining,
- psa_hash_operation_t *operation);
+ psa_hash_operation_t *value);
+/** Deserialise a `psa_hash_operation_t` from a buffer on the server side.
+ *
+ * \param pos[in,out] Pointer to a `uint8_t *` holding current position
+ * in the buffer.
+ * \param remaining[in,out] Pointer to a `size_t` holding number of bytes
+ * remaining in the buffer.
+ * \param value Pointer to a `psa_hash_operation_t` to receive the value
+ * deserialised from the buffer.
+ *
+ * \return \c 1 on success ("okay"), \c 0 on error.
+ */
int psasim_server_deserialise_psa_hash_operation_t(uint8_t **pos,
size_t *remaining,
- psa_hash_operation_t **operation);
+ psa_hash_operation_t **value);
diff --git a/tests/psa-client-server/psasim/src/psa_sim_serialise.pl b/tests/psa-client-server/psasim/src/psa_sim_serialise.pl
index 5161db1..21bfec5 100755
--- a/tests/psa-client-server/psasim/src/psa_sim_serialise.pl
+++ b/tests/psa-client-server/psasim/src/psa_sim_serialise.pl
@@ -55,9 +55,15 @@
if ($type eq "buffer") {
print declare_buffer_functions();
} else {
- print declare_needs($type);
- print declare_serialise($type);
- print declare_deserialise($type);
+ print declare_needs($type, "");
+ print declare_serialise($type, "");
+ print declare_deserialise($type, "");
+
+ if ($type =~ /^psa_\w+_operation_t$/) {
+ print declare_needs($type, "server_");
+ print declare_serialise($type, "server_");
+ print declare_deserialise($type, "server_");
+ }
}
}
@@ -85,15 +91,17 @@
sub declare_needs
{
- my ($type) = @_;
+ my ($type, $server) = @_;
my $an = ($type =~ /^[ui]/) ? "an" : "a";
my $type_d = $type;
$type_d =~ s/ /_/g;
+ my $ptr = (length($server)) ? "*" : "";
+
return <<EOF;
-/** Return how much buffer space is needed by \\c psasim_serialise_$type_d()
+/** Return how much buffer space is needed by \\c psasim_${server}serialise_$type_d()
* to serialise $an `$type`.
*
* \\param value The value that will be serialised into the buffer
@@ -104,21 +112,25 @@
* \\c psasim_serialise_$type_d() to serialise
* the given value.
*/
-size_t psasim_serialise_${type_d}_needs($type value);
+size_t psasim_${server}serialise_${type_d}_needs($type ${ptr}value);
EOF
}
sub declare_serialise
{
- my ($type) = @_;
+ my ($type, $server) = @_;
my $an = ($type =~ /^[ui]/) ? "an" : "a";
my $type_d = $type;
$type_d =~ s/ /_/g;
+ my $server_side = (length($server)) ? " on the server side" : "";
+
+ my $ptr = (length($server)) ? "*" : "";
+
return align_declaration(<<EOF);
-/** Serialise $an `$type` into a buffer.
+/** Serialise $an `$type` into a buffer${server_side}.
*
* \\param pos[in,out] Pointer to a `uint8_t *` holding current position
* in the buffer.
@@ -128,23 +140,27 @@
*
* \\return \\c 1 on success ("okay"), \\c 0 on error.
*/
-int psasim_serialise_$type_d(uint8_t **pos,
+int psasim_${server}serialise_$type_d(uint8_t **pos,
size_t *remaining,
- $type value);
+ $type ${ptr}value);
EOF
}
sub declare_deserialise
{
- my ($type) = @_;
+ my ($type, $server) = @_;
my $an = ($type =~ /^[ui]/) ? "an" : "a";
my $type_d = $type;
$type_d =~ s/ /_/g;
+ my $server_side = (length($server)) ? " on the server side" : "";
+
+ my $ptr = (length($server)) ? "*" : "";
+
return align_declaration(<<EOF);
-/** Deserialise $an `$type` from a buffer.
+/** Deserialise $an `$type` from a buffer${server_side}.
*
* \\param pos[in,out] Pointer to a `uint8_t *` holding current position
* in the buffer.
@@ -155,9 +171,9 @@
*
* \\return \\c 1 on success ("okay"), \\c 0 on error.
*/
-int psasim_deserialise_$type_d(uint8_t **pos,
+int psasim_${server}deserialise_$type_d(uint8_t **pos,
size_t *remaining,
- $type *value);
+ $type ${ptr}*value);
EOF
}