i8254.cc revision 5636
16019Shines@cs.fsu.edu/*
211929SMatteo.Andreozzi@arm.com * Copyright (c) 2008 The Regents of The University of Michigan
37189Sgblack@eecs.umich.edu * All rights reserved.
47189Sgblack@eecs.umich.edu *
57189Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
67189Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are
77189Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright
87189Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer;
97189Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright
107189Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the
117189Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution;
127189Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its
137189Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from
146019Shines@cs.fsu.edu * this software without specific prior written permission.
156019Shines@cs.fsu.edu *
166019Shines@cs.fsu.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176019Shines@cs.fsu.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186019Shines@cs.fsu.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196019Shines@cs.fsu.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206019Shines@cs.fsu.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216019Shines@cs.fsu.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226019Shines@cs.fsu.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236019Shines@cs.fsu.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246019Shines@cs.fsu.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256019Shines@cs.fsu.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266019Shines@cs.fsu.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276019Shines@cs.fsu.edu *
286019Shines@cs.fsu.edu * Authors: Gabe Black
296019Shines@cs.fsu.edu */
306019Shines@cs.fsu.edu
316019Shines@cs.fsu.edu#include "dev/x86/i8254.hh"
326019Shines@cs.fsu.edu#include "mem/packet.hh"
336019Shines@cs.fsu.edu#include "mem/packet_access.hh"
346019Shines@cs.fsu.edu
356019Shines@cs.fsu.eduTick
366019Shines@cs.fsu.eduX86ISA::I8254::read(PacketPtr pkt)
376019Shines@cs.fsu.edu{
386019Shines@cs.fsu.edu    assert(pkt->getSize() == 1);
396019Shines@cs.fsu.edu    Addr offset = pkt->getAddr() - pioAddr;
406019Shines@cs.fsu.edu    if (offset < 3) {
416735Sgblack@eecs.umich.edu        pkt->set(pit.readCounter(offset));
426735Sgblack@eecs.umich.edu    } else if (offset == 3) {
4310037SARM gem5 Developers        pkt->set(uint8_t(-1));
4410037SARM gem5 Developers    } else {
456019Shines@cs.fsu.edu        panic("Read from undefined i8254 register.\n");
466019Shines@cs.fsu.edu    }
476019Shines@cs.fsu.edu    return latency;
486019Shines@cs.fsu.edu}
496019Shines@cs.fsu.edu
507362Sgblack@eecs.umich.eduTick
5110037SARM gem5 DevelopersX86ISA::I8254::write(PacketPtr pkt)
526735Sgblack@eecs.umich.edu{
538229Snate@binkert.org    assert(pkt->getSize() == 1);
546019Shines@cs.fsu.edu    Addr offset = pkt->getAddr() - pioAddr;
558782Sgblack@eecs.umich.edu    if (offset < 3) {
566019Shines@cs.fsu.edu        pit.writeCounter(offset, pkt->get<uint8_t>());
576019Shines@cs.fsu.edu    } else if (offset == 3) {
586019Shines@cs.fsu.edu        pit.writeControl(pkt->get<uint8_t>());
596019Shines@cs.fsu.edu    } else {
606019Shines@cs.fsu.edu        panic("Write to undefined i8254 register.\n");
6111294Sandreas.hansson@arm.com    }
626019Shines@cs.fsu.edu    return latency;
637362Sgblack@eecs.umich.edu}
646019Shines@cs.fsu.edu
656019Shines@cs.fsu.eduX86ISA::I8254 *
6610037SARM gem5 DevelopersI8254Params::create()
6710037SARM gem5 Developers{
6810037SARM gem5 Developers    return new X86ISA::I8254(this);
6910037SARM gem5 Developers}
7010037SARM gem5 Developers