kmi.hh revision 7754
17754SWilliam.Wang@arm.com/* 27754SWilliam.Wang@arm.com * Copyright (c) 2010 ARM Limited 37754SWilliam.Wang@arm.com * All rights reserved 47754SWilliam.Wang@arm.com * 57754SWilliam.Wang@arm.com * The license below extends only to copyright in the software and shall 67754SWilliam.Wang@arm.com * not be construed as granting a license to any other intellectual 77754SWilliam.Wang@arm.com * property including but not limited to intellectual property relating 87754SWilliam.Wang@arm.com * to a hardware implementation of the functionality of the software 97754SWilliam.Wang@arm.com * licensed hereunder. You may use the software subject to the license 107754SWilliam.Wang@arm.com * terms below provided that you ensure that this notice is replicated 117754SWilliam.Wang@arm.com * unmodified and in its entirety in all distributions of the software, 127754SWilliam.Wang@arm.com * modified or unmodified, in source code or in binary form. 137754SWilliam.Wang@arm.com * 147754SWilliam.Wang@arm.com * Copyright (c) 2005 The Regents of The University of Michigan 157754SWilliam.Wang@arm.com * All rights reserved. 167754SWilliam.Wang@arm.com * 177754SWilliam.Wang@arm.com * Redistribution and use in source and binary forms, with or without 187754SWilliam.Wang@arm.com * modification, are permitted provided that the following conditions are 197754SWilliam.Wang@arm.com * met: redistributions of source code must retain the above copyright 207754SWilliam.Wang@arm.com * notice, this list of conditions and the following disclaimer; 217754SWilliam.Wang@arm.com * redistributions in binary form must reproduce the above copyright 227754SWilliam.Wang@arm.com * notice, this list of conditions and the following disclaimer in the 237754SWilliam.Wang@arm.com * documentation and/or other materials provided with the distribution; 247754SWilliam.Wang@arm.com * neither the name of the copyright holders nor the names of its 257754SWilliam.Wang@arm.com * contributors may be used to endorse or promote products derived from 267754SWilliam.Wang@arm.com * this software without specific prior written permission. 277754SWilliam.Wang@arm.com * 287754SWilliam.Wang@arm.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 297754SWilliam.Wang@arm.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 307754SWilliam.Wang@arm.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 317754SWilliam.Wang@arm.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 327754SWilliam.Wang@arm.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 337754SWilliam.Wang@arm.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 347754SWilliam.Wang@arm.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 357754SWilliam.Wang@arm.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 367754SWilliam.Wang@arm.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 377754SWilliam.Wang@arm.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 387754SWilliam.Wang@arm.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 397754SWilliam.Wang@arm.com * 407754SWilliam.Wang@arm.com * Authors: William Wang 417754SWilliam.Wang@arm.com */ 427754SWilliam.Wang@arm.com 437754SWilliam.Wang@arm.com 447754SWilliam.Wang@arm.com/** @file 457754SWilliam.Wang@arm.com * Implementiation of a PL050 KMI 467754SWilliam.Wang@arm.com */ 477754SWilliam.Wang@arm.com 487754SWilliam.Wang@arm.com#ifndef __DEV_ARM_PL050_HH__ 497754SWilliam.Wang@arm.com#define __DEV_ARM_PL050_HH__ 507754SWilliam.Wang@arm.com 517754SWilliam.Wang@arm.com#include "base/range.hh" 527754SWilliam.Wang@arm.com#include "dev/io_device.hh" 537754SWilliam.Wang@arm.com#include "params/Pl050.hh" 547754SWilliam.Wang@arm.com 557754SWilliam.Wang@arm.comclass Gic; 567754SWilliam.Wang@arm.com 577754SWilliam.Wang@arm.comclass Pl050 : public AmbaDevice 587754SWilliam.Wang@arm.com{ 597754SWilliam.Wang@arm.com protected: 607754SWilliam.Wang@arm.com static const int kmiCr = 0x000; 617754SWilliam.Wang@arm.com static const int kmiStat = 0x004; 627754SWilliam.Wang@arm.com static const int kmiData = 0x008; 637754SWilliam.Wang@arm.com static const int kmiClkDiv = 0x00C; 647754SWilliam.Wang@arm.com static const int kmiISR = 0x010; 657754SWilliam.Wang@arm.com 667754SWilliam.Wang@arm.com // control register 677754SWilliam.Wang@arm.com uint8_t control; 687754SWilliam.Wang@arm.com 697754SWilliam.Wang@arm.com // status register 707754SWilliam.Wang@arm.com uint8_t status; 717754SWilliam.Wang@arm.com 727754SWilliam.Wang@arm.com // received data (read) or data to be transmitted (write) 737754SWilliam.Wang@arm.com uint8_t kmidata; 747754SWilliam.Wang@arm.com 757754SWilliam.Wang@arm.com // clock divisor register 767754SWilliam.Wang@arm.com uint8_t clkdiv; 777754SWilliam.Wang@arm.com 787754SWilliam.Wang@arm.com BitUnion8(IntReg) 797754SWilliam.Wang@arm.com Bitfield<0> txintr; 807754SWilliam.Wang@arm.com Bitfield<1> rxintr; 817754SWilliam.Wang@arm.com EndBitUnion(IntReg) 827754SWilliam.Wang@arm.com 837754SWilliam.Wang@arm.com /** interrupt mask register. */ 847754SWilliam.Wang@arm.com IntReg intreg; 857754SWilliam.Wang@arm.com 867754SWilliam.Wang@arm.com /** Interrupt number to generate */ 877754SWilliam.Wang@arm.com int intNum; 887754SWilliam.Wang@arm.com 897754SWilliam.Wang@arm.com /** Gic to use for interrupting */ 907754SWilliam.Wang@arm.com Gic *gic; 917754SWilliam.Wang@arm.com 927754SWilliam.Wang@arm.com /** Delay before interrupting */ 937754SWilliam.Wang@arm.com Tick intDelay; 947754SWilliam.Wang@arm.com 957754SWilliam.Wang@arm.com /** Function to generate interrupt */ 967754SWilliam.Wang@arm.com void generateInterrupt(); 977754SWilliam.Wang@arm.com 987754SWilliam.Wang@arm.com /** Wrapper to create an event out of the thing */ 997754SWilliam.Wang@arm.com EventWrapper<Pl050, &Pl050::generateInterrupt> intEvent; 1007754SWilliam.Wang@arm.com 1017754SWilliam.Wang@arm.com public: 1027754SWilliam.Wang@arm.com typedef Pl050Params Params; 1037754SWilliam.Wang@arm.com const Params * 1047754SWilliam.Wang@arm.com params() const 1057754SWilliam.Wang@arm.com { 1067754SWilliam.Wang@arm.com return dynamic_cast<const Params *>(_params); 1077754SWilliam.Wang@arm.com } 1087754SWilliam.Wang@arm.com 1097754SWilliam.Wang@arm.com Pl050(const Params *p); 1107754SWilliam.Wang@arm.com 1117754SWilliam.Wang@arm.com virtual Tick read(PacketPtr pkt); 1127754SWilliam.Wang@arm.com virtual Tick write(PacketPtr pkt); 1137754SWilliam.Wang@arm.com 1147754SWilliam.Wang@arm.com /** 1157754SWilliam.Wang@arm.com * Return if we have an interrupt pending 1167754SWilliam.Wang@arm.com * @return interrupt status 1177754SWilliam.Wang@arm.com * @todo fix me when implementation improves 1187754SWilliam.Wang@arm.com */ 1197754SWilliam.Wang@arm.com virtual bool intStatus() { return false; } 1207754SWilliam.Wang@arm.com}; 1217754SWilliam.Wang@arm.com 1227754SWilliam.Wang@arm.com#endif 123