RTEMS 6.1-rc4
Loading...
Searching...
No Matches
rtems-rfs-bitmaps.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
18/*
19 * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
20 *
21 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions
23 * are met:
24 * 1. Redistributions of source code must retain the above copyright
25 * notice, this list of conditions and the following disclaimer.
26 * 2. Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in the
28 * documentation and/or other materials provided with the distribution.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
31 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
34 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
35 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
36 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
37 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
38 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
39 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40 * POSSIBILITY OF SUCH DAMAGE.
41 */
42
43
44#if !defined (_RTEMS_RFS_BITMAPS_H_)
45#define _RTEMS_RFS_BITMAPS_H_
46
50
56#define RTEMS_RFS_BITMAP_CLEAR_ZERO 0
57
58#if RTEMS_RFS_BITMAP_CLEAR_ZERO
59/*
60 * Bit set is a 1 and clear is 0.
61 */
62#define RTEMS_RFS_BITMAP_BIT_CLEAR 0
63#define RTEMS_RFS_BITMAP_BIT_SET 1
64#define RTEMS_RFS_BITMAP_ELEMENT_SET (RTEMS_RFS_BITMAP_ELEMENT_FULL_MASK)
65#define RTEMS_RFS_BITMAP_ELEMENT_CLEAR (0)
66#define RTEMS_RFS_BITMAP_SET_BITS(_t, _b) ((_t) | (_b))
67#define RTEMS_RFS_BITMAP_CLEAR_BITS(_t, _b) ((_t) & ~(_b))
68#define RTEMS_RFS_BITMAP_TEST_BIT(_t, _b) (((_t) & (1 << (_b))) != 0 ? true : false)
69#else
70/*
71 * Bit set is a 0 and clear is 1.
72 */
73#define RTEMS_RFS_BITMAP_BIT_CLEAR 1
74#define RTEMS_RFS_BITMAP_BIT_SET 0
75#define RTEMS_RFS_BITMAP_ELEMENT_SET (0)
76#define RTEMS_RFS_BITMAP_ELEMENT_CLEAR (RTEMS_RFS_BITMAP_ELEMENT_FULL_MASK)
77#define RTEMS_RFS_BITMAP_SET_BITS(_t, _b) ((_t) & ~(_b))
78#define RTEMS_RFS_BITMAP_CLEAR_BITS(_t, _b) ((_t) | (_b))
79#define RTEMS_RFS_BITMAP_TEST_BIT(_t, _b) (((_t) & (1 << (_b))) == 0 ? true : false)
80#endif
81
85#define RTEMS_RFS_BITMAP_INVERT_MASK(_mask) (~(_mask))
86
92#define RTEMS_RFS_BITMAP_ELEMENT_FULL_MASK (0xffffffffUL)
93
98#define RTEMS_RFS_BITMAP_SEARCH_WINDOW (rtems_rfs_bitmap_element_bits () * 64)
99
103typedef int32_t rtems_rfs_bitmap_bit;
104
109
113#define RTEMS_RFS_ELEMENT_BITS_POWER_2 (5)
114
119
124{
125 rtems_rfs_buffer_handle* buffer; //< Handle the to buffer with the bit
126 //map.
127 rtems_rfs_file_system* fs; //< The map's file system.
128 rtems_rfs_buffer_block block; //< The map's block number on disk.
129 size_t size; //< Number of bits in the map. Passed
130 //to create.
131 size_t free; //< Number of bits in the map that are
132 //free (clear).
133 rtems_rfs_bitmap_map search_bits; //< The search bit map memory.
135
139#define rtems_rfs_bitmap_numof_bits(_bytes) (8 * (_bytes))
140
145#define rtems_rfs_bitmap_element_bits() \
146 rtems_rfs_bitmap_numof_bits (sizeof (rtems_rfs_bitmap_element))
147
151#define rtems_rfs_bitmap_search_element_bits() \
152 (rtems_rfs_bitmap_element_bits() * rtems_rfs_bitmap_element_bits())
153
157#define rtems_rfs_bitmap_elements(_bits) \
158 ((((_bits) - 1) / rtems_rfs_bitmap_element_bits()) + 1)
159
163#define rtems_rfs_bitmap_release_buffer(_fs, _bm) \
164 rtems_rfs_buffer_handle_release (_fs, (_bm)->buffer)
165
174#define rtems_rfs_bitmap_map_index(_b) \
175 ((_b) >> RTEMS_RFS_ELEMENT_BITS_POWER_2)
176
181#define rtems_rfs_bitmap_map_offset(_b) \
182 ((_b) & ((1 << RTEMS_RFS_ELEMENT_BITS_POWER_2) - 1))
183
187#define rtems_rfs_bitmap_map_size(_c) ((_c)->size)
188
192#define rtems_rfs_bitmap_map_free(_c) ((_c)->free)
193
197#define rtems_rfs_bitmap_map_handle(_c) ((_c)->buffer)
198
202#define rtems_rfs_bitmap_map_block(_c) ((_c)->block)
203
213
224 unsigned int end);
225
238
251
262int
265 bool* state);
266
276
286
304 bool* allocate,
306
316
332 size_t size,
334
344
345#endif
uint32_t rtems_rfs_bitmap_element
Definition: rtems-rfs-bitmaps.h:108
int rtems_rfs_bitmap_map_set(rtems_rfs_bitmap_control *control, rtems_rfs_bitmap_bit bit)
Definition: rtems-rfs-bitmaps.c:209
int rtems_rfs_bitmap_create_search(rtems_rfs_bitmap_control *control)
Definition: rtems-rfs-bitmaps.c:612
int rtems_rfs_bitmap_map_clear_all(rtems_rfs_bitmap_control *control)
Definition: rtems-rfs-bitmaps.c:344
rtems_rfs_bitmap_element rtems_rfs_bitmap_mask(unsigned int size)
Definition: rtems-rfs-bitmaps.c:192
int rtems_rfs_bitmap_map_set_all(rtems_rfs_bitmap_control *control)
Definition: rtems-rfs-bitmaps.c:315
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:680
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:536
struct rtems_rfs_bitmap_control_s rtems_rfs_bitmap_control
int rtems_rfs_bitmap_close(rtems_rfs_bitmap_control *control)
Definition: rtems-rfs-bitmaps.c:703
int rtems_rfs_bitmap_map_clear(rtems_rfs_bitmap_control *control, rtems_rfs_bitmap_bit bit)
Definition: rtems-rfs-bitmaps.c:255
rtems_rfs_bitmap_element rtems_rfs_bitmap_mask_section(unsigned int start, unsigned int end)
Definition: rtems-rfs-bitmaps.c:200
int rtems_rfs_bitmap_map_test(rtems_rfs_bitmap_control *control, rtems_rfs_bitmap_bit bit, bool *state)
Definition: rtems-rfs-bitmaps.c:297
int32_t rtems_rfs_bitmap_bit
Definition: rtems-rfs-bitmaps.h:103
rtems_rfs_bitmap_element * rtems_rfs_bitmap_map
Definition: rtems-rfs-bitmaps.h:118
Maps Blocks to the Media Interface Layers.
uint32_t rtems_rfs_buffer_block
Definition: rtems-rfs-buffer.h:81
RTEMS File Systems Data Forward Declaration.
Manages the Trace and Debugging Features of the RTEMS RFS File System.
Definition: rtems-rfs-file-system.h:135
Definition: intercom.c:87
Definition: rtems-rfs-bitmaps.h:124
Definition: rtems-rfs-buffer.h:111