Mistake on this page?
Report an issue in GitHub or email us
tests/TESTS/COMMON/atomic_usage.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2017 ARM Limited
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20  * SOFTWARE.
21  */
22 #ifndef MBED_ATOMIC_USAGE_H
23 #define MBED_ATOMIC_USAGE_H
24 
25 #include "BlockDevice.h"
26 
27 /**
28  * Setup the given block device to test littlefs atomic operations
29  *
30  * Format the blockdevice with a littlefs filesystem and create
31  * the files and directories required to test atomic operations.
32  *
33  * @param bd Block device format and setup
34  * @param force_rebuild Force a reformat even if the device is already setup
35  * @return true if the block device was formatted, false otherwise
36  * @note utest asserts are used to detect fatal errors so utest must be
37  * initialized before calling this function.
38  */
39 bool setup_atomic_operations(BlockDevice *bd, bool force_rebuild);
40 
41 /**
42  * Perform a set of atomic littlefs operations on the block device
43  *
44  * Mount the block device as a littlefs filesystem and a series of
45  * atomic operations on it. Since the operations performed are atomic
46  * the file system will always be in a well defined state. The block
47  * device must have been setup by calling setup_atomic_operations.
48  *
49  * @param bd Block device to perform the operations on
50  * @return -1 if flash is exhausted, otherwise the cycle count on the fs
51  * @note utest asserts are used to detect fatal errors so utest must be
52  * initialized before calling this function.
53  */
54 int64_t perform_atomic_operations(BlockDevice *bd);
55 
56 /**
57  * Check that the littlefs image on the block device is in a good state
58  *
59  * Mount the block device as a littlefs filesystem and check the files
60  * and directories to ensure they are valid. Since all the operations
61  * performed are atomic the filesystem should always be in a good
62  * state.
63  *
64  * @param bd Block device to check
65  * @note This function does not change the contents of the block device
66  * @note utest asserts are used to detect fatal errors so utest must be
67  * initialized before calling this function.
68  */
69 void check_atomic_operations(BlockDevice *bd);
70 
71 #endif
A hardware device capable of writing and reading blocks.
Definition: BlockDevice.h:48
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.