xref: /optee_os/lib/libutils/isoc/include/malloc_flags.h (revision 5d5d7d0b1c038a6836be9f0b38585f5aa6a4dd01)
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2025, Linaro Limited.
4  */
5 #ifndef __MALLOC_FLAGS_H
6 #define __MALLOC_FLAGS_H
7 
8 /*
9  * This file doesn't have any dependencies to minimize impact when
10  * including this file.
11  *
12  * Pulling in for instance <util.h> for the BIT() macro would also define
13  * the MIN() macro which would cause a error in
14  * core/lib/libtomcrypt/src/pk/dsa/dsa_decrypt_key.c
15  */
16 
17 /*
18  * Memory allocation flags to control how buffers are allocated. Flags may
19  * be ignored depending on configuration or if they don't apply. These
20  * flags are primarily used by malloc() and friends in malloc.h, but can be
21  * extended with flags that only mean something for other functions to
22  * avoid needless translation of one class of flags to another class of
23  * flags.
24  */
25 #define MAF_NULL	0x00	/* Passed if no flags are needed */
26 #define MAF_ZERO_INIT	0x01	/* Zero initialize the allocated buffer */
27 #define MAF_NEX		0x02	/* Allocate from nexus heap */
28 #define MAF_FREE_WIPE	0x04	/* Free wipes allocated buffer */
29 /*
30  * Used by tee_mm_init() to indicatate that the pool should allocate
31  * from high address to low address.
32  */
33 #define MAF_HI_ALLOC	0x10
34 /*
35  * Used by phys_mem_alloc_flags() to indicate whether physical memory
36  * should be allocated from the Core or TA physical memory pool.
37  */
38 #define MAF_CORE_MEM	0x20
39 /*
40  * Used by virt_page_alloc() to inidicate whether the allocated memory
41  * should by guarded by an unmapped page at the beginning and end.
42  */
43 #define MAF_GUARD_HEAD	0x40
44 #define MAF_GUARD_TAIL	0x80
45 
46 #endif /*__MALLOC_FLAGS_H*/
47