gem5 [DEVELOP-FOR-25.1]
Loading...
Searching...
No Matches
lupio_ipi.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 The Regents of the University of California
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
30
31#include "cpu/base.hh"
32#include "debug/LupioIPI.hh"
33#include "mem/packet_access.hh"
34#include "params/LupioIPI.hh"
35#include "sim/system.hh"
36
37namespace gem5
38{
39
41 BasicPioDevice(params, params.pio_size),
43 intType(params.int_type),
44 nThread(params.num_threads)
45{
46 mask.resize(nThread, 0);
47 pending.resize(nThread, 0);
48
49 DPRINTF(LupioIPI, "LupioIPI initalized--number of CPUs: %d\n", nThread);
50}
51
52void
54{
55 for (int cpu = 0; cpu < nThread; cpu++) {
56 auto tc = system->threads[cpu];
57
58 if (mask[cpu] & pending[cpu]) {
59 tc->getCpuPtr()->postInterrupt(tc->threadId(), intType, 0);
60 } else {
61 tc->getCpuPtr()->clearInterrupt(tc->threadId(), intType, 0);
62 }
63 }
64}
65
66uint64_t
67LupioIPI::lupioIPIRead(uint8_t addr, int size)
68{
69 uint32_t r = 0;
70
71 int cpu = addr / LUPIO_IPI_MAX;
72 int reg = addr % LUPIO_IPI_MAX;
73
74 switch (reg) {
75 case LUPIO_IPI_MASK:
76 r = mask[cpu];
77 DPRINTF(LupioIPI, "Read IPI_MASK[%d]: %#x\n", cpu, r);
78 break;
79 case LUPIO_IPI_PEND:
80 r = pending[cpu];
81 DPRINTF(LupioIPI, "Read IPI_PEND[%d]: %#x\n", cpu, r);
82 break;
83
84 default:
85 panic("Unexpected read to LupioIPI device at address %#llx!",
86 addr);
87 break;
88 }
89
90 return r;
91}
92
93void
94LupioIPI::lupioIPIWrite(uint8_t addr, uint64_t val64, int size)
95{
96 uint32_t val = val64;
97
98 int cpu = addr / LUPIO_IPI_MAX;
99 int reg = addr % LUPIO_IPI_MAX;
100
101 switch (reg) {
102 case LUPIO_IPI_MASK:
103 mask[cpu] = val;
104 DPRINTF(LupioIPI, "Write IPI_MASK[%d]: %#x\n", cpu, mask[cpu]);
106 break;
107 case LUPIO_IPI_PEND:
108 pending[cpu] = val;
109 DPRINTF(LupioIPI, "Write IPI_PEND[%d]: %#x\n", cpu, pending[cpu]);
111 break;
112
113 default:
114 panic("Unexpected write to LupioIPI device at address %#llx!",
115 addr);
116 break;
117 }
118}
119
120Tick
122{
123 Addr ipi_addr = pkt->getAddr() - pioAddr;
124
126 "Read request - addr: %#x, size: %#x\n", ipi_addr, pkt->getSize());
127
128 uint64_t read_val = lupioIPIRead(ipi_addr, pkt->getSize());
129 DPRINTF(LupioIPI, "Packet Read: %#x\n", read_val);
130 pkt->setUintX(read_val, byteOrder);
131 pkt->makeResponse();
132
133 return pioDelay;
134}
135
136Tick
138{
139 Addr ipi_addr = pkt->getAddr() - pioAddr;
140
141 DPRINTF(LupioIPI, "Write register %#x value %#x\n", ipi_addr,
142 pkt->getUintX(byteOrder));
143
144 lupioIPIWrite(ipi_addr, pkt->getUintX(byteOrder), pkt->getSize());
145 DPRINTF(LupioIPI, "Packet Write Value: %d\n", pkt->getUintX(byteOrder));
146
147 pkt->makeResponse();
148
149 return pioDelay;
150}
151} // namespace gem5
#define DPRINTF(x,...)
Definition trace.hh:209
Addr pioAddr
Address that the device listens to.
Definition io_device.hh:151
BasicPioDevice(const Params &p, Addr size)
Definition io_device.cc:75
Tick pioDelay
Delay that the device experinces on an access.
Definition io_device.hh:157
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition lupio_ipi.cc:137
System * system
Definition lupio_ipi.hh:49
std::vector< uint32_t > pending
Definition lupio_ipi.hh:68
Tick read(PacketPtr pkt) override
Implement BasicPioDevice virtual functions.
Definition lupio_ipi.cc:121
std::vector< uint32_t > mask
Set of registers corresponding to each CPU for sending inter-processor interrupts.
Definition lupio_ipi.hh:67
void lupioIPIWrite(const uint8_t addr, uint64_t val64, int size)
Function to write to the word register of the corresponding CPU and raise the IRQ.
Definition lupio_ipi.cc:94
LupioIPI(const Params &params)
Definition lupio_ipi.cc:40
void lupioIPIUpdateIRQ()
Function to post and clear interrupts.
Definition lupio_ipi.cc:53
const ByteOrder byteOrder
Definition lupio_ipi.hh:48
uint32_t nThread
Definition lupio_ipi.hh:62
uint64_t lupioIPIRead(const uint8_t addr, int size)
Function to return the value in the word register of the corresponding CPU and lower the IRQ.
Definition lupio_ipi.cc:67
Addr getAddr() const
Definition packet.hh:807
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:361
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
Definition packet.hh:1062
unsigned getSize() const
Definition packet.hh:817
uint64_t getUintX(ByteOrder endian) const
Get the data in the packet byte swapped from the specified endianness and zero-extended to 64 bits.
Definition packet.cc:352
PioDeviceParams Params
Definition io_device.hh:134
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:220
const Params & params() const
Bitfield< 5, 3 > reg
Definition types.hh:92
Bitfield< 63 > val
Definition misc.hh:804
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
uint64_t Tick
Tick count type.
Definition types.hh:58
Packet * PacketPtr

Generated on Mon Oct 27 2025 04:13:02 for gem5 by doxygen 1.14.0