tsunami_io.cc (3885:fd4067a5b903) | tsunami_io.cc (3932:62e915bb6704) |
---|---|
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; --- 43 unchanged lines hidden (view full) --- 52#include "mem/port.hh" 53#include "sim/builder.hh" 54#include "sim/system.hh" 55 56using namespace std; 57//Should this be AlphaISA? 58using namespace TheISA; 59 | 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; --- 43 unchanged lines hidden (view full) --- 52#include "mem/port.hh" 53#include "sim/builder.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, time_t t, Tick i) 61 : _name(n), event(tsunami, i), addr(0) | 60TsunamiIO::RTC::RTC(const string &n, Tsunami* tsunami, const vector<int> &t, 61 bool bcd, Tick i) 62 : _name(n), event(tsunami, i), addr(0), year_is_bcd(bcd) |
62{ 63 memset(clock_data, 0, sizeof(clock_data)); 64 stat_regA = RTCA_32768HZ | RTCA_1024HZ; 65 stat_regB = RTCB_PRDC_IE |RTCB_BIN | RTCB_24HR; 66 | 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 if (year_is_bcd) { 69 // The RTC uses BCD for the last two digits in the year. 70 // They python year is a full year. 71 int _year = t[0] % 100; 72 int tens = _year / 10; 73 int ones = _year % 10; 74 75 year = (tens << 4) + ones; 76 } else { 77 // Even though the datasheet says that the year field should be 78 // interpreted as BCD, we just enter the number of years since 79 // 1900 since linux seems to be happy with that (and I believe 80 // that Tru64 was as well) 81 year = t[0] - 1900; 82 } 83 84 mon = t[1]; 85 mday = t[2]; 86 hour = t[3]; 87 min = t[4]; 88 sec = t[5]; 89 90 // wday is defined to be in the range from 1 - 7 with 1 being Sunday. 91 // the value coming from python is in the range from 0 - 6 with 0 being 92 // Monday. Fix that here. 93 wday = t[6] + 2; 94 if (wday > 7) 95 wday -= 7; 96 97 DPRINTFN("Real-time clock set to %s", getDateString()); 98} 99 100std::string 101TsunamiIO::RTC::getDateString() 102{ |
|
67 struct tm tm; | 103 struct tm tm; |
68 gmtime_r(&t, &tm); | |
69 | 104 |
70 sec = tm.tm_sec; 71 min = tm.tm_min; 72 hour = tm.tm_hour; 73 wday = tm.tm_wday + 1; 74 mday = tm.tm_mday; 75 mon = tm.tm_mon + 1; 76 year = tm.tm_year; | 105 memset(&tm, 0, sizeof(tm)); |
77 | 106 |
78 DPRINTFN("Real-time clock set to %s", asctime(&tm)); | 107 if (year_is_bcd) { 108 // undo the BCD and conver to years since 1900 guessing that 109 // anything before 1970 is actually after 2000 110 int _year = (year >> 4) * 10 + (year & 0xf); 111 if (_year < 70) 112 _year += 100; 113 114 tm.tm_year = _year; 115 } else { 116 // number of years since 1900 117 tm.tm_year = year; 118 } 119 120 // unix is 0-11 for month 121 tm.tm_mon = mon - 1; 122 tm.tm_mday = mday; 123 tm.tm_hour = hour; 124 tm.tm_min = min; 125 tm.tm_sec = sec; 126 127 // to add more annoyance unix is 0 - 6 with 0 as sunday 128 tm.tm_wday = wday - 1; 129 130 return asctime(&tm); |
79} 80 81void 82TsunamiIO::RTC::writeAddr(const uint8_t data) 83{ 84 if (data <= RTC_STAT_REGD) 85 addr = data; 86 else --- 332 unchanged lines hidden (view full) --- 419const char * 420TsunamiIO::PITimer::Counter::CounterEvent::description() 421{ 422 return "tsunami 8254 Interval timer"; 423} 424 425TsunamiIO::TsunamiIO(Params *p) 426 : BasicPioDevice(p), tsunami(p->tsunami), pitimer(p->name + "pitimer"), | 131} 132 133void 134TsunamiIO::RTC::writeAddr(const uint8_t data) 135{ 136 if (data <= RTC_STAT_REGD) 137 addr = data; 138 else --- 332 unchanged lines hidden (view full) --- 471const char * 472TsunamiIO::PITimer::Counter::CounterEvent::description() 473{ 474 return "tsunami 8254 Interval timer"; 475} 476 477TsunamiIO::TsunamiIO(Params *p) 478 : BasicPioDevice(p), tsunami(p->tsunami), pitimer(p->name + "pitimer"), |
427 rtc(p->name + ".rtc", p->tsunami, p->init_time, p->frequency) | 479 rtc(p->name + ".rtc", p->tsunami, p->init_time, p->year_is_bcd, 480 p->frequency) |
428{ 429 pioSize = 0x100; 430 431 // set the back pointer from tsunami to myself 432 tsunami->io = this; 433 434 timerData = 0; 435 picr = 0; --- 208 unchanged lines hidden (view full) --- 644 645BEGIN_DECLARE_SIM_OBJECT_PARAMS(TsunamiIO) 646 647 Param<Addr> pio_addr; 648 Param<Tick> pio_latency; 649 Param<Tick> frequency; 650 SimObjectParam<Platform *> platform; 651 SimObjectParam<System *> system; | 481{ 482 pioSize = 0x100; 483 484 // set the back pointer from tsunami to myself 485 tsunami->io = this; 486 487 timerData = 0; 488 picr = 0; --- 208 unchanged lines hidden (view full) --- 697 698BEGIN_DECLARE_SIM_OBJECT_PARAMS(TsunamiIO) 699 700 Param<Addr> pio_addr; 701 Param<Tick> pio_latency; 702 Param<Tick> frequency; 703 SimObjectParam<Platform *> platform; 704 SimObjectParam<System *> system; |
652 Param<time_t> time; | 705 VectorParam<int> time; 706 Param<bool> year_is_bcd; |
653 SimObjectParam<Tsunami *> tsunami; 654 655END_DECLARE_SIM_OBJECT_PARAMS(TsunamiIO) 656 657BEGIN_INIT_SIM_OBJECT_PARAMS(TsunamiIO) 658 659 INIT_PARAM(pio_addr, "Device Address"), 660 INIT_PARAM(pio_latency, "Programmed IO latency"), 661 INIT_PARAM(frequency, "clock interrupt frequency"), 662 INIT_PARAM(platform, "platform"), 663 INIT_PARAM(system, "system object"), 664 INIT_PARAM(time, "System time to use (0 for actual time"), | 707 SimObjectParam<Tsunami *> tsunami; 708 709END_DECLARE_SIM_OBJECT_PARAMS(TsunamiIO) 710 711BEGIN_INIT_SIM_OBJECT_PARAMS(TsunamiIO) 712 713 INIT_PARAM(pio_addr, "Device Address"), 714 INIT_PARAM(pio_latency, "Programmed IO latency"), 715 INIT_PARAM(frequency, "clock interrupt frequency"), 716 INIT_PARAM(platform, "platform"), 717 INIT_PARAM(system, "system object"), 718 INIT_PARAM(time, "System time to use (0 for actual time"), |
719 INIT_PARAM(year_is_bcd, ""), |
|
665 INIT_PARAM(tsunami, "Tsunami") 666 667END_INIT_SIM_OBJECT_PARAMS(TsunamiIO) 668 669CREATE_SIM_OBJECT(TsunamiIO) 670{ 671 TsunamiIO::Params *p = new TsunamiIO::Params; 672 p->frequency = frequency; 673 p->name = getInstanceName(); 674 p->pio_addr = pio_addr; 675 p->pio_delay = pio_latency; 676 p->platform = platform; 677 p->system = system; 678 p->init_time = time; | 720 INIT_PARAM(tsunami, "Tsunami") 721 722END_INIT_SIM_OBJECT_PARAMS(TsunamiIO) 723 724CREATE_SIM_OBJECT(TsunamiIO) 725{ 726 TsunamiIO::Params *p = new TsunamiIO::Params; 727 p->frequency = frequency; 728 p->name = getInstanceName(); 729 p->pio_addr = pio_addr; 730 p->pio_delay = pio_latency; 731 p->platform = platform; 732 p->system = system; 733 p->init_time = time; |
734 p->year_is_bcd = year_is_bcd; |
|
679 p->tsunami = tsunami; 680 return new TsunamiIO(p); 681} 682 683REGISTER_SIM_OBJECT("TsunamiIO", TsunamiIO) | 735 p->tsunami = tsunami; 736 return new TsunamiIO(p); 737} 738 739REGISTER_SIM_OBJECT("TsunamiIO", TsunamiIO) |