blob: 7580b78e572fde4625a33da45e6cb67fc28d92c1 [file] [log] [blame]
nabkah01002e5692022-10-10 12:36:46 +01001/*
2 * Copyright (c) 2022, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#ifndef PAGE_ALLOC_H
9#define PAGE_ALLOC_H
10
11#include <stdint.h>
12#include <stdlib.h>
13
14#define HEAP_NULL_PTR 0U
15#define HEAP_INVALID_LEN -1
16#define HEAP_OUT_OF_RANGE -2
17#define HEAP_INIT_FAILED -3
18#define HEAP_INIT_SUCCESS 0
19
20/*
21 * Initialize the memory heap space to be used
22 * @heap_base: heap base address
23 * @heap_len: heap size for use
24 */
25int page_pool_init(uint64_t heap_base, uint64_t heap_len);
26
27/*
28 * Return the pointer to the allocated pages
29 * @bytes_size: pages to allocate in byte unit
30 */
31void *page_alloc(u_register_t bytes_size);
32
33/*
34 * Reset heap memory usage cursor to heap base address
35 */
36void page_pool_reset(void);
37void page_free(u_register_t ptr);
38
39#endif /* PAGE_ALLOC_H */