malta_io.cc revision 11793
15222Sksewell@umich.edu/*
25222Sksewell@umich.edu * Copyright (c) 2004-2005 The Regents of The University of Michigan
35222Sksewell@umich.edu * All rights reserved.
45222Sksewell@umich.edu *
55222Sksewell@umich.edu * Redistribution and use in source and binary forms, with or without
65222Sksewell@umich.edu * modification, are permitted provided that the following conditions are
75222Sksewell@umich.edu * met: redistributions of source code must retain the above copyright
85222Sksewell@umich.edu * notice, this list of conditions and the following disclaimer;
95222Sksewell@umich.edu * redistributions in binary form must reproduce the above copyright
105222Sksewell@umich.edu * notice, this list of conditions and the following disclaimer in the
115222Sksewell@umich.edu * documentation and/or other materials provided with the distribution;
125222Sksewell@umich.edu * neither the name of the copyright holders nor the names of its
135222Sksewell@umich.edu * contributors may be used to endorse or promote products derived from
145222Sksewell@umich.edu * this software without specific prior written permission.
155222Sksewell@umich.edu *
165222Sksewell@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
175222Sksewell@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
185222Sksewell@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
195222Sksewell@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
205222Sksewell@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
215222Sksewell@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
225222Sksewell@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
235222Sksewell@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
245222Sksewell@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
255222Sksewell@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
265222Sksewell@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
275222Sksewell@umich.edu *
285222Sksewell@umich.edu * Authors: Ali Saidi
295222Sksewell@umich.edu *          Andrew Schultz
305222Sksewell@umich.edu *          Miguel Serrano
315222Sksewell@umich.edu */
325222Sksewell@umich.edu
335222Sksewell@umich.edu/** @file
345222Sksewell@umich.edu * Malta I/O including PIC, PIT, RTC, DMA
355222Sksewell@umich.edu */
365222Sksewell@umich.edu
3711793Sbrandon.potter@amd.com#include "dev/mips/malta_io.hh"
3811793Sbrandon.potter@amd.com
395222Sksewell@umich.edu#include <sys/time.h>
405222Sksewell@umich.edu
415222Sksewell@umich.edu#include <deque>
425222Sksewell@umich.edu#include <string>
435222Sksewell@umich.edu#include <vector>
445222Sksewell@umich.edu
456379Sgblack@eecs.umich.edu#include "base/time.hh"
465222Sksewell@umich.edu#include "base/trace.hh"
476658Snate@binkert.org#include "config/the_isa.hh"
488739Sgblack@eecs.umich.edu#include "debug/Malta.hh"
498229Snate@binkert.org#include "dev/mips/malta.hh"
505222Sksewell@umich.edu#include "dev/mips/malta_cchip.hh"
515222Sksewell@umich.edu#include "dev/mips/maltareg.h"
528229Snate@binkert.org#include "dev/rtcreg.h"
535222Sksewell@umich.edu#include "mem/packet.hh"
545222Sksewell@umich.edu#include "mem/packet_access.hh"
555222Sksewell@umich.edu#include "mem/port.hh"
565222Sksewell@umich.edu#include "params/MaltaIO.hh"
575222Sksewell@umich.edu#include "sim/system.hh"
585222Sksewell@umich.edu
595222Sksewell@umich.eduusing namespace std;
605222Sksewell@umich.eduusing namespace TheISA;
615222Sksewell@umich.edu
626379Sgblack@eecs.umich.eduMaltaIO::RTC::RTC(const string &name, const MaltaIOParams *p)
636379Sgblack@eecs.umich.edu    : MC146818(p->malta, name, p->time, p->year_is_bcd, p->frequency),
646379Sgblack@eecs.umich.edu      malta(p->malta)
655222Sksewell@umich.edu{
665222Sksewell@umich.edu}
675222Sksewell@umich.edu
686379Sgblack@eecs.umich.eduMaltaIO::MaltaIO(const Params *p)
699808Sstever@gmail.com    : BasicPioDevice(p, 0x100), malta(p->malta),
706379Sgblack@eecs.umich.edu      pitimer(this, p->name + "pitimer"), rtc(p->name + ".rtc", p)
715222Sksewell@umich.edu{
725222Sksewell@umich.edu    // set the back pointer from malta to myself
735222Sksewell@umich.edu    malta->io = this;
745222Sksewell@umich.edu
755222Sksewell@umich.edu    timerData = 0;
765222Sksewell@umich.edu    picr = 0;
775222Sksewell@umich.edu    picInterrupting = false;
785222Sksewell@umich.edu}
795222Sksewell@umich.edu
805222Sksewell@umich.eduTick
815222Sksewell@umich.eduMaltaIO::frequency() const
825222Sksewell@umich.edu{
837064Snate@binkert.org    return SimClock::Frequency / params()->frequency;
845222Sksewell@umich.edu}
855222Sksewell@umich.edu
865222Sksewell@umich.eduTick
875222Sksewell@umich.eduMaltaIO::read(PacketPtr pkt)
885222Sksewell@umich.edu{
896379Sgblack@eecs.umich.edu    panic("MaltaIO::read(...) not implemented inside malta_io.cc");
905222Sksewell@umich.edu    return pioDelay;
915222Sksewell@umich.edu}
925222Sksewell@umich.edu
935222Sksewell@umich.eduTick
945222Sksewell@umich.eduMaltaIO::write(PacketPtr pkt)
955222Sksewell@umich.edu{
966379Sgblack@eecs.umich.edu    panic("MaltaIO::write(...) not implemented inside malta_io.cc");
975222Sksewell@umich.edu    return pioDelay;
985222Sksewell@umich.edu}
995222Sksewell@umich.edu
1005222Sksewell@umich.eduvoid
1015222Sksewell@umich.eduMaltaIO::postIntr(uint8_t interrupt)
1025222Sksewell@umich.edu{
1035222Sksewell@umich.edu    malta->cchip->postIntr(interrupt);
1045222Sksewell@umich.edu    DPRINTF(Malta, "posting pic interrupt to cchip\n");
1055222Sksewell@umich.edu}
1065222Sksewell@umich.edu
1075222Sksewell@umich.eduvoid
1085222Sksewell@umich.eduMaltaIO::clearIntr(uint8_t interrupt)
1095222Sksewell@umich.edu{
1105222Sksewell@umich.edu    malta->cchip->clearIntr(interrupt);
1116379Sgblack@eecs.umich.edu    DPRINTF(Malta, "clear pic interrupt to cchip\n");
1125222Sksewell@umich.edu}
1135222Sksewell@umich.edu
1145222Sksewell@umich.eduvoid
11510905Sandreas.sandberg@arm.comMaltaIO::serialize(CheckpointOut &cp) const
1165222Sksewell@umich.edu{
1175222Sksewell@umich.edu    SERIALIZE_SCALAR(timerData);
1185222Sksewell@umich.edu    SERIALIZE_SCALAR(mask1);
1195222Sksewell@umich.edu    SERIALIZE_SCALAR(mask2);
1205222Sksewell@umich.edu    SERIALIZE_SCALAR(mode1);
1215222Sksewell@umich.edu    SERIALIZE_SCALAR(mode2);
1225222Sksewell@umich.edu    SERIALIZE_SCALAR(picr);
1235222Sksewell@umich.edu    SERIALIZE_SCALAR(picInterrupting);
1245222Sksewell@umich.edu
1255222Sksewell@umich.edu    // Serialize the timers
12610905Sandreas.sandberg@arm.com    pitimer.serialize("pitimer", cp);
12710905Sandreas.sandberg@arm.com    rtc.serialize("rtc", cp);
1285222Sksewell@umich.edu}
1295222Sksewell@umich.edu
1305222Sksewell@umich.eduvoid
13110905Sandreas.sandberg@arm.comMaltaIO::unserialize(CheckpointIn &cp)
1325222Sksewell@umich.edu{
1335222Sksewell@umich.edu    UNSERIALIZE_SCALAR(timerData);
1345222Sksewell@umich.edu    UNSERIALIZE_SCALAR(mask1);
1355222Sksewell@umich.edu    UNSERIALIZE_SCALAR(mask2);
1365222Sksewell@umich.edu    UNSERIALIZE_SCALAR(mode1);
1375222Sksewell@umich.edu    UNSERIALIZE_SCALAR(mode2);
1385222Sksewell@umich.edu    UNSERIALIZE_SCALAR(picr);
1395222Sksewell@umich.edu    UNSERIALIZE_SCALAR(picInterrupting);
1405222Sksewell@umich.edu
1415222Sksewell@umich.edu    // Unserialize the timers
14210905Sandreas.sandberg@arm.com    pitimer.unserialize("pitimer", cp);
14310905Sandreas.sandberg@arm.com    rtc.unserialize("rtc", cp);
1445222Sksewell@umich.edu}
1455222Sksewell@umich.edu
14610631Scdirik@micron.comvoid
14710631Scdirik@micron.comMaltaIO::startup()
14810631Scdirik@micron.com{
14910631Scdirik@micron.com    rtc.startup();
15010642Scdirik@micron.com    pitimer.startup();
15110631Scdirik@micron.com}
15210631Scdirik@micron.com
1535222Sksewell@umich.eduMaltaIO *
1545222Sksewell@umich.eduMaltaIOParams::create()
1555222Sksewell@umich.edu{
1565222Sksewell@umich.edu    return new MaltaIO(this);
1575222Sksewell@umich.edu}
158