1 /* 2 * Copyright (c) 2019 Nuclei Limited. All rights reserved. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Licensed under the Apache License, Version 2.0 (the License); you may 7 * not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 #ifndef __CORE_FEATURE_CACHE_H__ 19 #define __CORE_FEATURE_CACHE_H__ 20 /*! 21 * @file core_feature_cache.h 22 * @brief Cache feature API header file for Nuclei N/NX Core 23 */ 24 /* 25 * Cache Feature Configuration Macro: 26 * 1. __ICACHE_PRESENT: Define whether I-Cache Unit is present or not. 27 * * 0: Not present 28 * * 1: Present 29 * 1. __DCACHE_PRESENT: Define whether D-Cache Unit is present or not. 30 * * 0: Not present 31 * * 1: Present 32 */ 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 #if defined(__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1) 38 39 /* ########################## Cache functions #################################### */ 40 /** 41 * \defgroup NMSIS_Core_Cache Cache Functions 42 * \brief Functions that configure Instruction and Data Cache. 43 * @{ 44 */ 45 46 /** @} */ /* End of Doxygen Group NMSIS_Core_Cache */ 47 48 /** 49 * \defgroup NMSIS_Core_ICache I-Cache Functions 50 * \ingroup NMSIS_Core_Cache 51 * \brief Functions that configure Instruction Cache. 52 * @{ 53 */ 54 /** 55 * \brief Enable ICache 56 * \details 57 * This function enable I-Cache 58 * \remarks 59 * - This \ref CSR_MCACHE_CTL register control I Cache enable. 60 * \sa 61 * - \ref DisableICache 62 */ EnableICache(void)63__STATIC_FORCEINLINE void EnableICache (void) 64 { 65 __RV_CSR_SET(CSR_MCACHE_CTL, CSR_MCACHE_CTL_IE); 66 } 67 68 /** 69 * \brief Disable ICache 70 * \details 71 * This function Disable I-Cache 72 * \remarks 73 * - This \ref CSR_MCACHE_CTL register control I Cache enable. 74 * \sa 75 * - \ref EnableICache 76 */ DisableICache(void)77__STATIC_FORCEINLINE void DisableICache (void) 78 { 79 __RV_CSR_CLEAR(CSR_MCACHE_CTL, CSR_MCACHE_CTL_IE); 80 } 81 /** @} */ /* End of Doxygen Group NMSIS_Core_ICache */ 82 #endif /* defined(__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1) */ 83 84 #if defined(__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1) 85 /** 86 * \defgroup NMSIS_Core_DCache D-Cache Functions 87 * \ingroup NMSIS_Core_Cache 88 * \brief Functions that configure Data Cache. 89 * @{ 90 */ 91 /** 92 * \brief Enable DCache 93 * \details 94 * This function enable D-Cache 95 * \remarks 96 * - This \ref CSR_MCACHE_CTL register control D Cache enable. 97 * \sa 98 * - \ref DisableDCache 99 */ EnableDCache(void)100__STATIC_FORCEINLINE void EnableDCache (void) 101 { 102 __RV_CSR_SET(CSR_MCACHE_CTL, CSR_MCACHE_CTL_DE); 103 } 104 105 /** 106 * \brief Disable DCache 107 * \details 108 * This function Disable D-Cache 109 * \remarks 110 * - This \ref CSR_MCACHE_CTL register control D Cache enable. 111 * \sa 112 * - \ref EnableDCache 113 */ DisableDCache(void)114__STATIC_FORCEINLINE void DisableDCache (void) 115 { 116 __RV_CSR_CLEAR(CSR_MCACHE_CTL, CSR_MCACHE_CTL_DE); 117 } 118 /** @} */ /* End of Doxygen Group NMSIS_Core_DCache */ 119 #endif /* defined(__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1) */ 120 121 #ifdef __cplusplus 122 } 123 #endif 124 #endif /** __CORE_FEATURE_CACHE_H__ */ 125