RTEMS: cpukit/include/rtems/rfs/rtems-rfs-bitmaps.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
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
28#include <rtems/rfs/rtems-rfs-buffer.h>
29#include <rtems/rfs/rtems-rfs-file-system-fwd.h>
30#include <rtems/rfs/rtems-rfs-trace.h>
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
99 typedef rtems_rfs_bitmap_element* rtems_rfs_bitmap_map;
100
104 typedef struct rtems_rfs_bitmap_control_s
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.
115} rtems_rfs_bitmap_control;
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
193 rtems_rfs_bitmap_element rtems_rfs_bitmap_mask (unsigned int size);
194
204 rtems_rfs_bitmap_element rtems_rfs_bitmap_mask_section (unsigned int start,
205 unsigned int end);
206
217int rtems_rfs_bitmap_map_set (rtems_rfs_bitmap_control* control,
218 rtems_rfs_bitmap_bit bit);
219
230int rtems_rfs_bitmap_map_clear (rtems_rfs_bitmap_control* control,
231 rtems_rfs_bitmap_bit bit);
232
243int
244 rtems_rfs_bitmap_map_test (rtems_rfs_bitmap_control* control,
245 rtems_rfs_bitmap_bit bit,
246 bool* state);
247
256int rtems_rfs_bitmap_map_set_all (rtems_rfs_bitmap_control* control);
257
266int rtems_rfs_bitmap_map_clear_all (rtems_rfs_bitmap_control* control);
267
283int rtems_rfs_bitmap_map_alloc (rtems_rfs_bitmap_control* control,
284 rtems_rfs_bitmap_bit seed,
285 bool* allocate,
286 rtems_rfs_bitmap_bit* bit);
287
296int rtems_rfs_bitmap_create_search (rtems_rfs_bitmap_control* control);
297
310int rtems_rfs_bitmap_open (rtems_rfs_bitmap_control* control,
311 rtems_rfs_file_system* fs,
312 rtems_rfs_buffer_handle* buffer,
313 size_t size,
314 rtems_rfs_buffer_block block);
315
324int rtems_rfs_bitmap_close (rtems_rfs_bitmap_control* control);
325
326#endif
rtems_rfs_bitmap_element
uint32_t rtems_rfs_bitmap_element
Definition: rtems-rfs-bitmaps.h:89
rtems_rfs_bitmap_map_set
int rtems_rfs_bitmap_map_set(rtems_rfs_bitmap_control *control, rtems_rfs_bitmap_bit bit)
Definition: rtems-rfs-bitmaps.c:190
rtems_rfs_bitmap_create_search
int rtems_rfs_bitmap_create_search(rtems_rfs_bitmap_control *control)
Definition: rtems-rfs-bitmaps.c:593
rtems_rfs_bitmap_map_clear_all
int rtems_rfs_bitmap_map_clear_all(rtems_rfs_bitmap_control *control)
Definition: rtems-rfs-bitmaps.c:325
rtems_rfs_bitmap_mask
rtems_rfs_bitmap_element rtems_rfs_bitmap_mask(unsigned int size)
Definition: rtems-rfs-bitmaps.c:173
rtems_rfs_bitmap_map_set_all
int rtems_rfs_bitmap_map_set_all(rtems_rfs_bitmap_control *control)
Definition: rtems-rfs-bitmaps.c:296
rtems_rfs_bitmap_open
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:661
rtems_rfs_bitmap_map_alloc
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:517
rtems_rfs_bitmap_control
struct rtems_rfs_bitmap_control_s rtems_rfs_bitmap_control
rtems_rfs_bitmap_close
int rtems_rfs_bitmap_close(rtems_rfs_bitmap_control *control)
Definition: rtems-rfs-bitmaps.c:684
rtems_rfs_bitmap_map_clear
int rtems_rfs_bitmap_map_clear(rtems_rfs_bitmap_control *control, rtems_rfs_bitmap_bit bit)
Definition: rtems-rfs-bitmaps.c:236
rtems_rfs_bitmap_mask_section
rtems_rfs_bitmap_element rtems_rfs_bitmap_mask_section(unsigned int start, unsigned int end)
Definition: rtems-rfs-bitmaps.c:181
rtems_rfs_bitmap_map_test
int rtems_rfs_bitmap_map_test(rtems_rfs_bitmap_control *control, rtems_rfs_bitmap_bit bit, bool *state)
Definition: rtems-rfs-bitmaps.c:278
rtems_rfs_bitmap_bit
int32_t rtems_rfs_bitmap_bit
Definition: rtems-rfs-bitmaps.h:84
rtems_rfs_bitmap_map
rtems_rfs_bitmap_element * rtems_rfs_bitmap_map
Definition: rtems-rfs-bitmaps.h:99
rtems-rfs-buffer.h
Maps Blocks to the Media Interface Layers.
rtems_rfs_buffer_block
uint32_t rtems_rfs_buffer_block
Definition: rtems-rfs-buffer.h:62
rtems-rfs-file-system-fwd.h
RTEMS File Systems Data Forward Declaration.
rtems-rfs-trace.h
Manages the Trace and Debugging Features of the RTEMS RFS File System.
_rtems_rfs_file_system
Definition: rtems-rfs-file-system.h:116
control
Definition: intercom.c:74
rtems_rfs_bitmap_control_s
Definition: rtems-rfs-bitmaps.h:105
rtems_rfs_buffer_handle_t
Definition: rtems-rfs-buffer.h:92