speaker.cc (7903:7fcfb515d7bf) speaker.cc (8232:b28d06a175be)
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#include "base/bitunion.hh"
32#include "base/trace.hh"
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#include "base/bitunion.hh"
32#include "base/trace.hh"
33#include "debug/PcSpeaker.hh"
33#include "dev/x86/i8254.hh"
34#include "dev/x86/speaker.hh"
35#include "mem/packet.hh"
36#include "mem/packet_access.hh"
37
38Tick
39X86ISA::Speaker::read(PacketPtr pkt)
40{
41 assert(pkt->getAddr() == pioAddr);
42 assert(pkt->getSize() == 1);
43 controlVal.timer = timer->outputHigh(2) ? 1 : 0;
44 DPRINTF(PcSpeaker,
45 "Reading from speaker device: gate %s, speaker %s, output %s.\n",
46 controlVal.gate ? "on" : "off",
47 controlVal.speaker ? "on" : "off",
48 controlVal.timer ? "on" : "off");
49 pkt->set((uint8_t)controlVal);
50 pkt->makeAtomicResponse();
51 return latency;
52}
53
54Tick
55X86ISA::Speaker::write(PacketPtr pkt)
56{
57 assert(pkt->getAddr() == pioAddr);
58 assert(pkt->getSize() == 1);
59 SpeakerControl val = pkt->get<uint8_t>();
60 controlVal.gate = val.gate;
61 //Change the gate value in the timer.
62 if (!val.gate)
63 warn("The gate bit of the pc speaker isn't implemented and "
64 "is always on.\n");
65 //This would control whether the timer output is hooked up to a physical
66 //speaker. Since M5 can't make noise, it's value doesn't actually do
67 //anything.
68 controlVal.speaker = val.speaker;
69 DPRINTF(PcSpeaker, "Writing to speaker device: gate %s, speaker %s.\n",
70 controlVal.gate ? "on" : "off", controlVal.speaker ? "on" : "off");
71 pkt->makeAtomicResponse();
72 return latency;
73}
74
75void
76X86ISA::Speaker::serialize(std::ostream &os)
77{
78 uint8_t controlValData = controlVal.__data;
79 SERIALIZE_SCALAR(controlValData);
80}
81
82void
83X86ISA::Speaker::unserialize(Checkpoint *cp, const std::string &section)
84{
85 uint8_t controlValData;
86 UNSERIALIZE_SCALAR(controlValData);
87 controlVal.__data = controlValData;
88}
89
90X86ISA::Speaker *
91PcSpeakerParams::create()
92{
93 return new X86ISA::Speaker(this);
94}
34#include "dev/x86/i8254.hh"
35#include "dev/x86/speaker.hh"
36#include "mem/packet.hh"
37#include "mem/packet_access.hh"
38
39Tick
40X86ISA::Speaker::read(PacketPtr pkt)
41{
42 assert(pkt->getAddr() == pioAddr);
43 assert(pkt->getSize() == 1);
44 controlVal.timer = timer->outputHigh(2) ? 1 : 0;
45 DPRINTF(PcSpeaker,
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();
52 return latency;
53}
54
55Tick
56X86ISA::Speaker::write(PacketPtr pkt)
57{
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.
63 if (!val.gate)
64 warn("The gate bit of the pc speaker isn't implemented and "
65 "is always on.\n");
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
68 //anything.
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();
73 return latency;
74}
75
76void
77X86ISA::Speaker::serialize(std::ostream &os)
78{
79 uint8_t controlValData = controlVal.__data;
80 SERIALIZE_SCALAR(controlValData);
81}
82
83void
84X86ISA::Speaker::unserialize(Checkpoint *cp, const std::string &section)
85{
86 uint8_t controlValData;
87 UNSERIALIZE_SCALAR(controlValData);
88 controlVal.__data = controlValData;
89}
90
91X86ISA::Speaker *
92PcSpeakerParams::create()
93{
94 return new X86ISA::Speaker(this);
95}