|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2024 nono project
4: // Licensed under nono-license.txt
5: //
6:
7: //
8: // Goldfish (Qemu) RTC+Timer (の RTC のほう)
9: //
10:
11: #pragma once
12:
13: #include "rtc.h"
14:
15: class TextScreen;
16:
17: // GFRTC/GFTimer 共通
18: class GFRTC
19: {
20: public:
1.1.1.2 root 21: static const uint TIME_LOW = 0x00U >> 2;
22: static const uint TIME_HIGH = 0x04U >> 2;
23: static const uint ALARM_LOW = 0x08U >> 2;
24: static const uint ALARM_HIGH = 0x0cU >> 2;
25: static const uint INTR_STATUS = 0x10U >> 2;
26: static const uint ALARM_CLEAR = 0x14U >> 2;
27: static const uint ALARM_STATUS = 0x18U >> 2;
28: static const uint INTR_CLEAR = 0x1cU >> 2;
1.1 root 29: };
30:
31: class GFRTCDevice : public RTCDevice
32: {
33: using inherited = RTCDevice;
34:
35: public:
36: GFRTCDevice();
37: ~GFRTCDevice() override;
38:
39: void ResetHard(bool poweron) override;
40:
41: // モニタの下請け。(GFTimer から呼ばれる)
1.1.1.4 ! root 42: int MonitorScreenRTC(TextScreen&, int y) const;
1.1 root 43:
1.1.1.2 root 44: protected:
45: // BusIO インタフェース
46: static const uint32 NPORT = 0x1000 >> 2;
47: busdata ReadPort(uint32 offset);
48: busdata WritePort(uint32 offset, uint32 data);
49: busdata PeekPort(uint32 offset);
50:
1.1 root 51: private:
52: void Tick1Hz() override;
53:
54: time_t MkTime() const;
55:
56: uint GetSec() const override { return sec; }
57: uint GetMin() const override { return min; }
58: uint GetHour() const override { return hour; }
59: uint GetWday() const override;
60: uint GetMday() const override { return day; }
61: uint GetMon() const override { return mon; }
62: uint GetYear() const override { return year; }
63: uint GetLeap() const override { return year % 4; }
64:
65: void SetSec(uint v) override { sec = v; }
66: void SetMin(uint v) override { min = v; }
67: void SetHour(uint v) override { hour = v; }
68: void SetWday(uint v) override { }
69: void SetMday(uint v) override { day = v; }
70: void SetMon(uint v) override { mon = v; }
71: void SetYear(uint v) override { year = v; }
72: void SetLeap(uint v) override { }
73:
74: // 現在時刻
75: uint year; // 西暦 (ゲタなし)
76: uint mon; // 月 (1-12)
77: uint day;
78: uint hour;
79: uint min;
80: uint sec;
81:
1.1.1.4 ! root 82: // TIME レジスタラッチ。Goldfish 仕様により 1[nsec] 単位。
! 83: union64 time_nsec {};
1.1 root 84: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.