blob: bb5fb2e971a90875c7fe91cdb671ff0f28f8501a [file] [log] [blame]
Benjamin Walsh334c14e2015-09-18 16:36:57 -04001/*
2 * Copyright (c) 2015 Wind River Systems, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _cache__h_
18#define _cache__h_
19
Anas Nashifea8c6aad2016-12-23 07:32:56 -050020#include <kernel.h>
Benjamin Walsh334c14e2015-09-18 16:36:57 -040021
Peter Mitsisa0e45682016-01-22 12:38:49 -050022#ifdef __cplusplus
23extern "C" {
24#endif
25
Benjamin Walsh334c14e2015-09-18 16:36:57 -040026#define _sys_cache_flush_sig(x) void (x)(vaddr_t virt, size_t size)
27
Benjamin Walsh7b526e22015-10-30 17:04:00 -040028#if defined(CONFIG_CACHE_FLUSHING)
29
Benjamin Walsh334c14e2015-09-18 16:36:57 -040030#if defined(CONFIG_ARCH_CACHE_FLUSH_DETECT)
31 typedef _sys_cache_flush_sig(_sys_cache_flush_t);
32 extern _sys_cache_flush_t *sys_cache_flush;
33#else
34 extern _sys_cache_flush_sig(sys_cache_flush);
35#endif
Benjamin Walsh7b526e22015-10-30 17:04:00 -040036
37#else
38
39/*
40 * Provide NOP APIs for systems that do not have caches.
41 *
42 * An example is the Cortex-M chips. However, the functions are provided so
43 * that code that need to manipulate caches can be written in an
44 * architecture-agnostic manner. The functions do nothing. The cache line size
45 * value is always 0.
46 */
47
48static inline _sys_cache_flush_sig(sys_cache_flush)
49{
50 ARG_UNUSED(virt);
51 ARG_UNUSED(size);
52
53 /* do nothing */
54}
55
Benjamin Walsh334c14e2015-09-18 16:36:57 -040056#endif /* CACHE_FLUSHING */
57
58#if defined(CONFIG_CACHE_LINE_SIZE_DETECT)
59 extern size_t sys_cache_line_size;
Benjamin Walsh7b526e22015-10-30 17:04:00 -040060#elif defined(CONFIG_CACHE_LINE_SIZE)
Benjamin Walsh334c14e2015-09-18 16:36:57 -040061 #define sys_cache_line_size CONFIG_CACHE_LINE_SIZE
Benjamin Walsh7b526e22015-10-30 17:04:00 -040062#else
63 #define sys_cache_line_size 0
Benjamin Walsh334c14e2015-09-18 16:36:57 -040064#endif
65
Peter Mitsisa0e45682016-01-22 12:38:49 -050066#ifdef __cplusplus
67}
68#endif
69
Benjamin Walsh334c14e2015-09-18 16:36:57 -040070#endif /* _cache__h_ */