mbed library sources. Supersedes mbed-src.

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

Committer:
AnnaBridge
Date:
Wed Feb 20 22:31:08 2019 +0000
Revision:
189:f392fc9709a3
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 189:f392fc9709a3 1 /* mbed Microcontroller Library
AnnaBridge 189:f392fc9709a3 2 * Copyright (c) 2017 ARM Limited
AnnaBridge 189:f392fc9709a3 3 * SPDX-License-Identifier: Apache-2.0
AnnaBridge 189:f392fc9709a3 4 *
AnnaBridge 189:f392fc9709a3 5 * Licensed under the Apache License, Version 2.0 (the "License");
AnnaBridge 189:f392fc9709a3 6 * you may not use this file except in compliance with the License.
AnnaBridge 189:f392fc9709a3 7 * You may obtain a copy of the License at
AnnaBridge 189:f392fc9709a3 8 *
AnnaBridge 189:f392fc9709a3 9 * http://www.apache.org/licenses/LICENSE-2.0
AnnaBridge 189:f392fc9709a3 10 *
AnnaBridge 189:f392fc9709a3 11 * Unless required by applicable law or agreed to in writing, software
AnnaBridge 189:f392fc9709a3 12 * distributed under the License is distributed on an "AS IS" BASIS,
AnnaBridge 189:f392fc9709a3 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
AnnaBridge 189:f392fc9709a3 14 * See the License for the specific language governing permissions and
AnnaBridge 189:f392fc9709a3 15 * limitations under the License.
AnnaBridge 189:f392fc9709a3 16 */
AnnaBridge 189:f392fc9709a3 17 #ifndef MBED_FLASH_DATA_H
AnnaBridge 189:f392fc9709a3 18 #define MBED_FLASH_DATA_H
AnnaBridge 189:f392fc9709a3 19
AnnaBridge 189:f392fc9709a3 20 #include <stdint.h>
AnnaBridge 189:f392fc9709a3 21
AnnaBridge 189:f392fc9709a3 22 /** Target flash algorithm structure
AnnaBridge 189:f392fc9709a3 23 */
AnnaBridge 189:f392fc9709a3 24 typedef struct {
AnnaBridge 189:f392fc9709a3 25 const uint32_t init; /**< Init function address */
AnnaBridge 189:f392fc9709a3 26 const uint32_t uninit; /**< Uninit function address */
AnnaBridge 189:f392fc9709a3 27 const uint32_t erase_sector; /**< Erase sector function address */
AnnaBridge 189:f392fc9709a3 28 const uint32_t program_page; /**< Program page function address */
AnnaBridge 189:f392fc9709a3 29 const uint32_t static_base; /**< Static base address */
AnnaBridge 189:f392fc9709a3 30 uint32_t *algo_blob; /**< Pointer to flash algo binary blob */
AnnaBridge 189:f392fc9709a3 31 } flash_algo_t;
AnnaBridge 189:f392fc9709a3 32
AnnaBridge 189:f392fc9709a3 33 /** Sector information structure
AnnaBridge 189:f392fc9709a3 34 */
AnnaBridge 189:f392fc9709a3 35 typedef struct {
AnnaBridge 189:f392fc9709a3 36 const uint32_t start; /**< Sector start address */
AnnaBridge 189:f392fc9709a3 37 const uint32_t size; /**< Sector size */
AnnaBridge 189:f392fc9709a3 38 } sector_info_t;
AnnaBridge 189:f392fc9709a3 39
AnnaBridge 189:f392fc9709a3 40 /** Flash configuration structure
AnnaBridge 189:f392fc9709a3 41 */
AnnaBridge 189:f392fc9709a3 42 typedef struct {
AnnaBridge 189:f392fc9709a3 43 const uint32_t page_size; /**< The minimum program page size that can be written */
AnnaBridge 189:f392fc9709a3 44 const uint32_t flash_start; /**< Start address of the flash <0, flash_size) */
AnnaBridge 189:f392fc9709a3 45 const uint32_t flash_size; /**< Flash size. The size is accumulative sum of all sector sizes */
AnnaBridge 189:f392fc9709a3 46 const sector_info_t *sectors; /**< List of sectors - sector can vary in sizes */
AnnaBridge 189:f392fc9709a3 47 const uint32_t sector_info_count; /**< Number of sectors */
AnnaBridge 189:f392fc9709a3 48 } flash_target_config_t;
AnnaBridge 189:f392fc9709a3 49
AnnaBridge 189:f392fc9709a3 50 /** Target flash configuration
AnnaBridge 189:f392fc9709a3 51 * For targets not supporting TrustZone, its flash_set_target_config must define target_config.
AnnaBridge 189:f392fc9709a3 52 * For targets supporting TrustZone, it has the following requirements:
AnnaBridge 189:f392fc9709a3 53 * -# Flash IAP H/W can only configure to secure. It can access both secure/non-secure flash.
AnnaBridge 189:f392fc9709a3 54 * -# Flash IAP port is for secure build only. It exports secure functions for non-secure build.
AnnaBridge 189:f392fc9709a3 55 * -# In Flash IAP port, flash_set_target_config must define both target_config/target_config_ns for secure/non-secure flash respectively.
AnnaBridge 189:f392fc9709a3 56 * -# Non-secure application can access its non-secure flash only through secure flash IAP functions. It cannot access secure flash.
AnnaBridge 189:f392fc9709a3 57 */
AnnaBridge 189:f392fc9709a3 58 struct flash_s {
AnnaBridge 189:f392fc9709a3 59 const flash_target_config_t *target_config; /**< Normal/secure flash configuration structure for targets not supporting/supporting TrustZone */
AnnaBridge 189:f392fc9709a3 60 #if defined(__CORTEX_M23) || defined(__CORTEX_M33)
AnnaBridge 189:f392fc9709a3 61 const flash_target_config_t *target_config_ns; /**< Non-secure flash configuration structure for targets supporting TrustZone */
AnnaBridge 189:f392fc9709a3 62 #endif
AnnaBridge 189:f392fc9709a3 63 const flash_algo_t *flash_algo;
AnnaBridge 189:f392fc9709a3 64 };
AnnaBridge 189:f392fc9709a3 65
AnnaBridge 189:f392fc9709a3 66 /** Flash algo argument structure
AnnaBridge 189:f392fc9709a3 67 * Contains all registers that should be preserved
AnnaBridge 189:f392fc9709a3 68 */
AnnaBridge 189:f392fc9709a3 69 typedef struct {
AnnaBridge 189:f392fc9709a3 70 uint32_t r0;
AnnaBridge 189:f392fc9709a3 71 uint32_t r1;
AnnaBridge 189:f392fc9709a3 72 uint32_t r2;
AnnaBridge 189:f392fc9709a3 73 uint32_t r3;
AnnaBridge 189:f392fc9709a3 74 uint32_t r9;
AnnaBridge 189:f392fc9709a3 75 uint32_t pc;
AnnaBridge 189:f392fc9709a3 76 } args_t;
AnnaBridge 189:f392fc9709a3 77
AnnaBridge 189:f392fc9709a3 78 typedef int32_t (*flash_algo_jump_t)(args_t *);
AnnaBridge 189:f392fc9709a3 79
AnnaBridge 189:f392fc9709a3 80 // prototypes for flash algo CMSIS API
AnnaBridge 189:f392fc9709a3 81
AnnaBridge 189:f392fc9709a3 82 typedef int (*CMSIS_Algo_Function_Init)(unsigned long adr, unsigned long clk, unsigned long fnc);
AnnaBridge 189:f392fc9709a3 83 typedef int (*CMSIS_Algo_Function_UnInit)(unsigned long fnc);
AnnaBridge 189:f392fc9709a3 84 typedef int (*CMSIS_Algo_Function_EraseSector)(unsigned long adr);
AnnaBridge 189:f392fc9709a3 85 typedef int (*CMSIS_Algo_Function_EraseChip)(void);
AnnaBridge 189:f392fc9709a3 86 typedef int (*CMSIS_Algo_Function_ProgramPage)(unsigned long adr, unsigned long sz, unsigned char *buf);
AnnaBridge 189:f392fc9709a3 87 typedef unsigned long (*CMSIS_Algo_Function_Verify)(unsigned long adr, unsigned long sz, unsigned char *buf);
AnnaBridge 189:f392fc9709a3 88
AnnaBridge 189:f392fc9709a3 89 #ifdef __cplusplus
AnnaBridge 189:f392fc9709a3 90 extern "C" {
AnnaBridge 189:f392fc9709a3 91 #endif
AnnaBridge 189:f392fc9709a3 92
AnnaBridge 189:f392fc9709a3 93 /* Set target configuration
AnnaBridge 189:f392fc9709a3 94 */
AnnaBridge 189:f392fc9709a3 95 void flash_set_target_config(flash_t *obj);
AnnaBridge 189:f392fc9709a3 96
AnnaBridge 189:f392fc9709a3 97 #ifdef __cplusplus
AnnaBridge 189:f392fc9709a3 98 };
AnnaBridge 189:f392fc9709a3 99 #endif
AnnaBridge 189:f392fc9709a3 100
AnnaBridge 189:f392fc9709a3 101
AnnaBridge 189:f392fc9709a3 102 #endif