1// SPDX-License-Identifier: GPL-3.0-or-later
2
3#pragma once
4
5#include <mos/moslib_global.h>
6#include <mos/types.h>
7
8typedef u32 bitmap_line_t;
9
10#define BITMAP_LINE_BITS (sizeof(bitmap_line_t) * 8)
11#define BITMAP_LINE_COUNT(size) (ALIGN_UP(size, BITMAP_LINE_BITS) / BITMAP_LINE_BITS)
12
13MOSAPI bitmap_line_t *bitmap_create(size_t size);
14
15MOSAPI void bitmap_zero(bitmap_line_t *bitmap, size_t bitmap_nlines);
16MOSAPI bool bitmap_set(bitmap_line_t *bitmap, size_t bitmap_nlines, size_t index);
17MOSAPI bool bitmap_clear(bitmap_line_t *bitmap, size_t bitmap_nlines, size_t index);
18MOSAPI void bitmap_set_range(bitmap_line_t *bitmap, size_t bitmap_nlines, size_t start, size_t end, bool value);
19MOSAPI bool bitmap_get(const bitmap_line_t *bitmap, size_t bitmap_nlines, size_t index);
20
21MOSAPI size_t bitmap_find_first_free_n(bitmap_line_t *bitmap, size_t bitmap_nlines, size_t begin_bit, size_t n_bits);
22