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

Function rt_ofw_reverse_address

components/drivers/ofw/io.c:410–477  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

408}
409
410rt_uint64_t rt_ofw_reverse_address(struct rt_ofw_node *np, const char *range_type, rt_uint64_t address)
411{
412 rt_uint64_t bus_addr = address;
413
414 if (!range_type)
415 {
416 range_type = "ranges";
417 }
418
419 rt_ofw_foreach_parent_node(np)
420 {
421 rt_ssize_t len;
422 struct rt_ofw_prop *prop;
423 struct bus_ranges *ranges = RT_NULL;
424
425 prop = rt_ofw_get_prop(np, range_type, &len);
426
427 if (!prop || !len)
428 {
429 continue;
430 }
431
432 for (int i = 0; i < RT_ARRAY_SIZE(_bus_ranges); ++i)
433 {
434 if (!_bus_ranges[i])
435 {
436 break;
437 }
438
439 if (_bus_ranges[i]->np == np)
440 {
441 ranges = _bus_ranges[i];
442 break;
443 }
444 }
445
446 if (!ranges)
447 {
448 ranges = ofw_bus_ranges(np, prop);
449 }
450
451 if (ranges)
452 {
453 for (int i = 0; i < ranges->nr; ++i)
454 {
455 rt_uint64_t parent_addr = ranges->parent_addr[i];
456 rt_uint64_t child_size = ranges->child_size[i];
457
458 if (address >= parent_addr && address < parent_addr + child_size)
459 {
460 bus_addr = ranges->child_addr[i] + (address - parent_addr);
461
462 break;
463 }
464 }
465 }
466 else
467 {

Calls 3

rt_ofw_get_propFunction · 0.85
ofw_bus_rangesFunction · 0.85
rt_ofw_node_putFunction · 0.85

Tested by

no test coverage detected