--- nono/vm/sysclk.h 2026/04/29 17:04:50 1.1.1.6 +++ nono/vm/sysclk.h 2026/04/29 17:05:10 1.1.1.8 @@ -4,13 +4,16 @@ // Licensed under nono-license.txt // +// +// LUNA システムクロック +// + #pragma once -#include "device.h" -#include "scheduler.h" +#include "event.h" +#include "monitor.h" -class SysClkDevice - : public IODevice +class SysClkDevice : public IODevice { using inherited = IODevice; public: @@ -18,7 +21,7 @@ class SysClkDevice virtual ~SysClkDevice() override; bool Init() override; - bool PowerOn() override; + void ResetHard(bool poweron) override; protected: // BusIO インタフェース @@ -31,6 +34,8 @@ class SysClkDevice // イベントコールバック void Callback(Event& ev); + DECLARE_MONITOR_CALLBACK(MonitorUpdate); + // 割り込み状態をレジスタイメージにして返す uint8 GetInt() const; @@ -38,7 +43,18 @@ class SysClkDevice bool sysint {}; // 割り込みイベント - Event event {}; + Event event { this }; + + // 本来のイベント間隔。機種によって異なる。 + uint period {}; + + // システムクロックが刻んでいる時刻 + uint64 stime {}; + + // システムクロックを実時間に同期する場合 true + bool sync_rt {}; + + Monitor monitor { this }; }; -extern std::unique_ptr gSysClk; +extern SysClkDevice *gSysClk;