MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / numa_ofw_init

Function numa_ofw_init

components/drivers/core/numa.c:99–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97
98#ifdef RT_USING_OFW
99static int numa_ofw_init(void)
100{
101 int i = 0;
102 rt_uint32_t nid;
103 const char *numa_conf;
104 struct rt_ofw_node *np = RT_NULL;
105
106 numa_conf = rt_ofw_bootargs_select("numa=", 0);
107
108 if (!numa_conf || rt_strcmp(numa_conf, "on"))
109 {
110 return (int)RT_EOK;
111 }
112
113 numa_enabled = RT_TRUE;
114
115 for (int i = 0; i < RT_ARRAY_SIZE(cpu_numa_map); ++i)
116 {
117 cpu_numa_map[i] = -RT_ENOSYS;
118 }
119
120 rt_list_init(&numa_memory_nodes);
121
122 rt_ofw_foreach_cpu_node(np)
123 {
124 rt_ofw_prop_read_u32(np, "numa-node-id", (rt_uint32_t *)&cpu_numa_map[i]);
125
126 if (++i >= RT_CPUS_NR)
127 {
128 break;
129 }
130 }
131
132 rt_ofw_foreach_node_by_type(np, "memory")
133 {
134 if (!rt_ofw_prop_read_u32(np, "numa-node-id", &nid))
135 {
136 int mem_nr = rt_ofw_get_address_count(np);
137
138 for (i = 0; i < mem_nr; ++i)
139 {
140 rt_uint64_t addr, size;
141 struct numa_memory *nm;
142
143 if (rt_ofw_get_address(np, i, &addr, &size))
144 {
145 continue;
146 }
147
148 nm = rt_malloc(sizeof(*nm));
149
150 if (!nm)
151 {
152 LOG_E("No memory to record NUMA[%d] memory[%p, %p] info",
153 nid, addr, addr + size);
154
155 return (int)-RT_ENOMEM;
156 }

Callers

nothing calls this directly

Calls 8

rt_ofw_bootargs_selectFunction · 0.85
rt_strcmpFunction · 0.85
rt_list_initFunction · 0.85
rt_ofw_prop_read_u32Function · 0.85
rt_ofw_get_address_countFunction · 0.85
rt_ofw_get_addressFunction · 0.85
rt_mallocFunction · 0.85
rt_list_insert_beforeFunction · 0.85

Tested by

no test coverage detected