Browse Source

optimize `num_ids_word` init logic;

init `max_prio` by initialization-list
pull/1259/head
Wade 3 years ago
parent
commit
8f2994aa7f
  1. 9
      riscv/plic.cc

9
riscv/plic.cc

@ -67,15 +67,12 @@
#define REG_SIZE 0x1000000
plic_t::plic_t(std::vector<processor_t*>& procs, bool smode, uint32_t ndev)
: procs(procs), contexts(procs.size() * (smode ? 2 : 1))
: procs(procs), contexts(procs.size() * (smode ? 2 : 1)),
num_ids(ndev + 1), num_ids_word(((ndev + 1) + (32 - 1)) / 32),
max_prio((1UL << PLIC_PRIO_BITS) - 1)
{
size_t contexts_per_hart = smode ? 2 : 1;
num_ids = ndev + 1;
num_ids_word = num_ids / 32;
if ((num_ids_word * 32) < num_ids)
num_ids_word++;
max_prio = (1UL << PLIC_PRIO_BITS) - 1;
memset(priority, 0, sizeof(priority));
memset(level, 0, sizeof(level));

Loading…
Cancel
Save