gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
36namespace gem5
37{
38
39void
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
52Tick
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
68Tick
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
84void
86{
87 pit.serialize("pit", cp);
88}
89
90void
92{
93 pit.unserialize("pit", cp);
94}
95
96void
98{
99 pit.startup();
100}
101
102} // namespace gem5
#define DPRINTF(x,...)
Definition trace.hh:210
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
Addr getAddr() const
Definition packet.hh:807
void setLE(T v)
Set the value in the data pointer to v as little endian.
unsigned getSize() const
Definition packet.hh:817
void makeAtomicResponse()
Definition packet.hh:1074
T getLE() const
Get the data in the packet byte swapped from little endian to host endian.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition i8254.cc:91
std::vector< IntSourcePin< I8254 > * > intPin
Definition i8254.hh:67
void startup() override
startup() is the final initialization call before simulation.
Definition i8254.cc:97
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition i8254.cc:69
void counterInterrupt(unsigned int num)
Definition i8254.cc:40
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition i8254.cc:53
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition i8254.cc:85
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:188
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
std::ostream CheckpointOut
Definition serialize.hh:66
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
uint64_t Tick
Tick count type.
Definition types.hh:58
Declaration of the Packet class.

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