1 /* 2 * Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef CACHE_HAL_H 16 #define CACHE_HAL_H 17 18 #ifdef __cplusplus 19 extern "C" { 20 #endif 21 22 #include "plat_types.h" 23 24 enum HAL_CACHE_ID_T { 25 HAL_CACHE_ID_I_CACHE = 0, 26 HAL_CACHE_ID_D_CACHE, 27 HAL_CACHE_ID_NUM, 28 }; 29 30 struct HAL_CACHE_MON_DATA_T { 31 uint64_t r_hit; 32 uint64_t r_miss; 33 uint64_t w_hit; 34 uint64_t w_miss; 35 }; 36 37 uint8_t hal_cache_enable(enum HAL_CACHE_ID_T id); 38 uint8_t hal_cache_disable(enum HAL_CACHE_ID_T id); 39 uint8_t hal_cache_writebuffer_enable(enum HAL_CACHE_ID_T id); 40 uint8_t hal_cache_writebuffer_disable(enum HAL_CACHE_ID_T id); 41 uint8_t hal_cache_writebuffer_flush(enum HAL_CACHE_ID_T id); 42 uint8_t hal_cache_writeback_enable(enum HAL_CACHE_ID_T id); 43 uint8_t hal_cache_writeback_disable(enum HAL_CACHE_ID_T id); 44 uint8_t hal_cache_wrap_enable(enum HAL_CACHE_ID_T id); 45 uint8_t hal_cache_wrap_disable(enum HAL_CACHE_ID_T id); 46 uint8_t hal_cache_invalidate_all(enum HAL_CACHE_ID_T id); 47 uint8_t hal_cache_invalidate(enum HAL_CACHE_ID_T id, uint32_t start_address, uint32_t len); 48 uint8_t hal_cache_sync_all(enum HAL_CACHE_ID_T id); 49 uint8_t hal_cache_sync(enum HAL_CACHE_ID_T id, uint32_t start_address, uint32_t len); 50 uint8_t hal_cache_monitor_enable(enum HAL_CACHE_ID_T id); 51 uint8_t hal_cache_monitor_disable(enum HAL_CACHE_ID_T id); 52 uint8_t hal_cache_get_monitor_data(enum HAL_CACHE_ID_T id, struct HAL_CACHE_MON_DATA_T *md); 53 void hal_cache_print_stats(void); 54 void hal_cache_sleep(void); 55 void hal_cache_wakeup(void); 56 57 uint8_t hal_cachecp_enable(enum HAL_CACHE_ID_T id); 58 uint8_t hal_cachecp_disable(enum HAL_CACHE_ID_T id); 59 uint8_t hal_cachecp_writebuffer_enable(enum HAL_CACHE_ID_T id); 60 uint8_t hal_cachecp_writebuffer_disable(enum HAL_CACHE_ID_T id); 61 uint8_t hal_cachecp_writebuffer_flush(enum HAL_CACHE_ID_T id); 62 uint8_t hal_cachecp_writeback_enable(enum HAL_CACHE_ID_T id); 63 uint8_t hal_cachecp_writeback_disable(enum HAL_CACHE_ID_T id); 64 uint8_t hal_cachecp_invalidate(enum HAL_CACHE_ID_T id, uint32_t start_address, uint32_t len); 65 uint8_t hal_cachecp_sync_all(enum HAL_CACHE_ID_T id); 66 uint8_t hal_cachecp_monitor_enable(enum HAL_CACHE_ID_T id); 67 uint8_t hal_cachecp_monitor_disable(enum HAL_CACHE_ID_T id); 68 uint8_t hal_cachecp_get_monitor_data(enum HAL_CACHE_ID_T id, struct HAL_CACHE_MON_DATA_T *md); 69 void hal_cachecp_print_stats(void); 70 71 #ifdef __cplusplus 72 } 73 #endif 74 75 #endif /* CACHE_HAL_H */ 76