mbed-dev-f303

Committer:
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4
Date:
Tue Jun 14 09:21:18 2022 +0000
Revision:
0:bdf663c61a82
lib

Who changed what in which revision?

UserRevisionLine numberNew contents of line
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 1
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 2 /** \addtogroup hal */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 3 /** @{*/
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 4 /*
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 5 * Copyright (c) 2006-2016, ARM Limited, All Rights Reserved
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 6 * SPDX-License-Identifier: Apache-2.0
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 7 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 8 * Licensed under the Apache License, Version 2.0 (the "License"); you may
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 9 * not use this file except in compliance with the License.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 10 * You may obtain a copy of the License at
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 11 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 12 * http://www.apache.org/licenses/LICENSE-2.0
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 13 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 14 * Unless required by applicable law or agreed to in writing, software
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 17 * See the License for the specific language governing permissions and
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 18 * limitations under the License.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 19 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 20
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 21 #ifndef __DRIVER_STORAGE_H
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 22 #define __DRIVER_STORAGE_H
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 23
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 24 #include <stdint.h>
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 25
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 26 /****** This file has been deprecated since mbed-os-5.5 *****/
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 27
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 28 #ifdef __cplusplus
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 29 extern "C" {
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 30 #endif // __cplusplus
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 31
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 32 #include "Driver_Common.h"
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 33
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 34 #define ARM_STORAGE_API_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(1,00) /* API version */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 35
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 36
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 37 #define _ARM_Driver_Storage_(n) Driver_Storage##n
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 38 #define ARM_Driver_Storage_(n) _ARM_Driver_Storage_(n)
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 39
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 40 #define ARM_STORAGE_INVALID_OFFSET (0xFFFFFFFFFFFFFFFFULL) ///< Invalid address (relative to a storage controller's
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 41 ///< address space). A storage block may never start at this address.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 42
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 43 #define ARM_STORAGE_INVALID_ADDRESS (0xFFFFFFFFUL) ///< Invalid address within the processor's memory address space.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 44 ///< Refer to memory-mapped storage, i.e. < \ref ARM_DRIVER_STORAGE::ResolveAddress().
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 45
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 46 /****** Storage specific error codes *****/
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 47 #define ARM_STORAGE_ERROR_NOT_ERASABLE (ARM_DRIVER_ERROR_SPECIFIC - 1) ///< Part (or all) of the range provided to Erase() isn't erasable.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 48 #define ARM_STORAGE_ERROR_NOT_PROGRAMMABLE (ARM_DRIVER_ERROR_SPECIFIC - 2) ///< Part (or all) of the range provided to ProgramData() isn't programmable.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 49 #define ARM_STORAGE_ERROR_PROTECTED (ARM_DRIVER_ERROR_SPECIFIC - 3) ///< Part (or all) of the range to Erase() or ProgramData() is protected.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 50 #define ARM_STORAGE_ERROR_RUNTIME_OR_INTEGRITY_FAILURE (ARM_DRIVER_ERROR_SPECIFIC - 4) ///< Runtime or sanity-check failure.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 51
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 52 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 53 * \brief Attributes of the storage range within a storage block.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 54 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 55 typedef struct _ARM_STORAGE_BLOCK_ATTRIBUTES {
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 56 uint32_t erasable : 1; ///< Erasing blocks is permitted with a minimum granularity of 'erase_unit'.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 57 ///< @note: if 'erasable' is 0--i.e. the 'erase' operation isn't available--then
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 58 ///< 'erase_unit' (see below) is immaterial and should be 0.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 59 uint32_t programmable : 1; ///< Writing to ranges is permitted with a minimum granularity of 'program_unit'.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 60 ///< Writes are typically achieved through the ProgramData operation (following an erase);
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 61 ///< if storage isn't erasable (see 'erasable' above) but is memory-mapped
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 62 ///< (i.e. 'memory_mapped'), it can be written directly using memory-store operations.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 63 uint32_t executable : 1; ///< This storage block can hold program data; the processor can fetch and execute code
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 64 ///< sourced from it. Often this is accompanied with the device being 'memory_mapped' (see \ref ARM_STORAGE_INFO).
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 65 uint32_t protectable : 1; ///< The entire block can be protected from program and erase operations. Once protection
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 66 ///< is enabled for a block, its 'erasable' and 'programmable' bits are turned off.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 67 uint32_t reserved : 28;
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 68 uint32_t erase_unit; ///< Minimum erase size in bytes.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 69 ///< The offset of the start of the erase-range should also be aligned with this value.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 70 ///< Applicable if the 'erasable' attribute is set for the block.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 71 ///< @note: if 'erasable' (see above) is 0--i.e. the 'erase' operation isn't available--then
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 72 ///< 'erase_unit' is immaterial and should be 0.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 73 uint32_t protection_unit; ///< Minimum protectable size in bytes. Applicable if the 'protectable'
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 74 ///< attribute is set for the block. This should be a divisor of the block's size. A
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 75 ///< block can be considered to be made up of consecutive, individually-protectable fragments.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 76 } ARM_STORAGE_BLOCK_ATTRIBUTES;
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 77
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 78 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 79 * \brief A storage block is a range of memory with uniform attributes. Storage blocks
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 80 * combine to make up the address map of a storage controller.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 81 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 82 typedef struct _ARM_STORAGE_BLOCK {
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 83 uint64_t addr; ///< This is the start address of the storage block. It is
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 84 ///< expressed as an offset from the start of the storage map
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 85 ///< maintained by the owning storage controller.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 86 uint64_t size; ///< This is the size of the storage block, in units of bytes.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 87 ///< Together with addr, it describes a range [addr, addr+size).
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 88 ARM_STORAGE_BLOCK_ATTRIBUTES attributes; ///< Attributes for this block.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 89 } ARM_STORAGE_BLOCK;
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 90
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 91 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 92 * The check for a valid ARM_STORAGE_BLOCK.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 93 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 94 #define ARM_STORAGE_VALID_BLOCK(BLK) (((BLK)->addr != ARM_STORAGE_INVALID_OFFSET) && ((BLK)->size != 0))
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 95
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 96 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 97 * \brief Values for encoding storage memory-types with respect to programmability.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 98 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 99 * Please ensure that the maximum of the following memory types doesn't exceed 16; we
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 100 * encode this in a 4-bit field within ARM_STORAGE_INFO::programmability.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 101 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 102 #define ARM_STORAGE_PROGRAMMABILITY_RAM (0x0)
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 103 #define ARM_STORAGE_PROGRAMMABILITY_ROM (0x1) ///< Read-only memory.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 104 #define ARM_STORAGE_PROGRAMMABILITY_WORM (0x2) ///< write-once-read-only-memory (WORM).
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 105 #define ARM_STORAGE_PROGRAMMABILITY_ERASABLE (0x3) ///< re-programmable based on erase. Supports multiple writes.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 106
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 107 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 108 * Values for encoding data-retention levels for storage blocks.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 109 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 110 * Please ensure that the maximum of the following retention types doesn't exceed 16; we
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 111 * encode this in a 4-bit field within ARM_STORAGE_INFO::retention_level.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 112 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 113 #define ARM_RETENTION_WHILE_DEVICE_ACTIVE (0x0) ///< Data is retained only during device activity.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 114 #define ARM_RETENTION_ACROSS_SLEEP (0x1) ///< Data is retained across processor sleep.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 115 #define ARM_RETENTION_ACROSS_DEEP_SLEEP (0x2) ///< Data is retained across processor deep-sleep.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 116 #define ARM_RETENTION_BATTERY_BACKED (0x3) ///< Data is battery-backed. Device can be powered off.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 117 #define ARM_RETENTION_NVM (0x4) ///< Data is retained in non-volatile memory.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 118
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 119 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 120 * Device Data Security Protection Features. Applicable mostly to EXTERNAL_NVM.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 121 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 122 typedef struct _ARM_STORAGE_SECURITY_FEATURES {
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 123 uint32_t acls : 1; ///< Protection against internal software attacks using ACLs.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 124 uint32_t rollback_protection : 1; ///< Roll-back protection. Set to true if the creator of the storage
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 125 ///< can ensure that an external attacker can't force an
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 126 ///< older firmware to run or to revert back to a previous state.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 127 uint32_t tamper_proof : 1; ///< Tamper-proof memory (will be deleted on tamper-attempts using board level or chip level sensors).
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 128 uint32_t internal_flash : 1; ///< Internal flash.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 129 uint32_t reserved1 : 12;
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 130
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 131 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 132 * Encode support for hardening against various classes of attacks.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 133 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 134 uint32_t software_attacks : 1; ///< device software (malware running on the device).
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 135 uint32_t board_level_attacks : 1; ///< board level attacks (debug probes, copy protection fuses.)
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 136 uint32_t chip_level_attacks : 1; ///< chip level attacks (tamper-protection).
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 137 uint32_t side_channel_attacks : 1; ///< side channel attacks.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 138 uint32_t reserved2 : 12;
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 139 } ARM_STORAGE_SECURITY_FEATURES;
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 140
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 141 #define ARM_STORAGE_PROGRAM_CYCLES_INFINITE (0UL) /**< Infinite or unknown endurance for reprogramming. */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 142
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 143 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 144 * \brief Storage information. This contains device-metadata. It is the return
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 145 * value from calling GetInfo() on the storage driver.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 146 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 147 * \details These fields serve a different purpose than the ones contained in
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 148 * \ref ARM_STORAGE_CAPABILITIES, which is another structure containing
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 149 * device-level metadata. ARM_STORAGE_CAPABILITIES describes the API
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 150 * capabilities, whereas ARM_STORAGE_INFO describes the device. Furthermore
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 151 * ARM_STORAGE_CAPABILITIES fits within a single word, and is designed to be
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 152 * passed around by value; ARM_STORAGE_INFO, on the other hand, contains
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 153 * metadata which doesn't fit into a single word and requires the use of
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 154 * pointers to be moved around.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 155 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 156 typedef struct _ARM_STORAGE_INFO {
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 157 uint64_t total_storage; ///< Total available storage, in bytes.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 158 uint32_t program_unit; ///< Minimum programming size in bytes.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 159 ///< The offset of the start of the program-range should also be aligned with this value.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 160 ///< Applicable only if the 'programmable' attribute is set for a block.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 161 ///< @note: setting program_unit to 0 has the effect of disabling the size and alignment
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 162 ///< restrictions (setting it to 1 also has the same effect).
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 163 uint32_t optimal_program_unit; ///< Optimal programming page-size in bytes. Some storage controllers
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 164 ///< have internal buffers into which to receive data. Writing in chunks of
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 165 ///< 'optimal_program_unit' would achieve maximum programming speed.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 166 ///< Applicable only if the 'programmable' attribute is set for the underlying block(s).
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 167 uint32_t program_cycles; ///< A measure of endurance for reprogramming.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 168 ///< Use ARM_STORAGE_PROGRAM_CYCLES_INFINITE for infinite or unknown endurance.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 169 uint32_t erased_value : 1; ///< Contents of erased memory (usually 1 to indicate erased bytes with state 0xFF).
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 170 uint32_t memory_mapped : 1; ///< This storage device has a mapping onto the processor's memory address space.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 171 ///< @note: For a memory-mapped block which isn't erasable but is programmable (i.e. if
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 172 ///< 'erasable' is set to 0, but 'programmable' is 1), writes should be possible directly to
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 173 ///< the memory-mapped storage without going through the ProgramData operation.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 174 uint32_t programmability : 4; ///< A value to indicate storage programmability.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 175 uint32_t retention_level : 4;
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 176 uint32_t reserved : 22;
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 177 ARM_STORAGE_SECURITY_FEATURES security; ///< \ref ARM_STORAGE_SECURITY_FEATURES
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 178 } ARM_STORAGE_INFO;
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 179
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 180 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 181 \brief Operating status of the storage controller.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 182 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 183 typedef struct _ARM_STORAGE_STATUS {
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 184 uint32_t busy : 1; ///< Controller busy flag
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 185 uint32_t error : 1; ///< Read/Program/Erase error flag (cleared on start of next operation)
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 186 } ARM_STORAGE_STATUS;
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 187
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 188 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 189 * \brief Storage Driver API Capabilities.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 190 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 191 * This data structure is designed to fit within a single word so that it can be
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 192 * fetched cheaply using a call to driver->GetCapabilities().
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 193 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 194 typedef struct _ARM_STORAGE_CAPABILITIES {
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 195 uint32_t asynchronous_ops : 1; ///< Used to indicate if APIs like initialize,
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 196 ///< read, erase, program, etc. can operate in asynchronous mode.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 197 ///< Setting this bit to 1 means that the driver is capable
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 198 ///< of launching asynchronous operations; command completion is
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 199 ///< signaled by the invocation of a completion callback. If
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 200 ///< set to 1, drivers may still complete asynchronous
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 201 ///< operations synchronously as necessary--in which case they
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 202 ///< return a positive error code to indicate synchronous completion.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 203 uint32_t erase_all : 1; ///< Supports EraseAll operation.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 204 uint32_t reserved : 30;
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 205 } ARM_STORAGE_CAPABILITIES;
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 206
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 207 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 208 * Command opcodes for Storage. Completion callbacks use these codes to refer to
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 209 * completing commands. Refer to \ref ARM_Storage_Callback_t.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 210 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 211 typedef enum _ARM_STORAGE_OPERATION {
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 212 ARM_STORAGE_OPERATION_GET_VERSION,
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 213 ARM_STORAGE_OPERATION_GET_CAPABILITIES,
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 214 ARM_STORAGE_OPERATION_INITIALIZE,
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 215 ARM_STORAGE_OPERATION_UNINITIALIZE,
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 216 ARM_STORAGE_OPERATION_POWER_CONTROL,
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 217 ARM_STORAGE_OPERATION_READ_DATA,
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 218 ARM_STORAGE_OPERATION_PROGRAM_DATA,
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 219 ARM_STORAGE_OPERATION_ERASE,
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 220 ARM_STORAGE_OPERATION_ERASE_ALL,
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 221 ARM_STORAGE_OPERATION_GET_STATUS,
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 222 ARM_STORAGE_OPERATION_GET_INFO,
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 223 ARM_STORAGE_OPERATION_RESOLVE_ADDRESS,
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 224 ARM_STORAGE_OPERATION_GET_NEXT_BLOCK,
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 225 ARM_STORAGE_OPERATION_GET_BLOCK
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 226 } ARM_STORAGE_OPERATION;
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 227
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 228 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 229 * Declaration of the callback-type for command completion.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 230 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 231 * @param [in] status
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 232 * A code to indicate the status of the completed operation. For data
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 233 * transfer operations, the status field is overloaded in case of
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 234 * success to return the count of items successfully transferred; this
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 235 * can be done safely because error codes are negative values.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 236 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 237 * @param [in] operation
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 238 * The command op-code. This value isn't essential for the callback in
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 239 * the presence of the command instance-id, but it is expected that
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 240 * this information could be a quick and useful filter.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 241 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 242 typedef void (*ARM_Storage_Callback_t)(int32_t status, ARM_STORAGE_OPERATION operation);
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 243
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 244 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 245 * This is the set of operations constituting the Storage driver. Their
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 246 * implementation is platform-specific, and needs to be supplied by the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 247 * porting effort.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 248 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 249 * Some APIs within `ARM_DRIVER_STORAGE` will always operate synchronously:
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 250 * GetVersion, GetCapabilities, GetStatus, GetInfo, ResolveAddress,
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 251 * GetNextBlock, and GetBlock. This means that control returns to the caller
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 252 * with a relevant status code only after the completion of the operation (or
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 253 * the discovery of a failure condition).
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 254 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 255 * The remainder of the APIs: Initialize, Uninitialize, PowerControl, ReadData,
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 256 * ProgramData, Erase, EraseAll, can function asynchronously if the underlying
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 257 * controller supports it--i.e. if ARM_STORAGE_CAPABILITIES::asynchronous_ops is
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 258 * set. In the case of asynchronous operation, the invocation returns early
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 259 * (with ARM_DRIVER_OK) and results in a completion callback later. If
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 260 * ARM_STORAGE_CAPABILITIES::asynchronous_ops is not set, then all such APIs
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 261 * execute synchronously, and control returns to the caller with a status code
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 262 * only after the completion of the operation (or the discovery of a failure
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 263 * condition).
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 264 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 265 * If ARM_STORAGE_CAPABILITIES::asynchronous_ops is set, a storage driver may
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 266 * still choose to execute asynchronous operations in a synchronous manner. If
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 267 * so, the driver returns a positive value to indicate successful synchronous
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 268 * completion (or an error code in case of failure) and no further invocation of
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 269 * completion callback should be expected. The expected return value for
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 270 * synchronous completion of such asynchronous operations varies depending on
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 271 * the operation. For operations involving data access, it often equals the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 272 * amount of data transferred or affected. For non data-transfer operations,
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 273 * such as EraseAll or Initialize, it is usually 1.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 274 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 275 * Here's a code snippet to suggest how asynchronous APIs might be used by
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 276 * callers to handle both synchronous and asynchronous execution by the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 277 * underlying storage driver:
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 278 * \code
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 279 * ASSERT(ARM_DRIVER_OK == 0); // this is a precondition; it doesn't need to be put in code
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 280 * int32_t returnValue = drv->asynchronousAPI(...);
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 281 * if (returnValue < ARM_DRIVER_OK) {
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 282 * // handle error.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 283 * } else if (returnValue == ARM_DRIVER_OK) {
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 284 * ASSERT(drv->GetCapabilities().asynchronous_ops == 1);
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 285 * // handle early return from asynchronous execution; remainder of the work is done in the callback handler.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 286 * } else {
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 287 * ASSERT(returnValue == EXPECTED_RETURN_VALUE_FOR_SYNCHRONOUS_COMPLETION);
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 288 * // handle synchronous completion.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 289 * }
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 290 * \endcode
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 291 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 292 typedef struct _ARM_DRIVER_STORAGE {
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 293 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 294 * \brief Get driver version.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 295 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 296 * The function GetVersion() returns version information of the driver implementation in ARM_DRIVER_VERSION.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 297 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 298 * - API version is the version of the CMSIS-Driver specification used to implement this driver.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 299 * - Driver version is source code version of the actual driver implementation.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 300 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 301 * Example:
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 302 * \code
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 303 * extern ARM_DRIVER_STORAGE *drv_info;
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 304 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 305 * void read_version (void) {
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 306 * ARM_DRIVER_VERSION version;
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 307 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 308 * version = drv_info->GetVersion ();
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 309 * if (version.api < 0x10A) { // requires at minimum API version 1.10 or higher
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 310 * // error handling
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 311 * return;
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 312 * }
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 313 * }
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 314 * \endcode
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 315 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 316 * @return \ref ARM_DRIVER_VERSION.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 317 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 318 * @note This API returns synchronously--it does not result in an invocation
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 319 * of a completion callback.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 320 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 321 * @note The function GetVersion() can be called any time to obtain the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 322 * required information from the driver (even before initialization). It
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 323 * always returns the same information.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 324 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 325 ARM_DRIVER_VERSION (*GetVersion)(void);
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 326
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 327 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 328 * \brief Get driver capabilities.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 329 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 330 * \details The function GetCapabilities() returns information about
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 331 * capabilities in this driver implementation. The data fields of the struct
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 332 * ARM_STORAGE_CAPABILITIES encode various capabilities, for example if the device
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 333 * is able to execute operations asynchronously.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 334 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 335 * Example:
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 336 * \code
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 337 * extern ARM_DRIVER_STORAGE *drv_info;
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 338 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 339 * void read_capabilities (void) {
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 340 * ARM_STORAGE_CAPABILITIES drv_capabilities;
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 341 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 342 * drv_capabilities = drv_info->GetCapabilities ();
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 343 * // interrogate capabilities
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 344 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 345 * }
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 346 * \endcode
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 347 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 348 * @return \ref ARM_STORAGE_CAPABILITIES.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 349 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 350 * @note This API returns synchronously--it does not result in an invocation
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 351 * of a completion callback.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 352 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 353 * @note The function GetCapabilities() can be called any time to obtain the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 354 * required information from the driver (even before initialization). It
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 355 * always returns the same information.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 356 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 357 ARM_STORAGE_CAPABILITIES (*GetCapabilities)(void);
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 358
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 359 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 360 * \brief Initialize the Storage Interface.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 361 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 362 * The function Initialize is called when the middleware component starts
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 363 * operation. In addition to bringing the controller to a ready state,
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 364 * Initialize() receives a callback handler to be invoked upon completion of
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 365 * asynchronous operations.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 366 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 367 * Initialize() needs to be called explicitly before
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 368 * powering the peripheral using PowerControl(), and before initiating other
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 369 * accesses to the storage controller.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 370 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 371 * The function performs the following operations:
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 372 * - Initializes the resources needed for the Storage interface.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 373 * - Registers the \ref ARM_Storage_Callback_t callback function.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 374 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 375 * To start working with a peripheral the functions Initialize and PowerControl need to be called in this order:
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 376 * drv->Initialize (...); // Allocate I/O pins
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 377 * drv->PowerControl (ARM_POWER_FULL); // Power up peripheral, setup IRQ/DMA
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 378 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 379 * - Initialize() typically allocates the I/O resources (pins) for the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 380 * peripheral. The function can be called multiple times; if the I/O resources
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 381 * are already initialized it performs no operation and just returns with
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 382 * ARM_DRIVER_OK.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 383 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 384 * - PowerControl (ARM_POWER_FULL) sets the peripheral registers including
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 385 * interrupt (NVIC) and optionally DMA. The function can be called multiple
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 386 * times; if the registers are already set it performs no operation and just
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 387 * returns with ARM_DRIVER_OK.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 388 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 389 * To stop working with a peripheral the functions PowerControl and Uninitialize need to be called in this order:
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 390 * drv->PowerControl (ARM_POWER_OFF); // Terminate any pending transfers, reset IRQ/DMA, power off peripheral
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 391 * drv->Uninitialize (...); // Release I/O pins
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 392 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 393 * The functions PowerControl and Uninitialize always execute and can be used
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 394 * to put the peripheral into a Safe State, for example after any data
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 395 * transmission errors. To restart the peripheral in an error condition,
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 396 * you should first execute the Stop Sequence and then the Start Sequence.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 397 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 398 * @param [in] callback
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 399 * Caller-defined callback to be invoked upon command completion
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 400 * for asynchronous APIs (including the completion of
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 401 * initialization). Use a NULL pointer when no callback
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 402 * signals are required.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 403 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 404 * @note This API may execute asynchronously if
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 405 * ARM_STORAGE_CAPABILITIES::asynchronous_ops is set. Asynchronous
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 406 * execution is optional even if 'asynchronous_ops' is set.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 407 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 408 * @return If asynchronous activity is launched, an invocation returns
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 409 * ARM_DRIVER_OK, and the caller can expect to receive a callback in the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 410 * future with a status value of ARM_DRIVER_OK or an error-code. In the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 411 * case of synchronous execution, control returns after completion with a
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 412 * value of 1. Return values less than ARM_DRIVER_OK (0) signify errors.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 413 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 414 int32_t (*Initialize)(ARM_Storage_Callback_t callback);
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 415
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 416 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 417 * \brief De-initialize the Storage Interface.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 418 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 419 * The function Uninitialize() de-initializes the resources of Storage interface.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 420 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 421 * It is called when the middleware component stops operation, and wishes to
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 422 * release the software resources used by the interface.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 423 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 424 * @note This API may execute asynchronously if
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 425 * ARM_STORAGE_CAPABILITIES::asynchronous_ops is set. Asynchronous
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 426 * execution is optional even if 'asynchronous_ops' is set.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 427 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 428 * @return If asynchronous activity is launched, an invocation returns
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 429 * ARM_DRIVER_OK, and the caller can expect to receive a callback in the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 430 * future with a status value of ARM_DRIVER_OK or an error-code. In the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 431 * case of synchronous execution, control returns after completion with a
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 432 * value of 1. Return values less than ARM_DRIVER_OK (0) signify errors.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 433 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 434 int32_t (*Uninitialize)(void);
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 435
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 436 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 437 * \brief Control the Storage interface power.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 438 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 439 * The function \b ARM_Storage_PowerControl operates the power modes of the Storage interface.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 440 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 441 * To start working with a peripheral the functions Initialize and PowerControl need to be called in this order:
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 442 * drv->Initialize (...); // Allocate I/O pins
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 443 * drv->PowerControl (ARM_POWER_FULL); // Power up peripheral, setup IRQ/DMA
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 444 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 445 * - Initialize() typically allocates the I/O resources (pins) for the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 446 * peripheral. The function can be called multiple times; if the I/O resources
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 447 * are already initialized it performs no operation and just returns with
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 448 * ARM_DRIVER_OK.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 449 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 450 * - PowerControl (ARM_POWER_FULL) sets the peripheral registers including
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 451 * interrupt (NVIC) and optionally DMA. The function can be called multiple
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 452 * times; if the registers are already set it performs no operation and just
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 453 * returns with ARM_DRIVER_OK.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 454 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 455 * To stop working with a peripheral the functions PowerControl and Uninitialize need to be called in this order:
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 456 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 457 * drv->PowerControl (ARM_POWER_OFF); // Terminate any pending transfers, reset IRQ/DMA, power off peripheral
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 458 * drv->Uninitialize (...); // Release I/O pins
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 459 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 460 * The functions PowerControl and Uninitialize always execute and can be used
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 461 * to put the peripheral into a Safe State, for example after any data
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 462 * transmission errors. To restart the peripheral in an error condition,
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 463 * you should first execute the Stop Sequence and then the Start Sequence.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 464 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 465 * @param state
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 466 * \ref ARM_POWER_STATE. The target power-state for the storage controller.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 467 * The parameter state can have the following values:
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 468 * - ARM_POWER_FULL : set-up peripheral for data transfers, enable interrupts
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 469 * (NVIC) and optionally DMA. Can be called multiple times. If the peripheral
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 470 * is already in this mode, then the function performs no operation and returns
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 471 * with ARM_DRIVER_OK.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 472 * - ARM_POWER_LOW : may use power saving. Returns ARM_DRIVER_ERROR_UNSUPPORTED when not implemented.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 473 * - ARM_POWER_OFF : terminates any pending data transfers, disables peripheral, disables related interrupts and DMA.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 474 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 475 * @note This API may execute asynchronously if
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 476 * ARM_STORAGE_CAPABILITIES::asynchronous_ops is set. Asynchronous
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 477 * execution is optional even if 'asynchronous_ops' is set.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 478 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 479 * @return If asynchronous activity is launched, an invocation returns
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 480 * ARM_DRIVER_OK, and the caller can expect to receive a callback in the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 481 * future with a status value of ARM_DRIVER_OK or an error-code. In the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 482 * case of synchronous execution, control returns after completion with a
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 483 * value of 1. Return values less than ARM_DRIVER_OK (0) signify errors.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 484 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 485 int32_t (*PowerControl)(ARM_POWER_STATE state);
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 486
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 487 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 488 * \brief read the contents of a given address range from the storage device.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 489 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 490 * \details Read the contents of a range of storage memory into a buffer
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 491 * supplied by the caller. The buffer is owned by the caller and should
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 492 * remain accessible for the lifetime of this command.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 493 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 494 * @param [in] addr
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 495 * This specifies the address from where to read data.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 496 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 497 * @param [out] data
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 498 * The destination of the read operation. The buffer
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 499 * is owned by the caller and should remain accessible for the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 500 * lifetime of this command.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 501 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 502 * @param [in] size
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 503 * The number of bytes requested to read. The data buffer
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 504 * should be at least as large as this size.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 505 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 506 * @note This API may execute asynchronously if
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 507 * ARM_STORAGE_CAPABILITIES::asynchronous_ops is set. Asynchronous
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 508 * execution is optional even if 'asynchronous_ops' is set.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 509 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 510 * @return If asynchronous activity is launched, an invocation returns
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 511 * ARM_DRIVER_OK, and the caller can expect to receive a callback in the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 512 * future with the number of successfully transferred bytes passed in as
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 513 * the 'status' parameter. In the case of synchronous execution, control
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 514 * returns after completion with a positive transfer-count. Return values
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 515 * less than ARM_DRIVER_OK (0) signify errors.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 516 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 517 int32_t (*ReadData)(uint64_t addr, void *data, uint32_t size);
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 518
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 519 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 520 * \brief program (write into) the contents of a given address range of the storage device.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 521 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 522 * \details Write the contents of a given memory buffer into a range of
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 523 * storage memory. In the case of flash memory, the destination range in
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 524 * storage memory typically has its contents in an erased state from a
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 525 * preceding erase operation. The source memory buffer is owned by the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 526 * caller and should remain accessible for the lifetime of this command.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 527 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 528 * @param [in] addr
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 529 * This is the start address of the range to be written into. It
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 530 * needs to be aligned to the device's \em program_unit
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 531 * specified in \ref ARM_STORAGE_INFO.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 532 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 533 * @param [in] data
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 534 * The source of the write operation. The buffer is owned by the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 535 * caller and should remain accessible for the lifetime of this
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 536 * command.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 537 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 538 * @param [in] size
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 539 * The number of bytes requested to be written. The buffer
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 540 * should be at least as large as this size. \note 'size' should
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 541 * be a multiple of the device's 'program_unit' (see \ref
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 542 * ARM_STORAGE_INFO).
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 543 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 544 * @note It is best for the middleware to write in units of
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 545 * 'optimal_program_unit' (\ref ARM_STORAGE_INFO) of the device.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 546 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 547 * @note This API may execute asynchronously if
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 548 * ARM_STORAGE_CAPABILITIES::asynchronous_ops is set. Asynchronous
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 549 * execution is optional even if 'asynchronous_ops' is set.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 550 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 551 * @return If asynchronous activity is launched, an invocation returns
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 552 * ARM_DRIVER_OK, and the caller can expect to receive a callback in the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 553 * future with the number of successfully transferred bytes passed in as
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 554 * the 'status' parameter. In the case of synchronous execution, control
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 555 * returns after completion with a positive transfer-count. Return values
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 556 * less than ARM_DRIVER_OK (0) signify errors.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 557 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 558 int32_t (*ProgramData)(uint64_t addr, const void *data, uint32_t size);
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 559
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 560 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 561 * @brief Erase Storage range.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 562 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 563 * @details This function erases a range of storage specified by [addr, addr +
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 564 * size). Both 'addr' and 'addr + size' should align with the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 565 * 'erase_unit'(s) of the respective owning storage block(s) (see \ref
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 566 * ARM_STORAGE_BLOCK and \ref ARM_STORAGE_BLOCK_ATTRIBUTES). The range to
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 567 * be erased will have its contents returned to the un-programmed state--
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 568 * i.e. to 'erased_value' (see \ref ARM_STORAGE_BLOCK_ATTRIBUTES), which
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 569 * is usually 1 to indicate the pattern of all ones: 0xFF.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 570 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 571 * @param [in] addr
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 572 * This is the start-address of the range to be erased. It must
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 573 * start at an 'erase_unit' boundary of the underlying block.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 574 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 575 * @param [in] size
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 576 * Size (in bytes) of the range to be erased. 'addr + size'
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 577 * must be aligned with the 'erase_unit' of the underlying
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 578 * block.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 579 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 580 * @note This API may execute asynchronously if
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 581 * ARM_STORAGE_CAPABILITIES::asynchronous_ops is set. Asynchronous
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 582 * execution is optional even if 'asynchronous_ops' is set.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 583 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 584 * @return
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 585 * If the range to be erased doesn't align with the erase_units of the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 586 * respective start and end blocks, ARM_DRIVER_ERROR_PARAMETER is returned.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 587 * If any part of the range is protected, ARM_STORAGE_ERROR_PROTECTED is
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 588 * returned. If any part of the range is not erasable,
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 589 * ARM_STORAGE_ERROR_NOT_ERASABLE is returned. All such sanity-check
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 590 * failures result in the error code being returned synchronously and the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 591 * storage bytes within the range remain unaffected.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 592 * Otherwise the function executes in the following ways:
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 593 * If asynchronous activity is launched, an invocation returns
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 594 * ARM_DRIVER_OK, and the caller can expect to receive a callback in the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 595 * future with the number of successfully erased bytes passed in as
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 596 * the 'status' parameter. In the case of synchronous execution, control
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 597 * returns after completion with a positive erase-count. Return values
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 598 * less than ARM_DRIVER_OK (0) signify errors.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 599 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 600 * @note Erase() may return a smaller (positive) value than the size of the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 601 * requested range. The returned value indicates the actual number of bytes
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 602 * erased. It is the caller's responsibility to follow up with an appropriate
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 603 * request to complete the operation.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 604 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 605 * @note in the case of a failed erase (except when
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 606 * ARM_DRIVER_ERROR_PARAMETER, ARM_STORAGE_ERROR_PROTECTED, or
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 607 * ARM_STORAGE_ERROR_NOT_ERASABLE is returned synchronously), the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 608 * requested range should be assumed to be in an unknown state. The
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 609 * previous contents may not be retained.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 610 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 611 int32_t (*Erase)(uint64_t addr, uint32_t size);
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 612
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 613 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 614 * @brief Erase complete storage. Optional function for faster erase of the complete device.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 615 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 616 * This optional function erases the complete device. If the device does not
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 617 * support global erase then the function returns the error value \ref
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 618 * ARM_DRIVER_ERROR_UNSUPPORTED. The data field \em 'erase_all' = 1
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 619 * of the structure \ref ARM_STORAGE_CAPABILITIES encodes that
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 620 * ARM_STORAGE_EraseAll is supported.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 621 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 622 * @note This API may execute asynchronously if
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 623 * ARM_STORAGE_CAPABILITIES::asynchronous_ops is set. Asynchronous
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 624 * execution is optional even if 'asynchronous_ops' is set.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 625 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 626 * @return
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 627 * If any part of the storage range is protected,
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 628 * ARM_STORAGE_ERROR_PROTECTED is returned. If any part of the storage
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 629 * range is not erasable, ARM_STORAGE_ERROR_NOT_ERASABLE is returned. All
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 630 * such sanity-check failures result in the error code being returned
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 631 * synchronously and the storage bytes within the range remain unaffected.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 632 * Otherwise the function executes in the following ways:
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 633 * If asynchronous activity is launched, an invocation returns
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 634 * ARM_DRIVER_OK, and the caller can expect to receive a callback in the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 635 * future with ARM_DRIVER_OK passed in as the 'status' parameter. In the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 636 * case of synchronous execution, control returns after completion with a
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 637 * value of 1. Return values less than ARM_DRIVER_OK (0) signify errors.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 638 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 639 int32_t (*EraseAll)(void);
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 640
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 641 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 642 * @brief Get the status of the current (or previous) command executed by the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 643 * storage controller; stored in the structure \ref ARM_STORAGE_STATUS.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 644 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 645 * @return
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 646 * The status of the underlying controller.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 647 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 648 * @note This API returns synchronously--it does not result in an invocation
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 649 * of a completion callback.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 650 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 651 ARM_STORAGE_STATUS (*GetStatus)(void);
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 652
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 653 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 654 * @brief Get information about the Storage device; stored in the structure \ref ARM_STORAGE_INFO.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 655 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 656 * @param [out] info
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 657 * A caller-supplied buffer capable of being filled in with an
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 658 * \ref ARM_STORAGE_INFO.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 659 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 660 * @return ARM_DRIVER_OK if a ARM_STORAGE_INFO structure containing top level
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 661 * metadata about the storage controller is filled into the supplied
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 662 * buffer, else an appropriate error value.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 663 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 664 * @note It is the caller's responsibility to ensure that the buffer passed in
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 665 * is able to be initialized with a \ref ARM_STORAGE_INFO.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 666 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 667 * @note This API returns synchronously--it does not result in an invocation
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 668 * of a completion callback.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 669 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 670 int32_t (*GetInfo)(ARM_STORAGE_INFO *info);
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 671
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 672 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 673 * \brief For memory-mapped storage, resolve an address relative to
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 674 * the storage controller into a memory address.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 675 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 676 * @param addr
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 677 * This is the address for which we want a resolution to the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 678 * processor's physical address space. It is an offset from the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 679 * start of the storage map maintained by the owning storage
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 680 * controller.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 681 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 682 * @return
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 683 * The resolved address in the processor's address space; else
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 684 * ARM_STORAGE_INVALID_ADDRESS, if no resolution is possible.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 685 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 686 * @note This API returns synchronously. The invocation should return quickly,
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 687 * and result in a resolved address.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 688 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 689 uint32_t (*ResolveAddress)(uint64_t addr);
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 690
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 691 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 692 * @brief Advance to the successor of the current block (iterator), or fetch
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 693 * the first block (if 'prev_block' is passed in as NULL).
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 694 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 695 * @details This helper function fetches (an iterator to) the next block (or
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 696 * the first block if 'prev_block' is passed in as NULL). In the failure
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 697 * case, a terminating, invalid block iterator is filled into the out
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 698 * parameter: 'next_block'. In combination with \ref
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 699 * ARM_STORAGE_VALID_BLOCK(), it can be used to iterate over the sequence
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 700 * of blocks within the storage map:
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 701 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 702 * \code
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 703 * ARM_STORAGE_BLOCK block;
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 704 * for (drv->GetNextBlock(NULL, &block); ARM_STORAGE_VALID_BLOCK(&block); drv->GetNextBlock(&block, &block)) {
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 705 * // make use of block
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 706 * }
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 707 * \endcode
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 708 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 709 * @param[in] prev_block
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 710 * An existing block (iterator) within the same storage
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 711 * controller. The memory buffer holding this block is owned
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 712 * by the caller. This pointer may be NULL; if so, the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 713 * invocation fills in the first block into the out parameter:
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 714 * 'next_block'.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 715 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 716 * @param[out] next_block
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 717 * A caller-owned buffer large enough to be filled in with
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 718 * the following ARM_STORAGE_BLOCK. It is legal to provide the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 719 * same buffer using 'next_block' as was passed in with 'prev_block'. It
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 720 * is also legal to pass a NULL into this parameter if the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 721 * caller isn't interested in populating a buffer with the next
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 722 * block--i.e. if the caller only wishes to establish the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 723 * presence of a next block.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 724 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 725 * @return ARM_DRIVER_OK if a valid next block is found (or first block, if
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 726 * prev_block is passed as NULL); upon successful operation, the contents
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 727 * of the next (or first) block are filled into the buffer pointed to by
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 728 * the parameter 'next_block' and ARM_STORAGE_VALID_BLOCK(next_block) is
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 729 * guaranteed to be true. Upon reaching the end of the sequence of blocks
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 730 * (iterators), or in case the driver is unable to fetch information about
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 731 * the next (or first) block, an error (negative) value is returned and an
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 732 * invalid StorageBlock is populated into the supplied buffer. If
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 733 * prev_block is NULL, the first block is returned.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 734 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 735 * @note This API returns synchronously--it does not result in an invocation
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 736 * of a completion callback.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 737 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 738 int32_t (*GetNextBlock)(const ARM_STORAGE_BLOCK* prev_block, ARM_STORAGE_BLOCK *next_block);
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 739
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 740 /**
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 741 * @brief Find the storage block (iterator) encompassing a given storage address.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 742 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 743 * @param[in] addr
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 744 * Storage address in bytes.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 745 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 746 * @param[out] block
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 747 * A caller-owned buffer large enough to be filled in with the
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 748 * ARM_STORAGE_BLOCK encapsulating the given address. This value
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 749 * can also be passed in as NULL if the caller isn't interested
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 750 * in populating a buffer with the block--if the caller only
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 751 * wishes to establish the presence of a containing storage
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 752 * block.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 753 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 754 * @return ARM_DRIVER_OK if a containing storage-block is found. In this case,
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 755 * if block is non-NULL, the buffer pointed to by it is populated with
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 756 * the contents of the storage block--i.e. if block is valid and a block is
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 757 * found, ARM_STORAGE_VALID_BLOCK(block) would return true following this
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 758 * call. If there is no storage block containing the given offset, or in
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 759 * case the driver is unable to resolve an address to a storage-block, an
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 760 * error (negative) value is returned and an invalid StorageBlock is
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 761 * populated into the supplied buffer.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 762 *
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 763 * @note This API returns synchronously--it does not result in an invocation
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 764 * of a completion callback.
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 765 */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 766 int32_t (*GetBlock)(uint64_t addr, ARM_STORAGE_BLOCK *block);
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 767 } const ARM_DRIVER_STORAGE;
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 768
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 769 #ifdef __cplusplus
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 770 }
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 771 #endif // __cplusplus
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 772
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 773 #endif /* __DRIVER_STORAGE_H */
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 774
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 775 /** @}*/
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 0:bdf663c61a82 776