1545SN/A/*
211193Sandreas.hansson@arm.com * Copyright (c) 2012, 2015 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
4411793Sbrandon.potter@amd.com#include "dev/io_device.hh"
4511793Sbrandon.potter@amd.com
462657Ssaidi@eecs.umich.edu#include "base/trace.hh"
4710405Sandreas.hansson@arm.com#include "debug/AddrRanges.hh"
482901Ssaidi@eecs.umich.edu#include "sim/system.hh"
49545SN/A
504762Snate@binkert.orgPioDevice::PioDevice(const Params *p)
5113892Sgabeblack@google.com    : ClockedObject(p), sys(p->system), pioPort(this)
524762Snate@binkert.org{}
534762Snate@binkert.org
54545SN/APioDevice::~PioDevice()
55545SN/A{
56545SN/A}
57545SN/A
582542SN/Avoid
592541SN/APioDevice::init()
602541SN/A{
618851Sandreas.hansson@arm.com    if (!pioPort.isConnected())
628674Snilay@cs.wisc.edu        panic("Pio port of %s not connected to anything!", name());
638851Sandreas.hansson@arm.com    pioPort.sendRangeChange();
642541SN/A}
652541SN/A
6613784Sgabeblack@google.comPort &
6713784Sgabeblack@google.comPioDevice::getPort(const std::string &if_name, PortID idx)
688598Ssteve.reinhardt@amd.com{
698598Ssteve.reinhardt@amd.com    if (if_name == "pio") {
708922Swilliam.wang@arm.com        return pioPort;
718598Ssteve.reinhardt@amd.com    }
7213892Sgabeblack@google.com    return ClockedObject::getPort(if_name, idx);
738598Ssteve.reinhardt@amd.com}
742901Ssaidi@eecs.umich.edu
759808Sstever@gmail.comBasicPioDevice::BasicPioDevice(const Params *p, Addr size)
769808Sstever@gmail.com    : PioDevice(p), pioAddr(p->pio_addr), pioSize(size),
774762Snate@binkert.org      pioDelay(p->pio_latency)
784762Snate@binkert.org{}
794762Snate@binkert.org
808711Sandreas.hansson@arm.comAddrRangeList
819090Sandreas.hansson@arm.comBasicPioDevice::getAddrRanges() const
822539SN/A{
832539SN/A    assert(pioSize != 0);
848711Sandreas.hansson@arm.com    AddrRangeList ranges;
8510405Sandreas.hansson@arm.com    DPRINTF(AddrRanges, "registering range: %#x-%#x\n", pioAddr, pioSize);
868711Sandreas.hansson@arm.com    ranges.push_back(RangeSize(pioAddr, pioSize));
878711Sandreas.hansson@arm.com    return ranges;
882539SN/A}
89