Bring code into version control
[qemupp.git] / mc146818a.hpp
blobb7ec7ac8f50b53be6bdb92d56dd4eda977fe25c1
1 #ifndef MC146818A_HPP
2 #define MC146818A_HPP
4 #include <time.h>
6 #include "device.hpp"
7 #include "timer.hpp"
8 #include "io.hpp"
10 class RTC : public Device
12 public:
13 RTC(int32_t base_year, struct tm &tm);
14 virtual ~RTC(void);
16 void reset(void);
18 uint8_t cmos_read(uint8_t index);
19 void cmos_write(uint8_t index, uint8_t data);
21 OutputPin irq;
23 private:
24 int from_bcd(int a);
25 int to_bcd(int a);
27 void update_timer(int64_t current_time);
28 void set_time(void);
29 void copy_date(void);
31 void on_periodic(void);
32 void on_second(void);
33 void on_second2(void);
35 int32_t base_year;
37 uint8_t cmos_data[128];
38 struct tm current_tm;
40 int64_t next_periodic_time;
41 int64_t next_second_time;
43 Timer periodic_timer;
44 Timer second_timer;
45 Timer second_timer2;
48 #endif