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-2020 ARM Limited
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #ifndef MBED_ATOMIC_USAGE_H
18 #define MBED_ATOMIC_USAGE_H
19 
20 #include "BlockDevice.h"
21 
22 /**
23  * Setup the given block device to test littlefs atomic operations
24  *
25  * Format the blockdevice with a littlefs filesystem and create
26  * the files and directories required to test atomic operations.
27  *
28  * @param bd Block device format and setup
29  * @param force_rebuild Force a reformat even if the device is already setup
30  * @return true if the block device was formatted, false otherwise
31  * @note utest asserts are used to detect fatal errors so utest must be
32  * initialized before calling this function.
33  */
34 bool setup_atomic_operations(BlockDevice *bd, bool force_rebuild);
35 
36 /**
37  * Perform a set of atomic littlefs operations on the block device
38  *
39  * Mount the block device as a littlefs filesystem and a series of
40  * atomic operations on it. Since the operations performed are atomic
41  * the file system will always be in a well defined state. The block
42  * device must have been setup by calling setup_atomic_operations.
43  *
44  * @param bd Block device to perform the operations on
45  * @return -1 if flash is exhausted, otherwise the cycle count on the fs
46  * @note utest asserts are used to detect fatal errors so utest must be
47  * initialized before calling this function.
48  */
49 int64_t perform_atomic_operations(BlockDevice *bd);
50 
51 /**
52  * Check that the littlefs image on the block device is in a good state
53  *
54  * Mount the block device as a littlefs filesystem and check the files
55  * and directories to ensure they are valid. Since all the operations
56  * performed are atomic the filesystem should always be in a good
57  * state.
58  *
59  * @param bd Block device to check
60  * @note This function does not change the contents of the block device
61  * @note utest asserts are used to detect fatal errors so utest must be
62  * initialized before calling this function.
63  */
64 void check_atomic_operations(BlockDevice *bd);
65 
66 #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.