gem5  v21.1.0.2
i8254.cc
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 #include "dev/x86/i8254.hh"
30 
31 #include "debug/I8254.hh"
32 #include "dev/x86/intdev.hh"
33 #include "mem/packet.hh"
34 #include "mem/packet_access.hh"
35 
36 namespace gem5
37 {
38 
39 void
41 {
42  DPRINTF(I8254, "Interrupt from counter %d.\n", num);
43  if (num == 0) {
44  for (auto *wire: intPin) {
45  wire->raise();
46  //XXX This is a hack.
47  wire->lower();
48  }
49  }
50 }
51 
52 Tick
54 {
55  assert(pkt->getSize() == 1);
56  Addr offset = pkt->getAddr() - pioAddr;
57  if (offset < 3) {
58  pkt->setLE(pit.readCounter(offset));
59  } else if (offset == 3) {
60  pkt->setLE(uint8_t(-1));
61  } else {
62  panic("Read from undefined i8254 register.\n");
63  }
64  pkt->makeAtomicResponse();
65  return latency;
66 }
67 
68 Tick
70 {
71  assert(pkt->getSize() == 1);
72  Addr offset = pkt->getAddr() - pioAddr;
73  if (offset < 3) {
74  pit.writeCounter(offset, pkt->getLE<uint8_t>());
75  } else if (offset == 3) {
76  pit.writeControl(pkt->getLE<uint8_t>());
77  } else {
78  panic("Write to undefined i8254 register.\n");
79  }
80  pkt->makeAtomicResponse();
81  return latency;
82 }
83 
84 void
86 {
87  pit.serialize("pit", cp);
88 }
89 
90 void
92 {
93  pit.unserialize("pit", cp);
94 }
95 
96 void
98 {
99  pit.startup();
100 }
101 
102 } // namespace gem5
gem5::X86ISA::I8254::intPin
std::vector< IntSourcePin< I8254 > * > intPin
Definition: i8254.hh:67
gem5::X86ISA::I8254::counterInterrupt
void counterInterrupt(unsigned int num)
Definition: i8254.cc:40
gem5::X86ISA::I8254::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: i8254.cc:85
gem5::X86ISA::I8254::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: i8254.cc:91
gem5::X86ISA::I8254::startup
void startup() override
startup() is the final initialization call before simulation.
Definition: i8254.cc:97
gem5::CheckpointIn
Definition: serialize.hh:68
gem5::X86ISA::offset
offset
Definition: misc.hh:1030
gem5::X86ISA::I8254::write
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: i8254.cc:69
gem5::Packet::makeAtomicResponse
void makeAtomicResponse()
Definition: packet.hh:1043
gem5::X86ISA::I8254::read
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: i8254.cc:53
packet.hh
intdev.hh
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:186
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:283
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
packet_access.hh
gem5::Packet::getLE
T getLE() const
Get the data in the packet byte swapped from little endian to host endian.
Definition: packet_access.hh:78
gem5::CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:66
gem5::Packet::setLE
void setLE(T v)
Set the value in the data pointer to v as little endian.
Definition: packet_access.hh:108
gem5::Packet::getAddr
Addr getAddr() const
Definition: packet.hh:781
gem5::X86ISA::I8254
Definition: i8254.hh:43
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
i8254.hh
gem5::Packet::getSize
unsigned getSize() const
Definition: packet.hh:791
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:177

Generated on Tue Sep 21 2021 12:25:23 for gem5 by doxygen 1.8.17