gem5  v22.0.0.1
speaker.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/speaker.hh"
30 
31 #include "base/bitunion.hh"
32 #include "base/trace.hh"
33 #include "debug/PcSpeaker.hh"
34 #include "dev/x86/i8254.hh"
35 #include "mem/packet.hh"
36 #include "mem/packet_access.hh"
37 
38 namespace gem5
39 {
40 
41 Tick
43 {
44  assert(pkt->getAddr() == pioAddr);
45  assert(pkt->getSize() == 1);
46  controlVal.timer = timer->outputHigh(2) ? 1 : 0;
47  DPRINTF(PcSpeaker,
48  "Reading from speaker device: gate %s, speaker %s, output %s.\n",
49  controlVal.gate ? "on" : "off",
50  controlVal.speaker ? "on" : "off",
51  controlVal.timer ? "on" : "off");
52  pkt->setLE((uint8_t)controlVal);
53  pkt->makeAtomicResponse();
54  return latency;
55 }
56 
57 Tick
59 {
60  assert(pkt->getAddr() == pioAddr);
61  assert(pkt->getSize() == 1);
62  SpeakerControl val = pkt->getLE<uint8_t>();
63  controlVal.gate = val.gate;
64  //Change the gate value in the timer.
65  if (!val.gate)
66  warn("The gate bit of the pc speaker isn't implemented and "
67  "is always on.\n");
68  //This would control whether the timer output is hooked up to a physical
69  //speaker. Since M5 can't make noise, it's value doesn't actually do
70  //anything.
71  controlVal.speaker = val.speaker;
72  DPRINTF(PcSpeaker, "Writing to speaker device: gate %s, speaker %s.\n",
73  controlVal.gate ? "on" : "off", controlVal.speaker ? "on" : "off");
74  pkt->makeAtomicResponse();
75  return latency;
76 }
77 
78 void
80 {
81  SERIALIZE_SCALAR(controlVal);
82 }
83 
84 void
86 {
87  UNSERIALIZE_SCALAR(controlVal);
88 }
89 
90 } // namespace gem5
gem5::BasicPioDevice::pioAddr
Addr pioAddr
Address that the device listens to.
Definition: io_device.hh:151
warn
#define warn(...)
Definition: logging.hh:246
UNSERIALIZE_SCALAR
#define UNSERIALIZE_SCALAR(scalar)
Definition: serialize.hh:575
gem5::CheckpointIn
Definition: serialize.hh:68
gem5::X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:769
gem5::Packet::makeAtomicResponse
void makeAtomicResponse()
Definition: packet.hh:1056
speaker.hh
gem5::X86ISA::Speaker::latency
Tick latency
Definition: speaker.hh:47
gem5::X86ISA::Speaker::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: speaker.cc:79
packet.hh
gem5::X86ISA::Speaker::timer
Bitfield< 5 > timer
Definition: speaker.hh:52
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:291
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
bitunion.hh
gem5::X86ISA::Speaker::read
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: speaker.cc:42
SERIALIZE_SCALAR
#define SERIALIZE_SCALAR(scalar)
Definition: serialize.hh:568
packet_access.hh
gem5::X86ISA::Speaker::write
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: speaker.cc:58
gem5::X86ISA::Speaker::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: speaker.cc:85
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
trace.hh
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:790
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
i8254.hh
gem5::Packet::getSize
unsigned getSize() const
Definition: packet.hh:800

Generated on Sat Jun 18 2022 08:12:26 for gem5 by doxygen 1.8.17