RTEMS: cpukit/libfs/src/rfs/rtems-rfs-bitmaps.c File Reference

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
Macros | Functions
rtems-rfs-bitmaps.c File Reference
IO Library » File System Types and Mount » RTEMS File System Group Management

RTEMS File Systems Bitmap Routines. More...

`#include <stdlib.h>`
`#include <rtems/rfs/rtems-rfs-bitmaps.h>`

## Macros
#define | RTEMS_RFS_BITMAP_WARNINGS 0
#define | rtems_rfs_bitmap_check(_c, _sm)

## Functions
rtems_rfs_bitmap_element | rtems_rfs_bitmap_mask (unsigned int size)
rtems_rfs_bitmap_element | rtems_rfs_bitmap_mask_section (unsigned int start, unsigned int end)
int | rtems_rfs_bitmap_map_set (rtems_rfs_bitmap_control *control, rtems_rfs_bitmap_bit bit)
int | rtems_rfs_bitmap_map_clear (rtems_rfs_bitmap_control *control, rtems_rfs_bitmap_bit bit)
int | rtems_rfs_bitmap_map_test (rtems_rfs_bitmap_control *control, rtems_rfs_bitmap_bit bit, bool *state)
int | rtems_rfs_bitmap_map_set_all (rtems_rfs_bitmap_control *control)
int | rtems_rfs_bitmap_map_clear_all (rtems_rfs_bitmap_control *control)
int | rtems_rfs_bitmap_map_alloc (rtems_rfs_bitmap_control *control, rtems_rfs_bitmap_bit seed, bool *allocated, rtems_rfs_bitmap_bit *bit)
int | rtems_rfs_bitmap_create_search (rtems_rfs_bitmap_control *control)
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)
int | rtems_rfs_bitmap_close (rtems_rfs_bitmap_control *control)

## Detailed Description

RTEMS File Systems Bitmap Routines.

These functions manage bit maps. A bit map consists of the map of bit allocated in a block and a search map where a bit represents 32 actual bits. The search map allows for a faster search for an available bit as 32 search bits can checked in a test.

## Macro Definition Documentation

## ◆ rtems_rfs_bitmap_check

#define rtems_rfs_bitmap_check | ( |  | _c,
|  |  | _sm
| ) |  |

Value:
_Assert(_sm >= _c->search_bits && \
_sm < (_c->search_bits + \
rtems_rfs_bitmap_elements(rtems_rfs_bitmap_elements(_c->size))))
_Assert
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG.
Definition: assert.h:100
rtems_rfs_bitmap_elements
#define rtems_rfs_bitmap_elements(_bits)
Definition: rtems-rfs-bitmaps.h:138

## ◆ RTEMS_RFS_BITMAP_WARNINGS

#define RTEMS_RFS_BITMAP_WARNINGS 0

Set to 1 to enable warnings when developing.

## Function Documentation

## ◆ rtems_rfs_bitmap_close()

int rtems_rfs_bitmap_close | ( | rtems_rfs_bitmap_control * | control | ) |

Close a bitmap.

Parameters

  [in] | control | is the bit map control.

Return values

  0 | Successful operation.
  error_code | An error occurred.

## ◆ rtems_rfs_bitmap_create_search()

int rtems_rfs_bitmap_create_search | ( | rtems_rfs_bitmap_control * | control | ) |

Create a search bit map from the actual bit map.

Parameters

  [in] | control | is the map control.

Return values

  0 | Successful operation.
  error_code | An error occurred.

## ◆ 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
| ) |  |

Find a free bit searching from the seed up and down until found. The search is performing by moving up from the seed for the window distance then to search down from the seed for the window distance. This is repeated out from the seed for each window until a free bit is found. The search is performed by checking the search map to see if the map has a free bit.

Parameters

  [in] | control | is the map control.
  [in] | seed | is the bit to search out from.
  [out] | allocate | A bit was allocated.
  [out] | bit | will contain the bit found free if true is returned.

Return values

  0 | Successful operation.
  error_code | An error occurred.

## ◆ rtems_rfs_bitmap_map_clear()

int rtems_rfs_bitmap_map_clear | ( | rtems_rfs_bitmap_control * | control,
|  | rtems_rfs_bitmap_bit | bit
| ) |  |

Clear a bit in a map and make sure the search map bit is clear so a search will find this bit available.

Parameters

  [in] | control | is the control for the map.
  [in] | bit | is the bit in the map to clear.

Return values

  0 | Successful operation.
  error_code | An error occurred.

## ◆ rtems_rfs_bitmap_map_clear_all()

int rtems_rfs_bitmap_map_clear_all | ( | rtems_rfs_bitmap_control * | control | ) |

Clear all bits in the bitmap and set the dirty bit.

Parameters

  [in] | control | is the bitmap control.

Return values

  0 | Successful operation.
  error_code | An error occurred.

## ◆ rtems_rfs_bitmap_map_set()

int rtems_rfs_bitmap_map_set | ( | rtems_rfs_bitmap_control * | control,
|  | rtems_rfs_bitmap_bit | bit
| ) |  |

Set a bit in a map and if all the bits are set, set the search map bit as well.

Parameters

  [in] | control | is the control for the map.
  [in] | bit | is the bit in the map to set.

Return values

  0 | Successful operation.
  error_code | An error occurred.

## ◆ rtems_rfs_bitmap_map_set_all()

int rtems_rfs_bitmap_map_set_all | ( | rtems_rfs_bitmap_control * | control | ) |

Set all bits in the bitmap and set the dirty bit.

Parameters

  [in] | control | is the bitmap control.

Return values

  0 | Successful operation.
  error_code | An error occurred.

## ◆ rtems_rfs_bitmap_map_test()

int rtems_rfs_bitmap_map_test | ( | rtems_rfs_bitmap_control * | control,
|  | rtems_rfs_bitmap_bit | bit,
|  | bool * | state
| ) |  |

Test a bit in the map.

Parameters

  [in] | control | is the bitmap control.
  [in] | bit | is the bit to test.
  [in] | state | is the state of the bit if no error is returned.

Return values

  0 | Successful operation.
  error_code | An error occurred.

## ◆ rtems_rfs_bitmap_mask()

rtems_rfs_bitmap_element rtems_rfs_bitmap_mask | ( | unsigned int | size | ) |

Create a bit mask with the specified number of bits up to an element's size. The mask is aligned to bit 0 of the element.

Parameters

  [in] | size | is the number of bits in the mask.

Returns
  The mask of the argument size number of bits.

## ◆ rtems_rfs_bitmap_mask_section()

rtems_rfs_bitmap_element rtems_rfs_bitmap_mask_section | ( | unsigned int | start,
|  | unsigned int | end
| ) |  |

Create a bit mask section. A mask section is a mask that is not aligned to an end of the element.

Parameters

  [in] | start | is the first bit of the mask numbered from 0.
  [in] | end | is the end bit of the mask numbered from 0.

Returns
  Mask section as defined by the start and end arguments.

## ◆ 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
| ) |  |

Open a bitmap control with a map and search map.

Parameters

  [in] | control | is the map control.
  [in] | fs | is the file system data.
  [in] | buffer | is a pointer to the buffer handle the map is stored in.
  [in] | size | is the number of bits in the map.

Return values

  0 | Successful operation.
  error_code | An error occurred.