| 58 | } |
| 59 | |
| 60 | rt_err_t rt_numa_memory_affinity(rt_uint64_t phy_addr, rt_bitmap_t *out_affinity) |
| 61 | { |
| 62 | struct numa_memory *nm; |
| 63 | |
| 64 | if (!out_affinity) |
| 65 | { |
| 66 | return -RT_EINVAL; |
| 67 | } |
| 68 | |
| 69 | if (!numa_enabled) |
| 70 | { |
| 71 | /* Default to CPU#0 */ |
| 72 | RT_IRQ_AFFINITY_SET(out_affinity, 0); |
| 73 | |
| 74 | return RT_EOK; |
| 75 | } |
| 76 | |
| 77 | rt_memset(out_affinity, 0, sizeof(*out_affinity) * RT_BITMAP_LEN(RT_CPUS_NR)); |
| 78 | |
| 79 | rt_list_for_each_entry(nm, &numa_memory_nodes, list) |
| 80 | { |
| 81 | if (phy_addr >= nm->start && phy_addr < nm->end) |
| 82 | { |
| 83 | for (int i = 0; i < RT_ARRAY_SIZE(cpu_numa_map); ++i) |
| 84 | { |
| 85 | if (cpu_numa_map[i] == nm->nid) |
| 86 | { |
| 87 | RT_IRQ_AFFINITY_SET(out_affinity, i); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | return RT_EOK; |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | return -RT_EEMPTY; |
| 96 | } |
| 97 | |
| 98 | #ifdef RT_USING_OFW |
| 99 | static int numa_ofw_init(void) |
no test coverage detected