Example
Dependencies: FXAS21002 FXOS8700Q
simple-mbed-cloud-client/mbed-cloud-client/update-client-hub/modules/manifest-manager/update-client-manifest-manager/update-client-manifest-manager-context.h@0:11cc2b7889af, 2019-11-19 (annotated)
- Committer:
- maygup01
- Date:
- Tue Nov 19 09:49:38 2019 +0000
- Revision:
- 0:11cc2b7889af
Example
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
maygup01 | 0:11cc2b7889af | 1 | // ---------------------------------------------------------------------------- |
maygup01 | 0:11cc2b7889af | 2 | // Copyright 2016-2017 ARM Ltd. |
maygup01 | 0:11cc2b7889af | 3 | // |
maygup01 | 0:11cc2b7889af | 4 | // SPDX-License-Identifier: Apache-2.0 |
maygup01 | 0:11cc2b7889af | 5 | // |
maygup01 | 0:11cc2b7889af | 6 | // Licensed under the Apache License, Version 2.0 (the "License"); |
maygup01 | 0:11cc2b7889af | 7 | // you may not use this file except in compliance with the License. |
maygup01 | 0:11cc2b7889af | 8 | // You may obtain a copy of the License at |
maygup01 | 0:11cc2b7889af | 9 | // |
maygup01 | 0:11cc2b7889af | 10 | // http://www.apache.org/licenses/LICENSE-2.0 |
maygup01 | 0:11cc2b7889af | 11 | // |
maygup01 | 0:11cc2b7889af | 12 | // Unless required by applicable law or agreed to in writing, software |
maygup01 | 0:11cc2b7889af | 13 | // distributed under the License is distributed on an "AS IS" BASIS, |
maygup01 | 0:11cc2b7889af | 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
maygup01 | 0:11cc2b7889af | 15 | // See the License for the specific language governing permissions and |
maygup01 | 0:11cc2b7889af | 16 | // limitations under the License. |
maygup01 | 0:11cc2b7889af | 17 | // ---------------------------------------------------------------------------- |
maygup01 | 0:11cc2b7889af | 18 | |
maygup01 | 0:11cc2b7889af | 19 | #ifndef ARM_UC_MM_CONTEXT_TYPES_H |
maygup01 | 0:11cc2b7889af | 20 | #define ARM_UC_MM_CONTEXT_TYPES_H |
maygup01 | 0:11cc2b7889af | 21 | |
maygup01 | 0:11cc2b7889af | 22 | #include "update-client-manifest-manager/update-client-manifest-types.h" |
maygup01 | 0:11cc2b7889af | 23 | #include "update-client-manifest-manager/../source/arm_uc_mmConfig.h" |
maygup01 | 0:11cc2b7889af | 24 | #include "update-client-common/arm_uc_error.h" |
maygup01 | 0:11cc2b7889af | 25 | #include "update-client-common/arm_uc_types.h" |
maygup01 | 0:11cc2b7889af | 26 | #include "update-client-common/arm_uc_config.h" |
maygup01 | 0:11cc2b7889af | 27 | #include "update-client-common/arm_uc_scheduler.h" |
maygup01 | 0:11cc2b7889af | 28 | #include "update-client-manifest-manager/arm-pal-kv.h" |
maygup01 | 0:11cc2b7889af | 29 | |
maygup01 | 0:11cc2b7889af | 30 | |
maygup01 | 0:11cc2b7889af | 31 | struct arm_uc_mmInitContext_t { |
maygup01 | 0:11cc2b7889af | 32 | uint64_t timestamp; |
maygup01 | 0:11cc2b7889af | 33 | uint32_t state; |
maygup01 | 0:11cc2b7889af | 34 | arm_uc_buffer_t manifest; |
maygup01 | 0:11cc2b7889af | 35 | arm_uc_buffer_t keyPath; |
maygup01 | 0:11cc2b7889af | 36 | uint32_t loopCounters[1]; |
maygup01 | 0:11cc2b7889af | 37 | |
maygup01 | 0:11cc2b7889af | 38 | arm_uc_callback_t callbackStorage; // initialized in hub |
maygup01 | 0:11cc2b7889af | 39 | struct { |
maygup01 | 0:11cc2b7889af | 40 | unsigned root: 1; |
maygup01 | 0:11cc2b7889af | 41 | unsigned depidx: 3; |
maygup01 | 0:11cc2b7889af | 42 | unsigned missingDep: 1; |
maygup01 | 0:11cc2b7889af | 43 | }; |
maygup01 | 0:11cc2b7889af | 44 | uint8_t rootManifestBasePath[sizeof(MANIFEST_PREFIX "..") + CFSTORE_HASH_ID_SIZE]; |
maygup01 | 0:11cc2b7889af | 45 | uint8_t pathBuffer[220]; |
maygup01 | 0:11cc2b7889af | 46 | uint8_t manifestBuffer[640]; |
maygup01 | 0:11cc2b7889af | 47 | uint8_t currentHash [MAX_HASH_BYTES]; |
maygup01 | 0:11cc2b7889af | 48 | |
maygup01 | 0:11cc2b7889af | 49 | }; |
maygup01 | 0:11cc2b7889af | 50 | |
maygup01 | 0:11cc2b7889af | 51 | struct arm_uc_mm_get_latest_ts_context { |
maygup01 | 0:11cc2b7889af | 52 | uint64_t current_ts; |
maygup01 | 0:11cc2b7889af | 53 | uint64_t *max_ts; |
maygup01 | 0:11cc2b7889af | 54 | uint32_t state; |
maygup01 | 0:11cc2b7889af | 55 | arm_uc_buffer_t current_data; |
maygup01 | 0:11cc2b7889af | 56 | arm_uc_buffer_t max_ts_key; |
maygup01 | 0:11cc2b7889af | 57 | }; |
maygup01 | 0:11cc2b7889af | 58 | |
maygup01 | 0:11cc2b7889af | 59 | enum arm_uc_mm_pk_sig_state { |
maygup01 | 0:11cc2b7889af | 60 | UCMM_PKSIG_STATE_INVALID = 0, |
maygup01 | 0:11cc2b7889af | 61 | UCMM_PKSIG_STATE_IDLE, |
maygup01 | 0:11cc2b7889af | 62 | UCMM_PKSIG_STATE_FIND_CA, |
maygup01 | 0:11cc2b7889af | 63 | UCMM_PKSIG_STATE_FINDING_CA, |
maygup01 | 0:11cc2b7889af | 64 | UCMM_PKSIG_STATE_CHECK, |
maygup01 | 0:11cc2b7889af | 65 | }; |
maygup01 | 0:11cc2b7889af | 66 | |
maygup01 | 0:11cc2b7889af | 67 | enum arm_uc_mm_psk_sig_state { |
maygup01 | 0:11cc2b7889af | 68 | ARM_UC_MM_PSKSIG_STATE_INVALID = 0, |
maygup01 | 0:11cc2b7889af | 69 | ARM_UC_MM_PSKSIG_STATE_IDLE, |
maygup01 | 0:11cc2b7889af | 70 | ARM_UC_MM_PSKSIG_STATE_FIND_PSK, |
maygup01 | 0:11cc2b7889af | 71 | ARM_UC_MM_PSKSIG_STATE_FINDING_PSK, |
maygup01 | 0:11cc2b7889af | 72 | ARM_UC_MM_PSKSIG_STATE_FIND_SIG_START, |
maygup01 | 0:11cc2b7889af | 73 | ARM_UC_MM_PSKSIG_STATE_FIND_SIG, |
maygup01 | 0:11cc2b7889af | 74 | ARM_UC_MM_PSKSIG_STATE_VERIFY, |
maygup01 | 0:11cc2b7889af | 75 | }; |
maygup01 | 0:11cc2b7889af | 76 | |
maygup01 | 0:11cc2b7889af | 77 | typedef struct arm_uc_mm_validate_signature_context { |
maygup01 | 0:11cc2b7889af | 78 | union { |
maygup01 | 0:11cc2b7889af | 79 | enum arm_uc_mm_pk_sig_state pk_state; |
maygup01 | 0:11cc2b7889af | 80 | enum arm_uc_mm_psk_sig_state psk_state; |
maygup01 | 0:11cc2b7889af | 81 | }; |
maygup01 | 0:11cc2b7889af | 82 | void (* applicationEventHandler)(uintptr_t); |
maygup01 | 0:11cc2b7889af | 83 | union { |
maygup01 | 0:11cc2b7889af | 84 | #if defined(ARM_UC_FEATURE_MANIFEST_PUBKEY) && (ARM_UC_FEATURE_MANIFEST_PUBKEY == 1) |
maygup01 | 0:11cc2b7889af | 85 | struct { |
maygup01 | 0:11cc2b7889af | 86 | arm_uc_buffer_t fingerprint; |
maygup01 | 0:11cc2b7889af | 87 | arm_uc_buffer_t certList; |
maygup01 | 0:11cc2b7889af | 88 | arm_uc_buffer_t cert; |
maygup01 | 0:11cc2b7889af | 89 | }; |
maygup01 | 0:11cc2b7889af | 90 | #endif /* ARM_UC_FEATURE_MANIFEST_PUBKEY */ |
maygup01 | 0:11cc2b7889af | 91 | #if defined(ARM_UC_FEATURE_MANIFEST_PSK) && (ARM_UC_FEATURE_MANIFEST_PSK == 1) |
maygup01 | 0:11cc2b7889af | 92 | struct { |
maygup01 | 0:11cc2b7889af | 93 | arm_uc_buffer_t PSKid; |
maygup01 | 0:11cc2b7889af | 94 | int keyTableVersion; |
maygup01 | 0:11cc2b7889af | 95 | arm_uc_buffer_t keyTableRef; |
maygup01 | 0:11cc2b7889af | 96 | arm_uc_buffer_t keyTableIV; |
maygup01 | 0:11cc2b7889af | 97 | arm_uc_buffer_t PSK; |
maygup01 | 0:11cc2b7889af | 98 | arm_uc_buffer_t cipherText; |
maygup01 | 0:11cc2b7889af | 99 | }; |
maygup01 | 0:11cc2b7889af | 100 | #endif /* ARM_UC_FEATURE_MANIFEST_PSK */ |
maygup01 | 0:11cc2b7889af | 101 | }; |
maygup01 | 0:11cc2b7889af | 102 | arm_uc_buffer_t *manifest; |
maygup01 | 0:11cc2b7889af | 103 | arm_uc_error_t storedError; |
maygup01 | 0:11cc2b7889af | 104 | uint32_t sigIndex; |
maygup01 | 0:11cc2b7889af | 105 | uint32_t encryptionMode; |
maygup01 | 0:11cc2b7889af | 106 | } arm_uc_mm_validate_signature_context_t; |
maygup01 | 0:11cc2b7889af | 107 | |
maygup01 | 0:11cc2b7889af | 108 | #define ARM_UC_MM_FW_STATE_LIST\ |
maygup01 | 0:11cc2b7889af | 109 | ENUM_FIXED(ARM_UC_MM_FW_STATE_INVALID,0)\ |
maygup01 | 0:11cc2b7889af | 110 | ENUM_AUTO(ARM_UC_MM_FW_STATE_IDLE)\ |
maygup01 | 0:11cc2b7889af | 111 | ENUM_AUTO(ARM_UC_MM_FW_STATE_BEGIN)\ |
maygup01 | 0:11cc2b7889af | 112 | ENUM_AUTO(ARM_UC_MM_FW_STATE_FIND_ROOT)\ |
maygup01 | 0:11cc2b7889af | 113 | ENUM_AUTO(ARM_UC_MM_FW_STATE_FETCH_TS)\ |
maygup01 | 0:11cc2b7889af | 114 | ENUM_AUTO(ARM_UC_MM_FW_STATE_FETCH_NAME)\ |
maygup01 | 0:11cc2b7889af | 115 | ENUM_AUTO(ARM_UC_MM_FW_STATE_FIND_NEXT_ROOT)\ |
maygup01 | 0:11cc2b7889af | 116 | ENUM_AUTO(ARM_UC_MM_FW_STATE_FORMAT_ROOT_PREFIX)\ |
maygup01 | 0:11cc2b7889af | 117 | ENUM_AUTO(ARM_UC_MM_FW_STATE_FIND_MANIFEST)\ |
maygup01 | 0:11cc2b7889af | 118 | ENUM_AUTO(ARM_UC_MM_FW_STATE_READ_MANIFEST)\ |
maygup01 | 0:11cc2b7889af | 119 | ENUM_AUTO(ARM_UC_MM_FW_STATE_FETCH_ROOT)\ |
maygup01 | 0:11cc2b7889af | 120 | ENUM_AUTO(ARM_UC_MM_FW_STATE_FIND_URI)\ |
maygup01 | 0:11cc2b7889af | 121 | ENUM_AUTO(ARM_UC_MM_FW_STATE_READ_URI)\ |
maygup01 | 0:11cc2b7889af | 122 | ENUM_AUTO(ARM_UC_MM_FW_STATE_FETCH_URI_KEY)\ |
maygup01 | 0:11cc2b7889af | 123 | ENUM_AUTO(ARM_UC_MM_FW_STATE_FETCH_HASH)\ |
maygup01 | 0:11cc2b7889af | 124 | ENUM_AUTO(ARM_UC_MM_FW_STATE_FETCH_DEP_URI)\ |
maygup01 | 0:11cc2b7889af | 125 | ENUM_AUTO(ARM_UC_MM_FW_STATE_FETCH_DEP_HASH)\ |
maygup01 | 0:11cc2b7889af | 126 | ENUM_AUTO(ARM_UC_MM_FW_STATE_GET_FW_REF)\ |
maygup01 | 0:11cc2b7889af | 127 | ENUM_AUTO(ARM_UC_MM_FW_STATE_NOTIFY)\ |
maygup01 | 0:11cc2b7889af | 128 | ENUM_AUTO(ARM_UC_MM_FW_STATE_ROOT_NOTIFY_WAIT)\ |
maygup01 | 0:11cc2b7889af | 129 | ENUM_AUTO(ARM_UC_MM_FW_STATE_NEXT_IMAGE)\ |
maygup01 | 0:11cc2b7889af | 130 | ENUM_AUTO(ARM_UC_MM_FW_STATE_DONE)\ |
maygup01 | 0:11cc2b7889af | 131 | |
maygup01 | 0:11cc2b7889af | 132 | |
maygup01 | 0:11cc2b7889af | 133 | enum arm_uc_mm_fw_state { |
maygup01 | 0:11cc2b7889af | 134 | #define ENUM_AUTO(name) name, |
maygup01 | 0:11cc2b7889af | 135 | #define ENUM_FIXED(name, val) name = val, |
maygup01 | 0:11cc2b7889af | 136 | ARM_UC_MM_FW_STATE_LIST |
maygup01 | 0:11cc2b7889af | 137 | #undef ENUM_AUTO |
maygup01 | 0:11cc2b7889af | 138 | #undef ENUM_FIXED |
maygup01 | 0:11cc2b7889af | 139 | }; |
maygup01 | 0:11cc2b7889af | 140 | |
maygup01 | 0:11cc2b7889af | 141 | struct arm_uc_mm_fw_context_t { |
maygup01 | 0:11cc2b7889af | 142 | struct arm_uc_mm_get_latest_ts_context getLatestTs; |
maygup01 | 0:11cc2b7889af | 143 | uint64_t ts; |
maygup01 | 0:11cc2b7889af | 144 | arm_uc_manifest_handle_t *ID; |
maygup01 | 0:11cc2b7889af | 145 | enum arm_uc_mm_fw_state state; |
maygup01 | 0:11cc2b7889af | 146 | struct manifest_firmware_info_t *info; |
maygup01 | 0:11cc2b7889af | 147 | arm_uc_callback_t callbackStorage; // initialized in hub |
maygup01 | 0:11cc2b7889af | 148 | arm_uc_buffer_t current_data; |
maygup01 | 0:11cc2b7889af | 149 | char hashIDbuffer[CFSTORE_HASH_ID_SIZE]; |
maygup01 | 0:11cc2b7889af | 150 | uint8_t keyBuffer[ARM_PAL_KV_KEY_MAX_PATH]; |
maygup01 | 0:11cc2b7889af | 151 | }; |
maygup01 | 0:11cc2b7889af | 152 | |
maygup01 | 0:11cc2b7889af | 153 | #define ARM_UC_MM_INS_STATE_LIST\ |
maygup01 | 0:11cc2b7889af | 154 | ENUM_FIXED(ARM_UC_MM_INS_STATE_INVALID,0)\ |
maygup01 | 0:11cc2b7889af | 155 | ENUM_AUTO(ARM_UC_MM_INS_STATE_IDLE)\ |
maygup01 | 0:11cc2b7889af | 156 | ENUM_AUTO(ARM_UC_MM_INS_STATE_BEGIN)\ |
maygup01 | 0:11cc2b7889af | 157 | ENUM_AUTO(ARM_UC_MM_INS_STATE_VERIFY_BASIC_PARAMS)\ |
maygup01 | 0:11cc2b7889af | 158 | ENUM_AUTO(ARM_UC_MM_INS_STATE_HASH_VERIFY)\ |
maygup01 | 0:11cc2b7889af | 159 | ENUM_AUTO(ARM_UC_MM_INS_STATE_VERIFY_SIG_LOOP)\ |
maygup01 | 0:11cc2b7889af | 160 | ENUM_AUTO(ARM_UC_MM_INS_STATE_VERIFY_SIG_START)\ |
maygup01 | 0:11cc2b7889af | 161 | ENUM_AUTO(ARM_UC_MM_INS_STATE_VERIFY_SIG_WAIT)\ |
maygup01 | 0:11cc2b7889af | 162 | ENUM_AUTO(ARM_UC_MM_INS_STATE_VERIFY_PARAMS)\ |
maygup01 | 0:11cc2b7889af | 163 | ENUM_AUTO(ARM_UC_MM_INS_STATE_VERIFY_APP)\ |
maygup01 | 0:11cc2b7889af | 164 | ENUM_AUTO(ARM_UC_MM_INS_STATE_VERIFY_FAIL)\ |
maygup01 | 0:11cc2b7889af | 165 | ENUM_AUTO(ARM_UC_MM_INS_STATE_VERIFY_DONE)\ |
maygup01 | 0:11cc2b7889af | 166 | ENUM_AUTO(ARM_UC_MM_INS_STATE_STORE_BEGIN)\ |
maygup01 | 0:11cc2b7889af | 167 | ENUM_AUTO(ARM_UC_MM_INS_STATE_MATCHING)\ |
maygup01 | 0:11cc2b7889af | 168 | ENUM_AUTO(ARM_UC_MM_INS_STATE_MATCH_FETCHING)\ |
maygup01 | 0:11cc2b7889af | 169 | ENUM_AUTO(ARM_UC_MM_INS_STATE_STORE_MANIFEST_BEGIN)\ |
maygup01 | 0:11cc2b7889af | 170 | ENUM_AUTO(ARM_UC_MM_INS_STATE_STORE_MANIFEST)\ |
maygup01 | 0:11cc2b7889af | 171 | ENUM_AUTO(ARM_UC_MM_INS_STATE_STORE_FW_URI)\ |
maygup01 | 0:11cc2b7889af | 172 | ENUM_AUTO(ARM_UC_MM_INS_STATE_STORE_FW_HASH)\ |
maygup01 | 0:11cc2b7889af | 173 | ENUM_AUTO(ARM_UC_MM_INS_STATE_STORE_AES)\ |
maygup01 | 0:11cc2b7889af | 174 | ENUM_AUTO(ARM_UC_MM_INS_STATE_STORE_DEPS)\ |
maygup01 | 0:11cc2b7889af | 175 | ENUM_AUTO(ARM_UC_MM_INS_STATE_DEPSTART)\ |
maygup01 | 0:11cc2b7889af | 176 | ENUM_AUTO(ARM_UC_MM_INS_STATE_DEP_WAITING)\ |
maygup01 | 0:11cc2b7889af | 177 | ENUM_AUTO(ARM_UC_MM_INS_STATE_COMPLETION)\ |
maygup01 | 0:11cc2b7889af | 178 | ENUM_AUTO(ARM_UC_MM_INS_STATE_COMPLETION_FINDING)\ |
maygup01 | 0:11cc2b7889af | 179 | ENUM_AUTO(ARM_UC_MM_INS_STATE_VERIFY_TS_START)\ |
maygup01 | 0:11cc2b7889af | 180 | ENUM_AUTO(ARM_UC_MM_INS_STATE_VERIFY_TS)\ |
maygup01 | 0:11cc2b7889af | 181 | ENUM_AUTO(ARM_UC_MM_INS_STATE_STORE_TS_START)\ |
maygup01 | 0:11cc2b7889af | 182 | ENUM_AUTO(ARM_UC_MM_INS_STATE_STORE_TS)\ |
maygup01 | 0:11cc2b7889af | 183 | ENUM_AUTO(ARM_UC_MM_INS_STATE_DEP_CHECK)\ |
maygup01 | 0:11cc2b7889af | 184 | ENUM_AUTO(ARM_UC_MM_INS_STATE_DEP_CHECKING)\ |
maygup01 | 0:11cc2b7889af | 185 | ENUM_AUTO(ARM_UC_MM_INS_STATE_DEP_DELETE)\ |
maygup01 | 0:11cc2b7889af | 186 | ENUM_AUTO(ARM_UC_MM_INS_STATE_DONE)\ |
maygup01 | 0:11cc2b7889af | 187 | ENUM_AUTO(ARM_UC_MM_INS_STATE_ALERT)\ |
maygup01 | 0:11cc2b7889af | 188 | |
maygup01 | 0:11cc2b7889af | 189 | |
maygup01 | 0:11cc2b7889af | 190 | enum arm_uc_mm_insert_state { |
maygup01 | 0:11cc2b7889af | 191 | #define ENUM_AUTO(name) name, |
maygup01 | 0:11cc2b7889af | 192 | #define ENUM_FIXED(name, val) name = val, |
maygup01 | 0:11cc2b7889af | 193 | ARM_UC_MM_INS_STATE_LIST |
maygup01 | 0:11cc2b7889af | 194 | #undef ENUM_AUTO |
maygup01 | 0:11cc2b7889af | 195 | #undef ENUM_FIXED |
maygup01 | 0:11cc2b7889af | 196 | }; |
maygup01 | 0:11cc2b7889af | 197 | |
maygup01 | 0:11cc2b7889af | 198 | struct arm_uc_mmInsertContext_t { |
maygup01 | 0:11cc2b7889af | 199 | struct arm_uc_mm_get_latest_ts_context getLatestTs; |
maygup01 | 0:11cc2b7889af | 200 | arm_uc_mm_validate_signature_context_t signatureContext; |
maygup01 | 0:11cc2b7889af | 201 | uint64_t max_ts; |
maygup01 | 0:11cc2b7889af | 202 | uint64_t current_ts; |
maygup01 | 0:11cc2b7889af | 203 | arm_uc_manifest_handle_t *ID; |
maygup01 | 0:11cc2b7889af | 204 | enum arm_uc_mm_insert_state state; |
maygup01 | 0:11cc2b7889af | 205 | arm_uc_callback_t callbackStorage; // initialized in hub |
maygup01 | 0:11cc2b7889af | 206 | arm_uc_buffer_t manifest; |
maygup01 | 0:11cc2b7889af | 207 | arm_uc_mm_crypto_flags_t cryptoMode; |
maygup01 | 0:11cc2b7889af | 208 | arm_uc_buffer_t certificateStorage; |
maygup01 | 0:11cc2b7889af | 209 | uint32_t loopCounters[1]; |
maygup01 | 0:11cc2b7889af | 210 | }; |
maygup01 | 0:11cc2b7889af | 211 | |
maygup01 | 0:11cc2b7889af | 212 | struct arm_uc_mmContext_t { |
maygup01 | 0:11cc2b7889af | 213 | // Operational Contexts |
maygup01 | 0:11cc2b7889af | 214 | union { |
maygup01 | 0:11cc2b7889af | 215 | struct arm_uc_mmInitContext_t init; |
maygup01 | 0:11cc2b7889af | 216 | struct arm_uc_mm_fw_context_t getFw; |
maygup01 | 0:11cc2b7889af | 217 | struct arm_uc_mmInsertContext_t insert; |
maygup01 | 0:11cc2b7889af | 218 | }; |
maygup01 | 0:11cc2b7889af | 219 | }; |
maygup01 | 0:11cc2b7889af | 220 | typedef struct arm_uc_mmContext_t arm_uc_mmContext_t; |
maygup01 | 0:11cc2b7889af | 221 | |
maygup01 | 0:11cc2b7889af | 222 | |
maygup01 | 0:11cc2b7889af | 223 | enum arm_uc_mmState_t { |
maygup01 | 0:11cc2b7889af | 224 | ARM_UC_MM_STATE_INVALID = 0, |
maygup01 | 0:11cc2b7889af | 225 | ARM_UC_MM_STATE_IDLE, |
maygup01 | 0:11cc2b7889af | 226 | ARM_UC_MM_STATE_INIT, |
maygup01 | 0:11cc2b7889af | 227 | ARM_UC_MM_STATE_INSERTING, |
maygup01 | 0:11cc2b7889af | 228 | ARM_UC_MM_STATE_STORING_CA, |
maygup01 | 0:11cc2b7889af | 229 | ARM_UC_MM_STATE_FWINFO, |
maygup01 | 0:11cc2b7889af | 230 | ARM_UC_MM_STATE_TEST, |
maygup01 | 0:11cc2b7889af | 231 | }; |
maygup01 | 0:11cc2b7889af | 232 | |
maygup01 | 0:11cc2b7889af | 233 | typedef void (*ARM_UC_mmTestHook_t)(const char *, arm_uc_mmContext_t *, uint32_t, uint32_t, arm_uc_error_t); |
maygup01 | 0:11cc2b7889af | 234 | |
maygup01 | 0:11cc2b7889af | 235 | struct arm_uc_mmPersistentContext_t { |
maygup01 | 0:11cc2b7889af | 236 | enum arm_uc_mmState_t state; |
maygup01 | 0:11cc2b7889af | 237 | arm_uc_error_t reportedError; |
maygup01 | 0:11cc2b7889af | 238 | const char *errorFile; |
maygup01 | 0:11cc2b7889af | 239 | uint32_t errorLine; |
maygup01 | 0:11cc2b7889af | 240 | struct arm_uc_mmContext_t **ctx; |
maygup01 | 0:11cc2b7889af | 241 | arm_uc_callback_t applicationCallbackStorage; // initialized in mmCommon |
maygup01 | 0:11cc2b7889af | 242 | void (*applicationEventHandler)(uintptr_t); |
maygup01 | 0:11cc2b7889af | 243 | arm_uc_error_t (*testFSM)(uint32_t event); |
maygup01 | 0:11cc2b7889af | 244 | #if ARM_UC_MM_ENABLE_TEST_VECTORS |
maygup01 | 0:11cc2b7889af | 245 | ARM_UC_mmTestHook_t testHook; |
maygup01 | 0:11cc2b7889af | 246 | #endif |
maygup01 | 0:11cc2b7889af | 247 | }; |
maygup01 | 0:11cc2b7889af | 248 | |
maygup01 | 0:11cc2b7889af | 249 | typedef struct arm_uc_mmPersistentContext_t arm_uc_mmPersistentContext_t; |
maygup01 | 0:11cc2b7889af | 250 | extern arm_uc_mmPersistentContext_t arm_uc_mmPersistentContext; |
maygup01 | 0:11cc2b7889af | 251 | |
maygup01 | 0:11cc2b7889af | 252 | static inline arm_uc_mmContext_t *arm_uc_mmBuf2Context(arm_uc_buffer_t *b) |
maygup01 | 0:11cc2b7889af | 253 | { |
maygup01 | 0:11cc2b7889af | 254 | return (arm_uc_mmContext_t *)b->ptr; |
maygup01 | 0:11cc2b7889af | 255 | } |
maygup01 | 0:11cc2b7889af | 256 | |
maygup01 | 0:11cc2b7889af | 257 | static inline arm_uc_error_t arm_uc_mmContextBufSizeCheck(arm_uc_buffer_t *b) |
maygup01 | 0:11cc2b7889af | 258 | { |
maygup01 | 0:11cc2b7889af | 259 | arm_uc_error_t err = { .code = ERR_NONE }; |
maygup01 | 0:11cc2b7889af | 260 | if (b->size_max < sizeof(arm_uc_mmContext_t)) { |
maygup01 | 0:11cc2b7889af | 261 | err.code = MFST_ERR_SIZE; |
maygup01 | 0:11cc2b7889af | 262 | return err; |
maygup01 | 0:11cc2b7889af | 263 | } |
maygup01 | 0:11cc2b7889af | 264 | return err; |
maygup01 | 0:11cc2b7889af | 265 | } |
maygup01 | 0:11cc2b7889af | 266 | |
maygup01 | 0:11cc2b7889af | 267 | |
maygup01 | 0:11cc2b7889af | 268 | #endif // ARM_UC_MM_CONTEXT_TYPES_H |