malta_io.cc revision 6658
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 "dev/rtcreg.h" 47#include "dev/mips/malta_cchip.hh" 48#include "dev/mips/malta.hh" 49#include "dev/mips/malta_io.hh" 50#include "dev/mips/maltareg.h" 51#include "mem/packet.hh" 52#include "mem/packet_access.hh" 53#include "mem/port.hh" 54#include "params/MaltaIO.hh" 55#include "sim/system.hh" 56 57using namespace std; 58using namespace TheISA; 59 60MaltaIO::RTC::RTC(const string &name, const MaltaIOParams *p) 61 : MC146818(p->malta, name, p->time, p->year_is_bcd, p->frequency), 62 malta(p->malta) 63{ 64} 65 66MaltaIO::MaltaIO(const Params *p) 67 : BasicPioDevice(p), malta(p->malta), 68 pitimer(this, p->name + "pitimer"), rtc(p->name + ".rtc", p) 69{ 70 pioSize = 0x100; 71 72 // set the back pointer from malta to myself 73 malta->io = this; 74 75 timerData = 0; 76 picr = 0; 77 picInterrupting = false; 78} 79 80Tick 81MaltaIO::frequency() const 82{ 83 return Clock::Frequency / params()->frequency; 84} 85 86Tick 87MaltaIO::read(PacketPtr pkt) 88{ 89 panic("MaltaIO::read(...) not implemented inside malta_io.cc"); 90 return pioDelay; 91} 92 93Tick 94MaltaIO::write(PacketPtr pkt) 95{ 96 panic("MaltaIO::write(...) not implemented inside malta_io.cc"); 97 return pioDelay; 98} 99 100void 101MaltaIO::postIntr(uint8_t interrupt) 102{ 103 malta->cchip->postIntr(interrupt); 104 DPRINTF(Malta, "posting pic interrupt to cchip\n"); 105} 106 107void 108MaltaIO::clearIntr(uint8_t interrupt) 109{ 110 malta->cchip->clearIntr(interrupt); 111 DPRINTF(Malta, "clear pic interrupt to cchip\n"); 112} 113 114void 115MaltaIO::serialize(ostream &os) 116{ 117 SERIALIZE_SCALAR(timerData); 118 SERIALIZE_SCALAR(mask1); 119 SERIALIZE_SCALAR(mask2); 120 SERIALIZE_SCALAR(mode1); 121 SERIALIZE_SCALAR(mode2); 122 SERIALIZE_SCALAR(picr); 123 SERIALIZE_SCALAR(picInterrupting); 124 125 // Serialize the timers 126 pitimer.serialize("pitimer", os); 127 rtc.serialize("rtc", os); 128} 129 130void 131MaltaIO::unserialize(Checkpoint *cp, const string §ion) 132{ 133 UNSERIALIZE_SCALAR(timerData); 134 UNSERIALIZE_SCALAR(mask1); 135 UNSERIALIZE_SCALAR(mask2); 136 UNSERIALIZE_SCALAR(mode1); 137 UNSERIALIZE_SCALAR(mode2); 138 UNSERIALIZE_SCALAR(picr); 139 UNSERIALIZE_SCALAR(picInterrupting); 140 141 // Unserialize the timers 142 pitimer.unserialize("pitimer", cp, section); 143 rtc.unserialize("rtc", cp, section); 144} 145 146MaltaIO * 147MaltaIOParams::create() 148{ 149 return new MaltaIO(this); 150} 151