/*
 * #include "boot_lut_def.h"
 *
 *  Created on: Jun 26, 2022
 *      Author: Invcuser52
 */

#ifndef BOOT_LUT_DEF_H_
#define BOOT_LUT_DEF_H_

#include "stm32f7xx_hal_ext.h"

#define TABLE_BOOT_SUCCESS_STS  0xAA


typedef enum module_list_e
{
	MODULE_ONE_OS = 0,
	MODULE_TWO_OTSU,
	MODULE_THREE,
	MODULE_FOUR,
	MODULE_FIVE,
	MODULE_SIX,
	MODULE_SEVEN,
	MODULE_EIGHT,
	MODULE_NINE,
	MODULE_TEN,
	MDOULE_MAXIMUM = 50
}e_module_list;


typedef enum sbl_list
{
	bootloader_lut_one =0,  /* it should be 0 since it will be used as array inex */
	bootloader_lut_two =1,
	bootloader_lut_undefined,
	bootloader_lut_one_corrupted,
	bootloader_lut_two_corrupted,
	bootloader_lut_both_corrupted
}e_sbl_list;

typedef enum lut_selection
{
	lut_activate = 0x10,
	lut_deactivate = 0x20
}e_lut_selection;


typedef enum bank_selection
{
	bank_1 = 0x08000000,
	bank_2 = 0x08100000
}e_bank_selection;


typedef enum ffs_flag_e
{
	ffs_set = 0xAA,
	ffs_notSet = 0xBB,
	ffs_success = 0x55,
	ffs_undefined = 0xFF,

}e_ffs_flag;

// look up table control bytes   | size = 12
typedef struct lut_control
{
	e_module_list total_module;
	e_ffs_flag    FFS_flag;
	uint8_t       single_bin_boot;
	uint8_t       memory_chunk_release;
	uint16_t      boot_success_state;

}s_lut_control;

// module wise information   | size = 24bytes
typedef struct lut_moduel_details
{

	uint32_t 	 firmware_header;
	uint32_t	 code_loaded_address;
	uint32_t	 data_loaded_address;
	uint8_t		 code_load_area_memtype;
	uint8_t		 data_load_area_memtype;
	//uint8_t 	 dynamic_loading;
	uint8_t		 module_load_status;
	uint8_t		 module_id;
	uint32_t	 bin_size;
	uint32_t	 packet_count;
	//uint16_t	 reserv2;

}s_lut_module_details;


typedef struct boot_lut_table_def
{
	uint32_t 	  		 btable_bank_loc_flag;
	e_lut_selection 	 boot_selection;  // 4 bytes
	s_lut_control   	 table_control_data;   // 12 bytes
	s_lut_module_details software_module[MDOULE_MAXIMUM];   // 24*10 = 240
	uint32_t      		 boot_table_crc;   //
}s_boot_lut_table_def;   /// total size boot table 16  + 240 = 212






#endif /* BOOT_LUT_DEF_H_ */
