2 * Copyright (c) 2008 The Regents of The University of Michigan
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.
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.
31 #include "base/bitunion.hh"
32 #include "base/trace.hh"
33 #include "debug/PcSpeaker.hh"
34 #include "dev/x86/i8254.hh"
35 #include "dev/x86/speaker.hh"
36 #include "mem/packet.hh"
37 #include "mem/packet_access.hh"
40 X86ISA::Speaker::read(PacketPtr pkt
)
42 assert(pkt
->getAddr() == pioAddr
);
43 assert(pkt
->getSize() == 1);
44 controlVal
.timer
= timer
->outputHigh(2) ? 1 : 0;
46 "Reading from speaker device: gate %s, speaker %s, output %s.\n",
47 controlVal
.gate
? "on" : "off",
48 controlVal
.speaker
? "on" : "off",
49 controlVal
.timer
? "on" : "off");
50 pkt
->set((uint8_t)controlVal
);
51 pkt
->makeAtomicResponse();
56 X86ISA::Speaker::write(PacketPtr pkt
)
58 assert(pkt
->getAddr() == pioAddr
);
59 assert(pkt
->getSize() == 1);
60 SpeakerControl val
= pkt
->get
<uint8_t>();
61 controlVal
.gate
= val
.gate
;
62 //Change the gate value in the timer.
64 warn("The gate bit of the pc speaker isn't implemented and "
66 //This would control whether the timer output is hooked up to a physical
67 //speaker. Since M5 can't make noise, it's value doesn't actually do
69 controlVal
.speaker
= val
.speaker
;
70 DPRINTF(PcSpeaker
, "Writing to speaker device: gate %s, speaker %s.\n",
71 controlVal
.gate
? "on" : "off", controlVal
.speaker
? "on" : "off");
72 pkt
->makeAtomicResponse();
77 X86ISA::Speaker::serialize(CheckpointOut
&cp
) const
79 uint8_t controlValData
= controlVal
.__data
;
80 SERIALIZE_SCALAR(controlValData
);
84 X86ISA::Speaker::unserialize(CheckpointIn
&cp
)
86 uint8_t controlValData
;
87 UNSERIALIZE_SCALAR(controlValData
);
88 controlVal
.__data
= controlValData
;
92 PcSpeakerParams::create()
94 return new X86ISA::Speaker(this);