Mbed OS Reference
Loading...
Searching...
No Matches
DirectAccessDevicekey.h
1/*
2 * Copyright (c) 2018 ARM Limited. All rights reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 * Licensed under the Apache License, Version 2.0 (the License); you may
5 * not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef MBED_DIRECT_ACCESS_DEVICEKEY_H
18#define MBED_DIRECT_ACCESS_DEVICEKEY_H
19
20#include "FlashIAP.h"
21#include <stdio.h>
22/**
23 * @brief Returns devicekey directly from internal FlashIAP by given tdb internal position
24 *
25 * @param[in] tdb_start_offset FlashIAP Start address offset of tdb store
26 * @param[in] tdb_end_offset FlashIAP End address offset of tdb store
27 * @param[in] data_buf Buffer to store devicekey data
28 * @param[in] data_buf_size Max expected size of buffer to store the devicekey data
29 * @param[out] actual_data_size_ptr Actual retrieved devicekey size
30 *
31 * @returns MBED_ERROR_INVALID_ARGUMENT Illegal argument given
32 * MBED_ERROR_INVALID_SIZE data_buf_size is too small for retrieving actual data size
33 * MBED_ERROR_INVALID_DATA_DETECTED devicekey data invalid crc
34 * MBED_ERROR_ITEM_NOT_FOUND devicekey data not found
35 * MBED_ERROR_FAILED_OPERATION internal flash failure
36 * MBED_ERROR_READ_FAILED internal flash read failed
37 * MBED_SUCCESS successful
38 */
39int direct_access_to_devicekey(uint32_t tdb_start_offset, uint32_t tdb_end_offset, void *data_buf,
40 size_t data_buf_size, size_t *actual_data_size_ptr);
41
42/**
43 * @brief Returns the expected tdb internal position.
44 * Limitations:
45 * 1. supporting FILESYSTEM or TDB_EXTERNAL configuration only
46 * 2. supporting either both start_address and size are explicitly given (different than zero)
47 * or both of them are zero (default configuration)
48 *
49 * @param[out] out_tdb_start_offset Expected FlashIAP Start address offset of tdb store
50 * @param[out] out_tdb_end_offset Expected FlashIAP End address offset of tdb store
51 *
52 * @returns MBED_ERROR_FAILED_OPERATION internal flash failure
53 * MBED_ERROR_UNSUPPORTED kvstore configuration different than FILESYSTEM or TDB_EXTERNAL
54 * or start_address or size are different than 0 and the other isn't
55 * MBED_ERROR_INVALID_OPERATION tdb_start_offset or tdb_end_offset are not aligned or lower
56 * than end of code segment (when using default configuration)
57 * MBED_SUCCESS successful
58 *
59 */
60int get_expected_internal_TDBStore_position(uint32_t *out_tdb_start_offset, uint32_t *out_tdb_end_offset);
61
62#endif /* MBED_DIRECT_ACCESS_DEVICEKEY_H */