blob: 6641bc49b3c42c8cbd2c9542c935967079385720 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
// Copyright 2022 Nick Brassel (@tzarc)
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <stdint.h>
#include <stdlib.h>
/**
* @typedef Status returned from any wear-leveling API.
*/
typedef enum wear_leveling_status_t {
WEAR_LEVELING_FAILED, //< Invocation failed
WEAR_LEVELING_SUCCESS, //< Invocation succeeded
WEAR_LEVELING_CONSOLIDATED //< Invocation succeeded, consolidation occurred
} wear_leveling_status_t;
/**
* Wear-leveling initialization
*
* @return Status of the request
*/
wear_leveling_status_t wear_leveling_init(void);
/**
* Wear-leveling erasure.
*
* Clears the wear-leveling area, with the definition that the "reset state" of all data is zero.
*
* @return Status of the request
*/
wear_leveling_status_t wear_leveling_erase(void);
/**
* Writes logical data into the backing store.
*
* Skips writes if there are no changes to written values. The entire written block is considered when attempting to
* determine if an overwrite should occur -- if there is any data mismatch the entire block will be written to the log,
* not just the changed bytes.
*
* @param address[in] the logical address to write data
* @param value[in] pointer to the source buffer
* @param length[in] length of the data
* @return Status of the request
*/
wear_leveling_status_t wear_leveling_write(uint32_t address, const void* value, size_t length);
/**
* Reads logical data from the cache.
*
* @param address[in] the logical address to read data
* @param value[out] pointer to the destination buffer
* @param length[in] length of the data
* @return Status of the request
*/
wear_leveling_status_t wear_leveling_read(uint32_t address, void* value, size_t length);
|