speaker.hh revision 11175
16019SN/A/*
26019SN/A * Copyright (c) 2008 The Regents of The University of Michigan
37134Sgblack@eecs.umich.edu * All rights reserved.
47134Sgblack@eecs.umich.edu *
57134Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
67134Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are
77134Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright
87134Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer;
97134Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright
107134Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the
117134Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution;
127134Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its
137134Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from
147134Sgblack@eecs.umich.edu * this software without specific prior written permission.
156019SN/A *
166019SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176019SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186019SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196019SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206019SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216019SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226019SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236019SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246019SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256019SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266019SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276019SN/A *
286019SN/A * Authors: Gabe Black
296019SN/A */
306019SN/A
316019SN/A#ifndef __DEV_X86_SPEAKER_HH__
326019SN/A#define __DEV_X86_SPEAKER_HH__
336019SN/A
346019SN/A#include "base/bitunion.hh"
356019SN/A#include "dev/io_device.hh"
366019SN/A#include "params/PcSpeaker.hh"
376019SN/A
386019SN/Anamespace X86ISA
396019SN/A{
406019SN/A
416019SN/Aclass I8254;
426308SN/A
436308SN/Aclass Speaker : public BasicPioDevice
446309SN/A{
456309SN/A  protected:
466309SN/A    Tick latency;
476309SN/A
486309SN/A    BitUnion8(SpeakerControl)
497134Sgblack@eecs.umich.edu        Bitfield<0> gate;
507134Sgblack@eecs.umich.edu        Bitfield<1> speaker;
516309SN/A        Bitfield<5> timer;
526309SN/A    EndBitUnion(SpeakerControl)
536309SN/A
546309SN/A    SpeakerControl controlVal;
556309SN/A
566309SN/A    I8254 * timer;
577134Sgblack@eecs.umich.edu
586309SN/A  public:
596309SN/A    typedef PcSpeakerParams Params;
606309SN/A
616754SN/A    const Params *
626754SN/A    params() const
637134Sgblack@eecs.umich.edu    {
647134Sgblack@eecs.umich.edu        return dynamic_cast<const Params *>(_params);
657134Sgblack@eecs.umich.edu    }
667134Sgblack@eecs.umich.edu
676754SN/A    Speaker(Params *p) : BasicPioDevice(p, 1),
686754SN/A        latency(p->pio_latency), controlVal(0), timer(p->i8254)
696754SN/A    {
706754SN/A    }
716754SN/A
727134Sgblack@eecs.umich.edu    Tick read(PacketPtr pkt) override;
736754SN/A
746754SN/A    Tick write(PacketPtr pkt) override;
756754SN/A
766309SN/A    void serialize(CheckpointOut &cp) const override;
776309SN/A    void unserialize(CheckpointIn &cp) override;
786309SN/A};
797134Sgblack@eecs.umich.edu
806309SN/A} // namespace X86ISA
816309SN/A
826309SN/A#endif //__DEV_X86_SPEAKER_HH__
836309SN/A