|
|
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 (の Timer のほう)
9: //
10:
11: #include "device.h"
12:
13: class GFRTCDevice;
14: class InterruptDevice;
15: class Syncer;
16:
17: class GFTimerDevice : public IODevice
18: {
19: using inherited = IODevice;
20:
21: public:
22: GFTimerDevice();
23: ~GFTimerDevice() override;
24:
25: bool Init() override;
26: void ResetHard(bool poweron) override;
27:
1.1.1.2 root 28: protected:
29: // BusIO インタフェース
30: static const uint32 NPORT = 0x1000 >> 2;
31: busdata ReadPort(uint32 offset);
32: busdata WritePort(uint32 offset, uint32 data);
33: busdata PeekPort(uint32 offset);
1.1 root 34:
35: private:
36: DECLARE_MONITOR_CALLBACK(MonitorUpdate);
37:
1.1.1.4 ! root 38: void CallbackVT(Event *);
! 39: void CallbackRT(Event *);
1.1 root 40: void ChangeInterrupt();
41:
42: // アラーム開始。
43: void StartAlarm();
44:
45: // 現在時刻取得
46: uint64 Now() const;
47:
48: // TIMER レジスタ読み出し値。(アラームの基準点としても使う)
49: uint64 elapsed {};
50:
51: // アラーム予定時刻 (0 ならアラームなし)
52: uint64 alarm {};
53:
54: // 先に書き込まれた上位側を一旦保持しておくところ。
55: uint64 alarm_high {};
56:
57: bool sync_rt {};
58:
59: // 実時間同期用
60: uint64 mtime_epoch {}; // 調整実時間軸の起点(仮想時刻)
1.1.1.3 root 61: uint64 mtime {}; // 自身の調整実時間。(mtime_epoch からの経過時間)
1.1 root 62:
63: bool intr_enable {}; // 割り込み許可
64: bool intr_assert {}; // 割り込み発生
65:
1.1.1.4 ! root 66: Event *event {};
1.1 root 67:
1.1.1.3 root 68: Monitor *monitor {};
1.1 root 69:
70: GFRTCDevice *gfrtc {};
71: InterruptDevice *interrupt {};
72: Syncer *syncer {};
73: };
74:
75: static inline GFTimerDevice *GetGFTimerDevice() {
76: return Object::GetObject<GFTimerDevice>(OBJ_GFTIMER);
77: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.