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