From: Adrian Herrera Date: Mon, 9 Dec 2019 20:10:14 +0000 (+0000) Subject: cpu: IntrControl, clear all and check helpers X-Git-Tag: v20.0.0.0~265 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=700bf943f3244a693468908646cd69b1b2631ce5;p=gem5.git cpu: IntrControl, clear all and check helpers This patch extends the IntrControl to provided additional member functions for (1) clearing all pending interrupts in a PE and (2) checking for any pending interrupt in a PE. These are intended to be used from interrupt management related peripherals. Change-Id: I06b553872ed469e7449b872a0716865773ace154 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/26809 Reviewed-by: Bobby R. Bruce Maintainer: Giacomo Travaglini Tested-by: kokoro --- diff --git a/src/cpu/intr_control.cc b/src/cpu/intr_control.cc index 071b9d5f5..9274b375d 100644 --- a/src/cpu/intr_control.cc +++ b/src/cpu/intr_control.cc @@ -47,18 +47,32 @@ void IntrControl::post(int cpu_id, int int_num, int index) { DPRINTF(IntrControl, "post %d:%d (cpu %d)\n", int_num, index, cpu_id); - std::vector &tcvec = sys->threadContexts; - BaseCPU *cpu = tcvec[cpu_id]->getCpuPtr(); - cpu->postInterrupt(tcvec[cpu_id]->threadId(), int_num, index); + ThreadContext *tc = sys->getThreadContext(cpu_id); + tc->getCpuPtr()->postInterrupt(tc->threadId(), int_num, index); } void IntrControl::clear(int cpu_id, int int_num, int index) { DPRINTF(IntrControl, "clear %d:%d (cpu %d)\n", int_num, index, cpu_id); - std::vector &tcvec = sys->threadContexts; - BaseCPU *cpu = tcvec[cpu_id]->getCpuPtr(); - cpu->clearInterrupt(tcvec[cpu_id]->threadId(), int_num, index); + ThreadContext *tc = sys->getThreadContext(cpu_id); + tc->getCpuPtr()->clearInterrupt(tc->threadId(), int_num, index); +} + +void +IntrControl::clearAll(int cpu_id) +{ + DPRINTF(IntrControl, "Clear all pending interrupts for CPU %d\n", cpu_id); + ThreadContext *tc = sys->getThreadContext(cpu_id); + tc->getCpuPtr()->clearInterrupts(tc->threadId()); +} + +bool +IntrControl::havePosted(int cpu_id) const +{ + DPRINTF(IntrControl, "Check pending interrupts for CPU %d\n", cpu_id); + ThreadContext *tc = sys->getThreadContext(cpu_id); + return tc->getCpuPtr()->checkInterrupts(tc); } IntrControl * diff --git a/src/cpu/intr_control.hh b/src/cpu/intr_control.hh index b7ff2a8f8..a6f025ecb 100644 --- a/src/cpu/intr_control.hh +++ b/src/cpu/intr_control.hh @@ -45,6 +45,8 @@ class IntrControl : public SimObject void clear(int cpu_id, int int_num, int index); void post(int cpu_id, int int_num, int index); + void clearAll(int cpu_id); + bool havePosted(int cpu_id) const; void clear(int int_num, int index = 0)