cmos.hh revision 5629
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
415629Sgblack@eecs.umich.educlass Cmos : public BasicPioDevice
425390SN/A{
435390SN/A  protected:
445629Sgblack@eecs.umich.edu    Tick latency;
455629Sgblack@eecs.umich.edu
465390SN/A    uint8_t address;
475390SN/A
485390SN/A    static const int numRegs = 128;
495390SN/A
505390SN/A    uint8_t regs[numRegs];
515390SN/A
525390SN/A    uint8_t readRegister(uint8_t reg);
535390SN/A    void writeRegister(uint8_t reg, uint8_t val);
545390SN/A
555393SN/A    class X86RTC : public MC146818
565393SN/A    {
575393SN/A      public:
585611SN/A        X86RTC(EventManager *em, const std::string &n, const struct tm time,
595611SN/A                bool bcd, Tick frequency) :
605611SN/A            MC146818(em, n, time, bcd, frequency)
615393SN/A        {
625393SN/A        }
635393SN/A      protected:
645393SN/A        void handleEvent()
655393SN/A        {
665393SN/A            return;
675393SN/A        }
685393SN/A    } rtc;
695393SN/A
705390SN/A  public:
715629Sgblack@eecs.umich.edu    typedef CmosParams Params;
725390SN/A
735629Sgblack@eecs.umich.edu    Cmos(const Params *p) : BasicPioDevice(p), latency(p->pio_latency),
745629Sgblack@eecs.umich.edu        rtc(this, "rtc", p->time, true, ULL(5000000000))
755390SN/A    {
765629Sgblack@eecs.umich.edu        pioSize = 2;
775390SN/A        memset(regs, 0, numRegs * sizeof(uint8_t));
785390SN/A        address = 0;
795390SN/A    }
805390SN/A
815390SN/A    Tick read(PacketPtr pkt);
825390SN/A
835390SN/A    Tick write(PacketPtr pkt);
845390SN/A};
855390SN/A
865390SN/A}; // namespace X86ISA
875390SN/A
885629Sgblack@eecs.umich.edu#endif //__DEV_X86_CMOS_HH__
89