dtod.cc revision 10905
112027Sjungma@eit.uni-kl.de/* 212027Sjungma@eit.uni-kl.de * Copyright (c) 2004-2006 The Regents of The University of Michigan 312027Sjungma@eit.uni-kl.de * All rights reserved. 412027Sjungma@eit.uni-kl.de * 512027Sjungma@eit.uni-kl.de * Redistribution and use in source and binary forms, with or without 612027Sjungma@eit.uni-kl.de * modification, are permitted provided that the following conditions are 712027Sjungma@eit.uni-kl.de * met: redistributions of source code must retain the above copyright 812027Sjungma@eit.uni-kl.de * notice, this list of conditions and the following disclaimer; 912027Sjungma@eit.uni-kl.de * redistributions in binary form must reproduce the above copyright 1012027Sjungma@eit.uni-kl.de * notice, this list of conditions and the following disclaimer in the 1112027Sjungma@eit.uni-kl.de * documentation and/or other materials provided with the distribution; 1212027Sjungma@eit.uni-kl.de * neither the name of the copyright holders nor the names of its 1312027Sjungma@eit.uni-kl.de * contributors may be used to endorse or promote products derived from 1412027Sjungma@eit.uni-kl.de * this software without specific prior written permission. 1512027Sjungma@eit.uni-kl.de * 1612027Sjungma@eit.uni-kl.de * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1712027Sjungma@eit.uni-kl.de * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1812027Sjungma@eit.uni-kl.de * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1912027Sjungma@eit.uni-kl.de * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2012027Sjungma@eit.uni-kl.de * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2112027Sjungma@eit.uni-kl.de * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2212027Sjungma@eit.uni-kl.de * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2312027Sjungma@eit.uni-kl.de * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2412027Sjungma@eit.uni-kl.de * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2512027Sjungma@eit.uni-kl.de * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2612027Sjungma@eit.uni-kl.de * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2712027Sjungma@eit.uni-kl.de * 2812027Sjungma@eit.uni-kl.de * Authors: Ali Saidi 2912027Sjungma@eit.uni-kl.de */ 3012027Sjungma@eit.uni-kl.de 3112027Sjungma@eit.uni-kl.de/** @file 3212027Sjungma@eit.uni-kl.de * Time of date device implementation 3312027Sjungma@eit.uni-kl.de */ 3412027Sjungma@eit.uni-kl.de#include <sys/time.h> 3512027Sjungma@eit.uni-kl.de 3612027Sjungma@eit.uni-kl.de#include <deque> 3712027Sjungma@eit.uni-kl.de#include <string> 3812027Sjungma@eit.uni-kl.de#include <vector> 3912027Sjungma@eit.uni-kl.de 4012027Sjungma@eit.uni-kl.de#include "base/time.hh" 4112027Sjungma@eit.uni-kl.de#include "base/trace.hh" 4212027Sjungma@eit.uni-kl.de#include "config/the_isa.hh" 4312027Sjungma@eit.uni-kl.de#include "dev/sparc/dtod.hh" 4412027Sjungma@eit.uni-kl.de#include "dev/platform.hh" 4512027Sjungma@eit.uni-kl.de#include "mem/packet_access.hh" 4612027Sjungma@eit.uni-kl.de#include "mem/port.hh" 4712027Sjungma@eit.uni-kl.de#include "sim/system.hh" 4812027Sjungma@eit.uni-kl.de 4912027Sjungma@eit.uni-kl.deusing namespace std; 5012027Sjungma@eit.uni-kl.deusing namespace TheISA; 5112027Sjungma@eit.uni-kl.de 5212027Sjungma@eit.uni-kl.deDumbTOD::DumbTOD(const Params *p) 5312027Sjungma@eit.uni-kl.de : BasicPioDevice(p, 0x08) 5412027Sjungma@eit.uni-kl.de{ 5512027Sjungma@eit.uni-kl.de struct tm tm = p->time; 5612027Sjungma@eit.uni-kl.de todTime = mkutctime(&tm); 5712027Sjungma@eit.uni-kl.de 5812027Sjungma@eit.uni-kl.de DPRINTFN("Real-time clock set to %s\n", asctime(&tm)); 5912027Sjungma@eit.uni-kl.de DPRINTFN("Real-time clock set to %d\n", todTime); 6012027Sjungma@eit.uni-kl.de} 6112027Sjungma@eit.uni-kl.de 6212027Sjungma@eit.uni-kl.deTick 6312027Sjungma@eit.uni-kl.deDumbTOD::read(PacketPtr pkt) 6412027Sjungma@eit.uni-kl.de{ 6512027Sjungma@eit.uni-kl.de assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize); 6612027Sjungma@eit.uni-kl.de assert(pkt->getSize() == 8); 6712027Sjungma@eit.uni-kl.de 6812027Sjungma@eit.uni-kl.de pkt->set(todTime); 6912027Sjungma@eit.uni-kl.de todTime += 1000; 7012027Sjungma@eit.uni-kl.de 7112027Sjungma@eit.uni-kl.de pkt->makeAtomicResponse(); 7212027Sjungma@eit.uni-kl.de return pioDelay; 7312027Sjungma@eit.uni-kl.de} 7412027Sjungma@eit.uni-kl.de 7512027Sjungma@eit.uni-kl.deTick 7612027Sjungma@eit.uni-kl.deDumbTOD::write(PacketPtr pkt) 7712027Sjungma@eit.uni-kl.de{ 7812027Sjungma@eit.uni-kl.de panic("Dumb tod device doesn't support writes\n"); 7912027Sjungma@eit.uni-kl.de} 8012027Sjungma@eit.uni-kl.de 8112027Sjungma@eit.uni-kl.devoid 8212027Sjungma@eit.uni-kl.deDumbTOD::serialize(CheckpointOut &cp) const 8312027Sjungma@eit.uni-kl.de{ 8412027Sjungma@eit.uni-kl.de SERIALIZE_SCALAR(todTime); 8512027Sjungma@eit.uni-kl.de} 8612027Sjungma@eit.uni-kl.de 8712027Sjungma@eit.uni-kl.devoid 8812027Sjungma@eit.uni-kl.deDumbTOD::unserialize(CheckpointIn &cp) 8912027Sjungma@eit.uni-kl.de{ 9012027Sjungma@eit.uni-kl.de UNSERIALIZE_SCALAR(todTime); 9112027Sjungma@eit.uni-kl.de} 9212027Sjungma@eit.uni-kl.de 9312027Sjungma@eit.uni-kl.deDumbTOD * 9412027Sjungma@eit.uni-kl.deDumbTODParams::create() 9512027Sjungma@eit.uni-kl.de{ 9612027Sjungma@eit.uni-kl.de return new DumbTOD(this); 9712027Sjungma@eit.uni-kl.de} 9812027Sjungma@eit.uni-kl.de