1/*
2 * Copyright (C) 2020-2022 The opuntiaOS Project Authors.
3 * + Contributed by Nikita Melekhin <nimelehin@gmail.com>
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9#ifndef _KERNEL_ALGO_BITMAP_H
10#define _KERNEL_ALGO_BITMAP_H
11
12#include <libkern/types.h>
13
14struct bitmap {
15 uint8_t* data;
16 size_t len;
17};
18typedef struct bitmap bitmap_t;
19
20bitmap_t bitmap_wrap(uint8_t* data, size_t len);
21bitmap_t bitmap_allocate(size_t len);
22int bitmap_find_space(bitmap_t bitmap, int req);
23int bitmap_find_space_aligned(bitmap_t bitmap, int req, int alignment);
24int bitmap_set(bitmap_t bitmap, int where);
25int bitmap_unset(bitmap_t bitmap, int where);
26int bitmap_set_range(bitmap_t bitmap, int start, int len);
27int bitmap_unset_range(bitmap_t bitmap, int start, int len);
28#endif //_KERNEL_ALGO_BITMAP_H