Skip to content

Commit

Permalink
Merge pull request #239 from sifive/l2pf-update
Browse files Browse the repository at this point in the history
Add l2pf base address array with hart IDs as index, update register defines.
  • Loading branch information
bsousi5 committed Sep 30, 2020
2 parents 3a32afb + 3aa45f4 commit 9a06281
Showing 1 changed file with 38 additions and 18 deletions.
56 changes: 38 additions & 18 deletions metal_header/sifive_l2pf0.c++
Original file line number Diff line number Diff line change
Expand Up @@ -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<node>("sifive,l2pf")[0];
l2pf_base += std::to_string(t.get_fields<uint32_t>("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<uint32_t>("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<uint32_t>("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<uint32_t>("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<uint32_t>("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<uint32_t>("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<uint32_t>("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<uint32_t>("sifive,spf-streams")[0];
val = 0;
if (n.field_exists("sifive,l2pf-streams")) {
val = n.get_fields<uint32_t>("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));
});
}

0 comments on commit 9a06281

Please sign in to comment.