gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cmos.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 The Regents of The University of Michigan
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * Authors: Gabe Black
29  */
30 
31 #ifndef __DEV_X86_CMOS_HH__
32 #define __DEV_X86_CMOS_HH__
33 
34 #include "dev/io_device.hh"
35 #include "dev/mc146818.hh"
36 #include "params/Cmos.hh"
37 
38 namespace X86ISA
39 {
40 
41 class IntSourcePin;
42 
43 class Cmos : public BasicPioDevice
44 {
45  protected:
47 
48  uint8_t address;
49 
50  static const int numRegs = 128;
51 
52  uint8_t regs[numRegs];
53 
54  uint8_t readRegister(uint8_t reg);
55  void writeRegister(uint8_t reg, uint8_t val);
56 
57  class X86RTC : public MC146818
58  {
59  protected:
61  public:
62  X86RTC(EventManager *em, const std::string &n, const struct tm time,
63  bool bcd, Tick frequency, IntSourcePin * _intPin) :
64  MC146818(em, n, time, bcd, frequency), intPin(_intPin)
65  {
66  }
67  protected:
68  void handleEvent();
69  } rtc;
70 
71  public:
72  typedef CmosParams Params;
73 
74  Cmos(const Params *p) : BasicPioDevice(p, 2), latency(p->pio_latency),
75  rtc(this, "rtc", p->time, true, ULL(5000000000), p->int_pin)
76  {
77  memset(regs, 0, numRegs * sizeof(uint8_t));
78  address = 0;
79  }
80 
81  Tick read(PacketPtr pkt) override;
82 
83  Tick write(PacketPtr pkt) override;
84 
85  void startup() override;
86 
87  void serialize(CheckpointOut &cp) const override;
88  void unserialize(CheckpointIn &cp) override;
89 };
90 
91 } // namespace X86ISA
92 
93 #endif //__DEV_X86_CMOS_HH__
void writeRegister(uint8_t reg, uint8_t val)
Definition: cmos.cc:102
Bitfield< 5, 3 > reg
Definition: types.hh:89
static const int numRegs
Definition: cmos.hh:50
uint8_t readRegister(uint8_t reg)
Definition: cmos.cc:85
Real-Time Clock (MC146818)
Definition: mc146818.hh:41
Bitfield< 2 > em
Definition: misc.hh:603
PioDeviceParams Params
Definition: io_device.hh:116
uint64_t frequency() const
Tick latency
Definition: cmos.hh:46
Cmos(const Params *p)
Definition: cmos.hh:74
IntSourcePin * intPin
Definition: cmos.hh:60
X86ISA::Cmos::X86RTC rtc
Bitfield< 63 > val
Definition: misc.hh:770
Bitfield< 31 > n
Definition: miscregs.hh:1636
void handleEvent()
Definition: cmos.cc:38
uint64_t Tick
Tick count type.
Definition: types.hh:63
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: cmos.cc:47
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: cmos.cc:133
void startup() override
startup() is the final initialization call before simulation.
Definition: cmos.cc:117
#define ULL(N)
uint64_t constant
Definition: types.hh:50
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: cmos.cc:66
std::ostream CheckpointOut
Definition: serialize.hh:67
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: cmos.cc:123
uint8_t address
Definition: cmos.hh:48
CmosParams Params
Definition: cmos.hh:72
Bitfield< 0 > p
Definition: pagetable.hh:95
X86RTC(EventManager *em, const std::string &n, const struct tm time, bool bcd, Tick frequency, IntSourcePin *_intPin)
Definition: cmos.hh:62
uint8_t regs[numRegs]
Definition: cmos.hh:52

Generated on Fri Jun 9 2017 13:03:47 for gem5 by doxygen 1.8.6