i8254.hh revision 7811
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" 355636Sgblack@eecs.umich.edu#include "dev/io_device.hh" 365636Sgblack@eecs.umich.edu#include "params/I8254.hh" 375443SN/A 385390SN/Anamespace X86ISA 395390SN/A{ 405390SN/A 415827Sgblack@eecs.umich.educlass IntSourcePin; 425636Sgblack@eecs.umich.edu 435636Sgblack@eecs.umich.educlass I8254 : public BasicPioDevice 445390SN/A{ 455636Sgblack@eecs.umich.edu protected: 465636Sgblack@eecs.umich.edu Tick latency; 475642Sgblack@eecs.umich.edu class X86Intel8254Timer : public Intel8254Timer 485642Sgblack@eecs.umich.edu { 495642Sgblack@eecs.umich.edu protected: 505642Sgblack@eecs.umich.edu I8254 * parent; 515642Sgblack@eecs.umich.edu 525642Sgblack@eecs.umich.edu void 535642Sgblack@eecs.umich.edu counterInterrupt(unsigned int num) 545642Sgblack@eecs.umich.edu { 555642Sgblack@eecs.umich.edu parent->counterInterrupt(num); 565642Sgblack@eecs.umich.edu } 575642Sgblack@eecs.umich.edu 585642Sgblack@eecs.umich.edu public: 595642Sgblack@eecs.umich.edu X86Intel8254Timer(const std::string &name, I8254 * _parent) : 605642Sgblack@eecs.umich.edu Intel8254Timer(_parent, name), parent(_parent) 615642Sgblack@eecs.umich.edu {} 625642Sgblack@eecs.umich.edu }; 635642Sgblack@eecs.umich.edu 645642Sgblack@eecs.umich.edu 655642Sgblack@eecs.umich.edu X86Intel8254Timer pit; 665390SN/A 675827Sgblack@eecs.umich.edu IntSourcePin *intPin; 685642Sgblack@eecs.umich.edu 695642Sgblack@eecs.umich.edu void counterInterrupt(unsigned int num); 705390SN/A 715636Sgblack@eecs.umich.edu public: 725636Sgblack@eecs.umich.edu typedef I8254Params Params; 735636Sgblack@eecs.umich.edu 745636Sgblack@eecs.umich.edu const Params * 755636Sgblack@eecs.umich.edu params() const 765636Sgblack@eecs.umich.edu { 775636Sgblack@eecs.umich.edu return dynamic_cast<const Params *>(_params); 785636Sgblack@eecs.umich.edu } 795636Sgblack@eecs.umich.edu 805636Sgblack@eecs.umich.edu I8254(Params *p) : BasicPioDevice(p), latency(p->pio_latency), 815642Sgblack@eecs.umich.edu pit(p->name, this), intPin(p->int_pin) 825636Sgblack@eecs.umich.edu { 835636Sgblack@eecs.umich.edu pioSize = 4; 845636Sgblack@eecs.umich.edu } 855390SN/A Tick read(PacketPtr pkt); 865390SN/A 875390SN/A Tick write(PacketPtr pkt); 885636Sgblack@eecs.umich.edu 895636Sgblack@eecs.umich.edu bool 905636Sgblack@eecs.umich.edu outputHigh(unsigned int num) 915636Sgblack@eecs.umich.edu { 925636Sgblack@eecs.umich.edu return pit.outputHigh(num); 935636Sgblack@eecs.umich.edu } 945636Sgblack@eecs.umich.edu 955636Sgblack@eecs.umich.edu uint8_t 965636Sgblack@eecs.umich.edu readCounter(unsigned int num) 975636Sgblack@eecs.umich.edu { 985636Sgblack@eecs.umich.edu return pit.readCounter(num); 995636Sgblack@eecs.umich.edu } 1005636Sgblack@eecs.umich.edu 1015636Sgblack@eecs.umich.edu void 1025636Sgblack@eecs.umich.edu writeCounter(unsigned int num, const uint8_t data) 1035636Sgblack@eecs.umich.edu { 1045636Sgblack@eecs.umich.edu pit.writeCounter(num, data); 1055636Sgblack@eecs.umich.edu } 1065636Sgblack@eecs.umich.edu 1075636Sgblack@eecs.umich.edu void 1085636Sgblack@eecs.umich.edu writeControl(uint8_t val) 1095636Sgblack@eecs.umich.edu { 1105636Sgblack@eecs.umich.edu pit.writeControl(val); 1115636Sgblack@eecs.umich.edu } 1125390SN/A}; 1135390SN/A 1147811Ssteve.reinhardt@amd.com} // namespace X86ISA 1155390SN/A 1165390SN/A#endif //__DEV_X86_SOUTH_BRIDGE_I8254_HH__ 117