114270Sgabeblack@google.com/* 214270Sgabeblack@google.com * Copyright 2019 Google, Inc. 314270Sgabeblack@google.com * 414270Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 514270Sgabeblack@google.com * modification, are permitted provided that the following conditions are 614270Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 714270Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 814270Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 914270Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 1014270Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 1114270Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 1214270Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 1314270Sgabeblack@google.com * this software without specific prior written permission. 1414270Sgabeblack@google.com * 1514270Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1614270Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1714270Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1814270Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1914270Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2014270Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2114270Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2214270Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2314270Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2414270Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2514270Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2614270Sgabeblack@google.com * 2714270Sgabeblack@google.com * Authors: Gabe Black 2814270Sgabeblack@google.com */ 2914270Sgabeblack@google.com 3014270Sgabeblack@google.com#include "dev/intpin.hh" 3114270Sgabeblack@google.com 3214270Sgabeblack@google.com#include "base/logging.hh" 3314270Sgabeblack@google.com 3414270Sgabeblack@google.comvoid 3514270Sgabeblack@google.comIntSinkPinBase::bind(Port &peer) 3614270Sgabeblack@google.com{ 3714270Sgabeblack@google.com source = dynamic_cast<IntSourcePinBase *>(&peer); 3814270Sgabeblack@google.com fatal_if(!source, "Attempt to bind interrupt sink pin %s to " 3914270Sgabeblack@google.com "incompatible port %s.", name(), peer.name()); 4014270Sgabeblack@google.com Port::bind(peer); 4114270Sgabeblack@google.com} 4214270Sgabeblack@google.com 4314270Sgabeblack@google.comvoid 4414270Sgabeblack@google.comIntSinkPinBase::unbind() 4514270Sgabeblack@google.com{ 4614270Sgabeblack@google.com source = nullptr; 4714270Sgabeblack@google.com Port::unbind(); 4814270Sgabeblack@google.com} 4914270Sgabeblack@google.com 5014270Sgabeblack@google.comvoid 5114270Sgabeblack@google.comIntSourcePinBase::bind(Port &peer) 5214270Sgabeblack@google.com{ 5314270Sgabeblack@google.com sink = dynamic_cast<IntSinkPinBase *>(&peer); 5414270Sgabeblack@google.com fatal_if(!sink, "Attempt to bind interrupt source pin %s to " 5514270Sgabeblack@google.com "incompatible port %s.", name(), peer.name()); 5614270Sgabeblack@google.com Port::bind(peer); 5714270Sgabeblack@google.com 5814270Sgabeblack@google.com if (_state) 5914270Sgabeblack@google.com raise(); 6014270Sgabeblack@google.com else 6114270Sgabeblack@google.com lower(); 6214270Sgabeblack@google.com} 6314270Sgabeblack@google.com 6414270Sgabeblack@google.comvoid 6514270Sgabeblack@google.comIntSourcePinBase::unbind() 6614270Sgabeblack@google.com{ 6714270Sgabeblack@google.com sink = nullptr; 6814270Sgabeblack@google.com Port::unbind(); 6914270Sgabeblack@google.com} 70