]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_FreedomStudio/freedom-metal/src/memory.c
Update RISCC-V-RV32-SiFive_HiFive1_FreedomStudio project to latest tools and metal...
[freertos] / FreeRTOS / Demo / RISC-V_RV32_SiFive_HiFive1_FreedomStudio / freedom-metal / src / memory.c
1 /* Copyright 2019 SiFive, Inc */
2 /* SPDX-License-Identifier: Apache-2.0 */
3
4 #include <metal/machine.h>
5 #include <metal/memory.h>
6
7 struct metal_memory *metal_get_memory_from_address(const uintptr_t address) {
8         for(int i = 0; i < __METAL_DT_MAX_MEMORIES; i++) {
9                 struct metal_memory *mem = __metal_memory_table[i];
10
11                 uintptr_t lower_bound = metal_memory_get_base_address(mem);
12                 uintptr_t upper_bound  = lower_bound + metal_memory_get_size(mem);
13
14                 if((address >= lower_bound) && (address < upper_bound)) {
15                         return mem;
16                 }
17         }
18
19         return NULL;
20 }
21
22 extern __inline__ uintptr_t metal_memory_get_base_address(const struct metal_memory *memory);
23 extern __inline__ size_t metal_memory_get_size(const struct metal_memory *memory);
24 extern __inline__ int metal_memory_supports_atomics(const struct metal_memory *memory);
25 extern __inline__ int metal_memory_is_cachable(const struct metal_memory *memory);
26