ITS: Change type of flash region size

size_t is the more logical type to use for this struct element.
On PSoC64, also change the type of the size parameter to
nvc_flash_block() for consistency and to keep the code in
driver_smpu.c typecast- and warning-free.

Change-Id: I16b3b8d543e1d7ea84353b8e601327e13cef5e3b
Signed-off-by: Chris Brand <chris.brand@cypress.com>
diff --git a/platform/ext/common/tfm_hal_its.c b/platform/ext/common/tfm_hal_its.c
index ed7b6ad..ac5f09a 100644
--- a/platform/ext/common/tfm_hal_its.c
+++ b/platform/ext/common/tfm_hal_its.c
@@ -9,7 +9,7 @@
 #include "flash_layout.h"
 #include "tfm_hal_its.h"
 
-__WEAK void tfm_hal_its_fs_info(uint32_t *flash_area_addr, uint32_t *flash_area_size)
+__WEAK void tfm_hal_its_fs_info(uint32_t *flash_area_addr, size_t *flash_area_size)
 {
     if (!flash_area_addr || !flash_area_size) {
         return;
diff --git a/platform/ext/common/tfm_hal_ps.c b/platform/ext/common/tfm_hal_ps.c
index df88292..1f3f6e5 100644
--- a/platform/ext/common/tfm_hal_ps.c
+++ b/platform/ext/common/tfm_hal_ps.c
@@ -9,7 +9,7 @@
 #include "flash_layout.h"
 #include "tfm_hal_ps.h"
 
-__WEAK void tfm_hal_ps_fs_info(uint32_t *flash_area_addr, uint32_t *flash_area_size)
+__WEAK void tfm_hal_ps_fs_info(uint32_t *flash_area_addr, size_t *flash_area_size)
 {
     if (!flash_area_addr || !flash_area_size) {
         return;
diff --git a/platform/ext/target/cypress/psoc64/driver_smpu.c b/platform/ext/target/cypress/psoc64/driver_smpu.c
index acb2bfd..bb45f2b 100644
--- a/platform/ext/target/cypress/psoc64/driver_smpu.c
+++ b/platform/ext/target/cypress/psoc64/driver_smpu.c
@@ -84,18 +84,18 @@
     return false;
 }
 
-static bool is_whole_power_of_two(uint32_t size)
+static bool is_whole_power_of_two(size_t size)
 {
     return ((size - 1) & size) == 0;
 }
 
-static bool is_aligned(uint32_t base, uint32_t size)
+static bool is_aligned(uint32_t base, size_t size)
 {
     return (base % size) == 0;
 }
 
 /* size must be a whole power of two, >= 4 */
-static cy_en_prot_size_t bytes_to_regionsize(uint32_t size)
+static cy_en_prot_size_t bytes_to_regionsize(size_t size)
 {
     int ret = 1;
 
@@ -143,7 +143,7 @@
 #define NUM_SUBREGIONS 8
 
 static cy_en_prot_status_t calc_smpu_params(uint32_t base,
-                                            uint32_t size,
+                                            size_t size,
                                             cy_stc_smpu_cfg_t *slave_config)
 {
     /* Simplest case - base is a multiple of the size,
@@ -225,7 +225,7 @@
 }
 
 static cy_en_prot_status_t get_region(const PROT_SMPU_SMPU_STRUCT_Type *smpu,
-                                      uint32_t *base, uint32_t *size)
+                                      uint32_t *base, size_t *size)
 {
     cy_en_prot_status_t ret = CY_PROT_SUCCESS;
 
@@ -256,7 +256,7 @@
 {
     cy_en_prot_status_t ret;
     uint32_t base;
-    uint32_t size;
+    size_t size;
 
     ret = get_region(smpu, &base, &size);
 
@@ -274,11 +274,11 @@
     LOG_MSG("%s - address = %p, size = 0x%x bytes, %s subregions enabled\r\n",
            name,
            slave_config->address,
-           (uint32_t)REGIONSIZE_TO_BYTES(slave_config->regionSize),
+           REGIONSIZE_TO_BYTES(slave_config->regionSize),
            slave_config->subregions == ALL_ENABLED ? "all" : "some");
     if (slave_config->subregions != ALL_ENABLED) {
         LOG_MSG("\tsubregion size = 0x%x bytes\r\n",
-                (uint32_t)REGIONSIZE_TO_BYTES(slave_config->regionSize)/8);
+                REGIONSIZE_TO_BYTES(slave_config->regionSize)/8);
         for (int i=0; i<8; i++) {
             LOG_MSG("\tsubregion %d %s\r\n",
                     i,
@@ -290,7 +290,7 @@
 static void dump_smpu(const PROT_SMPU_SMPU_STRUCT_Type *smpu)
 {
     uint32_t base;
-    uint32_t size;
+    size_t size;
     uint32_t reg = smpu->ATT0;
 
     if (CY_PROT_SUCCESS == get_region(smpu, &base, &size)) {
@@ -312,7 +312,7 @@
                 subregions == ALL_ENABLED ? "all" : "some");
         if (subregions != ALL_ENABLED) {
             LOG_MSG("\tsubregion size = 0x%x bytes\r\n",
-                    (uint32_t)REGIONSIZE_TO_BYTES(size)/8);
+                    REGIONSIZE_TO_BYTES(size)/8);
             for (int i=0; i<8; i++) {
                 LOG_MSG("\tsubregion %d %s\r\n",
                         i,
diff --git a/platform/ext/target/cypress/psoc64/nv_counters.c b/platform/ext/target/cypress/psoc64/nv_counters.c
index 039517f..79154d7 100644
--- a/platform/ext/target/cypress/psoc64/nv_counters.c
+++ b/platform/ext/target/cypress/psoc64/nv_counters.c
@@ -83,7 +83,7 @@
     nv_counters->checksum = sum;
 }
 
-void nvc_flash_block(uint32_t *base, uint32_t *size)
+void nvc_flash_block(uint32_t *base, size_t *size)
 {
     *base = FLASH_NV_COUNTERS_AREA_OFFSET;
     *size = FLASH_NV_COUNTERS_AREA_SIZE;
@@ -94,7 +94,7 @@
     int32_t  err;
     uint32_t i;
     struct nv_counters_t nv_counters;
-    uint32_t size;
+    size_t size;
 
     /* Get the base address and size */
     nvc_flash_block(&nv_counters_offset, &size);
diff --git a/platform/ext/target/cypress/psoc64/nv_counters.h b/platform/ext/target/cypress/psoc64/nv_counters.h
index d0b09bc..3d599d3 100644
--- a/platform/ext/target/cypress/psoc64/nv_counters.h
+++ b/platform/ext/target/cypress/psoc64/nv_counters.h
@@ -22,6 +22,6 @@
  *
  * \return void
  */
-void nvc_flash_block(uint32_t *base, uint32_t *size);
+void nvc_flash_block(uint32_t *base, size_t *size);
 
 #endif /* __NV_COUNTERS_H__ */
diff --git a/platform/include/tfm_hal_its.h b/platform/include/tfm_hal_its.h
index 843eb71..77698fe 100644
--- a/platform/include/tfm_hal_its.h
+++ b/platform/include/tfm_hal_its.h
@@ -8,6 +8,8 @@
 #ifndef __TFM_HAL_ITS_H__
 #define __TFM_HAL_ITS_H__
 
+#include <stddef.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -25,7 +27,7 @@
  * If an error is detected within this function, is should leave the
  * content of the parameters unchanged.
  */
-void tfm_hal_its_fs_info(uint32_t *flash_area_addr, uint32_t *flash_area_size);
+void tfm_hal_its_fs_info(uint32_t *flash_area_addr, size_t *flash_area_size);
 
 #ifdef __cplusplus
 }
diff --git a/platform/include/tfm_hal_ps.h b/platform/include/tfm_hal_ps.h
index e372883..7b8a847 100644
--- a/platform/include/tfm_hal_ps.h
+++ b/platform/include/tfm_hal_ps.h
@@ -8,6 +8,8 @@
 #ifndef __TFM_HAL_PS_H__
 #define __TFM_HAL_PS_H__
 
+#include <stddef.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -25,7 +27,7 @@
  * If an error is detected within this function, is should leave the
  * content of the parameters unchanged.
  */
-void tfm_hal_ps_fs_info(uint32_t *flash_area_addr, uint32_t *flash_area_size);
+void tfm_hal_ps_fs_info(uint32_t *flash_area_addr, size_t *flash_area_size);
 
 #ifdef __cplusplus
 }