--- nono/vm/sysclk.h 2026/04/29 17:04:32 1.1.1.2 +++ nono/vm/sysclk.h 2026/04/29 17:04:56 1.1.1.7 @@ -1,40 +1,58 @@ // // nono -// Copyright (C) 2018 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt // #pragma once #include "device.h" +#include "monitor.h" #include "scheduler.h" -class SysClkDevice - : public IODevice +class SysClkDevice : public IODevice { - typedef IODevice inherited; + using inherited = IODevice; public: SysClkDevice(); - virtual ~SysClkDevice(); + virtual ~SysClkDevice() override; - virtual bool PowerOn(); + bool Init() override; + bool PowerOn() override; protected: // BusIO インタフェース static const uint32 NPORT = 1; - uint64 Read(uint32); - uint64 Write(uint32, uint32); - uint64 Peek(uint32); + uint64 Read(uint32 offset); + uint64 Write(uint32 offset, uint32 data); + uint64 Peek(uint32 offset); private: // イベントコールバック - void Callback(int); + void Callback(Event& ev); + void Callback_rt(Event& ev); + + DECLARE_MONITOR_CALLBACK(MonitorUpdate); // 割り込み状態をレジスタイメージにして返す uint8 GetInt() const; // システムクロック割り込み有りなら true。 - bool sysint = false; + bool sysint {}; // 割り込みイベント - Event event {}; + Event event { this }; + + // 本来のイベント間隔。機種によって異なる。 + uint period {}; + + // システムクロックが刻んでいる時刻 + uint64 stime {}; + + // システムクロックを実時間に同期する場合 true + bool sync_rt {}; + + Monitor monitor { this }; }; + +extern std::unique_ptr gSysClk;