io_device.cc revision 10603
1545SN/A/* 28948Sandreas.hansson@arm.com * Copyright (c) 2012 ARM Limited 38948Sandreas.hansson@arm.com * All rights reserved. 48948Sandreas.hansson@arm.com * 58948Sandreas.hansson@arm.com * The license below extends only to copyright in the software and shall 68948Sandreas.hansson@arm.com * not be construed as granting a license to any other intellectual 78948Sandreas.hansson@arm.com * property including but not limited to intellectual property relating 88948Sandreas.hansson@arm.com * to a hardware implementation of the functionality of the software 98948Sandreas.hansson@arm.com * licensed hereunder. You may use the software subject to the license 108948Sandreas.hansson@arm.com * terms below provided that you ensure that this notice is replicated 118948Sandreas.hansson@arm.com * unmodified and in its entirety in all distributions of the software, 128948Sandreas.hansson@arm.com * modified or unmodified, in source code or in binary form. 138948Sandreas.hansson@arm.com * 142512SN/A * Copyright (c) 2006 The Regents of The University of Michigan 15545SN/A * All rights reserved. 16545SN/A * 17545SN/A * Redistribution and use in source and binary forms, with or without 18545SN/A * modification, are permitted provided that the following conditions are 19545SN/A * met: redistributions of source code must retain the above copyright 20545SN/A * notice, this list of conditions and the following disclaimer; 21545SN/A * redistributions in binary form must reproduce the above copyright 22545SN/A * notice, this list of conditions and the following disclaimer in the 23545SN/A * documentation and/or other materials provided with the distribution; 24545SN/A * neither the name of the copyright holders nor the names of its 25545SN/A * contributors may be used to endorse or promote products derived from 26545SN/A * this software without specific prior written permission. 27545SN/A * 28545SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29545SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30545SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31545SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32545SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33545SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34545SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35545SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36545SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37545SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38545SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 392665Ssaidi@eecs.umich.edu * 402665Ssaidi@eecs.umich.edu * Authors: Ali Saidi 412665Ssaidi@eecs.umich.edu * Nathan Binkert 42545SN/A */ 43545SN/A 442657Ssaidi@eecs.umich.edu#include "base/trace.hh" 4510405Sandreas.hansson@arm.com#include "debug/AddrRanges.hh" 46545SN/A#include "dev/io_device.hh" 472901Ssaidi@eecs.umich.edu#include "sim/system.hh" 48545SN/A 498914Sandreas.hansson@arm.comPioPort::PioPort(PioDevice *dev) 509095Sandreas.hansson@arm.com : SimpleTimingPort(dev->name() + ".pio", dev), device(dev) 518914Sandreas.hansson@arm.com{ 528914Sandreas.hansson@arm.com} 532489SN/A 542489SN/ATick 553349Sbinkertn@umich.eduPioPort::recvAtomic(PacketPtr pkt) 562489SN/A{ 579549Sandreas.hansson@arm.com // @todo: We need to pay for this and not just zero it out 5810405Sandreas.hansson@arm.com pkt->firstWordDelay = pkt->lastWordDelay = 0; 599549Sandreas.hansson@arm.com 6010603SAndreas.Sandberg@ARM.com const Tick delay(pkt->isRead() ? device->read(pkt) : device->write(pkt)); 6110603SAndreas.Sandberg@ARM.com assert(pkt->isResponse() || pkt->isError()); 6210603SAndreas.Sandberg@ARM.com return delay; 632489SN/A} 642489SN/A 658711Sandreas.hansson@arm.comAddrRangeList 669090Sandreas.hansson@arm.comPioPort::getAddrRanges() const 672489SN/A{ 688711Sandreas.hansson@arm.com return device->getAddrRanges(); 692489SN/A} 702489SN/A 714762Snate@binkert.orgPioDevice::PioDevice(const Params *p) 728914Sandreas.hansson@arm.com : MemObject(p), sys(p->system), pioPort(this) 734762Snate@binkert.org{} 744762Snate@binkert.org 75545SN/APioDevice::~PioDevice() 76545SN/A{ 77545SN/A} 78545SN/A 792542SN/Avoid 802541SN/APioDevice::init() 812541SN/A{ 828851Sandreas.hansson@arm.com if (!pioPort.isConnected()) 838674Snilay@cs.wisc.edu panic("Pio port of %s not connected to anything!", name()); 848851Sandreas.hansson@arm.com pioPort.sendRangeChange(); 852541SN/A} 862541SN/A 879294Sandreas.hansson@arm.comBaseSlavePort & 889294Sandreas.hansson@arm.comPioDevice::getSlavePort(const std::string &if_name, PortID idx) 898598Ssteve.reinhardt@amd.com{ 908598Ssteve.reinhardt@amd.com if (if_name == "pio") { 918922Swilliam.wang@arm.com return pioPort; 928598Ssteve.reinhardt@amd.com } 938922Swilliam.wang@arm.com return MemObject::getSlavePort(if_name, idx); 948598Ssteve.reinhardt@amd.com} 952901Ssaidi@eecs.umich.edu 962901Ssaidi@eecs.umich.eduunsigned int 979342SAndreas.Sandberg@arm.comPioDevice::drain(DrainManager *dm) 982901Ssaidi@eecs.umich.edu{ 992901Ssaidi@eecs.umich.edu unsigned int count; 1009342SAndreas.Sandberg@arm.com count = pioPort.drain(dm); 1012901Ssaidi@eecs.umich.edu if (count) 1029342SAndreas.Sandberg@arm.com setDrainState(Drainable::Draining); 1032901Ssaidi@eecs.umich.edu else 1049342SAndreas.Sandberg@arm.com setDrainState(Drainable::Drained); 1052901Ssaidi@eecs.umich.edu return count; 1062901Ssaidi@eecs.umich.edu} 1072901Ssaidi@eecs.umich.edu 1089808Sstever@gmail.comBasicPioDevice::BasicPioDevice(const Params *p, Addr size) 1099808Sstever@gmail.com : PioDevice(p), pioAddr(p->pio_addr), pioSize(size), 1104762Snate@binkert.org pioDelay(p->pio_latency) 1114762Snate@binkert.org{} 1124762Snate@binkert.org 1138711Sandreas.hansson@arm.comAddrRangeList 1149090Sandreas.hansson@arm.comBasicPioDevice::getAddrRanges() const 1152539SN/A{ 1162539SN/A assert(pioSize != 0); 1178711Sandreas.hansson@arm.com AddrRangeList ranges; 11810405Sandreas.hansson@arm.com DPRINTF(AddrRanges, "registering range: %#x-%#x\n", pioAddr, pioSize); 1198711Sandreas.hansson@arm.com ranges.push_back(RangeSize(pioAddr, pioSize)); 1208711Sandreas.hansson@arm.com return ranges; 1212539SN/A} 122