malta_io.cc (10642:9d3b6e7dd205) malta_io.cc (10905:a6ca6831e775)
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
33/** @file
34 * Malta I/O including PIC, PIT, RTC, DMA
35 */
36
37#include <sys/time.h>
38
39#include <deque>
40#include <string>
41#include <vector>
42
43#include "base/time.hh"
44#include "base/trace.hh"
45#include "config/the_isa.hh"
46#include "debug/Malta.hh"
47#include "dev/mips/malta.hh"
48#include "dev/mips/malta_cchip.hh"
49#include "dev/mips/malta_io.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
58using namespace std;
59using namespace TheISA;
60
61MaltaIO::RTC::RTC(const string &name, const MaltaIOParams *p)
62 : MC146818(p->malta, name, p->time, p->year_is_bcd, p->frequency),
63 malta(p->malta)
64{
65}
66
67MaltaIO::MaltaIO(const Params *p)
68 : BasicPioDevice(p, 0x100), malta(p->malta),
69 pitimer(this, p->name + "pitimer"), rtc(p->name + ".rtc", p)
70{
71 // set the back pointer from malta to myself
72 malta->io = this;
73
74 timerData = 0;
75 picr = 0;
76 picInterrupting = false;
77}
78
79Tick
80MaltaIO::frequency() const
81{
82 return SimClock::Frequency / params()->frequency;
83}
84
85Tick
86MaltaIO::read(PacketPtr pkt)
87{
88 panic("MaltaIO::read(...) not implemented inside malta_io.cc");
89 return pioDelay;
90}
91
92Tick
93MaltaIO::write(PacketPtr pkt)
94{
95 panic("MaltaIO::write(...) not implemented inside malta_io.cc");
96 return pioDelay;
97}
98
99void
100MaltaIO::postIntr(uint8_t interrupt)
101{
102 malta->cchip->postIntr(interrupt);
103 DPRINTF(Malta, "posting pic interrupt to cchip\n");
104}
105
106void
107MaltaIO::clearIntr(uint8_t interrupt)
108{
109 malta->cchip->clearIntr(interrupt);
110 DPRINTF(Malta, "clear pic interrupt to cchip\n");
111}
112
113void
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
33/** @file
34 * Malta I/O including PIC, PIT, RTC, DMA
35 */
36
37#include <sys/time.h>
38
39#include <deque>
40#include <string>
41#include <vector>
42
43#include "base/time.hh"
44#include "base/trace.hh"
45#include "config/the_isa.hh"
46#include "debug/Malta.hh"
47#include "dev/mips/malta.hh"
48#include "dev/mips/malta_cchip.hh"
49#include "dev/mips/malta_io.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
58using namespace std;
59using namespace TheISA;
60
61MaltaIO::RTC::RTC(const string &name, const MaltaIOParams *p)
62 : MC146818(p->malta, name, p->time, p->year_is_bcd, p->frequency),
63 malta(p->malta)
64{
65}
66
67MaltaIO::MaltaIO(const Params *p)
68 : BasicPioDevice(p, 0x100), malta(p->malta),
69 pitimer(this, p->name + "pitimer"), rtc(p->name + ".rtc", p)
70{
71 // set the back pointer from malta to myself
72 malta->io = this;
73
74 timerData = 0;
75 picr = 0;
76 picInterrupting = false;
77}
78
79Tick
80MaltaIO::frequency() const
81{
82 return SimClock::Frequency / params()->frequency;
83}
84
85Tick
86MaltaIO::read(PacketPtr pkt)
87{
88 panic("MaltaIO::read(...) not implemented inside malta_io.cc");
89 return pioDelay;
90}
91
92Tick
93MaltaIO::write(PacketPtr pkt)
94{
95 panic("MaltaIO::write(...) not implemented inside malta_io.cc");
96 return pioDelay;
97}
98
99void
100MaltaIO::postIntr(uint8_t interrupt)
101{
102 malta->cchip->postIntr(interrupt);
103 DPRINTF(Malta, "posting pic interrupt to cchip\n");
104}
105
106void
107MaltaIO::clearIntr(uint8_t interrupt)
108{
109 malta->cchip->clearIntr(interrupt);
110 DPRINTF(Malta, "clear pic interrupt to cchip\n");
111}
112
113void
114MaltaIO::serialize(ostream &os)
114MaltaIO::serialize(CheckpointOut &cp) const
115{
116 SERIALIZE_SCALAR(timerData);
117 SERIALIZE_SCALAR(mask1);
118 SERIALIZE_SCALAR(mask2);
119 SERIALIZE_SCALAR(mode1);
120 SERIALIZE_SCALAR(mode2);
121 SERIALIZE_SCALAR(picr);
122 SERIALIZE_SCALAR(picInterrupting);
123
124 // Serialize the timers
115{
116 SERIALIZE_SCALAR(timerData);
117 SERIALIZE_SCALAR(mask1);
118 SERIALIZE_SCALAR(mask2);
119 SERIALIZE_SCALAR(mode1);
120 SERIALIZE_SCALAR(mode2);
121 SERIALIZE_SCALAR(picr);
122 SERIALIZE_SCALAR(picInterrupting);
123
124 // Serialize the timers
125 pitimer.serialize("pitimer", os);
126 rtc.serialize("rtc", os);
125 pitimer.serialize("pitimer", cp);
126 rtc.serialize("rtc", cp);
127}
128
129void
127}
128
129void
130MaltaIO::unserialize(Checkpoint *cp, const string &section)
130MaltaIO::unserialize(CheckpointIn &cp)
131{
132 UNSERIALIZE_SCALAR(timerData);
133 UNSERIALIZE_SCALAR(mask1);
134 UNSERIALIZE_SCALAR(mask2);
135 UNSERIALIZE_SCALAR(mode1);
136 UNSERIALIZE_SCALAR(mode2);
137 UNSERIALIZE_SCALAR(picr);
138 UNSERIALIZE_SCALAR(picInterrupting);
139
140 // Unserialize the timers
131{
132 UNSERIALIZE_SCALAR(timerData);
133 UNSERIALIZE_SCALAR(mask1);
134 UNSERIALIZE_SCALAR(mask2);
135 UNSERIALIZE_SCALAR(mode1);
136 UNSERIALIZE_SCALAR(mode2);
137 UNSERIALIZE_SCALAR(picr);
138 UNSERIALIZE_SCALAR(picInterrupting);
139
140 // Unserialize the timers
141 pitimer.unserialize("pitimer", cp, section);
142 rtc.unserialize("rtc", cp, section);
141 pitimer.unserialize("pitimer", cp);
142 rtc.unserialize("rtc", cp);
143}
144
145void
146MaltaIO::startup()
147{
148 rtc.startup();
149 pitimer.startup();
150}
151
152MaltaIO *
153MaltaIOParams::create()
154{
155 return new MaltaIO(this);
156}
143}
144
145void
146MaltaIO::startup()
147{
148 rtc.startup();
149 pitimer.startup();
150}
151
152MaltaIO *
153MaltaIOParams::create()
154{
155 return new MaltaIO(this);
156}