|
|
1.1 root 1: //
2: // nono
1.1.1.3 root 3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
1.1 root 5: //
6:
1.1.1.8 root 7: //
8: // LUNA システムクロック
9: //
10:
1.1 root 11: #pragma once
12:
1.1.1.9 ! root 13: #include "device.h"
1.1.1.8 root 14: #include "event.h"
1.1.1.7 root 15: #include "monitor.h"
1.1 root 16:
1.1.1.9 ! root 17: class InterruptDevice;
! 18:
1.1.1.7 root 19: class SysClkDevice : public IODevice
1.1 root 20: {
1.1.1.3 root 21: using inherited = IODevice;
1.1 root 22: public:
23: SysClkDevice();
1.1.1.5 root 24: virtual ~SysClkDevice() override;
1.1 root 25:
1.1.1.3 root 26: bool Init() override;
1.1.1.8 root 27: void ResetHard(bool poweron) override;
1.1 root 28:
1.1.1.2 root 29: protected:
30: // BusIO インタフェース
31: static const uint32 NPORT = 1;
1.1.1.6 root 32: uint64 Read(uint32 offset);
33: uint64 Write(uint32 offset, uint32 data);
34: uint64 Peek(uint32 offset);
1.1 root 35:
36: private:
37: // イベントコールバック
1.1.1.4 root 38: void Callback(Event& ev);
1.1.1.7 root 39:
40: DECLARE_MONITOR_CALLBACK(MonitorUpdate);
1.1 root 41:
1.1.1.2 root 42: // 割り込み状態をレジスタイメージにして返す
43: uint8 GetInt() const;
44:
1.1 root 45: // システムクロック割り込み有りなら true。
1.1.1.4 root 46: bool sysint {};
1.1 root 47:
48: // 割り込みイベント
1.1.1.7 root 49: Event event { this };
50:
51: // 本来のイベント間隔。機種によって異なる。
52: uint period {};
53:
54: // システムクロックが刻んでいる時刻
55: uint64 stime {};
56:
57: // システムクロックを実時間に同期する場合 true
58: bool sync_rt {};
59:
1.1.1.9 ! root 60: InterruptDevice *interrupt {};
! 61:
1.1.1.7 root 62: Monitor monitor { this };
1.1 root 63: };
1.1.1.5 root 64:
1.1.1.9 ! root 65: static inline SysClkDevice *GetSysClkDevice() {
! 66: return Object::GetObject<SysClkDevice>(OBJ_SYSCLK);
! 67: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.