speaker.hh revision 9338
18441SN/A/*
28441SN/A * Copyright (c) 2008 The Regents of The University of Michigan
37893SN/A * All rights reserved.
48983Snate@binkert.org *
58983Snate@binkert.org * Redistribution and use in source and binary forms, with or without
68983Snate@binkert.org * modification, are permitted provided that the following conditions are
78983Snate@binkert.org * met: redistributions of source code must retain the above copyright
87893SN/A * notice, this list of conditions and the following disclaimer;
97893SN/A * redistributions in binary form must reproduce the above copyright
107893SN/A * notice, this list of conditions and the following disclaimer in the
117893SN/A * documentation and/or other materials provided with the distribution;
127893SN/A * neither the name of the copyright holders nor the names of its
137893SN/A * contributors may be used to endorse or promote products derived from
147893SN/A * this software without specific prior written permission.
157893SN/A *
167893SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
177893SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
187893SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
197893SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
207893SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
217893SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
227893SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
237893SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
247893SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
257893SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
268844SAli.Saidi@ARM.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
278844SAli.Saidi@ARM.com *
288844SAli.Saidi@ARM.com * Authors: Gabe Black
29 */
30
31#ifndef __DEV_X86_SPEAKER_HH__
32#define __DEV_X86_SPEAKER_HH__
33
34#include "base/bitunion.hh"
35#include "dev/io_device.hh"
36#include "params/PcSpeaker.hh"
37
38namespace X86ISA
39{
40
41class I8254;
42
43class Speaker : public BasicPioDevice
44{
45  protected:
46    Tick latency;
47
48    BitUnion8(SpeakerControl)
49        Bitfield<0> gate;
50        Bitfield<1> speaker;
51        Bitfield<5> timer;
52    EndBitUnion(SpeakerControl)
53
54    SpeakerControl controlVal;
55
56    I8254 * timer;
57
58  public:
59    typedef PcSpeakerParams Params;
60
61    const Params *
62    params() const
63    {
64        return dynamic_cast<const Params *>(_params);
65    }
66
67    Speaker(Params *p) : BasicPioDevice(p),
68        latency(p->pio_latency), controlVal(0), timer(p->i8254)
69    {
70        pioSize = 1;
71    }
72
73    Tick read(PacketPtr pkt);
74
75    Tick write(PacketPtr pkt);
76
77    virtual void serialize(std::ostream &os);
78    virtual void unserialize(Checkpoint *cp, const std::string &section);
79
80};
81
82} // namespace X86ISA
83
84#endif //__DEV_X86_SPEAKER_HH__
85