misc: Delete the now unnecessary create methods.
[gem5.git] / src / dev / mips / malta_io.cc
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
29 /** @file
30 * Malta I/O including PIC, PIT, RTC, DMA
31 */
32
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
62 MaltaIO::MaltaIO(const Params &p)
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
75 MaltaIO::frequency() const
76 {
77 return SimClock::Frequency / params().frequency;
78 }
79
80 Tick
81 MaltaIO::read(PacketPtr pkt)
82 {
83 panic("MaltaIO::read(...) not implemented inside malta_io.cc");
84 return pioDelay;
85 }
86
87 Tick
88 MaltaIO::write(PacketPtr pkt)
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
109 MaltaIO::serialize(CheckpointOut &cp) const
110 {
111 SERIALIZE_SCALAR(timerData);
112 SERIALIZE_SCALAR(mask1);
113 SERIALIZE_SCALAR(mask2);
114 SERIALIZE_SCALAR(mode1);
115 SERIALIZE_SCALAR(mode2);
116 SERIALIZE_SCALAR(picr);
117 SERIALIZE_SCALAR(picInterrupting);
118
119 // Serialize the timers
120 pitimer.serialize("pitimer", cp);
121 rtc.serialize("rtc", cp);
122 }
123
124 void
125 MaltaIO::unserialize(CheckpointIn &cp)
126 {
127 UNSERIALIZE_SCALAR(timerData);
128 UNSERIALIZE_SCALAR(mask1);
129 UNSERIALIZE_SCALAR(mask2);
130 UNSERIALIZE_SCALAR(mode1);
131 UNSERIALIZE_SCALAR(mode2);
132 UNSERIALIZE_SCALAR(picr);
133 UNSERIALIZE_SCALAR(picInterrupting);
134
135 // Unserialize the timers
136 pitimer.unserialize("pitimer", cp);
137 rtc.unserialize("rtc", cp);
138 }
139
140 void
141 MaltaIO::startup()
142 {
143 rtc.startup();
144 pitimer.startup();
145 }