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