RTEMS  5.1
rtems-rfs-bitmaps.h
Go to the documentation of this file.
1 
16 /*
17  * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
18  *
19  * The license and distribution terms for this file may be
20  * found in the file LICENSE in this distribution or at
21  * http://www.rtems.org/license/LICENSE.
22  */
23 
24 
25 #if !defined (_RTEMS_RFS_BITMAPS_H_)
26 #define _RTEMS_RFS_BITMAPS_H_
27 
31 
37 #define RTEMS_RFS_BITMAP_CLEAR_ZERO 0
38 
39 #if RTEMS_RFS_BITMAP_CLEAR_ZERO
40 /*
41  * Bit set is a 1 and clear is 0.
42  */
43 #define RTEMS_RFS_BITMAP_BIT_CLEAR 0
44 #define RTEMS_RFS_BITMAP_BIT_SET 1
45 #define RTEMS_RFS_BITMAP_ELEMENT_SET (RTEMS_RFS_BITMAP_ELEMENT_FULL_MASK)
46 #define RTEMS_RFS_BITMAP_ELEMENT_CLEAR (0)
47 #define RTEMS_RFS_BITMAP_SET_BITS(_t, _b) ((_t) | (_b))
48 #define RTEMS_RFS_BITMAP_CLEAR_BITS(_t, _b) ((_t) & ~(_b))
49 #define RTEMS_RFS_BITMAP_TEST_BIT(_t, _b) (((_t) & (1 << (_b))) != 0 ? true : false)
50 #else
51 /*
52  * Bit set is a 0 and clear is 1.
53  */
54 #define RTEMS_RFS_BITMAP_BIT_CLEAR 1
55 #define RTEMS_RFS_BITMAP_BIT_SET 0
56 #define RTEMS_RFS_BITMAP_ELEMENT_SET (0)
57 #define RTEMS_RFS_BITMAP_ELEMENT_CLEAR (RTEMS_RFS_BITMAP_ELEMENT_FULL_MASK)
58 #define RTEMS_RFS_BITMAP_SET_BITS(_t, _b) ((_t) & ~(_b))
59 #define RTEMS_RFS_BITMAP_CLEAR_BITS(_t, _b) ((_t) | (_b))
60 #define RTEMS_RFS_BITMAP_TEST_BIT(_t, _b) (((_t) & (1 << (_b))) == 0 ? true : false)
61 #endif
62 
66 #define RTEMS_RFS_BITMAP_INVERT_MASK(_mask) (~(_mask))
67 
73 #define RTEMS_RFS_BITMAP_ELEMENT_FULL_MASK (0xffffffffUL)
74 
79 #define RTEMS_RFS_BITMAP_SEARCH_WINDOW (rtems_rfs_bitmap_element_bits () * 64)
80 
84 typedef int32_t rtems_rfs_bitmap_bit;
85 
89 typedef uint32_t rtems_rfs_bitmap_element;
90 
94 #define RTEMS_RFS_ELEMENT_BITS_POWER_2 (5)
95 
100 
105 {
106  rtems_rfs_buffer_handle* buffer; //< Handle the to buffer with the bit
107  //map.
108  rtems_rfs_file_system* fs; //< The map's file system.
109  rtems_rfs_buffer_block block; //< The map's block number on disk.
110  size_t size; //< Number of bits in the map. Passed
111  //to create.
112  size_t free; //< Number of bits in the map that are
113  //free (clear).
114  rtems_rfs_bitmap_map search_bits; //< The search bit map memory.
116 
120 #define rtems_rfs_bitmap_numof_bits(_bytes) (8 * (_bytes))
121 
126 #define rtems_rfs_bitmap_element_bits() \
127  rtems_rfs_bitmap_numof_bits (sizeof (rtems_rfs_bitmap_element))
128 
132 #define rtems_rfs_bitmap_search_element_bits() \
133  (rtems_rfs_bitmap_element_bits() * rtems_rfs_bitmap_element_bits())
134 
138 #define rtems_rfs_bitmap_elements(_bits) \
139  ((((_bits) - 1) / rtems_rfs_bitmap_element_bits()) + 1)
140 
144 #define rtems_rfs_bitmap_release_buffer(_fs, _bm) \
145  rtems_rfs_buffer_handle_release (_fs, (_bm)->buffer)
146 
155 #define rtems_rfs_bitmap_map_index(_b) \
156  ((_b) >> RTEMS_RFS_ELEMENT_BITS_POWER_2)
157 
162 #define rtems_rfs_bitmap_map_offset(_b) \
163  ((_b) & ((1 << RTEMS_RFS_ELEMENT_BITS_POWER_2) - 1))
164 
168 #define rtems_rfs_bitmap_map_size(_c) ((_c)->size)
169 
173 #define rtems_rfs_bitmap_map_free(_c) ((_c)->free)
174 
178 #define rtems_rfs_bitmap_map_handle(_c) ((_c)->buffer)
179 
183 #define rtems_rfs_bitmap_map_block(_c) ((_c)->block)
184 
194 
205  unsigned int end);
206 
219 
232 
243 int
246  bool* state);
247 
257 
267 
285  bool* allocate,
286  rtems_rfs_bitmap_bit* bit);
287 
297 
312  rtems_rfs_buffer_handle* buffer,
313  size_t size,
314  rtems_rfs_buffer_block block);
315 
325 
326 #endif
int rtems_rfs_bitmap_map_alloc(rtems_rfs_bitmap_control *control, rtems_rfs_bitmap_bit seed, bool *allocate, rtems_rfs_bitmap_bit *bit)
Definition: rtems-rfs-bitmaps.c:509
rtems_rfs_bitmap_element rtems_rfs_bitmap_mask(unsigned int size)
Definition: rtems-rfs-bitmaps.c:167
int rtems_rfs_bitmap_map_clear(rtems_rfs_bitmap_control *control, rtems_rfs_bitmap_bit bit)
Definition: rtems-rfs-bitmaps.c:229
int32_t rtems_rfs_bitmap_bit
Definition: rtems-rfs-bitmaps.h:84
int rtems_rfs_bitmap_map_test(rtems_rfs_bitmap_control *control, rtems_rfs_bitmap_bit bit, bool *state)
Definition: rtems-rfs-bitmaps.c:270
Definition: rtems-rfs-bitmaps.h:104
Definition: rtems-rfs-file-system.h:123
uint32_t rtems_rfs_buffer_block
Definition: rtems-rfs-buffer.h:62
int rtems_rfs_bitmap_create_search(rtems_rfs_bitmap_control *control)
Definition: rtems-rfs-bitmaps.c:585
rtems_rfs_bitmap_element * rtems_rfs_bitmap_map
Definition: rtems-rfs-bitmaps.h:99
rtems_rfs_bitmap_element rtems_rfs_bitmap_mask_section(unsigned int start, unsigned int end)
Definition: rtems-rfs-bitmaps.c:175
Manages the Trace and Debugging Features of the RTEMS RFS File System.
int rtems_rfs_bitmap_map_clear_all(rtems_rfs_bitmap_control *control)
Definition: rtems-rfs-bitmaps.c:317
int rtems_rfs_bitmap_close(rtems_rfs_bitmap_control *control)
Definition: rtems-rfs-bitmaps.c:671
int rtems_rfs_bitmap_map_set_all(rtems_rfs_bitmap_control *control)
Definition: rtems-rfs-bitmaps.c:288
Definition: intercom.c:74
int rtems_rfs_bitmap_open(rtems_rfs_bitmap_control *control, rtems_rfs_file_system *fs, rtems_rfs_buffer_handle *buffer, size_t size, rtems_rfs_buffer_block block)
Definition: rtems-rfs-bitmaps.c:648
uint32_t rtems_rfs_bitmap_element
Definition: rtems-rfs-bitmaps.h:89
int rtems_rfs_bitmap_map_set(rtems_rfs_bitmap_control *control, rtems_rfs_bitmap_bit bit)
Definition: rtems-rfs-bitmaps.c:184
Maps Blocks to the Media Interface Layers.
Definition: rtems-rfs-buffer.h:91
RTEMS File Systems Data Forward Declaration.
struct rtems_rfs_bitmap_control_s rtems_rfs_bitmap_control
unsigned size
Definition: tte.h:74