speaker.hh revision 9338
17553SN/A/*
27553SN/A * Copyright (c) 2008 The Regents of The University of Michigan
37553SN/A * All rights reserved.
47553SN/A *
57553SN/A * Redistribution and use in source and binary forms, with or without
67553SN/A * modification, are permitted provided that the following conditions are
77553SN/A * met: redistributions of source code must retain the above copyright
87553SN/A * notice, this list of conditions and the following disclaimer;
97553SN/A * redistributions in binary form must reproduce the above copyright
107553SN/A * notice, this list of conditions and the following disclaimer in the
117553SN/A * documentation and/or other materials provided with the distribution;
127553SN/A * neither the name of the copyright holders nor the names of its
137553SN/A * contributors may be used to endorse or promote products derived from
147553SN/A * this software without specific prior written permission.
157553SN/A *
167553SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
177553SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
187553SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
197553SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
207553SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
217553SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
227553SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
237553SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
247553SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
257553SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
267553SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
277553SN/A *
287553SN/A * Authors: Gabe Black
297553SN/A */
307553SN/A
317553SN/A#ifndef __DEV_X86_SPEAKER_HH__
327553SN/A#define __DEV_X86_SPEAKER_HH__
337553SN/A
347553SN/A#include "base/bitunion.hh"
357553SN/A#include "dev/io_device.hh"
367553SN/A#include "params/PcSpeaker.hh"
377553SN/A
388492Snilay@cs.wisc.edunamespace X86ISA
397553SN/A{
407553SN/A
417553SN/Aclass I8254;
427553SN/A
437553SN/Aclass Speaker : public BasicPioDevice
447553SN/A{
457553SN/A  protected:
467553SN/A    Tick latency;
477553SN/A
488335Snate@binkert.org    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