Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
app_storage.h
Go to the documentation of this file.
1/*****************************************************************************
2 * (c) 2024 Ledger SAS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may 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,
12 * WITHOUT 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#pragma once
18
19#include <stdint.h>
20#include <stdbool.h>
21
23#define APP_STORAGE_PROP_SETTINGS (1 << 0)
25#define APP_STORAGE_PROP_DATA (1 << 1)
26
28#define APP_STORAGE_TAG_LEN 4
29
31#define APP_STORAGE_TAG "NVRA"
32
34#define APP_STORAGE_HEADER_STRUCT_VERSION 1
35
37#define APP_STORAGE_SUCCESS 0
38#define APP_STORAGE_ERR_INVALID_ARGUMENT -1
39#define APP_STORAGE_ERR_NO_DATA_AVAILABLE -2
40#define APP_STORAGE_ERR_OVERFLOW -3
41#define APP_STORAGE_ERR_INVALID_HEADER -4
42#define APP_STORAGE_ERR_CORRUPTED -5
43
45#define APP_STORAGE_INITIAL_APP_DATA_VERSION 1
46
60
61#ifndef HAVE_BOLOS
62
63/* Getters for system information */
64uint32_t app_storage_get_size(void);
67
68/* Reads app storage data */
69int32_t app_storage_read(void *buf, uint32_t nbyte, uint32_t offset);
70
71/* Writes app storage data */
72int32_t app_storage_write(const void *buf, uint32_t nbyte, uint32_t offset);
73
74/* Setters */
75void app_storage_set_data_version(uint32_t data_version);
77
78/* Resets and zeroes out application storage */
80
81#endif // #ifndef HAVE_BOLOS
void app_storage_reset(void)
uint32_t app_storage_get_size(void)
int32_t app_storage_read(void *buf, uint32_t nbyte, uint32_t offset)
void app_storage_set_data_version(uint32_t data_version)
void app_storage_increment_data_version(void)
int32_t app_storage_write(const void *buf, uint32_t nbyte, uint32_t offset)
#define APP_STORAGE_TAG_LEN
Tag value.
Definition app_storage.h:28
uint16_t app_storage_get_properties(void)
uint32_t app_storage_get_data_version(void)
struct app_storage_header_s app_storage_header_t
Structure defining the header of application storage header.
Structure defining the header of application storage header.
Definition app_storage.h:51
char tag[APP_STORAGE_TAG_LEN]
['N','V','R','A'] array, when properly initialized
Definition app_storage.h:52
uint16_t struct_version
version of this structure (for OS)
Definition app_storage.h:54
uint32_t size
size in bytes of application data
Definition app_storage.h:53