1ed81f3ebSSandrine Bailleux /* 29edac047SDavid Cunado * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved. 3ed81f3ebSSandrine Bailleux * 4ed81f3ebSSandrine Bailleux * Redistribution and use in source and binary forms, with or without 5ed81f3ebSSandrine Bailleux * modification, are permitted provided that the following conditions are met: 6ed81f3ebSSandrine Bailleux * 7ed81f3ebSSandrine Bailleux * Redistributions of source code must retain the above copyright notice, this 8ed81f3ebSSandrine Bailleux * list of conditions and the following disclaimer. 9ed81f3ebSSandrine Bailleux * 10ed81f3ebSSandrine Bailleux * Redistributions in binary form must reproduce the above copyright notice, 11ed81f3ebSSandrine Bailleux * this list of conditions and the following disclaimer in the documentation 12ed81f3ebSSandrine Bailleux * and/or other materials provided with the distribution. 13ed81f3ebSSandrine Bailleux * 14ed81f3ebSSandrine Bailleux * Neither the name of ARM nor the names of its contributors may be used 15ed81f3ebSSandrine Bailleux * to endorse or promote products derived from this software without specific 16ed81f3ebSSandrine Bailleux * prior written permission. 17ed81f3ebSSandrine Bailleux * 18ed81f3ebSSandrine Bailleux * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19ed81f3ebSSandrine Bailleux * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20ed81f3ebSSandrine Bailleux * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21ed81f3ebSSandrine Bailleux * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 22ed81f3ebSSandrine Bailleux * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23ed81f3ebSSandrine Bailleux * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24ed81f3ebSSandrine Bailleux * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25ed81f3ebSSandrine Bailleux * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26ed81f3ebSSandrine Bailleux * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27ed81f3ebSSandrine Bailleux * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28ed81f3ebSSandrine Bailleux * POSSIBILITY OF SUCH DAMAGE. 29ed81f3ebSSandrine Bailleux */ 30ed81f3ebSSandrine Bailleux 31ed81f3ebSSandrine Bailleux #ifndef __UTILS_H__ 32ed81f3ebSSandrine Bailleux #define __UTILS_H__ 33ed81f3ebSSandrine Bailleux 34*53d9c9c8SScott Branden #if !ERROR_DEPRECATED 35*53d9c9c8SScott Branden #include <utils_def.h> 369edac047SDavid Cunado #endif 379edac047SDavid Cunado 38308d359bSDouglas Raillard /* 39308d359bSDouglas Raillard * C code should be put in this part of the header to avoid breaking ASM files 40308d359bSDouglas Raillard * or linker scripts including it. 41308d359bSDouglas Raillard */ 42308d359bSDouglas Raillard #if !(defined(__LINKER__) || defined(__ASSEMBLY__)) 43308d359bSDouglas Raillard 44308d359bSDouglas Raillard #include <types.h> 45308d359bSDouglas Raillard 46308d359bSDouglas Raillard /* 47308d359bSDouglas Raillard * Fill a region of normal memory of size "length" in bytes with zero bytes. 48308d359bSDouglas Raillard * 49308d359bSDouglas Raillard * WARNING: This function can only operate on normal memory. This means that 50308d359bSDouglas Raillard * the MMU must be enabled when using this function. Otherwise, use 51308d359bSDouglas Raillard * zeromem. 52308d359bSDouglas Raillard */ 53308d359bSDouglas Raillard void zero_normalmem(void *mem, u_register_t length); 54308d359bSDouglas Raillard 55308d359bSDouglas Raillard /* 56308d359bSDouglas Raillard * Fill a region of memory of size "length" in bytes with null bytes. 57308d359bSDouglas Raillard * 58308d359bSDouglas Raillard * Unlike zero_normalmem, this function has no restriction on the type of 59308d359bSDouglas Raillard * memory targeted and can be used for any device memory as well as normal 60308d359bSDouglas Raillard * memory. This function must be used instead of zero_normalmem when MMU is 61308d359bSDouglas Raillard * disabled. 62308d359bSDouglas Raillard * 63308d359bSDouglas Raillard * NOTE: When data cache and MMU are enabled, prefer zero_normalmem for faster 64308d359bSDouglas Raillard * zeroing. 65308d359bSDouglas Raillard */ 66308d359bSDouglas Raillard void zeromem(void *mem, u_register_t length); 67308d359bSDouglas Raillard #endif /* !(defined(__LINKER__) || defined(__ASSEMBLY__)) */ 68308d359bSDouglas Raillard 69ed81f3ebSSandrine Bailleux #endif /* __UTILS_H__ */ 70