gem5 v24.0.0.0
Loading...
Searching...
No Matches
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 "base/bitunion.hh"
33#include "dev/intpin.hh"
34#include "dev/io_device.hh"
35#include "dev/mc146818.hh"
36#include "params/Cmos.hh"
37
38namespace gem5
39{
40
41namespace X86ISA
42{
43
44class Cmos : public BasicPioDevice
45{
46 protected:
48
49 BitUnion8(CmosAddress)
50 Bitfield<6, 0> regNum;
51 Bitfield<7> nmiMask;
52 EndBitUnion(CmosAddress)
53
54 CmosAddress address;
55
56 static const int numRegs = 128;
57
58 uint8_t regs[numRegs];
59
60 uint8_t readRegister(uint8_t reg);
61 void writeRegister(uint8_t reg, uint8_t val);
62
63 class X86RTC : public MC146818
64 {
65 public:
67
68 X86RTC(EventManager *em, const std::string &n, const struct tm time,
69 bool bcd, Tick frequency, int int_pin_count) :
70 MC146818(em, n, time, bcd, frequency)
71 {
72 for (int i = 0; i < int_pin_count; i++) {
73 intPin.push_back(new IntSourcePin<X86RTC>(
74 csprintf("%s.int_pin[%d]", n, i), i, this));
75 }
76 }
77 protected:
78 void handleEvent();
79 } rtc;
80
81 public:
82 typedef CmosParams Params;
83
84 Cmos(const Params &p) : BasicPioDevice(p, 2), latency(p.pio_latency),
85 rtc(this, name() + ".rtc", p.time, true, 5000000000ULL,
86 p.port_int_pin_connection_count)
87 {
88 memset(regs, 0, numRegs * sizeof(uint8_t));
89 address = 0;
90 }
91
92 Port &
93 getPort(const std::string &if_name, PortID idx=InvalidPortID) override
94 {
95 if (if_name == "int_pin")
96 return *rtc.intPin.at(idx);
97 else
98 return BasicPioDevice::getPort(if_name, idx);
99 }
100
101 Tick read(PacketPtr pkt) override;
102
103 Tick write(PacketPtr pkt) override;
104
105 void startup() override;
106
107 void serialize(CheckpointOut &cp) const override;
108 void unserialize(CheckpointIn &cp) override;
109};
110
111} // namespace X86ISA
112} // namespace gem5
113
114#endif //__DEV_X86_CMOS_HH__
uint64_t frequency() const
Real-Time Clock (MC146818)
Definition mc146818.hh:42
virtual std::string name() const
Definition named.hh:47
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition io_device.cc:67
Ports are used to interface objects to each other.
Definition port.hh:62
X86RTC(EventManager *em, const std::string &n, const struct tm time, bool bcd, Tick frequency, int int_pin_count)
Definition cmos.hh:68
std::vector< IntSourcePin< X86RTC > * > intPin
Definition cmos.hh:66
Bitfield< 7 > nmiMask
Definition cmos.hh:51
Cmos(const Params &p)
Definition cmos.hh:84
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition cmos.hh:93
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition cmos.cc:69
void startup() override
startup() is the final initialization call before simulation.
Definition cmos.cc:121
gem5::X86ISA::Cmos::X86RTC rtc
static const int numRegs
Definition cmos.hh:56
uint8_t regs[numRegs]
Definition cmos.hh:58
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition cmos.cc:137
BitUnion8(CmosAddress) Bitfield< 6
CmosParams Params
Definition cmos.hh:82
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition cmos.cc:50
void writeRegister(uint8_t reg, uint8_t val)
Definition cmos.cc:106
uint8_t readRegister(uint8_t reg)
Definition cmos.cc:89
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition cmos.cc:127
STL vector class.
Definition stl.hh:37
#define EndBitUnion(name)
This closes off the class and union started by the above macro.
Definition bitunion.hh:428
Bitfield< 31 > n
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 32 > tm
Definition misc.hh:112
Bitfield< 5, 3 > reg
Definition types.hh:92
Bitfield< 63 > val
Definition misc.hh:804
Bitfield< 2 > em
Definition misc.hh:617
Bitfield< 0 > p
Definition pagetable.hh:151
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
const PortID InvalidPortID
Definition types.hh:246
std::ostream CheckpointOut
Definition serialize.hh:66
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition types.hh:245
uint64_t Tick
Tick count type.
Definition types.hh:58
std::string csprintf(const char *format, const Args &...args)
Definition cprintf.hh:161

Generated on Tue Jun 18 2024 16:24:04 for gem5 by doxygen 1.11.0