Annotation of nono/vm/goldfish_rtc.h, revision 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 (の 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:
        !            21:        static const uint TIME_LOW              = 0x00;
        !            22:        static const uint TIME_HIGH             = 0x04;
        !            23:        static const uint ALARM_LOW             = 0x08;
        !            24:        static const uint ALARM_HIGH    = 0x0c;
        !            25:        static const uint INTR_STATUS   = 0x10;
        !            26:        static const uint ALARM_CLEAR   = 0x14;
        !            27:        static const uint ALARM_STATUS  = 0x18;
        !            28:        static const uint INTR_CLEAR    = 0x1c;
        !            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:        busdata Read32(uint32 addr) override;
        !            43:        busdata Write32(uint32 addr, uint32 data) override;
        !            44:        busdata Peek8(uint32 addr) override;
        !            45: 
        !            46:        // モニタの下請け。(GFTimer から呼ばれる)
        !            47:        int MonitorUpdateRTC(TextScreen&, int y) const;
        !            48: 
        !            49:  private:
        !            50:        void Tick1Hz() override;
        !            51: 
        !            52:        time_t MkTime() const;
        !            53: 
        !            54:        uint GetSec()  const override { return sec; }
        !            55:        uint GetMin()  const override { return min; }
        !            56:        uint GetHour() const override { return hour; }
        !            57:        uint GetWday() const override;
        !            58:        uint GetMday() const override { return day; }
        !            59:        uint GetMon()  const override { return mon; }
        !            60:        uint GetYear() const override { return year; }
        !            61:        uint GetLeap() const override { return year % 4; }
        !            62: 
        !            63:        void SetSec(uint v)  override { sec = v; }
        !            64:        void SetMin(uint v)  override { min = v; }
        !            65:        void SetHour(uint v) override { hour = v; }
        !            66:        void SetWday(uint v) override { }
        !            67:        void SetMday(uint v) override { day = v; }
        !            68:        void SetMon(uint v)  override { mon = v; }
        !            69:        void SetYear(uint v) override { year = v; }
        !            70:        void SetLeap(uint v) override { }
        !            71: 
        !            72:        // 現在時刻
        !            73:        uint year;      // 西暦 (ゲタなし)
        !            74:        uint mon;       // 月 (1-12)
        !            75:        uint day;
        !            76:        uint hour;
        !            77:        uint min;
        !            78:        uint sec;
        !            79: 
        !            80:        // TIME レジスタラッチ
        !            81:        uint64 time_nsec {};
        !            82: };

unix.superglobalmegacorp.com

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