cmos.hh revision 9808
12379SN/A/* 22379SN/A * Copyright (c) 2008 The Regents of The University of Michigan 32379SN/A * All rights reserved. 42379SN/A * 52379SN/A * Redistribution and use in source and binary forms, with or without 62379SN/A * modification, are permitted provided that the following conditions are 72379SN/A * met: redistributions of source code must retain the above copyright 82379SN/A * notice, this list of conditions and the following disclaimer; 92379SN/A * redistributions in binary form must reproduce the above copyright 102379SN/A * notice, this list of conditions and the following disclaimer in the 112379SN/A * documentation and/or other materials provided with the distribution; 122379SN/A * neither the name of the copyright holders nor the names of its 132379SN/A * contributors may be used to endorse or promote products derived from 142379SN/A * this software without specific prior written permission. 152379SN/A * 162379SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172379SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182379SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192379SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202379SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212379SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222379SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232379SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242379SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252379SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262379SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu * 282665Ssaidi@eecs.umich.edu * Authors: Gabe Black 292379SN/A */ 302379SN/A 312379SN/A#ifndef __DEV_X86_CMOS_HH__ 322379SN/A#define __DEV_X86_CMOS_HH__ 332379SN/A 342379SN/A#include "dev/io_device.hh" 352379SN/A#include "dev/mc146818.hh" 362379SN/A#include "params/Cmos.hh" 372379SN/A 382379SN/Anamespace X86ISA 392379SN/A{ 402379SN/A 412980Sgblack@eecs.umich.educlass IntSourcePin; 422423SN/A 432809Ssaidi@eecs.umich.educlass Cmos : public BasicPioDevice 442379SN/A{ 452394SN/A protected: 462394SN/A Tick latency; 472379SN/A 482379SN/A uint8_t address; 492399SN/A 502379SN/A static const int numRegs = 128; 512379SN/A 522982Sstever@eecs.umich.edu uint8_t regs[numRegs]; 532379SN/A 542399SN/A uint8_t readRegister(uint8_t reg); 552379SN/A void writeRegister(uint8_t reg, uint8_t val); 562379SN/A 572809Ssaidi@eecs.umich.edu class X86RTC : public MC146818 582809Ssaidi@eecs.umich.edu { 592809Ssaidi@eecs.umich.edu protected: 602809Ssaidi@eecs.umich.edu IntSourcePin * intPin; 612809Ssaidi@eecs.umich.edu public: 622809Ssaidi@eecs.umich.edu X86RTC(EventManager *em, const std::string &n, const struct tm time, 632809Ssaidi@eecs.umich.edu bool bcd, Tick frequency, IntSourcePin * _intPin) : 642809Ssaidi@eecs.umich.edu MC146818(em, n, time, bcd, frequency), intPin(_intPin) 652379SN/A { 662399SN/A } 672399SN/A protected: 682399SN/A void handleEvent(); 692399SN/A } rtc; 702379SN/A 712379SN/A public: 722379SN/A typedef CmosParams Params; 732423SN/A 742379SN/A Cmos(const Params *p) : BasicPioDevice(p, 2), latency(p->pio_latency), 752379SN/A rtc(this, "rtc", p->time, true, ULL(5000000000), p->int_pin) 762379SN/A { 772399SN/A memset(regs, 0, numRegs * sizeof(uint8_t)); 782399SN/A address = 0; 792379SN/A } 802979Sgblack@eecs.umich.edu 812379SN/A Tick read(PacketPtr pkt); 822979Sgblack@eecs.umich.edu 832399SN/A Tick write(PacketPtr pkt); 842379SN/A 852379SN/A virtual void serialize(std::ostream &os); 862379SN/A virtual void unserialize(Checkpoint *cp, const std::string §ion); 872379SN/A 882379SN/A}; 892399SN/A 902379SN/A} // namespace X86ISA 912379SN/A 922399SN/A#endif //__DEV_X86_CMOS_HH__ 932399SN/A