12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370 |
- enum _flash_driver_version_constants
- {
- kFLASH_DriverVersionName = 'F',
- kFLASH_DriverVersionMajor = 2,
- kFLASH_DriverVersionMinor = 4,
- kFLASH_DriverVersionBugfix = 1
- };
- enum _flash_status
- {
- kStatus_FLASH_Success = MAKE_STATUS(kStatusGroupGeneric, 0),
- kStatus_FLASH_InvalidArgument = MAKE_STATUS(kStatusGroupGeneric, 4),
- kStatus_FLASH_SizeError = MAKE_STATUS(kStatusGroupFlashDriver, 0),
- kStatus_FLASH_AlignmentError =
- MAKE_STATUS(kStatusGroupFlashDriver, 1),
- kStatus_FLASH_AddressError = MAKE_STATUS(kStatusGroupFlashDriver, 2),
- kStatus_FLASH_AccessError =
- MAKE_STATUS(kStatusGroupFlashDriver, 3),
- kStatus_FLASH_ProtectionViolation = MAKE_STATUS(
- kStatusGroupFlashDriver, 4),
- kStatus_FLASH_CommandFailure =
- MAKE_STATUS(kStatusGroupFlashDriver, 5),
- kStatus_FLASH_UnknownProperty = MAKE_STATUS(kStatusGroupFlashDriver, 6),
- kStatus_FLASH_EraseKeyError = MAKE_STATUS(kStatusGroupFlashDriver, 7),
- kStatus_FLASH_RegionExecuteOnly =
- MAKE_STATUS(kStatusGroupFlashDriver, 8),
- kStatus_FLASH_ExecuteInRamFunctionNotReady =
- MAKE_STATUS(kStatusGroupFlashDriver, 9),
- kStatus_FLASH_PartitionStatusUpdateFailure =
- MAKE_STATUS(kStatusGroupFlashDriver, 10),
- kStatus_FLASH_SetFlexramAsEepromError =
- MAKE_STATUS(kStatusGroupFlashDriver, 11),
- kStatus_FLASH_RecoverFlexramAsRamError =
- MAKE_STATUS(kStatusGroupFlashDriver, 12),
- kStatus_FLASH_SetFlexramAsRamError = MAKE_STATUS(kStatusGroupFlashDriver, 13),
- kStatus_FLASH_RecoverFlexramAsEepromError =
- MAKE_STATUS(kStatusGroupFlashDriver, 14),
- kStatus_FLASH_CommandNotSupported = MAKE_STATUS(kStatusGroupFlashDriver, 15),
- kStatus_FLASH_SwapSystemNotInUninitialized =
- MAKE_STATUS(kStatusGroupFlashDriver, 16),
- kStatus_FLASH_SwapIndicatorAddressError =
- MAKE_STATUS(kStatusGroupFlashDriver, 17),
- kStatus_FLASH_ReadOnlyProperty = MAKE_STATUS(kStatusGroupFlashDriver, 18),
- kStatus_FLASH_InvalidPropertyValue =
- MAKE_STATUS(kStatusGroupFlashDriver, 19),
- kStatus_FLASH_InvalidSpeculationOption =
- MAKE_STATUS(kStatusGroupFlashDriver, 20),
- };
- enum _flash_driver_api_keys
- {
- kFLASH_ApiEraseKey = FOUR_CHAR_CODE('k', 'f', 'e', 'k')
- };
- typedef enum _flash_margin_value
- {
- kFLASH_MarginValueNormal,
- kFLASH_MarginValueUser,
- kFLASH_MarginValueFactory,
- kFLASH_MarginValueInvalid
- } flash_margin_value_t;
- typedef enum _flash_security_state
- {
- kFLASH_SecurityStateNotSecure = 0xc33cc33cU,
- kFLASH_SecurityStateBackdoorEnabled = 0x5aa55aa5U,
- kFLASH_SecurityStateBackdoorDisabled = 0x5ac33ca5U
- } flash_security_state_t;
- typedef enum _flash_protection_state
- {
- kFLASH_ProtectionStateUnprotected,
- kFLASH_ProtectionStateProtected,
- kFLASH_ProtectionStateMixed
- } flash_protection_state_t;
- typedef enum _flash_execute_only_access_state
- {
- kFLASH_AccessStateUnLimited,
- kFLASH_AccessStateExecuteOnly,
- kFLASH_AccessStateMixed
- } flash_execute_only_access_state_t;
- typedef enum _flash_property_tag
- {
- kFLASH_PropertyPflashSectorSize = 0x00U,
- kFLASH_PropertyPflashTotalSize = 0x01U,
- kFLASH_PropertyPflashBlockSize = 0x02U,
- kFLASH_PropertyPflashBlockCount = 0x03U,
- kFLASH_PropertyPflashBlockBaseAddr = 0x04U,
- kFLASH_PropertyPflashFacSupport = 0x05U,
- kFLASH_PropertyPflashAccessSegmentSize = 0x06U,
- kFLASH_PropertyPflashAccessSegmentCount = 0x07U,
- kFLASH_PropertyFlexRamBlockBaseAddr = 0x08U,
- kFLASH_PropertyFlexRamTotalSize = 0x09U,
- kFLASH_PropertyDflashSectorSize = 0x10U,
- kFLASH_PropertyDflashTotalSize = 0x11U,
- kFLASH_PropertyDflashBlockSize = 0x12U,
- kFLASH_PropertyDflashBlockCount = 0x13U,
- kFLASH_PropertyDflashBlockBaseAddr = 0x14U,
- kFLASH_PropertyEepromTotalSize = 0x15U,
- kFLASH_PropertyFlashMemoryIndex = 0x20U
- } flash_property_tag_t;
- enum _flash_execute_in_ram_function_constants
- {
- kFLASH_ExecuteInRamFunctionMaxSizeInWords = 16U,
- kFLASH_ExecuteInRamFunctionTotalNum = 2U
- };
- typedef struct _flash_execute_in_ram_function_config
- {
- uint32_t activeFunctionCount;
- uint32_t *flashRunCommand;
- uint32_t *flashCommonBitOperation;
- } flash_execute_in_ram_function_config_t;
- typedef enum _flash_read_resource_option
- {
- kFLASH_ResourceOptionFlashIfr =
- 0x00U,
- kFLASH_ResourceOptionVersionId = 0x01U
- } flash_read_resource_option_t;
- enum _flash_read_resource_range
- {
- kFLASH_ResourceRangePflashIfrSizeInBytes = 1024U,
- kFLASH_ResourceRangeVersionIdSizeInBytes = 8U,
- kFLASH_ResourceRangeVersionIdStart = 0x08U,
- kFLASH_ResourceRangeVersionIdEnd = 0x0FU,
- kFLASH_ResourceRangePflashSwapIfrStart = 0x40000U,
- kFLASH_ResourceRangePflashSwapIfrEnd =
- (kFLASH_ResourceRangePflashSwapIfrStart + 0x3FFU),
- kFLASH_ResourceRangePflashIfrSizeInBytes = 256U,
- kFLASH_ResourceRangeVersionIdSizeInBytes = 8U,
- kFLASH_ResourceRangeVersionIdStart = 0x00U,
- kFLASH_ResourceRangeVersionIdEnd = 0x07U,
- kFLASH_ResourceRangePflashSwapIfrStart = 0x8000U,
- kFLASH_ResourceRangePflashSwapIfrStart = 0x10000U,
- kFLASH_ResourceRangePflashSwapIfrStart = 0x20000U,
- kFLASH_ResourceRangePflashSwapIfrStart = 0,
- kFLASH_ResourceRangePflashSwapIfrEnd =
- (kFLASH_ResourceRangePflashSwapIfrStart + 0xFFU),
- kFLASH_ResourceRangeDflashIfrStart = 0x800000U,
- kFLASH_ResourceRangeDflashIfrEnd = 0x8003FFU,
- };
- enum _k3_flash_read_once_index
- {
- kFLASH_RecordIndexSwapAddr = 0xA1U,
- kFLASH_RecordIndexSwapEnable = 0xA2U,
- kFLASH_RecordIndexSwapDisable = 0xA3U,
- };
- typedef enum _flash_flexram_function_option
- {
- kFLASH_FlexramFunctionOptionAvailableAsRam = 0xFFU,
- kFLASH_FlexramFunctionOptionAvailableForEeprom = 0x00U
- } flash_flexram_function_option_t;
- enum _flash_acceleration_ram_property
- {
- kFLASH_AccelerationRamSize = 0x400U
- };
- typedef enum _flash_swap_function_option
- {
- kFLASH_SwapFunctionOptionEnable = 0x00U,
- kFLASH_SwapFunctionOptionDisable = 0x01U
- } flash_swap_function_option_t;
- typedef enum _flash_swap_control_option
- {
- kFLASH_SwapControlOptionIntializeSystem = 0x01U,
- kFLASH_SwapControlOptionSetInUpdateState = 0x02U,
- kFLASH_SwapControlOptionSetInCompleteState = 0x04U,
- kFLASH_SwapControlOptionReportStatus = 0x08U,
- kFLASH_SwapControlOptionDisableSystem = 0x10U
- } flash_swap_control_option_t;
- typedef enum _flash_swap_state
- {
- kFLASH_SwapStateUninitialized = 0x00U,
- kFLASH_SwapStateReady = 0x01U,
- kFLASH_SwapStateUpdate = 0x02U,
- kFLASH_SwapStateUpdateErased = 0x03U,
- kFLASH_SwapStateComplete = 0x04U,
- kFLASH_SwapStateDisabled = 0x05U
- } flash_swap_state_t;
- typedef enum _flash_swap_block_status
- {
- kFLASH_SwapBlockStatusLowerHalfProgramBlocksAtZero =
- 0x00U,
- kFLASH_SwapBlockStatusUpperHalfProgramBlocksAtZero =
- 0x01U,
- } flash_swap_block_status_t;
- typedef struct _flash_swap_state_config
- {
- flash_swap_state_t flashSwapState;
- flash_swap_block_status_t currentSwapBlockStatus;
- flash_swap_block_status_t nextSwapBlockStatus;
- } flash_swap_state_config_t;
- typedef struct _flash_swap_ifr_field_config
- {
- uint16_t swapIndicatorAddress;
- uint16_t swapEnableWord;
- uint8_t reserved0[4];
- uint8_t reserved1[2];
- uint16_t swapDisableWord;
- uint8_t reserved2[4];
- } flash_swap_ifr_field_config_t;
- typedef union _flash_swap_ifr_field_data
- {
- uint32_t flashSwapIfrData[2];
- flash_swap_ifr_field_config_t flashSwapIfrField;
- } flash_swap_ifr_field_data_t;
- typedef union _pflash_protection_status_low
- {
- uint32_t protl32b;
- struct
- {
- uint8_t protsl;
- uint8_t protsh;
- uint8_t reserved[2];
- } prots16b;
- } pflash_protection_status_low_t;
- typedef struct _pflash_protection_status
- {
- pflash_protection_status_low_t valueLow32b;
- ((FSL_FEATURE_FLASH_IS_FTFE == 1) && (defined(FTFE_FPROTH0_PROT_MASK))) || \
- ((FSL_FEATURE_FLASH_IS_FTFL == 1) && (defined(FTFL_FPROTH0_PROT_MASK)))
- struct
- {
- uint32_t proth32b;
- } valueHigh32b;
- } pflash_protection_status_t;
- typedef enum _flash_partition_flexram_load_option
- {
- kFLASH_PartitionFlexramLoadOptionLoadedWithValidEepromData =
- 0x00U,
- kFLASH_PartitionFlexramLoadOptionNotLoaded = 0x01U
- } flash_partition_flexram_load_option_t;
- typedef enum _flash_memory_index
- {
- kFLASH_MemoryIndexPrimaryFlash = 0x00U,
- kFLASH_MemoryIndexSecondaryFlash = 0x01U,
- } flash_memory_index_t;
- typedef enum _flash_cache_controller_index
- {
- kFLASH_CacheControllerIndexForCore0 = 0x00U,
- kFLASH_CacheControllerIndexForCore1 = 0x01U,
- } flash_cache_controller_index_t;
- typedef enum _flash_prefetch_speculation_option
- {
- kFLASH_prefetchSpeculationOptionEnable = 0x00U,
- kFLASH_prefetchSpeculationOptionDisable = 0x01U
- } flash_prefetch_speculation_option_t;
- typedef struct _flash_prefetch_speculation_status
- {
- flash_prefetch_speculation_option_t instructionOption;
- flash_prefetch_speculation_option_t dataOption;
- } flash_prefetch_speculation_status_t;
- typedef enum _flash_cache_clear_process
- {
- kFLASH_CacheClearProcessPre = 0x00U,
- kFLASH_CacheClearProcessPost = 0x01U,
- } flash_cache_clear_process_t;
- typedef struct _flash_protection_config
- {
- uint32_t regionBase;
- uint32_t regionSize;
- uint32_t regionCount;
- } flash_protection_config_t;
- typedef struct _flash_access_config
- {
- uint32_t SegmentBase;
- uint32_t SegmentSize;
- uint32_t SegmentCount;
- } flash_access_config_t;
- typedef struct _flash_operation_config
- {
- uint32_t convertedAddress;
- uint32_t activeSectorSize;
- uint32_t activeBlockSize;
- uint32_t blockWriteUnitSize;
- uint32_t sectorCmdAddressAligment;
- uint32_t sectionCmdAddressAligment;
- uint32_t resourceCmdAddressAligment;
- uint32_t checkCmdAddressAligment;
- } flash_operation_config_t;
- typedef struct _flash_config
- {
- uint32_t PFlashBlockBase;
- uint32_t PFlashTotalSize;
- uint8_t PFlashBlockCount;
- uint8_t FlashMemoryIndex;
- uint8_t Reserved0[2];
- uint32_t PFlashSectorSize;
- uint32_t Reserved1;
- uint32_t PFlashAccessSegmentSize;
- uint32_t PFlashAccessSegmentCount;
- uint32_t *flashExecuteInRamFunctionInfo;
- uint32_t FlexRAMBlockBase;
-
- uint32_t FlexRAMTotalSize;
-
- uint32_t
- DFlashBlockBase;
-
- uint32_t DFlashTotalSize;
-
- uint32_t EEpromTotalSize;
-
- } flash_config_t;
- extern "C" {
- status_t FLASH_Init(flash_config_t *config);
- status_t FLASH_PrepareExecuteInRamFunctions(flash_config_t *config);
- status_t FLASH_EraseAll(flash_config_t *config, uint32_t key);
- status_t FLASH_Erase(flash_config_t *config, uint32_t start, uint32_t lengthInBytes, uint32_t key);
- status_t FLASH_EraseAllUnsecure(flash_config_t *config, uint32_t key);
- status_t FLASH_EraseAllExecuteOnlySegments(flash_config_t *config, uint32_t key);
- status_t FLASH_Program(flash_config_t *config, uint32_t start, uint32_t *src, uint32_t lengthInBytes);
- status_t FLASH_ProgramOnce(flash_config_t *config, uint32_t index, uint32_t *src, uint32_t lengthInBytes);
- status_t FLASH_ProgramSection(flash_config_t *config, uint32_t start, uint32_t *src, uint32_t lengthInBytes);
- status_t FLASH_EepromWrite(flash_config_t *config, uint32_t start, uint8_t *src, uint32_t lengthInBytes);
- status_t FLASH_ReadResource(
- flash_config_t *config, uint32_t start, uint32_t *dst, uint32_t lengthInBytes, flash_read_resource_option_t option);
- status_t FLASH_ReadOnce(flash_config_t *config, uint32_t index, uint32_t *dst, uint32_t lengthInBytes);
- status_t FLASH_GetSecurityState(flash_config_t *config, flash_security_state_t *state);
- status_t FLASH_SecurityBypass(flash_config_t *config, const uint8_t *backdoorKey);
- status_t FLASH_VerifyEraseAll(flash_config_t *config, flash_margin_value_t margin);
- status_t FLASH_VerifyErase(flash_config_t *config, uint32_t start, uint32_t lengthInBytes, flash_margin_value_t margin);
- status_t FLASH_VerifyProgram(flash_config_t *config,
- uint32_t start,
- uint32_t lengthInBytes,
- const uint32_t *expectedData,
- flash_margin_value_t margin,
- uint32_t *failedAddress,
- uint32_t *failedData);
- status_t FLASH_VerifyEraseAllExecuteOnlySegments(flash_config_t *config, flash_margin_value_t margin);
- status_t FLASH_IsProtected(flash_config_t *config,
- uint32_t start,
- uint32_t lengthInBytes,
- flash_protection_state_t *protection_state);
- status_t FLASH_IsExecuteOnly(flash_config_t *config,
- uint32_t start,
- uint32_t lengthInBytes,
- flash_execute_only_access_state_t *access_state);
- status_t FLASH_GetProperty(flash_config_t *config, flash_property_tag_t whichProperty, uint32_t *value);
- status_t FLASH_SetProperty(flash_config_t *config, flash_property_tag_t whichProperty, uint32_t value);
- status_t FLASH_SetFlexramFunction(flash_config_t *config, flash_flexram_function_option_t option);
- status_t FLASH_SwapControl(flash_config_t *config,
- uint32_t address,
- flash_swap_control_option_t option,
- flash_swap_state_config_t *returnInfo);
- status_t FLASH_Swap(flash_config_t *config, uint32_t address, flash_swap_function_option_t option);
- status_t FLASH_ProgramPartition(flash_config_t *config,
- flash_partition_flexram_load_option_t option,
- uint32_t eepromDataSizeCode,
- uint32_t flexnvmPartitionCode);
- status_t FLASH_PflashSetProtection(flash_config_t *config, pflash_protection_status_t *protectStatus);
- status_t FLASH_PflashGetProtection(flash_config_t *config, pflash_protection_status_t *protectStatus);
- status_t FLASH_DflashSetProtection(flash_config_t *config, uint8_t protectStatus);
- status_t FLASH_DflashGetProtection(flash_config_t *config, uint8_t *protectStatus);
- status_t FLASH_EepromSetProtection(flash_config_t *config, uint8_t protectStatus);
- status_t FLASH_EepromGetProtection(flash_config_t *config, uint8_t *protectStatus);
- status_t FLASH_PflashSetPrefetchSpeculation(flash_prefetch_speculation_status_t *speculationStatus);
- status_t FLASH_PflashGetPrefetchSpeculation(flash_prefetch_speculation_status_t *speculationStatus);
- }
|