91 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			91 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/****************************************************************************
 | 
						|
 | 
						|
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
 | 
						|
 | 
						|
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
 | 
						|
be copied by any method or incorporated into another program without
 | 
						|
the express written consent of Aerospace C.Power. This Information or any portion
 | 
						|
thereof remains the property of Aerospace C.Power. The Information contained herein
 | 
						|
is believed to be accurate and Aerospace C.Power assumes no responsibility or
 | 
						|
liability for its use in any way and conveys no license or title under
 | 
						|
any patent or copyright and makes no representation or warranty that this
 | 
						|
Information is free from patent or copyright infringement.
 | 
						|
 | 
						|
****************************************************************************/
 | 
						|
#ifndef IOT_FLASH_LAYOUT_H
 | 
						|
#define IOT_FLASH_LAYOUT_H
 | 
						|
 | 
						|
#include "iot_config.h"
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
extern "C" {
 | 
						|
#endif
 | 
						|
 | 
						|
/* [NOTE]:SP, SBL, param, OEM partition offset and size are fixed. */
 | 
						|
 | 
						|
#define PART_NUM_INVALID    (0xFF)
 | 
						|
 | 
						|
/* define partition properties */
 | 
						|
#define MTD_AUTH_NONE       (0x0)
 | 
						|
#define MTD_AUTH_READ       (1 << 0)
 | 
						|
#define MTD_AUTH_WRITE      (1 << 1)
 | 
						|
#define MTD_AUTH_RW         (MTD_AUTH_READ | MTD_AUTH_WRITE)
 | 
						|
#define SET_CORE_AUTHORITY(authority, core)   (((authority) & 0x3) << (core * 2))
 | 
						|
#define GET_CORE_AUTHORITY(authority, core)   (((authority) >> (core * 2)) & 0x3)
 | 
						|
#define SET_CORE_NONE(core)     SET_CORE_AUTHORITY(MTD_AUTH_NONE, core)
 | 
						|
#define SET_CORE_R_ONLY(core)   SET_CORE_AUTHORITY(MTD_AUTH_READ, core)
 | 
						|
#define SET_CORE_W_ONLY(core)   SET_CORE_AUTHORITY(MTD_AUTH_WRITE, core)
 | 
						|
#define SET_CORE_RW(core)       SET_CORE_AUTHORITY(MTD_AUTH_RW, core)
 | 
						|
 | 
						|
/* define partition type */
 | 
						|
typedef enum {
 | 
						|
    PART_NUM_MIN = 0,   // keep this as the first one
 | 
						|
    PART_NUM_SP = 0,
 | 
						|
    PART_NUM_SBL = 1,
 | 
						|
    PART_NUM_PARAM = 2,
 | 
						|
    PART_NUM_OEM = 3,
 | 
						|
    PART_NUM_PIB1 = 4,
 | 
						|
    PART_NUM_LOG1 = 5,
 | 
						|
    PART_NUM_PIB2 = 6,
 | 
						|
    PART_NUM_LOG2 = 7,
 | 
						|
    PART_NUM_FW1 = 8,
 | 
						|
    PART_NUM_FW2 = 9,
 | 
						|
    PART_NUM_CUS_DATA = 10,
 | 
						|
    PART_NUM_CAL_DATA = 11,
 | 
						|
    PART_NUM_RUN = 12,
 | 
						|
    PART_NUM_SBL2 = 13,
 | 
						|
    PART_NUM_CUS_FW1 = 14,
 | 
						|
    PART_NUM_CUS_FW2 = 15,
 | 
						|
    PART_NUM_PIB1_EXT = 16,
 | 
						|
    PART_NUM_PIB2_EXT = 17,
 | 
						|
    PART_NUM_CUS_RUN = 18,
 | 
						|
    PART_NUM_DUMP = 19,
 | 
						|
 | 
						|
    PART_NUM_MAX = 20,   // keep this as the last one
 | 
						|
} part_num_t;
 | 
						|
 | 
						|
/* layout_part_info_t structure uses bit field and defines partitions in 4K units.
 | 
						|
 * now redefine partition structure to improve execution efficiency.
 | 
						|
 */
 | 
						|
typedef struct _part_info_t {
 | 
						|
    uint32_t offset;
 | 
						|
    uint32_t size;
 | 
						|
    uint8_t authority;
 | 
						|
} part_info_t;
 | 
						|
 | 
						|
uint32_t iot_layout_init_index(uint8_t index, uint8_t flash_size, uint8_t psram_eb);
 | 
						|
uint32_t iot_layout_get_index(uint8_t *build_index, uint8_t *run_index);
 | 
						|
 | 
						|
uint32_t iot_layout_get_part_offset(uint8_t part, uint32_t *offset);
 | 
						|
uint32_t iot_layout_get_part_size(uint8_t part, uint32_t *size);
 | 
						|
uint32_t iot_layout_get_part_authority(uint8_t part, uint8_t *authority);
 | 
						|
uint32_t iot_layout_get_part_info(uint8_t part, part_info_t *part_info);
 | 
						|
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
}
 | 
						|
#endif
 | 
						|
 | 
						|
#endif //IOT_FLASH_LAYOUT_H
 | 
						|
 |