i8254.cc revision 5390
12381SN/A/*
210713Sandreas.hansson@arm.com * Copyright (c) 2004-2005 The Regents of The University of Michigan
38711Sandreas.hansson@arm.com * All rights reserved.
48711Sandreas.hansson@arm.com *
58711Sandreas.hansson@arm.com * Redistribution and use in source and binary forms, with or without
68711Sandreas.hansson@arm.com * modification, are permitted provided that the following conditions are
78711Sandreas.hansson@arm.com * met: redistributions of source code must retain the above copyright
88711Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer;
98711Sandreas.hansson@arm.com * redistributions in binary form must reproduce the above copyright
108711Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer in the
118711Sandreas.hansson@arm.com * documentation and/or other materials provided with the distribution;
128711Sandreas.hansson@arm.com * neither the name of the copyright holders nor the names of its
138711Sandreas.hansson@arm.com * contributors may be used to endorse or promote products derived from
142381SN/A * this software without specific prior written permission.
152381SN/A *
162381SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172381SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182381SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192381SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202381SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212381SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222381SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232381SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242381SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252381SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262381SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272381SN/A *
282381SN/A * Authors: Gabe Black
292381SN/A */
302381SN/A
312381SN/A#include "dev/x86/south_bridge/i8254.hh"
322381SN/A#include "mem/packet_access.hh"
332381SN/A
342381SN/ATick
352381SN/AX86ISA::I8254::read(PacketPtr pkt)
362381SN/A{
372381SN/A    assert(pkt->getSize() == 1);
382381SN/A    switch(pkt->getAddr() - addrRange.start)
392665Ssaidi@eecs.umich.edu    {
402665Ssaidi@eecs.umich.edu      case 0x0:
418853Sandreas.hansson@arm.com        warn("Reading from timer 0 counter.\n");
428922Swilliam.wang@arm.com        break;
432381SN/A      case 0x1:
442381SN/A        warn("Reading from timer 1 counter.\n");
452381SN/A        break;
462381SN/A      case 0x2:
478922Swilliam.wang@arm.com        warn("Reading from timer 2 counter.\n");
482381SN/A        break;
492381SN/A      case 0x3:
502381SN/A        fatal("Reading from timer control word which is read only.\n");
512381SN/A        break;
522381SN/A      default:
539235Sandreas.hansson@arm.com        panic("Read from undefined i8254 register.\n");
542381SN/A    }
552381SN/A    return SubDevice::read(pkt);
563401Sktlim@umich.edu}
573401Sktlim@umich.edu
582381SN/ATick
598922Swilliam.wang@arm.comX86ISA::I8254::write(PacketPtr pkt)
608922Swilliam.wang@arm.com{
619087Sandreas.hansson@arm.com    assert(pkt->getSize() == 1);
622381SN/A    switch(pkt->getAddr() - addrRange.start)
638708Sandreas.hansson@arm.com    {
642381SN/A      case 0x0:
658922Swilliam.wang@arm.com        warn("Writing to timer 0 counter.\n");
668922Swilliam.wang@arm.com        break;
678922Swilliam.wang@arm.com      case 0x1:
688922Swilliam.wang@arm.com        warn("Writing to timer 1 counter.\n");
698922Swilliam.wang@arm.com        break;
708922Swilliam.wang@arm.com      case 0x2:
715476Snate@binkert.org        warn("Writing to timer 2 counter.\n");
722640Sstever@eecs.umich.edu        break;
738965Sandreas.hansson@arm.com      case 0x3:
748965Sandreas.hansson@arm.com        processControlWord(pkt->get<uint8_t>());
759031Sandreas.hansson@arm.com        return latency;
768965Sandreas.hansson@arm.com      default:
779031Sandreas.hansson@arm.com        panic("Write to undefined i8254 register.\n");
788965Sandreas.hansson@arm.com    }
798922Swilliam.wang@arm.com    return SubDevice::write(pkt);
808922Swilliam.wang@arm.com}
818922Swilliam.wang@arm.com
828922Swilliam.wang@arm.comvoid
838922Swilliam.wang@arm.comX86ISA::I8254::processControlWord(uint8_t word)
848922Swilliam.wang@arm.com{
858922Swilliam.wang@arm.com    warn("I8254 received control word %x.\n", word);
868922Swilliam.wang@arm.com}
878965Sandreas.hansson@arm.com