Update build system.
[lwext4.git] / src / lwext4 / ext4_bcache.h
index c1e1d45c76c18067a561937a5624c0c8b0ab2c7e..c64841b6cae60711ee5057edf22436f8758c8f29 100644 (file)
 \r
 /**@brief      Single block descriptor.*/\r
 struct ext4_block {\r
-       /**@brief       Dirty flag.*/\r
-       bool            dirty;\r
+    /**@brief  Dirty flag.*/\r
+    bool               dirty;\r
 \r
-       /**@brief       Logical block ID*/\r
-       uint64_t        lb_id;\r
+    /**@brief  Logical block ID*/\r
+    uint64_t   lb_id;\r
 \r
-       /**@brief       Data buffer.*/\r
-       uint8_t         *data;\r
+    /**@brief   Cache id*/\r
+    uint32_t    cache_id;\r
+\r
+    /**@brief  Data buffer.*/\r
+    uint8_t            *data;\r
 };\r
 \r
 \r
 /**@brief      Block cache descriptor.*/\r
 struct ext4_bcache {\r
 \r
-       /**@brief       Item count in block cache*/\r
-       uint32_t        cnt;\r
+    /**@brief  Item count in block cache*/\r
+    uint32_t   cnt;\r
 \r
-       /**@brief       Item size in block cache*/\r
-       uint32_t        itemsize;\r
+    /**@brief  Item size in block cache*/\r
+    uint32_t   itemsize;\r
 \r
-       /**@brief       Last recently used counter.*/\r
-       uint32_t        lru_ctr;\r
+    /**@brief  Last recently used counter.*/\r
+    uint32_t   lru_ctr;\r
 \r
-       /**@brief       Reference count table (cnt).*/\r
-       uint32_t        *refctr;\r
+    /**@brief  Reference count table (cnt).*/\r
+    uint32_t   *refctr;\r
 \r
-       /**@brief       Last recently used ID table (cnt)*/\r
-       uint32_t        *lru_id;\r
+    /**@brief  Last recently used ID table (cnt)*/\r
+    uint32_t   *lru_id;\r
 \r
-       /**@brief       Free delay mode table (cnt)*/\r
-       uint8_t         *free_delay;\r
+    /**@brief  Free delay mode table (cnt)*/\r
+    uint8_t    *free_delay;\r
 \r
-       /**@brief       Logical block table (cnt).*/\r
-       uint64_t        *lba;\r
+    /**@brief  Logical block table (cnt).*/\r
+    uint64_t   *lba;\r
 \r
-       /**@brief       Cache data buffers (cnt * itemsize)*/\r
-       uint8_t         *data;\r
+    /**@brief  Cache data buffers (cnt * itemsize)*/\r
+    uint8_t            *data;\r
 \r
-       /**@brief       Currently referenced datablocks*/\r
-       uint32_t        ref_blocks;\r
+    /**@brief  Currently referenced datablocks*/\r
+    uint32_t   ref_blocks;\r
 \r
-       /**@brief       Maximum referenced datablocks*/\r
-       uint32_t        max_ref_blocks;\r
+    /**@brief  Maximum referenced datablocks*/\r
+    uint32_t   max_ref_blocks;\r
 \r
 };\r
 \r
 /**@brief      Static initializer of block cache structure.*/\r
-#define EXT4_BCACHE_STATIC_INSTANCE(__name, __cnt, __itemsize) \\r
-       static uint32_t __name##_refctr[(__cnt)];                                       \\r
-       static uint32_t __name##_lru_id[(__cnt)];                                       \\r
-       static uint8_t          __name##_free_delay[(__cnt)];                   \\r
-       static uint64_t __name##_lba[(__cnt)];                                          \\r
-       static uint8_t  __name##_data[(__cnt) * (__itemsize)];          \\r
-       static struct ext4_bcache       __name = {                                              \\r
-               .cnt       = __cnt,                                                                             \\r
-               .itemsize  = __itemsize,                                                                \\r
-               .lru_ctr   = 0,                                                                                 \\r
-               .refctr    = __name##_refctr,                                                   \\r
-               .lru_id    = __name##_lru_id,                                                   \\r
-               .lba       = __name##_lba,                                                              \\r
-               .free_delay= __name##_free_delay,                                               \\r
-               .data      = __name##_data,                                                             \\r
-       }\r
+#define EXT4_BCACHE_STATIC_INSTANCE(__name, __cnt, __itemsize)      \\r
+        static uint32_t        __name##_refctr[(__cnt)];                   \\r
+        static uint32_t        __name##_lru_id[(__cnt)];                   \\r
+        static uint8_t         __name##_free_delay[(__cnt)];           \\r
+        static uint64_t        __name##_lba[(__cnt)];                      \\r
+        static uint8_t         __name##_data[(__cnt) * (__itemsize)];      \\r
+        static struct ext4_bcache      __name = {                      \\r
+                .cnt      = __cnt,                                 \\r
+                .itemsize  = __itemsize,                            \\r
+                .lru_ctr   = 0,                                     \\r
+                .refctr           = __name##_refctr,                       \\r
+                .lru_id    = __name##_lru_id,                       \\r
+                .lba      = __name##_lba,                          \\r
+                .free_delay= __name##_free_delay,                   \\r
+                .data     = __name##_data,                         \\r
+        }\r
 \r
 \r
 /**@brief      Dynamic initialization of block cache.\r
@@ -114,26 +117,30 @@ struct    ext4_bcache {
  * @param      cnt items count in block cache\r
  * @param      itemsize single item size (in bytes)\r
  * @return     standard error code*/\r
-int    ext4_bcache_init_dynamic(struct ext4_bcache *bc, uint32_t cnt, uint32_t itemsize);\r
+int    ext4_bcache_init_dynamic(struct ext4_bcache *bc, uint32_t cnt,\r
+    uint32_t itemsize);\r
 \r
 /**@brief      Dynamic de-initialization of block cache.\r
  * @param      bc block cache descriptor\r
  * @return     standard error code*/\r
 int ext4_bcache_fini_dynamic(struct    ext4_bcache *bc);\r
 \r
-/**@brief      Allocate block from block cache memory. Unreferenced block allocation is based\r
- *                     on LRU (Last Recently Used) algorithm.\r
+/**@brief      Allocate block from block cache memory.\r
+ *          Unreferenced block allocation is based on LRU\r
+ *          (Last Recently Used) algorithm.\r
  * @param      bc      block cache descriptor\r
  * @param      b block to alloc\r
  * @param      is_new block is new (needs to be read)\r
  * @return  standard error code*/\r
-int ext4_bcache_alloc(struct ext4_bcache *bc, struct ext4_block *b, bool *is_new);\r
+int ext4_bcache_alloc(struct ext4_bcache *bc, struct ext4_block *b,\r
+    bool *is_new);\r
 \r
 /**@brief      Free block from cache memory (decrement reference counter).\r
  * @param      bc      block cache descriptor\r
  * @param      b block to free\r
  * @return  standard error code*/\r
-int ext4_bcache_free (struct ext4_bcache *bc, struct ext4_block *b, uint8_t free_delay);\r
+int ext4_bcache_free (struct ext4_bcache *bc, struct ext4_block *b,\r
+    uint8_t free_delay);\r
 \r
 \r
 /**@brief      Return a full status of block cache.\r