diff --git a/metal_header/sifive_l2pf0.c++ b/metal_header/sifive_l2pf0.c++ index 783e0b96..5f13f0c2 100644 --- a/metal_header/sifive_l2pf0.c++ +++ b/metal_header/sifive_l2pf0.c++ @@ -14,31 +14,51 @@ void sifive_l2pf0::include_headers() { } void sifive_l2pf0::create_defines() { + uint32_t count = 0; + std::string l2pf_base = "{ "; + + dtb.match(std::regex("cpu"), [&](node n) { + if (n.field_exists("sifive,l2pf")) { + node t = n.get_fields("sifive,l2pf")[0]; + l2pf_base += std::to_string(t.get_fields("reg")[0]); + l2pf_base += "UL, "; + } else { + l2pf_base += "0, "; + } + }); + l2pf_base += "}"; + dtb.match(std::regex(compat_string), [&](node n) { uint32_t val = 0; + /* Generate defines for L2 prefetch parameters */ + if (count == 0) { + /* Array of base addresses with HART IDs as the index */ + emit_def("METAL_SIFIVE_L2PF0_BASE_ADDR", l2pf_base); - if (n.field_exists("sifive,spf-queue-entries")) { - val = n.get_fields("sifive,spf-queue-entries")[0]; - } - emit_def("METAL_SIFIVE_L2PF0_QUEUE_ENTRIES", std::to_string(val)); + if (n.field_exists("sifive,l2pf-queue-entries")) { + val = n.get_fields("sifive,l2pf-queue-entries")[0]; + } + emit_def("METAL_SIFIVE_L2PF0_QUEUE_ENTRIES", std::to_string(val)); - val = 0; - if (n.field_exists("sifive,spf-window-bits")) { - val = n.get_fields("sifive,spf-window-bits")[0]; - } - emit_def("METAL_SIFIVE_L2PF0_WINDOW_BITS", std::to_string(val)); + val = 0; + if (n.field_exists("sifive,l2pf-window-bits")) { + val = n.get_fields("sifive,l2pf-window-bits")[0]; + } + emit_def("METAL_SIFIVE_L2PF0_WINDOW_BITS", std::to_string(val)); - val = 0; - if (n.field_exists("sifive,spf-distance-bits")) { - val = n.get_fields("sifive,spf-distance-bits")[0]; - } - emit_def("METAL_SIFIVE_L2PF0_DISTANCE_BITS", std::to_string(val)); + val = 0; + if (n.field_exists("sifive,l2pf-distance-bits")) { + val = n.get_fields("sifive,l2pf-distance-bits")[0]; + } + emit_def("METAL_SIFIVE_L2PF0_DISTANCE_BITS", std::to_string(val)); - val = 0; - if (n.field_exists("sifive,spf-streams")) { - val = n.get_fields("sifive,spf-streams")[0]; + val = 0; + if (n.field_exists("sifive,l2pf-streams")) { + val = n.get_fields("sifive,l2pf-streams")[0]; + } + emit_def("METAL_SIFIVE_L2PF0_STREAMS", std::to_string(val)); + count++; } - emit_def("METAL_SIFIVE_L2PF0_STREAMS", std::to_string(val)); }); }