gem5  v21.1.0.2
mhu.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #include "dev/arm/css/mhu.hh"
39 
40 #include "debug/MHU.hh"
41 #include "dev/arm/base_gic.hh"
42 #include "dev/arm/css/scp.hh"
43 #include "mem/packet_access.hh"
44 #include "params/Ap2ScpDoorbell.hh"
45 #include "params/MHU.hh"
46 #include "params/Scp2ApDoorbell.hh"
47 
48 namespace gem5
49 {
50 
51 Scp2ApDoorbell::Scp2ApDoorbell(const Scp2ApDoorbellParams &p)
52  : MhuDoorbell(p), interrupt(p.interrupt->get())
53 {}
54 
55 Ap2ScpDoorbell::Ap2ScpDoorbell(const Ap2ScpDoorbellParams &p)
56  : MhuDoorbell(p)
57 {}
58 
59 MHU::MHU(const MHUParams &p)
60  : BasicPioDevice(p, p.pio_size),
61  scpLow(p.lowp_scp2ap),
62  scpHigh(p.highp_scp2ap),
63  scpSec(p.sec_scp2ap),
64  apLow(p.lowp_ap2scp),
65  apHigh(p.highp_ap2scp),
66  apSec(p.sec_ap2scp),
67  pid{ 0x98, 0xb0, 0x1b, 0x0, 0x4 },
68  compid{ 0x0d, 0xf0, 0x05, 0xb1 },
69  scfg(0)
70 {
71  apLow->setScp(p.scp);
72  apHigh->setScp(p.scp);
73  apSec->setScp(p.scp);
74 }
75 
78 {
79  return AddrRangeList({ RangeSize(pioAddr, pioSize) });
80 }
81 
82 Tick
84 {
85  const Addr addr = pkt->getAddr() - pioAddr;
86  const bool secure = pkt->isSecure();
87 
88  uint32_t value = read32(addr, secure);
89 
90  DPRINTF(MHU, "Reading %#x at address: %#x\n", value, addr);
91 
92  pkt->setUintX(value, ByteOrder::little);
93  pkt->makeAtomicResponse();
94  return pioDelay;
95 }
96 
97 uint32_t
98 MHU::read32(const Addr addr, bool secure_access)
99 {
100  switch (addr) {
101  case SCP_INTR_L_STAT:
102  return scpLow->channel;
103  case SCP_INTR_H_STAT:
104  return scpHigh->channel;
105  case CPU_INTR_L_STAT:
106  return apLow->channel;
107  case CPU_INTR_H_STAT:
108  return apHigh->channel;
109  case SCP_INTR_S_STAT:
110  if (secure_access) {
111  return scpSec->channel;
112  } else {
113  if (!bits(scfg, 0))
114  scpSec->set(SVI_INT);
115  return 0;
116  }
117  case CPU_INTR_S_STAT:
118  if (secure_access) {
119  return apSec->channel;
120  } else {
121  if (!bits(scfg, 0))
122  scpSec->set(SVI_INT);
123  return 0;
124  }
125  case MHU_SCFG:
126  return scfg;
127  case PID4:
128  return pid[4];
129  case PID0:
130  return pid[0];
131  case PID1:
132  return pid[1];
133  case PID2:
134  return pid[2];
135  case PID3:
136  return pid[3];
137  case COMPID0:
138  return compid[0];
139  case COMPID1:
140  return compid[1];
141  case COMPID2:
142  return compid[2];
143  case COMPID3:
144  return compid[3];
145  default:
146  panic("Invalid register read at address: %#x\n", addr);
147  }
148 }
149 
150 Tick
152 {
153  const Addr addr = pkt->getAddr() - pioAddr;
154 
155  assert(pkt->getSize() == sizeof(uint32_t));
156  const uint32_t value = pkt->getLE<uint32_t>();
157 
158  DPRINTF(MHU, "Writing %#x at address: %#x\n", value, addr);
159 
160  switch (addr) {
161  case SCP_INTR_L_SET:
162  scpLow->set(value);
163  break;
164  case SCP_INTR_L_CLEAR:
165  scpLow->clear(value);
166  break;
167  case SCP_INTR_H_SET:
168  scpHigh->set(value);
169  break;
170  case SCP_INTR_H_CLEAR:
171  scpHigh->clear(value);
172  break;
173  case CPU_INTR_L_SET:
174  apLow->set(value);
175  break;
176  case CPU_INTR_L_CLEAR:
177  apLow->clear(value);
178  break;
179  case CPU_INTR_H_SET:
180  apHigh->set(value);
181  break;
182  case CPU_INTR_H_CLEAR:
183  apHigh->clear(value);
184  break;
185  case SCP_INTR_S_SET:
186  scpSec->set(value);
187  break;
188  case SCP_INTR_S_CLEAR:
189  scpSec->clear(value);
190  break;
191  case CPU_INTR_S_SET:
192  apSec->set(value);
193  break;
194  case CPU_INTR_S_CLEAR:
195  apSec->clear(value);
196  break;
197  case MHU_SCFG:
198  scfg = value;
199  break;
200  default:
201  panic("Invalid register write at address: %#x\n", addr);
202  }
203 
204  pkt->makeAtomicResponse();
205  return pioDelay;
206 }
207 
208 void
209 MhuDoorbell::update(uint32_t new_val)
210 {
211  const bool int_old = channel != 0;
212  const bool int_new = new_val != 0;
213 
214  channel = new_val;
215  if (int_old && !int_new) {
216  clearInterrupt();
217  } else if (!int_old && int_new) {
218  raiseInterrupt();
219  }
220 }
221 
222 void
224 {
225  interrupt->raise();
226 }
227 
228 void
230 {
231  interrupt->clear();
232 }
233 
234 void
236 {
237  scp->raiseInterrupt(this);
238 }
239 
240 void
242 {
243  scp->clearInterrupt(this);
244 }
245 
246 } // namespace gem5
gem5::MHU::PID0
@ PID0
Definition: mhu.hh:133
gem5::Ap2ScpDoorbell::raiseInterrupt
void raiseInterrupt() override
Definition: mhu.cc:235
gem5::MHU::apHigh
Ap2ScpDoorbell * apHigh
Definition: mhu.hh:162
gem5::BasicPioDevice::pioAddr
Addr pioAddr
Address that the device listens to.
Definition: io_device.hh:151
gem5::MhuDoorbell::channel
uint32_t channel
Definition: mhu.hh:72
gem5::MHU::COMPID1
@ COMPID1
Definition: mhu.hh:139
gem5::MHU::PID1
@ PID1
Definition: mhu.hh:134
gem5::MHU::SCP_INTR_H_CLEAR
@ SCP_INTR_H_CLEAR
Definition: mhu.hh:113
gem5::MHU::write
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: mhu.cc:151
gem5::RangeSize
AddrRange RangeSize(Addr start, Addr size)
Definition: addr_range.hh:661
gem5::MHU::SCP_INTR_H_SET
@ SCP_INTR_H_SET
Definition: mhu.hh:112
gem5::Ap2ScpDoorbell::Ap2ScpDoorbell
Ap2ScpDoorbell(const Ap2ScpDoorbellParams &p)
Definition: mhu.cc:55
gem5::AddrRangeList
std::list< AddrRange > AddrRangeList
Convenience typedef for a collection of address ranges.
Definition: addr_range.hh:641
gem5::MHU::getAddrRanges
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
Definition: mhu.cc:77
base_gic.hh
gem5::MHU
Message Handling Unit.
Definition: mhu.hh:102
gem5::MHU::PID2
@ PID2
Definition: mhu.hh:135
gem5::MHU::COMPID3
@ COMPID3
Definition: mhu.hh:141
gem5::Packet::isSecure
bool isSecure() const
Definition: packet.hh:810
gem5::Scp2ApDoorbell::clearInterrupt
void clearInterrupt() override
Definition: mhu.cc:229
gem5::MhuDoorbell::clear
void clear(uint32_t val)
Definition: mhu.hh:64
gem5::Packet::makeAtomicResponse
void makeAtomicResponse()
Definition: packet.hh:1043
gem5::MHU::pid
uint32_t pid[5]
Definition: mhu.hh:166
gem5::MHU::SCP_INTR_S_CLEAR
@ SCP_INTR_S_CLEAR
Definition: mhu.hh:125
gem5::MhuDoorbell::set
void set(uint32_t val)
Definition: mhu.hh:63
gem5::MhuDoorbell::update
void update(uint32_t new_val)
Definition: mhu.cc:209
scp.hh
gem5::MHU::COMPID2
@ COMPID2
Definition: mhu.hh:140
mhu.hh
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:186
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:283
gem5::MhuDoorbell::clearInterrupt
virtual void clearInterrupt()=0
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::ArmInterruptPin::clear
virtual void clear()=0
Clear a signalled interrupt.
gem5::Scp2ApDoorbell::Scp2ApDoorbell
Scp2ApDoorbell(const Scp2ApDoorbellParams &p)
Definition: mhu.cc:51
gem5::MHU::MHU_SCFG
@ MHU_SCFG
Definition: mhu.hh:130
gem5::MHU::read32
uint32_t read32(const Addr addr, bool secure_access)
Definition: mhu.cc:98
gem5::BasicPioDevice::pioDelay
Tick pioDelay
Delay that the device experinces on an access.
Definition: io_device.hh:157
gem5::MHU::CPU_INTR_L_CLEAR
@ CPU_INTR_L_CLEAR
Definition: mhu.hh:118
gem5::MHU::SCP_INTR_L_STAT
@ SCP_INTR_L_STAT
From SCP to Application Processor.
Definition: mhu.hh:108
gem5::bits
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition: bitfield.hh:76
gem5::MHU::scpSec
Scp2ApDoorbell * scpSec
Definition: mhu.hh:159
gem5::MHU::apSec
Ap2ScpDoorbell * apSec
Definition: mhu.hh:163
gem5::MHU::PID3
@ PID3
Definition: mhu.hh:136
gem5::Ap2ScpDoorbell::clearInterrupt
void clearInterrupt() override
Definition: mhu.cc:241
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::MhuDoorbell
Definition: mhu.hh:54
packet_access.hh
gem5::MHU::CPU_INTR_S_STAT
@ CPU_INTR_S_STAT
Definition: mhu.hh:126
gem5::MHU::scfg
uint32_t scfg
Definition: mhu.hh:169
gem5::MHU::CPU_INTR_S_SET
@ CPU_INTR_S_SET
Definition: mhu.hh:127
gem5::MHU::SCP_INTR_L_SET
@ SCP_INTR_L_SET
Definition: mhu.hh:109
gem5::Ap2ScpDoorbell::scp
Scp * scp
Definition: mhu.hh:98
gem5::MHU::SVI_INT
static const uint32_t SVI_INT
Definition: mhu.hh:146
gem5::MHU::read
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: mhu.cc:83
gem5::MHU::CPU_INTR_L_SET
@ CPU_INTR_L_SET
Definition: mhu.hh:117
gem5::MHU::COMPID0
@ COMPID0
Definition: mhu.hh:138
gem5::MHU::CPU_INTR_H_SET
@ CPU_INTR_H_SET
Definition: mhu.hh:120
gem5::MHU::apLow
Ap2ScpDoorbell * apLow
Definition: mhu.hh:161
gem5::MHU::SCP_INTR_S_SET
@ SCP_INTR_S_SET
Definition: mhu.hh:124
gem5::MHU::scpHigh
Scp2ApDoorbell * scpHigh
Definition: mhu.hh:158
gem5::MhuDoorbell::raiseInterrupt
virtual void raiseInterrupt()=0
gem5::Scp::raiseInterrupt
virtual void raiseInterrupt(const Doorbell *doorbell)=0
gem5::MHU::compid
uint32_t compid[4]
Definition: mhu.hh:167
gem5::MHU::CPU_INTR_H_CLEAR
@ CPU_INTR_H_CLEAR
Definition: mhu.hh:121
gem5::MHU::SCP_INTR_L_CLEAR
@ SCP_INTR_L_CLEAR
Definition: mhu.hh:110
gem5::Packet::getLE
T getLE() const
Get the data in the packet byte swapped from little endian to host endian.
Definition: packet_access.hh:78
gem5::BasicPioDevice::pioSize
Addr pioSize
Size that the device's address range.
Definition: io_device.hh:154
gem5::MHU::SCP_INTR_H_STAT
@ SCP_INTR_H_STAT
Definition: mhu.hh:111
gem5::MHU::PID4
@ PID4
Definition: mhu.hh:132
gem5::Scp2ApDoorbell::interrupt
ArmInterruptPin * interrupt
Definition: mhu.hh:84
gem5::ArmInterruptPin::raise
virtual void raise()=0
Signal an interrupt.
gem5::Packet::getAddr
Addr getAddr() const
Definition: packet.hh:781
gem5::MHU::CPU_INTR_L_STAT
@ CPU_INTR_L_STAT
From Application Processor to SCP.
Definition: mhu.hh:116
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::BasicPioDevice
Definition: io_device.hh:147
gem5::Packet::setUintX
void setUintX(uint64_t w, ByteOrder endian)
Set the value in the word w after truncating it to the length of the packet and then byteswapping it ...
Definition: packet.cc:351
gem5::Scp2ApDoorbell::raiseInterrupt
void raiseInterrupt() override
Definition: mhu.cc:223
gem5::MHU::CPU_INTR_S_CLEAR
@ CPU_INTR_S_CLEAR
Definition: mhu.hh:128
gem5::Packet::getSize
unsigned getSize() const
Definition: packet.hh:791
gem5::MHU::MHU
MHU(const MHUParams &p)
Definition: mhu.cc:59
gem5::MHU::scpLow
Scp2ApDoorbell * scpLow
Definition: mhu.hh:157
gem5::MHU::SCP_INTR_S_STAT
@ SCP_INTR_S_STAT
Definition: mhu.hh:123
gem5::MHU::CPU_INTR_H_STAT
@ CPU_INTR_H_STAT
Definition: mhu.hh:119
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:177
gem5::Scp::clearInterrupt
virtual void clearInterrupt(const Doorbell *doorbell)=0
gem5::X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:84

Generated on Tue Sep 21 2021 12:25:09 for gem5 by doxygen 1.8.17