Mistake on this page?
Report an issue in GitHub or email us
lfs2_filebd.h
1 /*
2  * Block device emulated in a file
3  *
4  * Copyright (c) 2017, Arm Limited. All rights reserved.
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 #ifndef LFS2_FILEBD_H
8 #define LFS2_FILEBD_H
9 
10 #include "lfs2.h"
11 #include "lfs2_util.h"
12 
13 #ifdef __cplusplus
14 extern "C"
15 {
16 #endif
17 
18 
19 // Block device specific tracing
20 #ifdef LFS2_FILEBD_YES_TRACE
21 #define LFS2_FILEBD_TRACE(...) LFS2_TRACE(__VA_ARGS__)
22 #else
23 #define LFS2_FILEBD_TRACE(...)
24 #endif
25 
26 // filebd config (optional)
28  // 8-bit erase value to use for simulating erases. -1 does not simulate
29  // erases, which can speed up testing by avoiding all the extra block-device
30  // operations to store the erase value.
31  int32_t erase_value;
32 };
33 
34 // filebd state
35 typedef struct lfs2_filebd {
36  int fd;
37  const struct lfs2_filebd_config *cfg;
39 
40 
41 // Create a file block device using the geometry in lfs2_config
42 int lfs2_filebd_create(const struct lfs2_config *cfg, const char *path);
43 int lfs2_filebd_createcfg(const struct lfs2_config *cfg, const char *path,
44  const struct lfs2_filebd_config *bdcfg);
45 
46 // Clean up memory associated with block device
47 int lfs2_filebd_destroy(const struct lfs2_config *cfg);
48 
49 // Read a block
50 int lfs2_filebd_read(const struct lfs2_config *cfg, lfs2_block_t block,
51  lfs2_off_t off, void *buffer, lfs2_size_t size);
52 
53 // Program a block
54 //
55 // The block must have previously been erased.
56 int lfs2_filebd_prog(const struct lfs2_config *cfg, lfs2_block_t block,
57  lfs2_off_t off, const void *buffer, lfs2_size_t size);
58 
59 // Erase a block
60 //
61 // A block must be erased before being programmed. The
62 // state of an erased block is undefined.
63 int lfs2_filebd_erase(const struct lfs2_config *cfg, lfs2_block_t block);
64 
65 // Sync the block device
66 int lfs2_filebd_sync(const struct lfs2_config *cfg);
67 
68 
69 #ifdef __cplusplus
70 } /* extern "C" */
71 #endif
72 
73 #endif
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.