Interface: Introduce psa_call() type range
The range of parameter 'type' for psa_call() was applied long
time ago, but the spec required preprocessor is not defined.
Introduce the definition and updated the relevant code.
Signed-off-by: Ken Liu <Ken.Liu@arm.com>
Change-Id: I9ecc842bcdb3b1b564e8d9fb6fccefd7952fb420
diff --git a/interface/include/psa/client.h b/interface/include/psa/client.h
index 7aee1e5..b4e8b09 100644
--- a/interface/include/psa/client.h
+++ b/interface/include/psa/client.h
@@ -58,6 +58,15 @@
*/
#define PSA_MAX_IOVEC (4u)
+
+/**
+ * The minimum and maximum value in THIS implementation that can be passed
+ * as the type parameter in a call to psa_call().
+ */
+
+#define PSA_CALL_TYPE_MIN (0)
+#define PSA_CALL_TYPE_MAX (INT16_MAX)
+
/**
* An IPC message type that indicates a generic client request.
*/
diff --git a/interface/src/tfm_psa_call.c b/interface/src/tfm_psa_call.c
index 62d9ad2..b25ccdd 100644
--- a/interface/src/tfm_psa_call.c
+++ b/interface/src/tfm_psa_call.c
@@ -16,10 +16,10 @@
psa_outvec *out_vec,
size_t out_len)
{
- if ((type > INT16_MAX) ||
- (type < INT16_MIN) ||
- (in_len > UINT8_MAX) ||
- (out_len > UINT8_MAX)) {
+ if ((type > PSA_CALL_TYPE_MAX) ||
+ (type < PSA_CALL_TYPE_MIN) ||
+ (in_len > PSA_MAX_IOVEC) ||
+ (out_len > PSA_MAX_IOVEC)) {
return PSA_ERROR_PROGRAMMER_ERROR;
}
diff --git a/interface/src/tfm_psa_ns_api.c b/interface/src/tfm_psa_ns_api.c
index c10baa6..819c72b 100644
--- a/interface/src/tfm_psa_ns_api.c
+++ b/interface/src/tfm_psa_ns_api.c
@@ -38,10 +38,10 @@
psa_outvec *out_vec,
size_t out_len)
{
- if ((type > INT16_MAX) ||
- (type < INT16_MIN) ||
- (in_len > UINT8_MAX) ||
- (out_len > UINT8_MAX)) {
+ if ((type > PSA_CALL_TYPE_MAX) ||
+ (type < PSA_CALL_TYPE_MIN) ||
+ (in_len > PSA_MAX_IOVEC) ||
+ (out_len > PSA_MAX_IOVEC)) {
return PSA_ERROR_PROGRAMMER_ERROR;
}