gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
malta_io.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2004-2005 The Regents of The University of Michigan
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  * Authors: Ali Saidi
29  * Andrew Schultz
30  * Miguel Serrano
31  */
32 
37 #include "dev/mips/malta_io.hh"
38 
39 #include <sys/time.h>
40 
41 #include <deque>
42 #include <string>
43 #include <vector>
44 
45 #include "base/time.hh"
46 #include "base/trace.hh"
47 #include "debug/Malta.hh"
48 #include "dev/mips/malta.hh"
49 #include "dev/mips/malta_cchip.hh"
50 #include "dev/mips/maltareg.h"
51 #include "dev/rtcreg.h"
52 #include "mem/packet.hh"
53 #include "mem/packet_access.hh"
54 #include "mem/port.hh"
55 #include "params/MaltaIO.hh"
56 #include "sim/system.hh"
57 
58 using namespace std;
59 
60 MaltaIO::RTC::RTC(const string &name, const MaltaIOParams *p)
61  : MC146818(p->malta, name, p->time, p->year_is_bcd, p->frequency),
62  malta(p->malta)
63 {
64 }
65 
67  : BasicPioDevice(p, 0x100), malta(p->malta),
68  pitimer(this, p->name + "pitimer"), rtc(p->name + ".rtc", p)
69 {
70  // set the back pointer from malta to myself
71  malta->io = this;
72 
73  timerData = 0;
74  picr = 0;
75  picInterrupting = false;
76 }
77 
78 Tick
80 {
81  return SimClock::Frequency / params()->frequency;
82 }
83 
84 Tick
86 {
87  panic("MaltaIO::read(...) not implemented inside malta_io.cc");
88  return pioDelay;
89 }
90 
91 Tick
93 {
94  panic("MaltaIO::write(...) not implemented inside malta_io.cc");
95  return pioDelay;
96 }
97 
98 void
99 MaltaIO::postIntr(uint8_t interrupt)
100 {
101  malta->cchip->postIntr(interrupt);
102  DPRINTF(Malta, "posting pic interrupt to cchip\n");
103 }
104 
105 void
106 MaltaIO::clearIntr(uint8_t interrupt)
107 {
108  malta->cchip->clearIntr(interrupt);
109  DPRINTF(Malta, "clear pic interrupt to cchip\n");
110 }
111 
112 void
114 {
122 
123  // Serialize the timers
124  pitimer.serialize("pitimer", cp);
125  rtc.serialize("rtc", cp);
126 }
127 
128 void
130 {
138 
139  // Unserialize the timers
140  pitimer.unserialize("pitimer", cp);
141  rtc.unserialize("rtc", cp);
142 }
143 
144 void
146 {
147  rtc.startup();
148  pitimer.startup();
149 }
150 
151 MaltaIO *
152 MaltaIOParams::create()
153 {
154  return new MaltaIO(this);
155 }
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:167
#define DPRINTF(x,...)
Definition: trace.hh:229
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: malta_io.cc:113
MaltaIO(const Params *p)
Initialize all the data for devices supported by Malta I/O.
Definition: malta_io.cc:66
Emulation of the Malta CChip CSRs.
const std::string & name()
Definition: trace.cc:54
void clearIntr(uint32_t interrupt)
clear an interrupt previously posted to the CPU.
Definition: malta_cchip.cc:121
Real-Time Clock (MC146818)
Definition: mc146818.hh:41
PioDeviceParams Params
Definition: io_device.hh:134
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:586
Definition: cprintf.cc:42
Malta * malta
Definition: malta_io.hh:59
Tick Frequency
The simulated frequency of curTick(). (In ticks per second)
Definition: core.cc:49
void startup()
Start ticking.
RTC(const std::string &name, const MaltaIOParams *p)
Definition: malta_io.cc:60
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: malta_io.cc:85
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: malta_io.cc:92
#define UNSERIALIZE_SCALAR(scalar)
Definition: serialize.hh:645
uint8_t mask1
Mask of the PIC1.
Definition: malta_io.hh:71
void serialize(const std::string &base, CheckpointOut &cp) const
Serialize this object to the given output stream.
Definition: mc146818.cc:269
void postIntr(uint8_t interrupt)
Post an Interrupt to the CPU.
Definition: malta_io.cc:99
uint16_t timerData
The interval is set via two writes to the PIT.
Definition: malta_io.hh:100
uint64_t Tick
Tick count type.
Definition: types.hh:63
void clearIntr(uint8_t interrupt)
Clear an Interrupt to the CPU.
Definition: malta_io.cc:106
Port Object Declaration.
void startup() override
Start running.
Definition: malta_io.cc:145
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
MaltaIO * io
Pointer to the MaltaIO device which has the RTC.
Definition: malta.hh:66
Intel8254Timer pitimer
Intel 8253 Periodic Interval Timer.
Definition: malta_io.hh:92
RTC rtc
Definition: malta_io.hh:94
Top level class for Malta Chipset emulation.
Definition: malta.hh:56
#define SERIALIZE_SCALAR(scalar)
Definition: serialize.hh:643
List of Tsunami CSRs.
Malta * malta
A pointer to the Malta device which be belong to.
Definition: malta_io.hh:89
Declaration of the Packet class.
std::ostream CheckpointOut
Definition: serialize.hh:68
virtual void startup()
Start ticking.
Definition: mc146818.cc:127
void unserialize(const std::string &base, CheckpointIn &cp)
Reconstruct the state of this object from a checkpoint.
Definition: mc146818.cc:289
uint8_t mode1
Mode of PIC1.
Definition: malta_io.hh:77
const Params * params() const
Definition: malta_io.hh:112
uint8_t mode2
Mode of PIC2.
Definition: malta_io.hh:80
Tick pioDelay
Delay that the device experinces on an access.
Definition: io_device.hh:163
void postIntr(uint32_t interrupt)
post an interrupt to the CPU.
Definition: malta_cchip.cc:106
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: malta_io.cc:129
MaltaCChip * cchip
Pointer to the Malta CChip.
Definition: malta.hh:72
Malta I/O device is a catch all for all the south bridge stuff we care to implement.
Definition: malta_io.hh:52
uint8_t mask2
Mask of the PIC2.
Definition: malta_io.hh:74
Bitfield< 0 > p
const std::string & name() const
Definition: mc146818.hh:88
Tick frequency() const
Return the freqency of the RTC.
Definition: malta_io.cc:79
bool picInterrupting
Is the pic interrupting right now or not.
Definition: malta_io.hh:86
Malta I/O Space mapping including RTC/timer interrupts.
void serialize(const std::string &base, CheckpointOut &cp) const
Serialize this object to the given output stream.
Declaration of top level class for the Malta chipset.
void unserialize(const std::string &base, CheckpointIn &cp)
Reconstruct the state of this object from a checkpoint.
uint8_t picr
Raw PIC interrupt register before masking.
Definition: malta_io.hh:83

Generated on Fri Feb 28 2020 16:27:00 for gem5 by doxygen 1.8.13