gem5  v20.1.0.0
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 
33 #include "dev/mips/malta_io.hh"
34 
35 #include <sys/time.h>
36 
37 #include <deque>
38 #include <string>
39 #include <vector>
40 
41 #include "base/time.hh"
42 #include "base/trace.hh"
43 #include "debug/Malta.hh"
44 #include "dev/mips/malta.hh"
45 #include "dev/mips/malta_cchip.hh"
46 #include "dev/mips/maltareg.h"
47 #include "dev/rtcreg.h"
48 #include "mem/packet.hh"
49 #include "mem/packet_access.hh"
50 #include "mem/port.hh"
51 #include "params/MaltaIO.hh"
52 #include "sim/system.hh"
53 
54 using namespace std;
55 
56 MaltaIO::RTC::RTC(const string &name, const MaltaIOParams *p)
57  : MC146818(p->malta, name, p->time, p->year_is_bcd, p->frequency),
58  malta(p->malta)
59 {
60 }
61 
63  : BasicPioDevice(p, 0x100), malta(p->malta),
64  pitimer(this, p->name + "pitimer"), rtc(p->name + ".rtc", p)
65 {
66  // set the back pointer from malta to myself
67  malta->io = this;
68 
69  timerData = 0;
70  picr = 0;
71  picInterrupting = false;
72 }
73 
74 Tick
76 {
77  return SimClock::Frequency / params()->frequency;
78 }
79 
80 Tick
82 {
83  panic("MaltaIO::read(...) not implemented inside malta_io.cc");
84  return pioDelay;
85 }
86 
87 Tick
89 {
90  panic("MaltaIO::write(...) not implemented inside malta_io.cc");
91  return pioDelay;
92 }
93 
94 void
95 MaltaIO::postIntr(uint8_t interrupt)
96 {
97  malta->cchip->postIntr(interrupt);
98  DPRINTF(Malta, "posting pic interrupt to cchip\n");
99 }
100 
101 void
102 MaltaIO::clearIntr(uint8_t interrupt)
103 {
104  malta->cchip->clearIntr(interrupt);
105  DPRINTF(Malta, "clear pic interrupt to cchip\n");
106 }
107 
108 void
110 {
118 
119  // Serialize the timers
120  pitimer.serialize("pitimer", cp);
121  rtc.serialize("rtc", cp);
122 }
123 
124 void
126 {
134 
135  // Unserialize the timers
136  pitimer.unserialize("pitimer", cp);
137  rtc.unserialize("rtc", cp);
138 }
139 
140 void
142 {
143  rtc.startup();
144  pitimer.startup();
145 }
146 
147 MaltaIO *
148 MaltaIOParams::create()
149 {
150  return new MaltaIO(this);
151 }
MaltaIO::picr
uint8_t picr
Raw PIC interrupt register before masking.
Definition: malta_io.hh:79
Intel8254Timer::unserialize
void unserialize(const std::string &base, CheckpointIn &cp)
Reconstruct the state of this object from a checkpoint.
Definition: intel_8254_timer.cc:80
Malta::cchip
MaltaCChip * cchip
Pointer to the Malta CChip.
Definition: malta.hh:69
MC146818::unserialize
void unserialize(const std::string &base, CheckpointIn &cp)
Reconstruct the state of this object from a checkpoint.
Definition: mc146818.cc:285
MaltaIO::clearIntr
void clearIntr(uint8_t interrupt)
Clear an Interrupt to the CPU.
Definition: malta_io.cc:102
MaltaIO::rtc
RTC rtc
Definition: malta_io.hh:90
malta.hh
system.hh
MaltaIO::write
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: malta_io.cc:88
UNSERIALIZE_SCALAR
#define UNSERIALIZE_SCALAR(scalar)
Definition: serialize.hh:797
Intel8254Timer::serialize
void serialize(const std::string &base, CheckpointOut &cp) const
Serialize this object to the given output stream.
Definition: intel_8254_timer.cc:71
MaltaCChip::clearIntr
void clearIntr(uint32_t interrupt)
clear an interrupt previously posted to the CPU.
Definition: malta_cchip.cc:118
malta_io.hh
Intel8254Timer::startup
void startup()
Start ticking.
Definition: intel_8254_timer.cc:89
time.hh
MaltaIO::malta
Malta * malta
A pointer to the Malta device which be belong to.
Definition: malta_io.hh:85
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
MaltaIO::mode2
uint8_t mode2
Mode of PIC2.
Definition: malta_io.hh:76
MaltaIO::pitimer
Intel8254Timer pitimer
Intel 8253 Periodic Interval Timer.
Definition: malta_io.hh:88
MaltaIO::RTC::RTC
RTC(const std::string &name, const MaltaIOParams *p)
Definition: malta_io.cc:56
malta_cchip.hh
MaltaIO::mask1
uint8_t mask1
Mask of the PIC1.
Definition: malta_io.hh:67
packet.hh
SimClock::Frequency
Tick Frequency
The simulated frequency of curTick(). (In ticks per second)
Definition: core.cc:46
MaltaIO::params
const Params * params() const
Definition: malta_io.hh:108
maltareg.h
MC146818::serialize
void serialize(const std::string &base, CheckpointOut &cp) const
Serialize this object to the given output stream.
Definition: mc146818.cc:265
MaltaCChip::postIntr
void postIntr(uint32_t interrupt)
post an interrupt to the CPU.
Definition: malta_cchip.cc:103
cp
Definition: cprintf.cc:40
MaltaIO::mode1
uint8_t mode1
Mode of PIC1.
Definition: malta_io.hh:73
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:234
PioDevice::Params
PioDeviceParams Params
Definition: io_device.hh:131
port.hh
MaltaIO::mask2
uint8_t mask2
Mask of the PIC2.
Definition: malta_io.hh:70
MC146818
Real-Time Clock (MC146818)
Definition: mc146818.hh:38
MaltaIO::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: malta_io.cc:125
name
const std::string & name()
Definition: trace.cc:50
SERIALIZE_SCALAR
#define SERIALIZE_SCALAR(scalar)
Definition: serialize.hh:790
packet_access.hh
SimObject::name
virtual const std::string name() const
Definition: sim_object.hh:133
MaltaIO::postIntr
void postIntr(uint8_t interrupt)
Post an Interrupt to the CPU.
Definition: malta_io.cc:95
MaltaIO::frequency
Tick frequency() const
Return the freqency of the RTC.
Definition: malta_io.cc:75
std
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:587
Malta
Top level class for Malta Chipset emulation.
Definition: malta.hh:53
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
MaltaIO::timerData
uint16_t timerData
The interval is set via two writes to the PIT.
Definition: malta_io.hh:96
BasicPioDevice
Definition: io_device.hh:150
MaltaIO::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: malta_io.cc:109
BasicPioDevice::pioDelay
Tick pioDelay
Delay that the device experinces on an access.
Definition: io_device.hh:160
MaltaIO
Malta I/O device is a catch all for all the south bridge stuff we care to implement.
Definition: malta_io.hh:48
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
rtcreg.h
trace.hh
MaltaIO::picInterrupting
bool picInterrupting
Is the pic interrupting right now or not.
Definition: malta_io.hh:82
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
Malta::io
MaltaIO * io
Pointer to the MaltaIO device which has the RTC.
Definition: malta.hh:63
MaltaIO::read
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: malta_io.cc:81
CheckpointIn
Definition: serialize.hh:67
MaltaIO::MaltaIO
MaltaIO(const Params *p)
Initialize all the data for devices supported by Malta I/O.
Definition: malta_io.cc:62
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:171
MaltaIO::startup
void startup() override
Start running.
Definition: malta_io.cc:141
MC146818::startup
virtual void startup()
Start ticking.
Definition: mc146818.cc:123

Generated on Wed Sep 30 2020 14:02:11 for gem5 by doxygen 1.8.17