gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
lupio_sys.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 "debug/LupioSYS.hh"
32#include "mem/packet_access.hh"
33#include "params/LupioSYS.hh"
34#include "sim/sim_exit.hh"
35
36namespace gem5
37{
38
41{
42 DPRINTF(LupioSYS, "LupioSYS initalized\n");
43}
44
45uint8_t
47{
48 return 0;
49}
50
51void
52LupioSYS::lupioSYSWrite(uint8_t addr, uint64_t val64)
53{
54 switch (addr >> 2) {
55 case LUPIO_SYS_HALT:
56 DPRINTF(LupioSYS, "Trying to halt\n");
57 exitSimLoopNow("LUPIO_SYS_HALT called, exiting", val64, 0, false);
58 break;
59 case LUPIO_SYS_REBT:
60 DPRINTF(LupioSYS, "Trying to reboot\n");
61 exitSimLoopNow("LUPIO_SYS_REBT called, exiting", val64, 0, false);
62 break;
63
64 default:
65 panic("Unexpected write to the LupioRTC device at address %d!",
66 addr);
67 break;
68 }
69}
70
71Tick
73{
74 Addr daddr = pkt->getAddr() - pioAddr;
75
77 "Read request - addr: %#x, size: %#x\n", daddr, pkt->getSize());
78
79 uint64_t sys_read = lupioSYSRead(daddr);
80 DPRINTF(LupioSYS, "Packet Read: %#x\n", sys_read);
81 pkt->setUintX(sys_read, byteOrder);
82 pkt->makeResponse();
83
84 return pioDelay;
85}
86
87Tick
89{
90 Addr daddr = pkt->getAddr() - pioAddr;
91
92 DPRINTF(LupioSYS, "Write register %#x value %#x\n", daddr,
93 pkt->getUintX(byteOrder));
94
95 lupioSYSWrite(daddr, pkt->getUintX(byteOrder));
96 DPRINTF(LupioSYS, "Packet Write Value: %d\n", pkt->getUintX(byteOrder));
97
98 pkt->makeResponse();
99
100 return pioDelay;
101}
102} // 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
uint8_t lupioSYSRead(const uint8_t addr)
Definition lupio_sys.cc:46
void lupioSYSWrite(const uint8_t addr, const uint64_t val64)
Definition lupio_sys.cc:52
Tick read(PacketPtr pkt) override
Implement BasicPioDevice virtual functions.
Definition lupio_sys.cc:72
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition lupio_sys.cc:88
LupioSYS(const Params &params)
Definition lupio_sys.cc:39
const ByteOrder byteOrder
Definition lupio_sys.hh:49
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< 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
void exitSimLoopNow(const std::string &message, int exit_code, Tick repeat, bool serialize)
Schedule an event as above, but make it high priority so it runs before any normal events which are s...

Generated on Mon May 26 2025 09:19:10 for gem5 by doxygen 1.13.2