Mistake on this page?
Report an issue in GitHub or email us
lfs2_rambd.h
1 /*
2  * Block device emulated in RAM
3  *
4  * Copyright (c) 2017, Arm Limited. All rights reserved.
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 #ifndef LFS2_RAMBD_H
8 #define LFS2_RAMBD_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_RAMBD_YES_TRACE
21 #define LFS2_RAMBD_TRACE(...) LFS2_TRACE(__VA_ARGS__)
22 #else
23 #define LFS2_RAMBD_TRACE(...)
24 #endif
25 
26 // rambd config (optional)
28  // 8-bit erase value to simulate erasing with. -1 indicates no erase
29  // occurs, which is still a valid block device
30  int32_t erase_value;
31 
32  // Optional statically allocated buffer for the block device.
33  void *buffer;
34 };
35 
36 // rambd state
37 typedef struct lfs2_rambd {
38  uint8_t *buffer;
39  const struct lfs2_rambd_config *cfg;
40 } lfs2_rambd_t;
41 
42 
43 // Create a RAM block device using the geometry in lfs2_config
44 int lfs2_rambd_create(const struct lfs2_config *cfg);
45 int lfs2_rambd_createcfg(const struct lfs2_config *cfg,
46  const struct lfs2_rambd_config *bdcfg);
47 
48 // Clean up memory associated with block device
49 int lfs2_rambd_destroy(const struct lfs2_config *cfg);
50 
51 // Read a block
52 int lfs2_rambd_read(const struct lfs2_config *cfg, lfs2_block_t block,
53  lfs2_off_t off, void *buffer, lfs2_size_t size);
54 
55 // Program a block
56 //
57 // The block must have previously been erased.
58 int lfs2_rambd_prog(const struct lfs2_config *cfg, lfs2_block_t block,
59  lfs2_off_t off, const void *buffer, lfs2_size_t size);
60 
61 // Erase a block
62 //
63 // A block must be erased before being programmed. The
64 // state of an erased block is undefined.
65 int lfs2_rambd_erase(const struct lfs2_config *cfg, lfs2_block_t block);
66 
67 // Sync the block device
68 int lfs2_rambd_sync(const struct lfs2_config *cfg);
69 
70 
71 #ifdef __cplusplus
72 } /* extern "C" */
73 #endif
74 
75 #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.