Chris Brand | c47d710 | 2020-02-20 11:12:18 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved. |
Jamie Fox | 6a3946a | 2020-12-07 21:50:31 +0000 | [diff] [blame^] | 3 | * Copyright (c) 2020-2021, Arm Limited. All rights reserved. |
Chris Brand | c47d710 | 2020-02-20 11:12:18 -0800 | [diff] [blame] | 4 | * |
| 5 | * SPDX-License-Identifier: BSD-3-Clause |
| 6 | * |
| 7 | */ |
| 8 | |
Chris Brand | c47d710 | 2020-02-20 11:12:18 -0800 | [diff] [blame] | 9 | #include "tfm_hal_ps.h" |
| 10 | |
Jamie Fox | 6a3946a | 2020-12-07 21:50:31 +0000 | [diff] [blame^] | 11 | #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 |
| 33 | tfm_hal_ps_fs_info(struct tfm_hal_ps_fs_info_t *fs_info) |
Chris Brand | c47d710 | 2020-02-20 11:12:18 -0800 | [diff] [blame] | 34 | { |
Jamie Fox | 6a3946a | 2020-12-07 21:50:31 +0000 | [diff] [blame^] | 35 | if (!fs_info) { |
| 36 | return TFM_HAL_ERROR_INVALID_INPUT; |
Chris Brand | c47d710 | 2020-02-20 11:12:18 -0800 | [diff] [blame] | 37 | } |
| 38 | |
Jamie Fox | 6a3946a | 2020-12-07 21:50:31 +0000 | [diff] [blame^] | 39 | 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 Brand | c47d710 | 2020-02-20 11:12:18 -0800 | [diff] [blame] | 44 | } |