Annotation of nono/vm/goldfish_rtc.h, revision 1.1.1.2

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 (の RTC のほう)
                      9: //
                     10: 
                     11: #pragma once
                     12: 
                     13: #include "rtc.h"
                     14: 
                     15: class TextScreen;
                     16: 
                     17: // GFRTC/GFTimer 共通
                     18: class GFRTC
                     19: {
                     20:  public:
1.1.1.2 ! root       21:        static const uint TIME_LOW              = 0x00U >> 2;
        !            22:        static const uint TIME_HIGH             = 0x04U >> 2;
        !            23:        static const uint ALARM_LOW             = 0x08U >> 2;
        !            24:        static const uint ALARM_HIGH    = 0x0cU >> 2;
        !            25:        static const uint INTR_STATUS   = 0x10U >> 2;
        !            26:        static const uint ALARM_CLEAR   = 0x14U >> 2;
        !            27:        static const uint ALARM_STATUS  = 0x18U >> 2;
        !            28:        static const uint INTR_CLEAR    = 0x1cU >> 2;
1.1       root       29: };
                     30: 
                     31: class GFRTCDevice : public RTCDevice
                     32: {
                     33:        using inherited = RTCDevice;
                     34: 
                     35:  public:
                     36:        GFRTCDevice();
                     37:        ~GFRTCDevice() override;
                     38: 
                     39:        bool Init() override;
                     40:        void ResetHard(bool poweron) override;
                     41: 
                     42:        // モニタの下請け。(GFTimer から呼ばれる)
                     43:        int MonitorUpdateRTC(TextScreen&, int y) const;
                     44: 
1.1.1.2 ! root       45:  protected:
        !            46:        // BusIO インタフェース
        !            47:        static const uint32 NPORT = 0x1000 >> 2;
        !            48:        busdata ReadPort(uint32 offset);
        !            49:        busdata WritePort(uint32 offset, uint32 data);
        !            50:        busdata PeekPort(uint32 offset);
        !            51: 
1.1       root       52:  private:
                     53:        void Tick1Hz() override;
                     54: 
                     55:        time_t MkTime() const;
                     56: 
                     57:        uint GetSec()  const override { return sec; }
                     58:        uint GetMin()  const override { return min; }
                     59:        uint GetHour() const override { return hour; }
                     60:        uint GetWday() const override;
                     61:        uint GetMday() const override { return day; }
                     62:        uint GetMon()  const override { return mon; }
                     63:        uint GetYear() const override { return year; }
                     64:        uint GetLeap() const override { return year % 4; }
                     65: 
                     66:        void SetSec(uint v)  override { sec = v; }
                     67:        void SetMin(uint v)  override { min = v; }
                     68:        void SetHour(uint v) override { hour = v; }
                     69:        void SetWday(uint v) override { }
                     70:        void SetMday(uint v) override { day = v; }
                     71:        void SetMon(uint v)  override { mon = v; }
                     72:        void SetYear(uint v) override { year = v; }
                     73:        void SetLeap(uint v) override { }
                     74: 
                     75:        // 現在時刻
                     76:        uint year;      // 西暦 (ゲタなし)
                     77:        uint mon;       // 月 (1-12)
                     78:        uint day;
                     79:        uint hour;
                     80:        uint min;
                     81:        uint sec;
                     82: 
                     83:        // TIME レジスタラッチ
                     84:        uint64 time_nsec {};
                     85: };

unix.superglobalmegacorp.com

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