Mistake on this page?
Report an issue in GitHub or email us
lfs_emubd.h
1 /*
2  * Block device emulated on standard files
3  *
4  * Copyright (c) 2017, Arm Limited. All rights reserved.
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 #ifndef LFS_EMUBD_H
8 #define LFS_EMUBD_H
9 
10 #include "lfs.h"
11 #include "lfs_util.h"
12 
13 #ifdef __cplusplus
14 extern "C"
15 {
16 #endif
17 
18 
19 // Config options
20 #ifndef LFS_EMUBD_READ_SIZE
21 #define LFS_EMUBD_READ_SIZE 1
22 #endif
23 
24 #ifndef LFS_EMUBD_PROG_SIZE
25 #define LFS_EMUBD_PROG_SIZE 1
26 #endif
27 
28 #ifndef LFS_EMUBD_ERASE_SIZE
29 #define LFS_EMUBD_ERASE_SIZE 512
30 #endif
31 
32 #ifndef LFS_EMUBD_TOTAL_SIZE
33 #define LFS_EMUBD_TOTAL_SIZE 524288
34 #endif
35 
36 
37 // The emu bd state
38 typedef struct lfs_emubd {
39  char *path;
40  char *child;
41 
42  struct {
43  uint64_t read_count;
44  uint64_t prog_count;
45  uint64_t erase_count;
46  } stats;
47 
48  struct {
49  uint32_t read_size;
50  uint32_t prog_size;
51  uint32_t block_size;
52  uint32_t block_count;
53  } cfg;
54 } lfs_emubd_t;
55 
56 
57 // Create a block device using path for the directory to store blocks
58 int lfs_emubd_create(const struct lfs_config *cfg, const char *path);
59 
60 // Clean up memory associated with emu block device
61 void lfs_emubd_destroy(const struct lfs_config *cfg);
62 
63 // Read a block
64 int lfs_emubd_read(const struct lfs_config *cfg, lfs_block_t block,
65  lfs_off_t off, void *buffer, lfs_size_t size);
66 
67 // Program a block
68 //
69 // The block must have previously been erased.
70 int lfs_emubd_prog(const struct lfs_config *cfg, lfs_block_t block,
71  lfs_off_t off, const void *buffer, lfs_size_t size);
72 
73 // Erase a block
74 //
75 // A block must be erased before being programmed. The
76 // state of an erased block is undefined.
77 int lfs_emubd_erase(const struct lfs_config *cfg, lfs_block_t block);
78 
79 // Sync the block device
80 int lfs_emubd_sync(const struct lfs_config *cfg);
81 
82 
83 #ifdef __cplusplus
84 } /* extern "C" */
85 #endif
86 
87 #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.