gem5  v20.1.0.0
interrupts.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Google Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met: redistributions of source code must retain the above copyright
7  * notice, this list of conditions and the following disclaimer;
8  * redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution;
11  * neither the name of the copyright holders nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
29 
31 #include "arch/arm/interrupts.hh"
32 #include "arch/arm/miscregs.hh"
34 #include "arch/arm/types.hh"
35 #include "params/IrisInterrupts.hh"
36 
37 void
39 {
40  using namespace ArmISA;
41 
42  CPSR cpsr = tc->readMiscRegNoEffect(MISCREG_CPSR);
43  CPSR orig_cpsr = cpsr;
45  SCR orig_scr = scr;
47  HCR orig_hcr = hcr;
48 
49  // Set up state so we can get either physical or virtual interrupt bits.
50  cpsr.mode = 0;
51  cpsr.width = 0;
52  cpsr.el = EL1;
53  tc->setMiscReg(MISCREG_CPSR, cpsr);
54  scr.eel2 = 1;
55  tc->setMiscReg(MISCREG_SCR, scr);
56 
57  // Get the virtual bits.
58  hcr.imo = 1;
59  hcr.fmo = 1;
60  hcr.amo = 1;
62 
64  // There is also a virtual abort, but it's not used by gem5.
65  bool virt_irq = bits(7, isr_el1);
66  bool virt_fiq = bits(6, isr_el1);
67 
68  // Get the physical bits.
69  hcr.imo = 0;
70  hcr.fmo = 0;
71  hcr.amo = 0;
73 
75  bool phys_abort = bits(8, isr_el1);
76  bool phys_irq = bits(7, isr_el1);
77  bool phys_fiq = bits(6, isr_el1);
78 
79  tc->setMiscReg(MISCREG_CPSR, orig_cpsr);
80  tc->setMiscReg(MISCREG_SCR_EL3, orig_scr);
81  tc->setMiscReg(MISCREG_HCR_EL2, orig_hcr);
82 
83  bool interrupts[ArmISA::NumInterruptTypes];
84  uint64_t intStatus = 0;
85 
86  for (bool &i: interrupts)
87  i = false;
88 
89  interrupts[ArmISA::INT_ABT] = phys_abort;
90  interrupts[ArmISA::INT_IRQ] = phys_irq;
91  interrupts[ArmISA::INT_FIQ] = phys_fiq;
93  interrupts[ArmISA::INT_VIRT_IRQ] = virt_irq;
94  interrupts[ArmISA::INT_VIRT_FIQ] = virt_fiq;
95 
96  for (int i = 0; i < NumInterruptTypes; i++) {
97  if (interrupts[i])
98  intStatus |= (0x1ULL << i);
99  }
100 
101  SERIALIZE_ARRAY(interrupts, NumInterruptTypes);
102  SERIALIZE_SCALAR(intStatus);
103 }
104 
105 void
107 {
108 }
109 
111 IrisInterruptsParams::create()
112 {
113  return new Iris::Interrupts(this);
114 }
ThreadContext::readMiscRegNoEffect
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
ArmISA::INT_VIRT_FIQ
@ INT_VIRT_FIQ
Definition: interrupts.hh:65
miscregs_types.hh
Iris::Interrupts::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: interrupts.cc:38
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
ArmISA::INT_FIQ
@ INT_FIQ
Definition: interrupts.hh:62
ArmISA::INT_SEV
@ INT_SEV
Definition: interrupts.hh:63
ArmISA::MISCREG_ISR_EL1
@ MISCREG_ISR_EL1
Definition: miscregs.hh:731
ArmISA::MISCREG_SEV_MAILBOX
@ MISCREG_SEV_MAILBOX
Definition: miscregs.hh:88
ArmISA
Definition: ccregs.hh:41
types.hh
cp
Definition: cprintf.cc:40
interrupts.hh
ArmISA::INT_ABT
@ INT_ABT
Definition: interrupts.hh:60
SERIALIZE_ARRAY
#define SERIALIZE_ARRAY(member, size)
Definition: serialize.hh:832
ArmISA::MISCREG_HCR_EL2
@ MISCREG_HCR_EL2
Definition: miscregs.hh:578
ArmISA::EL1
@ EL1
Definition: types.hh:623
SERIALIZE_SCALAR
#define SERIALIZE_SCALAR(scalar)
Definition: serialize.hh:790
Iris::Interrupts
Definition: interrupts.hh:38
ArmISA::INT_VIRT_IRQ
@ INT_VIRT_IRQ
Definition: interrupts.hh:64
miscregs.hh
ArmISA::MISCREG_SCR_EL3
@ MISCREG_SCR_EL3
Definition: miscregs.hh:585
interrupts.hh
ArmISA::MISCREG_CPSR
@ MISCREG_CPSR
Definition: miscregs.hh:57
ThreadContext::readMiscReg
virtual RegVal readMiscReg(RegIndex misc_reg)=0
ThreadContext::setMiscReg
virtual void setMiscReg(RegIndex misc_reg, RegVal val)=0
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
ArmISA::NumInterruptTypes
@ NumInterruptTypes
Definition: interrupts.hh:66
BaseInterrupts::tc
ThreadContext * tc
Definition: interrupts.hh:40
CheckpointIn
Definition: serialize.hh:67
thread_context.hh
Iris::Interrupts::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: interrupts.cc:106
ArmISA::MISCREG_SCR
@ MISCREG_SCR
Definition: miscregs.hh:237
ArmISA::INT_IRQ
@ INT_IRQ
Definition: interrupts.hh:61
ULL
#define ULL(N)
uint64_t constant
Definition: types.hh:50
RegVal
uint64_t RegVal
Definition: types.hh:168
bits
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition: bitfield.hh:75

Generated on Wed Sep 30 2020 14:01:58 for gem5 by doxygen 1.8.17