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