Annotation of nono/vm/goldfish_timer.h, revision 1.1.1.1

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: 
                     30:        busdata Read32(uint32 addr) override;
                     31:        busdata Write32(uint32 addr, uint32 data) override;
                     32:        busdata Peek8(uint32 addr) override;
                     33: 
                     34:  private:
                     35:        DECLARE_MONITOR_CALLBACK(MonitorUpdate);
                     36: 
                     37:        void CallbackVT(Event& ev);
                     38:        void CallbackRT(Event& ev);
                     39:        void ChangeInterrupt();
                     40: 
                     41:        // アラーム開始。
                     42:        void StartAlarm();
                     43: 
                     44:        // 現在時刻取得
                     45:        uint64 Now() const;
                     46: 
                     47:        // TIMER レジスタ読み出し値。(アラームの基準点としても使う)
                     48:        uint64 elapsed {};
                     49: 
                     50:        // アラーム予定時刻 (0 ならアラームなし)
                     51:        uint64 alarm {};
                     52: 
                     53:        // 先に書き込まれた上位側を一旦保持しておくところ。
                     54:        uint64 alarm_high {};
                     55: 
                     56:        bool sync_rt {};
                     57: 
                     58:        // 実時間同期用
                     59:        uint64 mtime_epoch {};  // 調整実時間軸の起点(仮想時刻)
                     60:        uint64 mtime {};                // 自身の調整実時間
                     61: 
                     62:        bool intr_enable {};    // 割り込み許可
                     63:        bool intr_assert {};    // 割り込み発生
                     64: 
                     65:        Event event { this };
                     66: 
                     67:        Monitor monitor { this };
                     68: 
                     69:        GFRTCDevice *gfrtc {};
                     70:        InterruptDevice *interrupt {};
                     71:        Syncer *syncer {};
                     72: };
                     73: 
                     74: static inline GFTimerDevice *GetGFTimerDevice() {
                     75:        return Object::GetObject<GFTimerDevice>(OBJ_GFTIMER);
                     76: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.