1/* @title: Page Allocation */
2#pragma once
3#include <compiler/core.h>
4#include <mem/alloc_param.h>
5#include <stddef.h>
6#include <stdint.h>
7
8#define ALLOC_FLAG_EX_PG_CONTIGUOUS ALLOC_FLAG_AVAIL_BIT(0)
9
10#define page_alloc(page_count, ...) \
11 page_alloc_full((page_count), alloc_params_with_defaults( \
12 ALLOC_FLAGS_NONE, ALLOC_BEHAVIOR_NORMAL, \
13 ##__VA_ARGS__))
14
15#define page_alloc_demand(page_count, ...) \
16 page_alloc_demand_full((page_count), \
17 alloc_params_with_defaults(ALLOC_FLAGS_NONE, \
18 ALLOC_BEHAVIOR_NORMAL, \
19 ##__VA_ARGS__))
20
21#define page_free_2(ptr, page_count) \
22 page_free_3((ptr), (page_count), ALLOC_BEHAVIOR_NORMAL)
23#define page_free_3(ptr, page_count, bh) \
24 page_free_full((ptr), (page_count), (bh))
25
26#define page_free(...) PP_CALL(page_free, __VA_ARGS__)
27
28void *page_alloc_full(size_t page_count, struct alloc_params params) cw_alloc();
29void *page_alloc_demand_full(size_t page_count, struct alloc_params params)
30 cw_alloc();
31void page_free_full(void *ptr, size_t page_count, enum alloc_behavior behavior);
32bool page_alloc_vaddr_in_vas(vaddr_t vaddr);
33void page_alloc_init(void);
34