xref: /rk3399_ARM-atf/include/lib/utils.h (revision 82cb2c1ad9897473743f08437d0a3995bed561b9)
1ed81f3ebSSandrine Bailleux /*
29edac047SDavid Cunado  * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
3ed81f3ebSSandrine Bailleux  *
4*82cb2c1aSdp-arm  * SPDX-License-Identifier: BSD-3-Clause
5ed81f3ebSSandrine Bailleux  */
6ed81f3ebSSandrine Bailleux 
7ed81f3ebSSandrine Bailleux #ifndef __UTILS_H__
8ed81f3ebSSandrine Bailleux #define __UTILS_H__
9ed81f3ebSSandrine Bailleux 
1053d9c9c8SScott Branden #if !ERROR_DEPRECATED
1153d9c9c8SScott Branden #include <utils_def.h>
129edac047SDavid Cunado #endif
139edac047SDavid Cunado 
14308d359bSDouglas Raillard /*
15308d359bSDouglas Raillard  * C code should be put in this part of the header to avoid breaking ASM files
16308d359bSDouglas Raillard  * or linker scripts including it.
17308d359bSDouglas Raillard  */
18308d359bSDouglas Raillard #if !(defined(__LINKER__) || defined(__ASSEMBLY__))
19308d359bSDouglas Raillard 
20308d359bSDouglas Raillard #include <types.h>
21308d359bSDouglas Raillard 
22308d359bSDouglas Raillard /*
23308d359bSDouglas Raillard  * Fill a region of normal memory of size "length" in bytes with zero bytes.
24308d359bSDouglas Raillard  *
25308d359bSDouglas Raillard  * WARNING: This function can only operate on normal memory. This means that
26308d359bSDouglas Raillard  *          the MMU must be enabled when using this function. Otherwise, use
27308d359bSDouglas Raillard  *          zeromem.
28308d359bSDouglas Raillard  */
29308d359bSDouglas Raillard void zero_normalmem(void *mem, u_register_t length);
30308d359bSDouglas Raillard 
31308d359bSDouglas Raillard /*
32308d359bSDouglas Raillard  * Fill a region of memory of size "length" in bytes with null bytes.
33308d359bSDouglas Raillard  *
34308d359bSDouglas Raillard  * Unlike zero_normalmem, this function has no restriction on the type of
35308d359bSDouglas Raillard  * memory targeted and can be used for any device memory as well as normal
36308d359bSDouglas Raillard  * memory. This function must be used instead of zero_normalmem when MMU is
37308d359bSDouglas Raillard  * disabled.
38308d359bSDouglas Raillard  *
39308d359bSDouglas Raillard  * NOTE: When data cache and MMU are enabled, prefer zero_normalmem for faster
40308d359bSDouglas Raillard  *       zeroing.
41308d359bSDouglas Raillard  */
42308d359bSDouglas Raillard void zeromem(void *mem, u_register_t length);
43308d359bSDouglas Raillard #endif /* !(defined(__LINKER__) || defined(__ASSEMBLY__)) */
44308d359bSDouglas Raillard 
45ed81f3ebSSandrine Bailleux #endif /* __UTILS_H__ */
46