malta_io.cc revision 8739
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 375222Sksewell@umich.edu#include <sys/time.h> 385222Sksewell@umich.edu 395222Sksewell@umich.edu#include <deque> 405222Sksewell@umich.edu#include <string> 415222Sksewell@umich.edu#include <vector> 425222Sksewell@umich.edu 436379Sgblack@eecs.umich.edu#include "base/time.hh" 445222Sksewell@umich.edu#include "base/trace.hh" 456658Snate@binkert.org#include "config/the_isa.hh" 468739Sgblack@eecs.umich.edu#include "debug/Malta.hh" 478229Snate@binkert.org#include "dev/mips/malta.hh" 485222Sksewell@umich.edu#include "dev/mips/malta_cchip.hh" 495222Sksewell@umich.edu#include "dev/mips/malta_io.hh" 505222Sksewell@umich.edu#include "dev/mips/maltareg.h" 518229Snate@binkert.org#include "dev/rtcreg.h" 525222Sksewell@umich.edu#include "mem/packet.hh" 535222Sksewell@umich.edu#include "mem/packet_access.hh" 545222Sksewell@umich.edu#include "mem/port.hh" 555222Sksewell@umich.edu#include "params/MaltaIO.hh" 565222Sksewell@umich.edu#include "sim/system.hh" 575222Sksewell@umich.edu 585222Sksewell@umich.eduusing namespace std; 595222Sksewell@umich.eduusing namespace TheISA; 605222Sksewell@umich.edu 616379Sgblack@eecs.umich.eduMaltaIO::RTC::RTC(const string &name, const MaltaIOParams *p) 626379Sgblack@eecs.umich.edu : MC146818(p->malta, name, p->time, p->year_is_bcd, p->frequency), 636379Sgblack@eecs.umich.edu malta(p->malta) 645222Sksewell@umich.edu{ 655222Sksewell@umich.edu} 665222Sksewell@umich.edu 676379Sgblack@eecs.umich.eduMaltaIO::MaltaIO(const Params *p) 686379Sgblack@eecs.umich.edu : BasicPioDevice(p), malta(p->malta), 696379Sgblack@eecs.umich.edu pitimer(this, p->name + "pitimer"), rtc(p->name + ".rtc", p) 705222Sksewell@umich.edu{ 715222Sksewell@umich.edu pioSize = 0x100; 725222Sksewell@umich.edu 735222Sksewell@umich.edu // set the back pointer from malta to myself 745222Sksewell@umich.edu malta->io = this; 755222Sksewell@umich.edu 765222Sksewell@umich.edu timerData = 0; 775222Sksewell@umich.edu picr = 0; 785222Sksewell@umich.edu picInterrupting = false; 795222Sksewell@umich.edu} 805222Sksewell@umich.edu 815222Sksewell@umich.eduTick 825222Sksewell@umich.eduMaltaIO::frequency() const 835222Sksewell@umich.edu{ 847064Snate@binkert.org return SimClock::Frequency / params()->frequency; 855222Sksewell@umich.edu} 865222Sksewell@umich.edu 875222Sksewell@umich.eduTick 885222Sksewell@umich.eduMaltaIO::read(PacketPtr pkt) 895222Sksewell@umich.edu{ 906379Sgblack@eecs.umich.edu panic("MaltaIO::read(...) not implemented inside malta_io.cc"); 915222Sksewell@umich.edu return pioDelay; 925222Sksewell@umich.edu} 935222Sksewell@umich.edu 945222Sksewell@umich.eduTick 955222Sksewell@umich.eduMaltaIO::write(PacketPtr pkt) 965222Sksewell@umich.edu{ 976379Sgblack@eecs.umich.edu panic("MaltaIO::write(...) not implemented inside malta_io.cc"); 985222Sksewell@umich.edu return pioDelay; 995222Sksewell@umich.edu} 1005222Sksewell@umich.edu 1015222Sksewell@umich.eduvoid 1025222Sksewell@umich.eduMaltaIO::postIntr(uint8_t interrupt) 1035222Sksewell@umich.edu{ 1045222Sksewell@umich.edu malta->cchip->postIntr(interrupt); 1055222Sksewell@umich.edu DPRINTF(Malta, "posting pic interrupt to cchip\n"); 1065222Sksewell@umich.edu} 1075222Sksewell@umich.edu 1085222Sksewell@umich.eduvoid 1095222Sksewell@umich.eduMaltaIO::clearIntr(uint8_t interrupt) 1105222Sksewell@umich.edu{ 1115222Sksewell@umich.edu malta->cchip->clearIntr(interrupt); 1126379Sgblack@eecs.umich.edu DPRINTF(Malta, "clear pic interrupt to cchip\n"); 1135222Sksewell@umich.edu} 1145222Sksewell@umich.edu 1155222Sksewell@umich.eduvoid 1165222Sksewell@umich.eduMaltaIO::serialize(ostream &os) 1175222Sksewell@umich.edu{ 1185222Sksewell@umich.edu SERIALIZE_SCALAR(timerData); 1195222Sksewell@umich.edu SERIALIZE_SCALAR(mask1); 1205222Sksewell@umich.edu SERIALIZE_SCALAR(mask2); 1215222Sksewell@umich.edu SERIALIZE_SCALAR(mode1); 1225222Sksewell@umich.edu SERIALIZE_SCALAR(mode2); 1235222Sksewell@umich.edu SERIALIZE_SCALAR(picr); 1245222Sksewell@umich.edu SERIALIZE_SCALAR(picInterrupting); 1255222Sksewell@umich.edu 1265222Sksewell@umich.edu // Serialize the timers 1275222Sksewell@umich.edu pitimer.serialize("pitimer", os); 1285222Sksewell@umich.edu rtc.serialize("rtc", os); 1295222Sksewell@umich.edu} 1305222Sksewell@umich.edu 1315222Sksewell@umich.eduvoid 1325222Sksewell@umich.eduMaltaIO::unserialize(Checkpoint *cp, const string §ion) 1335222Sksewell@umich.edu{ 1345222Sksewell@umich.edu UNSERIALIZE_SCALAR(timerData); 1355222Sksewell@umich.edu UNSERIALIZE_SCALAR(mask1); 1365222Sksewell@umich.edu UNSERIALIZE_SCALAR(mask2); 1375222Sksewell@umich.edu UNSERIALIZE_SCALAR(mode1); 1385222Sksewell@umich.edu UNSERIALIZE_SCALAR(mode2); 1395222Sksewell@umich.edu UNSERIALIZE_SCALAR(picr); 1405222Sksewell@umich.edu UNSERIALIZE_SCALAR(picInterrupting); 1415222Sksewell@umich.edu 1425222Sksewell@umich.edu // Unserialize the timers 1435222Sksewell@umich.edu pitimer.unserialize("pitimer", cp, section); 1445222Sksewell@umich.edu rtc.unserialize("rtc", cp, section); 1455222Sksewell@umich.edu} 1465222Sksewell@umich.edu 1475222Sksewell@umich.eduMaltaIO * 1485222Sksewell@umich.eduMaltaIOParams::create() 1495222Sksewell@umich.edu{ 1505222Sksewell@umich.edu return new MaltaIO(this); 1515222Sksewell@umich.edu} 152