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

Function rt_ofw_get_address_array

components/drivers/ofw/io.c:211–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209}
210
211int rt_ofw_get_address_array(struct rt_ofw_node *np, int nr, rt_uint64_t *out_regs)
212{
213 int count;
214
215 if (np && nr > 0 && out_regs)
216 {
217 rt_ssize_t len;
218 int max_nr;
219 int addr_cells = rt_ofw_io_addr_cells(np);
220 int size_cells = rt_ofw_io_size_cells(np);
221 const fdt32_t *cell = rt_ofw_prop_read_raw(np, "reg", &len);
222
223 max_nr = len / (sizeof(*cell) * (addr_cells + size_cells));
224
225 if (nr > max_nr)
226 {
227 nr = max_nr;
228 }
229
230 count = nr;
231
232 while (nr --> 0)
233 {
234 *out_regs = rt_fdt_next_cell(&cell, addr_cells);
235 *out_regs = rt_ofw_translate_address(np, RT_NULL, *out_regs);
236 ++out_regs;
237
238 *out_regs = rt_fdt_next_cell(&cell, size_cells);
239 ++out_regs;
240 }
241 }
242 else
243 {
244 count = -RT_EINVAL;
245 }
246
247 return count;
248}
249
250static struct bus_ranges *ofw_bus_ranges(struct rt_ofw_node *np, struct rt_ofw_prop *prop)
251{

Callers 3

gicv3_ofw_initFunction · 0.85
gicv2_ofw_initFunction · 0.85

Calls 5

rt_ofw_io_addr_cellsFunction · 0.85
rt_ofw_io_size_cellsFunction · 0.85
rt_ofw_prop_read_rawFunction · 0.85
rt_fdt_next_cellFunction · 0.85
rt_ofw_translate_addressFunction · 0.85

Tested by

no test coverage detected