gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
i8254.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_I8254_HH__
32 #define __DEV_X86_I8254_HH__
33 
34 #include "dev/intel_8254_timer.hh"
35 #include "dev/intpin.hh"
36 #include "dev/io_device.hh"
37 #include "params/I8254.hh"
38 
39 namespace X86ISA
40 {
41 
42 class I8254 : public BasicPioDevice
43 {
44  protected:
47  {
48  protected:
50 
51  void
52  counterInterrupt(unsigned int num)
53  {
54  parent->counterInterrupt(num);
55  }
56 
57  public:
58  X86Intel8254Timer(const std::string &name, I8254 * _parent) :
59  Intel8254Timer(_parent, name), parent(_parent)
60  {}
61  };
62 
63 
65 
67 
68  void counterInterrupt(unsigned int num);
69 
70  public:
71  typedef I8254Params Params;
72 
73  Port &
74  getPort(const std::string &if_name, PortID idx=InvalidPortID) override
75  {
76  if (if_name == "int_pin")
77  return *intPin.at(idx);
78  else
79  return BasicPioDevice::getPort(if_name, idx);
80  }
81 
82  const Params *
83  params() const
84  {
85  return dynamic_cast<const Params *>(_params);
86  }
87 
88  I8254(Params *p) : BasicPioDevice(p, 4), latency(p->pio_latency),
89  pit(p->name, this)
90  {
91  for (int i = 0; i < p->port_int_pin_connection_count; i++) {
92  intPin.push_back(new IntSourcePin<I8254>(csprintf(
93  "%s.int_pin[%d]", name(), i), i, this));
94  }
95  }
96  Tick read(PacketPtr pkt) override;
97 
98  Tick write(PacketPtr pkt) override;
99 
100  bool
101  outputHigh(unsigned int num)
102  {
103  return pit.outputHigh(num);
104  }
105 
106  uint8_t
107  readCounter(unsigned int num)
108  {
109  return pit.readCounter(num);
110  }
111 
112  void
113  writeCounter(unsigned int num, const uint8_t data)
114  {
115  pit.writeCounter(num, data);
116  }
117 
118  void
119  writeControl(uint8_t val)
120  {
121  pit.writeControl(val);
122  }
123 
124  void serialize(CheckpointOut &cp) const override;
125  void unserialize(CheckpointIn &cp) override;
126 
127  void startup() override;
128 
129 };
130 
131 } // namespace X86ISA
132 
133 #endif //__DEV_X86_SOUTH_BRIDGE_I8254_HH__
Ports are used to interface objects to each other.
Definition: port.hh:60
void writeControl(const CtrlReg data)
Write control word.
Bitfield< 7 > i
Tick latency
Definition: i8254.hh:45
const PortID InvalidPortID
Definition: types.hh:238
void counterInterrupt(unsigned int num)
Definition: i8254.cc:39
Programmable Interval Timer (Intel 8254)
void counterInterrupt(unsigned int num)
Definition: i8254.hh:52
Definition: cprintf.cc:42
uint8_t readCounter(unsigned int num)
X86Intel8254Timer pit
Definition: i8254.hh:64
void writeCounter(unsigned int num, const uint8_t data)
void startup()
Start ticking.
STL vector class.
Definition: stl.hh:40
Bitfield< 63 > val
Definition: misc.hh:771
bool outputHigh(unsigned int num)
void writeCounter(unsigned int num, const uint8_t data)
Definition: i8254.hh:113
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:162
void writeControl(uint8_t val)
Definition: i8254.hh:119
uint64_t Tick
Tick count type.
Definition: types.hh:63
const std::string & name() const
bool outputHigh(unsigned int num)
Definition: i8254.hh:101
X86Intel8254Timer(const std::string &name, I8254 *_parent)
Definition: i8254.hh:58
uint8_t readCounter(unsigned int num)
Definition: i8254.hh:107
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
I8254(Params *p)
Definition: i8254.hh:88
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: i8254.hh:74
I8254Params Params
Definition: i8254.hh:71
const Params * params() const
Definition: i8254.hh:83
std::ostream CheckpointOut
Definition: serialize.hh:68
This is exposed globally, independent of the ISA.
Definition: acpi.hh:57
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:110
std::vector< IntSourcePin< I8254 > * > intPin
Definition: i8254.hh:66
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
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: i8254.cc:68
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
Bitfield< 0 > p
Definition: pagetable.hh:152
const char data[]
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: i8254.cc:52
void serialize(const std::string &base, CheckpointOut &cp) const
Serialize this object to the given output stream.
void unserialize(const std::string &base, CheckpointIn &cp)
Reconstruct the state of this object from a checkpoint.

Generated on Fri Feb 28 2020 16:27:01 for gem5 by doxygen 1.8.13