1 /* Manual version of auto-generated version. */
2 
3 /*
4  * Original code taken from mcuboot project at:
5  * https://github.com/mcu-tools/mcuboot
6  * Git SHA of the original version: ac55554059147fff718015be9f4bd3108123f50a
7  * Modifications are Copyright (c) 2020-2021 Arm Limited.
8  */
9 
10 #ifndef __SYSFLASH_H__
11 #define __SYSFLASH_H__
12 
13 #include "flash_layout.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 #ifdef DEFAULT_MCUBOOT_FLASH_MAP
20 
21 #if (MCUBOOT_IMAGE_NUMBER == 1)
22 /*
23  * NOTE: the definition below returns the same values for true/false on
24  * purpose, to avoid having to mark x as non-used by all callers when
25  * running in single image mode.
26  */
27 #define FLASH_AREA_IMAGE_PRIMARY(x)     (((x) == 0) ? FLASH_AREA_0_ID : \
28                                                       FLASH_AREA_0_ID)
29 #define FLASH_AREA_IMAGE_SECONDARY(x)   (((x) == 0) ? FLASH_AREA_2_ID : \
30                                                       FLASH_AREA_2_ID)
31 #elif (MCUBOOT_IMAGE_NUMBER == 2)
32 /* MCUBoot currently supports only up to 2 updatable firmware images.
33  * If the number of the current image is greater than MCUBOOT_IMAGE_NUMBER - 1
34  * then a dummy value will be assigned to the flash area macros.
35  */
36 #define FLASH_AREA_IMAGE_PRIMARY(x)     (((x) == 0) ? FLASH_AREA_0_ID : \
37                                          ((x) == 1) ? FLASH_AREA_1_ID : \
38                                                       255 )
39 #define FLASH_AREA_IMAGE_SECONDARY(x)   (((x) == 0) ? FLASH_AREA_2_ID : \
40                                          ((x) == 1) ? FLASH_AREA_3_ID : \
41                                                       255 )
42 #else
43 #error "Image slot and flash area mapping is not defined"
44 #endif
45 
46 #define FLASH_AREA_IMAGE_SCRATCH        FLASH_AREA_SCRATCH_ID
47 
48 #endif /* DEFAULT_MCUBOOT_FLASH_MAP */
49 
50 #ifdef __cplusplus
51 }
52 #endif
53 
54 #endif /* __SYSFLASH_H__ */