cmos.hh revision 7903
15390SN/A/* 25452SN/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 315629Sgblack@eecs.umich.edu#ifndef __DEV_X86_CMOS_HH__ 325629Sgblack@eecs.umich.edu#define __DEV_X86_CMOS_HH__ 335390SN/A 345629Sgblack@eecs.umich.edu#include "dev/io_device.hh" 355393SN/A#include "dev/mc146818.hh" 365629Sgblack@eecs.umich.edu#include "params/Cmos.hh" 375390SN/A 385390SN/Anamespace X86ISA 395390SN/A{ 405390SN/A 415827Sgblack@eecs.umich.educlass IntSourcePin; 425632Sgblack@eecs.umich.edu 435629Sgblack@eecs.umich.educlass Cmos : public BasicPioDevice 445390SN/A{ 455390SN/A protected: 465629Sgblack@eecs.umich.edu Tick latency; 475629Sgblack@eecs.umich.edu 485390SN/A uint8_t address; 495390SN/A 505390SN/A static const int numRegs = 128; 515390SN/A 525390SN/A uint8_t regs[numRegs]; 535390SN/A 545390SN/A uint8_t readRegister(uint8_t reg); 555390SN/A void writeRegister(uint8_t reg, uint8_t val); 565390SN/A 575393SN/A class X86RTC : public MC146818 585393SN/A { 595632Sgblack@eecs.umich.edu protected: 605827Sgblack@eecs.umich.edu IntSourcePin * intPin; 615393SN/A public: 625611SN/A X86RTC(EventManager *em, const std::string &n, const struct tm time, 635827Sgblack@eecs.umich.edu bool bcd, Tick frequency, IntSourcePin * _intPin) : 645634Sgblack@eecs.umich.edu MC146818(em, n, time, bcd, frequency), intPin(_intPin) 655393SN/A { 665393SN/A } 675393SN/A protected: 685632Sgblack@eecs.umich.edu void handleEvent(); 695393SN/A } rtc; 705393SN/A 715390SN/A public: 725629Sgblack@eecs.umich.edu typedef CmosParams Params; 735390SN/A 745629Sgblack@eecs.umich.edu Cmos(const Params *p) : BasicPioDevice(p), latency(p->pio_latency), 755634Sgblack@eecs.umich.edu rtc(this, "rtc", p->time, true, ULL(5000000000), p->int_pin) 765390SN/A { 775629Sgblack@eecs.umich.edu pioSize = 2; 785390SN/A memset(regs, 0, numRegs * sizeof(uint8_t)); 795390SN/A address = 0; 805390SN/A } 815390SN/A 825390SN/A Tick read(PacketPtr pkt); 835390SN/A 845390SN/A Tick write(PacketPtr pkt); 857903Shestness@cs.utexas.edu 867903Shestness@cs.utexas.edu virtual void serialize(std::ostream &os); 877903Shestness@cs.utexas.edu virtual void unserialize(Checkpoint *cp, const std::string §ion); 887903Shestness@cs.utexas.edu 895390SN/A}; 905390SN/A 917811Ssteve.reinhardt@amd.com} // namespace X86ISA 925390SN/A 935629Sgblack@eecs.umich.edu#endif //__DEV_X86_CMOS_HH__ 94