nabkah01 | 002e569 | 2022-10-10 12:36:46 +0100 | [diff] [blame^] | 1 | /* |
| 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 | */ |
| 25 | int 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 | */ |
| 31 | void *page_alloc(u_register_t bytes_size); |
| 32 | |
| 33 | /* |
| 34 | * Reset heap memory usage cursor to heap base address |
| 35 | */ |
| 36 | void page_pool_reset(void); |
| 37 | void page_free(u_register_t ptr); |
| 38 | |
| 39 | #endif /* PAGE_ALLOC_H */ |