15390SN/A/* 25443SN/A * Copyright (c) 2008 The Regents of The University of Michigan 35390SN/A * All rights reserved. 45390SN/A * 55390SN/A * Redistribution and use in source and binary forms, with or without 65390SN/A * modification, are permitted provided that the following conditions are 75390SN/A * met: redistributions of source code must retain the above copyright 85390SN/A * notice, this list of conditions and the following disclaimer; 95390SN/A * redistributions in binary form must reproduce the above copyright 105390SN/A * notice, this list of conditions and the following disclaimer in the 115390SN/A * documentation and/or other materials provided with the distribution; 125390SN/A * neither the name of the copyright holders nor the names of its 135390SN/A * contributors may be used to endorse or promote products derived from 145390SN/A * this software without specific prior written permission. 155390SN/A * 165390SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 175390SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 185390SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 195390SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 205390SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 215390SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 225390SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 235390SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 245390SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 255390SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 265390SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 275390SN/A * 285390SN/A * Authors: Gabe Black 295390SN/A */ 305390SN/A 315636Sgblack@eecs.umich.edu#ifndef __DEV_X86_I8254_HH__ 325636Sgblack@eecs.umich.edu#define __DEV_X86_I8254_HH__ 335390SN/A 345443SN/A#include "dev/intel_8254_timer.hh" 3514290Sgabeblack@google.com#include "dev/intpin.hh" 365636Sgblack@eecs.umich.edu#include "dev/io_device.hh" 375636Sgblack@eecs.umich.edu#include "params/I8254.hh" 385443SN/A 395390SN/Anamespace X86ISA 405390SN/A{ 415390SN/A 425636Sgblack@eecs.umich.educlass I8254 : public BasicPioDevice 435390SN/A{ 445636Sgblack@eecs.umich.edu protected: 455636Sgblack@eecs.umich.edu Tick latency; 465642Sgblack@eecs.umich.edu class X86Intel8254Timer : public Intel8254Timer 475642Sgblack@eecs.umich.edu { 485642Sgblack@eecs.umich.edu protected: 495642Sgblack@eecs.umich.edu I8254 * parent; 505642Sgblack@eecs.umich.edu 515642Sgblack@eecs.umich.edu void 525642Sgblack@eecs.umich.edu counterInterrupt(unsigned int num) 535642Sgblack@eecs.umich.edu { 545642Sgblack@eecs.umich.edu parent->counterInterrupt(num); 555642Sgblack@eecs.umich.edu } 565642Sgblack@eecs.umich.edu 575642Sgblack@eecs.umich.edu public: 585642Sgblack@eecs.umich.edu X86Intel8254Timer(const std::string &name, I8254 * _parent) : 595642Sgblack@eecs.umich.edu Intel8254Timer(_parent, name), parent(_parent) 605642Sgblack@eecs.umich.edu {} 615642Sgblack@eecs.umich.edu }; 625642Sgblack@eecs.umich.edu 6311320Ssteve.reinhardt@amd.com 645642Sgblack@eecs.umich.edu X86Intel8254Timer pit; 655390SN/A 6614291Sgabeblack@google.com std::vector<IntSourcePin<I8254> *> intPin; 6711320Ssteve.reinhardt@amd.com 685642Sgblack@eecs.umich.edu void counterInterrupt(unsigned int num); 695390SN/A 705636Sgblack@eecs.umich.edu public: 715636Sgblack@eecs.umich.edu typedef I8254Params Params; 725636Sgblack@eecs.umich.edu 7314290Sgabeblack@google.com Port & 7414290Sgabeblack@google.com getPort(const std::string &if_name, PortID idx=InvalidPortID) override 7514290Sgabeblack@google.com { 7614290Sgabeblack@google.com if (if_name == "int_pin") 7714290Sgabeblack@google.com return *intPin.at(idx); 7814290Sgabeblack@google.com else 7914290Sgabeblack@google.com return BasicPioDevice::getPort(if_name, idx); 8014290Sgabeblack@google.com } 8114290Sgabeblack@google.com 825636Sgblack@eecs.umich.edu const Params * 835636Sgblack@eecs.umich.edu params() const 845636Sgblack@eecs.umich.edu { 855636Sgblack@eecs.umich.edu return dynamic_cast<const Params *>(_params); 865636Sgblack@eecs.umich.edu } 875636Sgblack@eecs.umich.edu 889808Sstever@gmail.com I8254(Params *p) : BasicPioDevice(p, 4), latency(p->pio_latency), 8914290Sgabeblack@google.com pit(p->name, this) 905636Sgblack@eecs.umich.edu { 9114290Sgabeblack@google.com for (int i = 0; i < p->port_int_pin_connection_count; i++) { 9214291Sgabeblack@google.com intPin.push_back(new IntSourcePin<I8254>(csprintf( 9314290Sgabeblack@google.com "%s.int_pin[%d]", name(), i), i, this)); 9414290Sgabeblack@google.com } 955636Sgblack@eecs.umich.edu } 9611175Sandreas.hansson@arm.com Tick read(PacketPtr pkt) override; 975390SN/A 9811175Sandreas.hansson@arm.com Tick write(PacketPtr pkt) override; 995636Sgblack@eecs.umich.edu 1005636Sgblack@eecs.umich.edu bool 1015636Sgblack@eecs.umich.edu outputHigh(unsigned int num) 1025636Sgblack@eecs.umich.edu { 1035636Sgblack@eecs.umich.edu return pit.outputHigh(num); 1045636Sgblack@eecs.umich.edu } 1055636Sgblack@eecs.umich.edu 1065636Sgblack@eecs.umich.edu uint8_t 1075636Sgblack@eecs.umich.edu readCounter(unsigned int num) 1085636Sgblack@eecs.umich.edu { 1095636Sgblack@eecs.umich.edu return pit.readCounter(num); 1105636Sgblack@eecs.umich.edu } 1115636Sgblack@eecs.umich.edu 1125636Sgblack@eecs.umich.edu void 1135636Sgblack@eecs.umich.edu writeCounter(unsigned int num, const uint8_t data) 1145636Sgblack@eecs.umich.edu { 1155636Sgblack@eecs.umich.edu pit.writeCounter(num, data); 1165636Sgblack@eecs.umich.edu } 1175636Sgblack@eecs.umich.edu 1185636Sgblack@eecs.umich.edu void 1195636Sgblack@eecs.umich.edu writeControl(uint8_t val) 1205636Sgblack@eecs.umich.edu { 1215636Sgblack@eecs.umich.edu pit.writeControl(val); 1225636Sgblack@eecs.umich.edu } 1237903Shestness@cs.utexas.edu 12411168Sandreas.hansson@arm.com void serialize(CheckpointOut &cp) const override; 12511168Sandreas.hansson@arm.com void unserialize(CheckpointIn &cp) override; 12610905Sandreas.sandberg@arm.com 12711175Sandreas.hansson@arm.com void startup() override; 1287903Shestness@cs.utexas.edu 1295390SN/A}; 1305390SN/A 1317811Ssteve.reinhardt@amd.com} // namespace X86ISA 1325390SN/A 1335390SN/A#endif //__DEV_X86_SOUTH_BRIDGE_I8254_HH__ 134