gem5  v20.1.0.0
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 
29 #ifndef __DEV_X86_CMOS_HH__
30 #define __DEV_X86_CMOS_HH__
31 
32 #include "dev/intpin.hh"
33 #include "dev/io_device.hh"
34 #include "dev/mc146818.hh"
35 #include "params/Cmos.hh"
36 
37 namespace X86ISA
38 {
39 
40 class Cmos : public BasicPioDevice
41 {
42  protected:
44 
45  uint8_t address;
46 
47  static const int numRegs = 128;
48 
49  uint8_t regs[numRegs];
50 
51  uint8_t readRegister(uint8_t reg);
52  void writeRegister(uint8_t reg, uint8_t val);
53 
54  class X86RTC : public MC146818
55  {
56  public:
58 
59  X86RTC(EventManager *em, const std::string &n, const struct tm time,
60  bool bcd, Tick frequency, int int_pin_count) :
61  MC146818(em, n, time, bcd, frequency)
62  {
63  for (int i = 0; i < int_pin_count; i++) {
64  intPin.push_back(new IntSourcePin<X86RTC>(
65  csprintf("%s.int_pin[%d]", n, i), i, this));
66  }
67  }
68  protected:
69  void handleEvent();
70  } rtc;
71 
72  public:
73  typedef CmosParams Params;
74 
75  Cmos(const Params *p) : BasicPioDevice(p, 2), latency(p->pio_latency),
76  rtc(this, name() + ".rtc", p->time, true, ULL(5000000000),
77  p->port_int_pin_connection_count)
78  {
79  memset(regs, 0, numRegs * sizeof(uint8_t));
80  address = 0;
81  }
82 
83  Port &
84  getPort(const std::string &if_name, PortID idx=InvalidPortID) override
85  {
86  if (if_name == "int_pin")
87  return *rtc.intPin.at(idx);
88  else
89  return BasicPioDevice::getPort(if_name, idx);
90  }
91 
92  Tick read(PacketPtr pkt) override;
93 
94  Tick write(PacketPtr pkt) override;
95 
96  void startup() override;
97 
98  void serialize(CheckpointOut &cp) const override;
99  void unserialize(CheckpointIn &cp) override;
100 };
101 
102 } // namespace X86ISA
103 
104 #endif //__DEV_X86_CMOS_HH__
X86ISA::Cmos::numRegs
static const int numRegs
Definition: cmos.hh:47
io_device.hh
InvalidPortID
const PortID InvalidPortID
Definition: types.hh:238
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
X86ISA::Cmos::readRegister
uint8_t readRegister(uint8_t reg)
Definition: cmos.cc:85
X86ISA::Cmos::X86RTC::handleEvent
void handleEvent()
Definition: cmos.cc:37
IntSourcePin
Definition: intpin.hh:109
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
X86ISA::Cmos::Params
CmosParams Params
Definition: cmos.hh:73
X86ISA::Cmos::writeRegister
void writeRegister(uint8_t reg, uint8_t val)
Definition: cmos.cc:102
PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
X86ISA::Cmos::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: cmos.cc:133
std::vector
STL vector class.
Definition: stl.hh:37
X86ISA::reg
Bitfield< 5, 3 > reg
Definition: types.hh:87
X86ISA::Cmos::Cmos
Cmos(const Params *p)
Definition: cmos.hh:75
ArmISA::n
Bitfield< 31 > n
Definition: miscregs_types.hh:450
cp
Definition: cprintf.cc:40
X86ISA::Cmos::latency
Tick latency
Definition: cmos.hh:43
PioDevice::getPort
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: io_device.cc:64
X86ISA::Cmos::read
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: cmos.cc:47
Port
Ports are used to interface objects to each other.
Definition: port.hh:56
X86ISA::Cmos::startup
void startup() override
startup() is the final initialization call before simulation.
Definition: cmos.cc:117
PioDevice::Params
PioDeviceParams Params
Definition: io_device.hh:131
X86ISA::Cmos::X86RTC
Definition: cmos.hh:54
X86ISA::em
Bitfield< 2 > em
Definition: misc.hh:602
MC146818
Real-Time Clock (MC146818)
Definition: mc146818.hh:38
X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:769
X86ISA
This is exposed globally, independent of the ISA.
Definition: acpi.hh:55
Clocked::frequency
uint64_t frequency() const
Definition: clocked_object.hh:212
X86ISA::Cmos::write
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: cmos.cc:66
SimObject::name
virtual const std::string name() const
Definition: sim_object.hh:133
X86ISA::Cmos::address
uint8_t address
Definition: cmos.hh:45
X86ISA::Cmos
Definition: cmos.hh:40
X86ISA::Cmos::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: cmos.cc:123
X86ISA::p
Bitfield< 0 > p
Definition: pagetable.hh:151
X86ISA::Cmos::regs
uint8_t regs[numRegs]
Definition: cmos.hh:49
X86ISA::Cmos::X86RTC::X86RTC
X86RTC(EventManager *em, const std::string &n, const struct tm time, bool bcd, Tick frequency, int int_pin_count)
Definition: cmos.hh:59
X86ISA::Cmos::rtc
X86ISA::Cmos::X86RTC rtc
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
BasicPioDevice
Definition: io_device.hh:150
X86ISA::Cmos::getPort
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: cmos.hh:84
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
EventManager
Definition: eventq.hh:973
intpin.hh
CheckpointIn
Definition: serialize.hh:67
X86ISA::Cmos::X86RTC::intPin
std::vector< IntSourcePin< X86RTC > * > intPin
Definition: cmos.hh:57
csprintf
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:158
ULL
#define ULL(N)
uint64_t constant
Definition: types.hh:50
mc146818.hh

Generated on Wed Sep 30 2020 14:02:11 for gem5 by doxygen 1.8.17