1/* 2 * Copyright (c) 2004-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 26 unchanged lines hidden (view full) --- 35 */ 36 37#include <sys/time.h> 38 39#include <deque> 40#include <string> 41#include <vector> 42 |
43#include "base/time.hh" |
44#include "base/trace.hh" 45#include "dev/pitreg.h" 46#include "dev/rtcreg.h" 47#include "dev/alpha/tsunami_cchip.hh" 48#include "dev/alpha/tsunami.hh" 49#include "dev/alpha/tsunami_io.hh" 50#include "dev/alpha/tsunamireg.h" 51#include "mem/packet.hh" 52#include "mem/packet_access.hh" 53#include "mem/port.hh" |
54#include "sim/system.hh" 55 56using namespace std; 57//Should this be AlphaISA? 58using namespace TheISA; 59 |
60TsunamiIO::RTC::RTC(const string &n, Tsunami* tsunami, 61 const TsunamiIO::Params *p) 62 : _name(n), event(tsunami, p->frequency), addr(0) |
63{ 64 memset(clock_data, 0, sizeof(clock_data)); 65 stat_regA = RTCA_32768HZ | RTCA_1024HZ; 66 stat_regB = RTCB_PRDC_IE |RTCB_BIN | RTCB_24HR; 67 |
68 year = p->time.tm_year; |
69 |
70 if (p->year_is_bcd) { |
71 // The datasheet says that the year field can be either BCD or 72 // years since 1900. Linux seems to be happy with years since 73 // 1900. 74 year = year % 100; 75 int tens = year / 10; 76 int ones = year % 10; 77 year = (tens << 4) + ones; 78 } 79 80 // Unix is 0-11 for month, data seet says start at 1 |
81 mon = p->time.tm_mon + 1; 82 mday = p->time.tm_mday; 83 hour = p->time.tm_hour; 84 min = p->time.tm_min; 85 sec = p->time.tm_sec; |
86 87 // Datasheet says 1 is sunday |
88 wday = p->time.tm_wday + 1; |
89 |
90 DPRINTFN("Real-time clock set to %s", asctime(&p->time)); |
91} 92 93void 94TsunamiIO::RTC::writeAddr(const uint8_t data) 95{ 96 if (data <= RTC_STAT_REGD) 97 addr = data; 98 else --- 330 unchanged lines hidden (view full) --- 429} 430 431const char * 432TsunamiIO::PITimer::Counter::CounterEvent::description() 433{ 434 return "tsunami 8254 Interval timer"; 435} 436 |
437TsunamiIO::TsunamiIO(const Params *p) |
438 : BasicPioDevice(p), tsunami(p->tsunami), pitimer(p->name + "pitimer"), |
439 rtc(p->name + ".rtc", p->tsunami, p) |
440{ 441 pioSize = 0x100; 442 443 // set the back pointer from tsunami to myself 444 tsunami->io = this; 445 446 timerData = 0; 447 picr = 0; --- 201 unchanged lines hidden (view full) --- 649 UNSERIALIZE_SCALAR(picr); 650 UNSERIALIZE_SCALAR(picInterrupting); 651 652 // Unserialize the timers 653 pitimer.unserialize("pitimer", cp, section); 654 rtc.unserialize("rtc", cp, section); 655} 656 |
657TsunamiIO * 658TsunamiIOParams::create() |
659{ |
660 return new TsunamiIO(this); |
661} |