mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers flash_data.h Source File

flash_data.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2017 ARM Limited
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 #ifndef MBED_FLASH_DATA_H
00018 #define MBED_FLASH_DATA_H
00019 
00020 #include <stdint.h>
00021 
00022 /** Target flash algorithm structure
00023  */
00024 typedef struct {
00025     const uint32_t init; /**< Init function address */
00026     const uint32_t uninit; /**< Uninit function address */
00027     const uint32_t erase_sector; /**< Erase sector function address */
00028     const uint32_t program_page; /**< Program page function address */
00029     const uint32_t static_base; /**< Static base address */
00030     uint32_t *algo_blob; /**< Pointer to flash algo binary blob */
00031 } flash_algo_t;
00032 
00033 /** Sector information structure
00034  */
00035 typedef struct {
00036     const uint32_t start; /**< Sector start address */
00037     const uint32_t size; /**< Sector size */
00038 } sector_info_t;
00039 
00040 /** Flash configuration structure
00041  */
00042 typedef struct {
00043     const uint32_t page_size; /**< The minimum program page size that can be written */
00044     const uint32_t flash_start; /**< Start address of the flash <0, flash_size) */
00045     const uint32_t flash_size; /**<  Flash size. The size is accumulative sum of all sector sizes */
00046     const sector_info_t *sectors; /**<  List of sectors - sector can vary in sizes */
00047     const uint32_t sector_info_count; /**< Number of sectors */
00048 } flash_target_config_t;
00049 
00050 /** Target flash configuration
00051  *  For targets not supporting TrustZone, its flash_set_target_config must define target_config.
00052  *  For targets supporting TrustZone, it has the following requirements:
00053  *  -# Flash IAP H/W can only configure to secure. It can access both secure/non-secure flash.
00054  *  -# Flash IAP port is for secure build only. It exports secure functions for non-secure build.
00055  *  -# In Flash IAP port, flash_set_target_config must define both target_config/target_config_ns for secure/non-secure flash respectively.
00056  *  -# Non-secure application can access its non-secure flash only through secure flash IAP functions. It cannot access secure flash.
00057  */
00058 struct flash_s {
00059     const flash_target_config_t *target_config; /**< Normal/secure flash configuration structure for targets not supporting/supporting TrustZone */
00060 #if defined(__CORTEX_M23) || defined(__CORTEX_M33)
00061     const flash_target_config_t *target_config_ns; /**< Non-secure flash configuration structure for targets supporting TrustZone */
00062 #endif
00063     const flash_algo_t *flash_algo;
00064 };
00065 
00066 /** Flash algo argument structure
00067  *  Contains all registers that should be preserved
00068  */
00069 typedef struct {
00070     uint32_t r0;
00071     uint32_t r1;
00072     uint32_t r2;
00073     uint32_t r3;
00074     uint32_t r9;
00075     uint32_t pc;
00076 } args_t;
00077 
00078 typedef int32_t (*flash_algo_jump_t)(args_t *);
00079 
00080 // prototypes for flash algo CMSIS API
00081 
00082 typedef int (*CMSIS_Algo_Function_Init)(unsigned long adr, unsigned long clk, unsigned long fnc);
00083 typedef int (*CMSIS_Algo_Function_UnInit)(unsigned long fnc);
00084 typedef int (*CMSIS_Algo_Function_EraseSector)(unsigned long adr);
00085 typedef int (*CMSIS_Algo_Function_EraseChip)(void);
00086 typedef int (*CMSIS_Algo_Function_ProgramPage)(unsigned long adr, unsigned long sz, unsigned char *buf);
00087 typedef unsigned long (*CMSIS_Algo_Function_Verify)(unsigned long adr, unsigned long sz, unsigned char *buf);
00088 
00089 #ifdef __cplusplus
00090 extern "C" {
00091 #endif
00092 
00093 /* Set target configuration
00094  */
00095 void flash_set_target_config(flash_t *obj);
00096 
00097 #ifdef __cplusplus
00098 };
00099 #endif
00100 
00101 
00102 #endif