MCPcopy Create free account
hub / github.com/F-Stack/f-stack / win_cpu_from_dt

Function win_cpu_from_dt

freebsd/arm/mv/mv_common.c:2559–2662  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2557}
2558
2559static int
2560win_cpu_from_dt(void)
2561{
2562 pcell_t ranges[48];
2563 phandle_t node;
2564 int i, entry_size, err, t, tuple_size, tuples;
2565 u_long sram_base, sram_size;
2566
2567 t = 0;
2568 /* Retrieve 'ranges' property of '/localbus' node. */
2569 if ((err = fdt_get_ranges("/localbus", ranges, sizeof(ranges),
2570 &tuples, &tuple_size)) == 0) {
2571 /*
2572 * Fill CPU decode windows table.
2573 */
2574 bzero((void *)&cpu_win_tbl, sizeof(cpu_win_tbl));
2575
2576 entry_size = tuple_size / sizeof(pcell_t);
2577 cpu_wins_no = tuples;
2578
2579 /* Check range */
2580 if (tuples > nitems(cpu_win_tbl)) {
2581 debugf("too many tuples to fit into cpu_win_tbl\n");
2582 return (ENOMEM);
2583 }
2584
2585 for (i = 0, t = 0; t < tuples; i += entry_size, t++) {
2586 cpu_win_tbl[t].target = 1;
2587 cpu_win_tbl[t].attr = fdt32_to_cpu(ranges[i + 1]);
2588 cpu_win_tbl[t].base = fdt32_to_cpu(ranges[i + 2]);
2589 cpu_win_tbl[t].size = fdt32_to_cpu(ranges[i + 3]);
2590 cpu_win_tbl[t].remap = ~0;
2591 debugf("target = 0x%0x attr = 0x%0x base = 0x%0x "
2592 "size = 0x%0x remap = 0x%0x\n",
2593 cpu_win_tbl[t].target,
2594 cpu_win_tbl[t].attr, cpu_win_tbl[t].base,
2595 cpu_win_tbl[t].size, cpu_win_tbl[t].remap);
2596 }
2597 }
2598
2599 /*
2600 * Retrieve CESA SRAM data.
2601 */
2602 if ((node = OF_finddevice("sram")) != -1)
2603 if (ofw_bus_node_is_compatible(node, "mrvl,cesa-sram"))
2604 goto moveon;
2605
2606 if ((node = OF_finddevice("/")) == -1)
2607 return (ENXIO);
2608
2609 if ((node = fdt_find_compatible(node, "mrvl,cesa-sram", 0)) == 0)
2610 /* SRAM block is not always present. */
2611 return (0);
2612moveon:
2613 sram_base = sram_size = 0;
2614 if (fdt_regsize(node, &sram_base, &sram_size) != 0)
2615 return (EINVAL);
2616

Callers 1

soc_decode_winFunction · 0.85

Calls 3

fdt_get_rangesFunction · 0.85
bzeroFunction · 0.85
fdt32_to_cpuFunction · 0.85

Tested by

no test coverage detected