blob: 337ba5f98a41dd5c653565f4b4d10a42cefcae7a [file] [log] [blame]
Chris Brandc47d7102020-02-20 11:12:18 -08001/*
2 * Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
Jamie Fox6a3946a2020-12-07 21:50:31 +00003 * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
Chris Brandc47d7102020-02-20 11:12:18 -08004 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 *
7 */
8
Chris Brandc47d7102020-02-20 11:12:18 -08009#include "tfm_hal_ps.h"
10
Jamie Fox6a3946a2020-12-07 21:50:31 +000011#include "cmsis_compiler.h"
12#include "flash_layout.h"
13
14/* The base address of the dedicated flash area for PS */
15#ifndef TFM_HAL_PS_FLASH_AREA_ADDR
16#error "TFM_HAL_PS_FLASH_AREA_ADDR must be defined by the target in flash_layout.h"
17#endif
18
19/* The size of the dedicated flash area for PS in bytes */
20#ifndef TFM_HAL_PS_FLASH_AREA_SIZE
21#error "TFM_HAL_PS_FLASH_AREA_SIZE must be defined by the target in flash_layout.h"
22#endif
23
24/* The number of contiguous physical flash erase sectors per logical filesystem
25 * erase block. Adjust so that the maximum required asset size will fit in one
26 * logical block.
27 */
28#ifndef TFM_HAL_PS_SECTORS_PER_BLOCK
29#error "TFM_HAL_PS_SECTORS_PER_BLOCK must be defined by the target in flash_layout.h"
30#endif
31
32__WEAK enum tfm_hal_status_t
33tfm_hal_ps_fs_info(struct tfm_hal_ps_fs_info_t *fs_info)
Chris Brandc47d7102020-02-20 11:12:18 -080034{
Jamie Fox6a3946a2020-12-07 21:50:31 +000035 if (!fs_info) {
36 return TFM_HAL_ERROR_INVALID_INPUT;
Chris Brandc47d7102020-02-20 11:12:18 -080037 }
38
Jamie Fox6a3946a2020-12-07 21:50:31 +000039 fs_info->flash_area_addr = TFM_HAL_PS_FLASH_AREA_ADDR;
40 fs_info->flash_area_size = TFM_HAL_PS_FLASH_AREA_SIZE;
41 fs_info->sectors_per_block = TFM_HAL_PS_SECTORS_PER_BLOCK;
42
43 return TFM_HAL_SUCCESS;
Chris Brandc47d7102020-02-20 11:12:18 -080044}