gem5  v22.1.0.0
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 
29 #include "dev/lupio/lupio_sys.hh"
30 
31 #include "debug/LupioSYS.hh"
32 #include "mem/packet_access.hh"
33 #include "params/LupioSYS.hh"
34 #include "sim/sim_exit.hh"
35 
36 namespace gem5
37 {
38 
39 LupioSYS::LupioSYS(const Params &params) :
40  BasicPioDevice(params, params.pio_size)
41 {
42  DPRINTF(LupioSYS, "LupioSYS initalized\n");
43 }
44 
45 uint8_t
47 {
48  return 0;
49 }
50 
51 void
52 LupioSYS::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 
71 Tick
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 
87 Tick
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:186
Addr pioAddr
Address that the device listens to.
Definition: io_device.hh:151
Tick pioDelay
Delay that the device experinces on an access.
Definition: io_device.hh:157
LupioSYS: A Real-Time System Controller virtual device which provides a way for the software to halt ...
Definition: lupio_sys.hh:47
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
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
Addr getAddr() const
Definition: packet.hh:805
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:1059
unsigned getSize() const
Definition: packet.hh:815
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:178
Bitfield< 3 > addr
Definition: types.hh:84
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
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
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...
Definition: sim_events.cc:99

Generated on Wed Dec 21 2022 10:22:34 for gem5 by doxygen 1.9.1