blob: 43ca6b810f15778a9b1baeb04c8dae21cefcc4b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
/* Copyright 2019 SiFive, Inc */
/* SPDX-License-Identifier: Apache-2.0 */
#include <metal/machine.h>
#include <metal/memory.h>
struct metal_memory *metal_get_memory_from_address(const uintptr_t address) {
for(int i = 0; i < __METAL_DT_MAX_MEMORIES; i++) {
struct metal_memory *mem = __metal_memory_table[i];
uintptr_t lower_bound = metal_memory_get_base_address(mem);
uintptr_t upper_bound = lower_bound + metal_memory_get_size(mem);
if((address >= lower_bound) && (address < upper_bound)) {
return mem;
}
}
return NULL;
}
extern inline uintptr_t metal_memory_get_base_address(const struct metal_memory *memory);
extern inline size_t metal_memory_get_size(const struct metal_memory *memory);
extern inline int metal_memory_supports_atomics(const struct metal_memory *memory);
extern inline int metal_memory_is_cachable(const struct metal_memory *memory);
|