DPE: Initialise target_locality argument

If target_locality is not encoded in input, initialise it
to the LOCALITY_NONE (no locality). Also, set locality
for RoT context to be RSE Secure.

Signed-off-by: Maulik Patel <maulik.patel@arm.com>
Change-Id: Id3ab6f954c121a84c68c58e2fa6d27dce00f703b
diff --git a/partitions/dice_protection_environment/dpe_cmd_decode.c b/partitions/dice_protection_environment/dpe_cmd_decode.c
index 644fb7c..ae53060 100644
--- a/partitions/dice_protection_environment/dpe_cmd_decode.c
+++ b/partitions/dice_protection_environment/dpe_cmd_decode.c
@@ -230,6 +230,7 @@
     return_certificate = false;
     allow_new_context_to_export = false;
     export_cdi = false;
+    target_locality = DEFAULT_TARGET_LOCALITY;
 
     /* Decode DeriveContext command */
     QCBORDecode_EnterMap(decode_ctx, &item);
diff --git a/partitions/dice_protection_environment/dpe_context_mngr.c b/partitions/dice_protection_environment/dpe_context_mngr.c
index 6c4aff3..fbbb203 100644
--- a/partitions/dice_protection_environment/dpe_context_mngr.c
+++ b/partitions/dice_protection_environment/dpe_context_mngr.c
@@ -103,8 +103,7 @@
     component_ctx_array[i].parent_idx = INVALID_COMPONENT_IDX;
     component_ctx_array[i].linked_layer_idx = INVALID_LAYER_IDX;
     (void)memset(&component_ctx_array[i].data, 0, sizeof(struct component_context_data_t));
-    //TODO: Question: how to initialise MHU Id mapping?
-    component_ctx_array[i].target_locality = 0;
+    component_ctx_array[i].target_locality = DEFAULT_TARGET_LOCALITY;
     /* Allow component to be derived by default */
 }
 
@@ -502,6 +501,8 @@
     rot_layer_ctx->data.cdi_key_id = dpe_plat_get_rot_cdi_key_id();
     /* Init RoT context, ready to be derived in next call to DeriveContext */
     rot_comp_ctx->nonce = 0;
+    /* Set the target locality for RoT context */
+    rot_comp_ctx->target_locality = LOCALITY_RSE_S;
     /* Parent component index for derived RoT context is same */
     rot_comp_ctx->parent_idx = 0;
     /* Link context to RoT Layer */
diff --git a/partitions/dice_protection_environment/dpe_context_mngr.h b/partitions/dice_protection_environment/dpe_context_mngr.h
index 79e7368..4aaaffd 100644
--- a/partitions/dice_protection_environment/dpe_context_mngr.h
+++ b/partitions/dice_protection_environment/dpe_context_mngr.h
@@ -13,6 +13,7 @@
 #include <stdbool.h>
 #include "dice_protection_environment.h"
 #include "dpe_crypto_config.h"
+#include "platform_locality.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -47,6 +48,9 @@
 #define SET_IDX(handle, idx) ((handle & 0xffff0000) | idx)
 #define SET_NONCE(handle, nonce) ((handle & 0x00ffff) | (nonce << 16))
 
+/* Current locality by default */
+#define DEFAULT_TARGET_LOCALITY  LOCALITY_NONE
+
 struct component_context_data_t {
     uint8_t        measurement_value[DICE_HASH_SIZE];
     uint8_t        measurement_descriptor[DICE_CODE_DESCRIPTOR_MAX_SIZE];