1 /* Copyright 2019 SiFive, Inc */
2 /* SPDX-License-Identifier: Apache-2.0 */
4 #include <metal/machine.h>
5 #include <metal/memory.h>
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];
11 uintptr_t lower_bound = metal_memory_get_base_address(mem);
12 uintptr_t upper_bound = lower_bound + metal_memory_get_size(mem);
14 if((address >= lower_bound) && (address < upper_bound)) {
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);