MT2523 API Reference  LinkIt SDK v4
hal_cache.h
1 /* Copyright Statement:
2  *
3  * (C) 2005-2017 MediaTek Inc. All rights reserved.
4  *
5  * This software/firmware and related documentation ("MediaTek Software") are
6  * protected under relevant copyright laws. The information contained herein
7  * is confidential and proprietary to MediaTek Inc. ("MediaTek") and/or its licensors.
8  * Without the prior written permission of MediaTek and/or its licensors,
9  * any reproduction, modification, use or disclosure of MediaTek Software,
10  * and information contained herein, in whole or in part, shall be strictly prohibited.
11  * You may only use, reproduce, modify, or distribute (as applicable) MediaTek Software
12  * if you have agreed to and been bound by the applicable license agreement with
13  * MediaTek ("License Agreement") and been granted explicit permission to do so within
14  * the License Agreement ("Permitted User"). If you are not a Permitted User,
15  * please cease any access or use of MediaTek Software immediately.
16  * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
17  * THAT MEDIATEK SOFTWARE RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES
18  * ARE PROVIDED TO RECEIVER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
19  * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
21  * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
22  * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
23  * SUPPLIED WITH MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
24  * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
25  * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
26  * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
27  * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
28  * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
29  * CUMULATIVE LIABILITY WITH RESPECT TO MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
30  * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE MEDIATEK SOFTWARE AT ISSUE,
31  * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
32  * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
33  */
34 
35 #ifndef __HAL_CACHE_H__
36 #define __HAL_CACHE_H__
37 #include "hal_platform.h"
38 
39 #ifdef HAL_CACHE_MODULE_ENABLED
40 
150 #ifdef __cplusplus
151 extern "C" {
152 #endif
153 
154 /*****************************************************************************
155  * Enums
156  *****************************************************************************/
157 
163 typedef enum {
173 
174 
176 typedef enum {
183 
184 
186 typedef enum {
205 
210 /*****************************************************************************
211  * Structures
212  *****************************************************************************/
213 
219 typedef struct {
221  uint32_t cache_region_size;
223 
228 /*****************************************************************************
229  * Functions
230  *****************************************************************************/
231 
239 
240 
247 
248 
256 
257 
264 
265 
274 hal_cache_status_t hal_cache_region_enable(hal_cache_region_t region);
275 
276 
284 hal_cache_status_t hal_cache_region_disable(hal_cache_region_t region);
285 
286 
294 hal_cache_status_t hal_cache_set_size(hal_cache_size_t cache_size);
295 
307 hal_cache_status_t hal_cache_region_config(hal_cache_region_t region, const hal_cache_region_config_t *region_config);
308 
317 
326 hal_cache_status_t hal_cache_invalidate_multiple_cache_lines(uint32_t address, uint32_t length);
327 
328 
335 
344 
353 hal_cache_status_t hal_cache_flush_multiple_cache_lines(uint32_t address, uint32_t length);
354 
355 
363 
364 
372 bool hal_cache_is_cacheable(uint32_t address);
373 
374 
382 #define HAL_CACHE_LINE_SIZE (32)
383 
384 
385 #ifdef HAL_CACHE_WITH_REMAP_FEATURE
386 
390 #define HAL_CACHE_VIRTUAL_TO_PHYSICAL(address) (address & (~VRAM_BASE))
391 
392 
396 #define HAL_CACHE_PHYSICAL_TO_VIRTUAL(address) (address | VRAM_BASE)
397 #endif
398 
399 
405 #ifdef __cplusplus
406 }
407 #endif
408 
413 #endif /*HAL_CACHE_MODULE_ENABLED*/
414 #endif /* __HAL_CACHE_H__ */
415 
416 
CACHE region 5.
Definition: hal_cache.h:192
hal_cache_status_t hal_cache_init(void)
This function initializes the CACHE, sets the default cacheable attribute for the project memory layo...
CACHE region 1.
Definition: hal_cache.h:188
CACHE region 2.
Definition: hal_cache.h:189
No CACHE.
Definition: hal_cache.h:177
The total number of CACHE regions (invalid region).
Definition: hal_cache.h:203
hal_cache_region_t
This enum defines the CACHE region number.
Definition: hal_cache.h:186
hal_cache_status_t hal_cache_region_config(hal_cache_region_t region, const hal_cache_region_config_t *region_config)
This function configures the CACHE.
CACHE region 15.
Definition: hal_cache.h:202
CACHE region 14.
Definition: hal_cache.h:201
CACHE region 7.
Definition: hal_cache.h:194
CACHE size is 8kB.
Definition: hal_cache.h:178
hal_cache_status_t hal_cache_region_enable(hal_cache_region_t region)
This function enables a single CACHE region.
hal_cache_status_t hal_cache_region_disable(hal_cache_region_t region)
This function disables a single CACHE region.
uint32_t cache_region_address
Starting address of the CACHE region.
Definition: hal_cache.h:220
CACHE region 10.
Definition: hal_cache.h:197
CACHE size is 32kB.
Definition: hal_cache.h:180
CACHE is busy.
Definition: hal_cache.h:165
bool hal_cache_is_cacheable(uint32_t address)
This function checks whether the memory is cacheable.
CACHE region error, CACHE region is not a value of type hal_cache_region_t.
Definition: hal_cache.h:167
CACHE size is invalid, total CACHE size is not a value of type hal_cache_size_t.
Definition: hal_cache.h:166
CACHE API call returns successfully.
Definition: hal_cache.h:171
CACHE region enable error, CACHE region is not set at the time the region is being enabled...
Definition: hal_cache.h:170
CACHE region size error, CACHE region size is not a multiple of 4kB.
Definition: hal_cache.h:169
hal_cache_status_t hal_cache_invalidate_multiple_cache_lines(uint32_t address, uint32_t length)
This function invalidates the CACHE lines by address and length.
hal_cache_status_t hal_cache_deinit(void)
This function deinitializes the CACHE, returning the CACHE module to its default state.
CACHE region 13.
Definition: hal_cache.h:200
hal_cache_size_t
This enum defines the CACHE size.
Definition: hal_cache.h:176
hal_cache_status_t hal_cache_flush_multiple_cache_lines(uint32_t address, uint32_t length)
This function flushes the CACHE lines by address and length.
CACHE region 12.
Definition: hal_cache.h:199
CACHE size is 16kB.
Definition: hal_cache.h:179
hal_cache_status_t hal_cache_invalidate_one_cache_line(uint32_t address)
This function invalidates a CACHE line at a given address.
hal_cache_status_t hal_cache_invalidate_all_cache_lines(void)
This function invalidates the whole CACHE.
CACHE region 9.
Definition: hal_cache.h:196
Invalid parameter.
Definition: hal_cache.h:164
CACHE region 3.
Definition: hal_cache.h:190
CACHE region address error, CACHE region address is not 4kB aligned.
Definition: hal_cache.h:168
uint32_t cache_region_size
The CACHE region size.
Definition: hal_cache.h:221
CACHE region 11.
Definition: hal_cache.h:198
CACHE region 8.
Definition: hal_cache.h:195
CACHE region 4.
Definition: hal_cache.h:191
hal_cache_status_t hal_cache_disable(void)
This function disables the CACHE controller.
CACHE region 6.
Definition: hal_cache.h:193
hal_cache_status_t hal_cache_enable(void)
This function enables the CACHE controller.
CACHE region 0.
Definition: hal_cache.h:187
hal_cache_status_t hal_cache_flush_all_cache_lines(void)
This function flushes the whole CACHE.
The total number of CACHE sizes (invalid size).
Definition: hal_cache.h:181
hal_cache_status_t hal_cache_set_size(hal_cache_size_t cache_size)
This function sets the total size of the CACHE.
hal_cache_status_t hal_cache_flush_one_cache_line(uint32_t address)
This function flushes one CACHE line by address.
hal_cache_status_t
This enum defines the CACHE API return status.
Definition: hal_cache.h:163
The CACHE region configuration structure that contains the start address and the size of the region...
Definition: hal_cache.h:219