1 /* Headers for DS1287-based DEC 5000/200 real-time clock chip emulation. 2 Copyright 2003 Brian R. Gaeke. 3 4 This file is part of VMIPS. 5 6 VMIPS is free software; you can redistribute it and/or modify it 7 under the terms of the GNU General Public License as published by the 8 Free Software Foundation; either version 2 of the License, or (at your 9 option) any later version. 10 11 VMIPS is distributed in the hope that it will be useful, but 12 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 for more details. 15 16 You should have received a copy of the GNU General Public License along 17 with VMIPS; if not, write to the Free Software Foundation, Inc., 18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 19 20 /* Dallas Semiconductor DS1287 real-time clock chip, as implemented 21 * as a memory-mapped device in the DEC 5000/200 (KN02). 22 */ 23 24 #ifndef _DECRTC_H_ 25 #define _DECRTC_H_ 26 27 #include <ctime> 28 #include "deviceint.h" 29 #include "devicemap.h" 30 #include "task.h" 31 class Clock; 32 class DeviceExc; 33 34 class DECRTCDevice : public DeviceMap, public DeviceInt { 35 protected: 36 /* Utility class to trigger interrupts to the RTC. */ 37 class ClockTrigger : public CancelableTask 38 { 39 public: 40 ClockTrigger (DECRTCDevice *rtc); 41 virtual ~ClockTrigger (); 42 protected: 43 virtual void real_task (); 44 DECRTCDevice *rtc; 45 }; 46 public: 47 DECRTCDevice (Clock *_clock, uint32 _irq); 48 virtual ~DECRTCDevice (); 49 uint32 fetch_word (uint32 offset, int mode, DeviceExc *client); 50 void store_word (uint32 offset, uint32 data, DeviceExc *client); descriptor_str()51 const char *descriptor_str () const { return "DECstation 5000/200 RTC"; } 52 void ready_clock (); 53 private: 54 ClockTrigger *clock_trigger; 55 Clock *clock; 56 uint8 rtc_reg[64]; 57 uint8 write_masks[64]; 58 uint32 frequency_ns; 59 uint32 irq; 60 bool interrupt_enable; 61 void update_host_time (); 62 const struct tm *get_host_time () const; 63 void unready_clock (); 64 }; 65 66 #endif /* _DECRTC_H_ */ 67