Platform: TF-M ITS and PS HAL
Expands the TF-M Internal Trusted Storage and Protected Storage HALs to
cover all flash and filesystem configuration parameters required from
the platform. The CMSIS Flash APIs are exposed to abstract the flash
device, along with a function and some definitions to expose further
parameters required by the filesystem.
Updates ITS to use the new HALs and removes its_flash_info_external.c,
its_flash_info_internal.c and its_flash.c. Also moves the
block_to_block_move() function from its_flash.c to the filesystem, as
its implementation is agnostic to the flash device. The its_flash.h
header is kept as a helper to abstract the different flash block device
wrappers (NOR, NAND, RAM).
The ITS filesystem is updated to take a configuration struct as an
initialisation parameter, which is filled using values from the HAL.
Change-Id: I95ae44795a59b1f36c9b95d057f44b4ae3ba2344
Signed-off-by: Jamie Fox <jamie.fox@arm.com>
diff --git a/platform/ext/common/tfm_hal_its.c b/platform/ext/common/tfm_hal_its.c
index ac5f09a..e53623f 100644
--- a/platform/ext/common/tfm_hal_its.c
+++ b/platform/ext/common/tfm_hal_its.c
@@ -1,20 +1,44 @@
/*
* Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
+ * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
-#include "cmsis_compiler.h"
-#include "flash_layout.h"
#include "tfm_hal_its.h"
-__WEAK void tfm_hal_its_fs_info(uint32_t *flash_area_addr, size_t *flash_area_size)
+#include "cmsis_compiler.h"
+#include "flash_layout.h"
+
+/* The base address of the dedicated flash area for ITS */
+#ifndef TFM_HAL_ITS_FLASH_AREA_ADDR
+#error "TFM_HAL_ITS_FLASH_AREA_ADDR must be defined by the target in flash_layout.h"
+#endif
+
+/* The size of the dedicated flash area for ITS in bytes */
+#ifndef TFM_HAL_ITS_FLASH_AREA_SIZE
+#error "TFM_HAL_ITS_FLASH_AREA_SIZE must be defined by the target in flash_layout.h"
+#endif
+
+/* The number of contiguous physical flash erase sectors per logical filesystem
+ * erase block. Adjust so that the maximum required asset size will fit in one
+ * logical block.
+ */
+#ifndef TFM_HAL_ITS_SECTORS_PER_BLOCK
+#error "TFM_HAL_ITS_SECTORS_PER_BLOCK must be defined by the target in flash_layout.h"
+#endif
+
+__WEAK enum tfm_hal_status_t
+tfm_hal_its_fs_info(struct tfm_hal_its_fs_info_t *fs_info)
{
- if (!flash_area_addr || !flash_area_size) {
- return;
+ if (!fs_info) {
+ return TFM_HAL_ERROR_INVALID_INPUT;
}
- *flash_area_addr = ITS_FLASH_AREA_ADDR;
- *flash_area_size = ITS_FLASH_AREA_SIZE;
+ fs_info->flash_area_addr = TFM_HAL_ITS_FLASH_AREA_ADDR;
+ fs_info->flash_area_size = TFM_HAL_ITS_FLASH_AREA_SIZE;
+ fs_info->sectors_per_block = TFM_HAL_ITS_SECTORS_PER_BLOCK;
+
+ return TFM_HAL_SUCCESS;
}