dtod.cc revision 10531
16145SN/A/* 28688SN/A * Copyright (c) 2004-2006 The Regents of The University of Michigan 36145SN/A * All rights reserved. 46145SN/A * 56145SN/A * Redistribution and use in source and binary forms, with or without 66145SN/A * modification, are permitted provided that the following conditions are 76145SN/A * met: redistributions of source code must retain the above copyright 86145SN/A * notice, this list of conditions and the following disclaimer; 96145SN/A * redistributions in binary form must reproduce the above copyright 106145SN/A * notice, this list of conditions and the following disclaimer in the 116145SN/A * documentation and/or other materials provided with the distribution; 126145SN/A * neither the name of the copyright holders nor the names of its 136145SN/A * contributors may be used to endorse or promote products derived from 146145SN/A * this software without specific prior written permission. 156145SN/A * 166145SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 176145SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 186145SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 196145SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 206145SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 216145SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 226145SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236145SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246145SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256145SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 266145SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276145SN/A * 286145SN/A * Authors: Ali Saidi 296145SN/A */ 307039SN/A 317039SN/A/** @file 327039SN/A * Time of date device implementation 336145SN/A */ 346145SN/A#include <sys/time.h> 357039SN/A 367039SN/A#include <deque> 376145SN/A#include <string> 387039SN/A#include <vector> 399350SN/A 4011108Sdavid.hashe@amd.com#include "base/time.hh" 4110301SN/A#include "base/trace.hh" 4210301SN/A#include "config/the_isa.hh" 4310301SN/A#include "dev/sparc/dtod.hh" 447039SN/A#include "dev/platform.hh" 459206SN/A#include "mem/packet_access.hh" 466145SN/A#include "mem/port.hh" 477039SN/A#include "sim/system.hh" 4810920SN/A 496285SN/Ausing namespace std; 509206SN/Ausing namespace TheISA; 517039SN/A 527039SN/ADumbTOD::DumbTOD(const Params *p) 536876SN/A : BasicPioDevice(p, 0x08) 546876SN/A{ 557039SN/A struct tm tm = p->time; 566145SN/A todTime = mkutctime(&tm); 577039SN/A 587039SN/A DPRINTFN("Real-time clock set to %s\n", asctime(&tm)); 599504SN/A DPRINTFN("Real-time clock set to %d\n", todTime); 609504SN/A} 619504SN/A 6210837SN/ATick 6310837SN/ADumbTOD::read(PacketPtr pkt) 646285SN/A{ 6510525SN/A assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize); 6610918SN/A assert(pkt->getSize() == 8); 6711294Sandreas.hansson@arm.com 6810525SN/A pkt->allocate(); 697039SN/A pkt->set(todTime); 707039SN/A todTime += 1000; 717039SN/A 727039SN/A pkt->makeAtomicResponse(); 7310012SN/A return pioDelay; 7410012SN/A} 757039SN/A 766285SN/ATick 7711523Sdavid.guillen@arm.comDumbTOD::write(PacketPtr pkt) 7811523Sdavid.guillen@arm.com{ 7911523Sdavid.guillen@arm.com panic("Dumb tod device doesn't support writes\n"); 8011523Sdavid.guillen@arm.com} 8110012SN/A 8211169Sandreas.hansson@arm.comvoid 836285SN/ADumbTOD::serialize(std::ostream &os) 8411169Sandreas.hansson@arm.com{ 8511168Sandreas.hansson@arm.com SERIALIZE_SCALAR(todTime); 8611168Sandreas.hansson@arm.com} 8711168Sandreas.hansson@arm.com 888688SN/Avoid 8911169Sandreas.hansson@arm.comDumbTOD::unserialize(Checkpoint *cp, const std::string §ion) 909270SN/A{ 919270SN/A UNSERIALIZE_SCALAR(todTime); 927562SN/A} 938436SN/A 948436SN/ADumbTOD * 958436SN/ADumbTODParams::create() 968937SN/A{ 978937SN/A return new DumbTOD(this); 988937SN/A} 9912133Sspwilson2@wisc.edu