speaker.cc revision 5390
113168Smatt.horsnell@arm.com/*
213168Smatt.horsnell@arm.com * Copyright (c) 2004-2005 The Regents of The University of Michigan
313168Smatt.horsnell@arm.com * All rights reserved.
413168Smatt.horsnell@arm.com *
513168Smatt.horsnell@arm.com * Redistribution and use in source and binary forms, with or without
613168Smatt.horsnell@arm.com * modification, are permitted provided that the following conditions are
713168Smatt.horsnell@arm.com * met: redistributions of source code must retain the above copyright
813168Smatt.horsnell@arm.com * notice, this list of conditions and the following disclaimer;
913168Smatt.horsnell@arm.com * redistributions in binary form must reproduce the above copyright
1013168Smatt.horsnell@arm.com * notice, this list of conditions and the following disclaimer in the
1113168Smatt.horsnell@arm.com * documentation and/or other materials provided with the distribution;
1213168Smatt.horsnell@arm.com * neither the name of the copyright holders nor the names of its
1313168Smatt.horsnell@arm.com * contributors may be used to endorse or promote products derived from
1413168Smatt.horsnell@arm.com * this software without specific prior written permission.
1513168Smatt.horsnell@arm.com *
1613168Smatt.horsnell@arm.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1713168Smatt.horsnell@arm.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1813168Smatt.horsnell@arm.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1913168Smatt.horsnell@arm.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2013168Smatt.horsnell@arm.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2113168Smatt.horsnell@arm.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2213168Smatt.horsnell@arm.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2313168Smatt.horsnell@arm.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2413168Smatt.horsnell@arm.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2513168Smatt.horsnell@arm.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2613168Smatt.horsnell@arm.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2713168Smatt.horsnell@arm.com *
2813168Smatt.horsnell@arm.com * Authors: Gabe Black
2913168Smatt.horsnell@arm.com */
3013168Smatt.horsnell@arm.com
3113168Smatt.horsnell@arm.com#include "base/bitunion.hh"
3213168Smatt.horsnell@arm.com#include "dev/x86/south_bridge/speaker.hh"
3313168Smatt.horsnell@arm.com#include "mem/packet_access.hh"
3413168Smatt.horsnell@arm.com
3513168Smatt.horsnell@arm.comBitUnion8(SpeakerControl)
3613168Smatt.horsnell@arm.com    Bitfield<0> gate;
3713168Smatt.horsnell@arm.com    Bitfield<1> speaker;
3813168Smatt.horsnell@arm.com    Bitfield<5> timer;
3913168Smatt.horsnell@arm.comEndBitUnion(SpeakerControl)
4013168Smatt.horsnell@arm.com
4113168Smatt.horsnell@arm.comTick
4213168Smatt.horsnell@arm.comX86ISA::Speaker::read(PacketPtr pkt)
4313168Smatt.horsnell@arm.com{
4413168Smatt.horsnell@arm.com    assert(pkt->getAddr() == addrRange.start);
4513168Smatt.horsnell@arm.com    assert(pkt->getSize() == 1);
4613168Smatt.horsnell@arm.com    SpeakerControl val = 0xFF;
4713168Smatt.horsnell@arm.com    warn("Reading from speaker device: gate %s, speaker %s, output %s.\n",
4813168Smatt.horsnell@arm.com            val.gate ? "on" : "off",
4913168Smatt.horsnell@arm.com            val.speaker ? "on" : "off",
5013168Smatt.horsnell@arm.com            val.timer ? "on" : "off");
5113168Smatt.horsnell@arm.com    pkt->set((uint8_t)val);
5213168Smatt.horsnell@arm.com    return latency;
5313168Smatt.horsnell@arm.com}
5413168Smatt.horsnell@arm.com
5513169Smatt.horsnell@arm.comTick
5613169Smatt.horsnell@arm.comX86ISA::Speaker::write(PacketPtr pkt)
5713169Smatt.horsnell@arm.com{
5813169Smatt.horsnell@arm.com    assert(pkt->getAddr() == addrRange.start);
5913169Smatt.horsnell@arm.com    assert(pkt->getSize() == 1);
6013169Smatt.horsnell@arm.com    SpeakerControl val = pkt->get<uint8_t>();
6113169Smatt.horsnell@arm.com    warn("Writing to speaker device: gate %s, speaker %s.\n",
6213169Smatt.horsnell@arm.com            val.gate ? "on" : "off", val.speaker ? "on" : "off");
6313169Smatt.horsnell@arm.com    return latency;
6413169Smatt.horsnell@arm.com}
6513169Smatt.horsnell@arm.com