blob: 66dce1d24ba112374136b9e61eaccc5471cde6af [file] [log] [blame]
David Brown5153bd62017-01-06 11:16:53 -07001/* Manual version of auto-generated version. */
2
3#ifndef __SYSFLASH_H__
4#define __SYSFLASH_H__
5
Ulf Magnussone96b6872020-01-13 12:06:44 +01006#include <devicetree.h>
David Vinczeb75c12a2019-03-22 14:58:33 +01007#include <mcuboot_config/mcuboot_config.h>
Andrzej Puzdrowski419a4752019-01-23 16:31:19 +01008
David Vinczeb75c12a2019-03-22 14:58:33 +01009#if (MCUBOOT_IMAGE_NUMBER == 1)
Fabio Utzigb0f04732019-07-31 09:49:19 -030010/*
11 * NOTE: the definition below returns the same values for true/false on
12 * purpose, to avoid having to mark x as non-used by all callers when
13 * running in single image mode.
14 */
15#define FLASH_AREA_IMAGE_PRIMARY(x) (((x) == 0) ? \
Kumar Gala6e26e382020-05-07 19:31:57 -050016 FLASH_AREA_ID(image_0) : \
17 FLASH_AREA_ID(image_0))
Fabio Utzigb0f04732019-07-31 09:49:19 -030018#define FLASH_AREA_IMAGE_SECONDARY(x) (((x) == 0) ? \
Kumar Gala6e26e382020-05-07 19:31:57 -050019 FLASH_AREA_ID(image_1) : \
20 FLASH_AREA_ID(image_1))
David Vinczeb75c12a2019-03-22 14:58:33 +010021#elif (MCUBOOT_IMAGE_NUMBER == 2)
22/* MCUBoot currently supports only up to 2 updateable firmware images.
23 * If the number of the current image is greater than MCUBOOT_IMAGE_NUMBER - 1
24 * then a dummy value will be assigned to the flash area macros.
25 */
Fabio Utzigb0f04732019-07-31 09:49:19 -030026#define FLASH_AREA_IMAGE_PRIMARY(x) (((x) == 0) ? \
Kumar Gala6e26e382020-05-07 19:31:57 -050027 FLASH_AREA_ID(image_0) : \
Fabio Utzigb0f04732019-07-31 09:49:19 -030028 ((x) == 1) ? \
Kumar Gala6e26e382020-05-07 19:31:57 -050029 FLASH_AREA_ID(image_2) : \
Fabio Utzigb0f04732019-07-31 09:49:19 -030030 255)
31#define FLASH_AREA_IMAGE_SECONDARY(x) (((x) == 0) ? \
Kumar Gala6e26e382020-05-07 19:31:57 -050032 FLASH_AREA_ID(image_1) : \
Fabio Utzigb0f04732019-07-31 09:49:19 -030033 ((x) == 1) ? \
Kumar Gala6e26e382020-05-07 19:31:57 -050034 FLASH_AREA_ID(image_3) : \
Fabio Utzigb0f04732019-07-31 09:49:19 -030035 255)
David Vinczeb75c12a2019-03-22 14:58:33 +010036#else
37#error "Image slot and flash area mapping is not defined"
38#endif
39
Fabio Utzigc58842e2019-11-28 10:30:01 -030040#if !defined(CONFIG_BOOT_SWAP_USING_MOVE)
Kumar Gala6e26e382020-05-07 19:31:57 -050041#define FLASH_AREA_IMAGE_SCRATCH FLASH_AREA_ID(image_scratch)
Fabio Utzigc58842e2019-11-28 10:30:01 -030042#endif
David Brown5153bd62017-01-06 11:16:53 -070043
44#endif /* __SYSFLASH_H__ */