Annotation of nono/vm/mk48t02.h, revision 1.1.1.4

1.1       root        1: //
                      2: // nono
1.1.1.3   root        3: // Copyright (C) 2020 nono project
                      4: // Licensed under nono-license.txt
1.1       root        5: //
                      6: 
                      7: #pragma once
                      8: 
                      9: #include "device.h"
1.1.1.3   root       10: #include "mappedfile.h"
1.1       root       11: #include "rtc.h"
                     12: 
                     13: // MK48T02 の時計部分のレジスタと内部状態
                     14: struct MK48T02Clock
                     15: {
                     16:        // コントロールレジスタは以下の3つを保持。
                     17:        uint8 ctrl;
                     18:        static const uint8 WRITE        = 0x80; // WRITE BIT
                     19:        static const uint8 READ         = 0x40; // READ BIT
                     20:        static const uint8 SIGN         = 0x20; // SIGN BIT (?)
                     21: 
                     22:        // 秒カウンタ(BCD)
                     23:        uint8 sec;
                     24:        // 秒カウンタの bit7 が STOP ビット
                     25:        static const uint8 STOP         = 0x80;
                     26:        // STOP 状態を保持
                     27:        bool stop;
                     28: 
                     29:        // 分カウンタ(BCD)
                     30:        uint8 min;
                     31: 
                     32:        // 時カウンタ(BCD)
                     33:        uint8 hour;
                     34:        // 時カウンタの bit7 が KICKSTART ビット
                     35:        static const uint8 KICKSTART    = 0x80;
                     36:        // KICKSTART 状態を保持
                     37:        bool kickstart;
                     38: 
                     39:        // 曜日カウンタ
                     40:        uint8 wday;
                     41:        static const uint8 FREQTEST             = 0x40; // Frequency Test (未実装)
                     42: 
                     43:        // 日カウンタ
                     44:        uint8 mday;
                     45:        // 月カウンタ
                     46:        uint8 mon;
                     47:        // 年カウンタ (0 が 1970年)
                     48:        uint8 year;
                     49:        static const int YEAR_EPOCH = 1970;
                     50: };
                     51: 
                     52: class MK48T02Device : public RTCDevice
                     53: {
1.1.1.3   root       54:        using inherited = RTCDevice;
1.1       root       55:  public:
                     56:        MK48T02Device();
1.1.1.3   root       57:        ~MK48T02Device() override;
1.1       root       58: 
1.1.1.3   root       59:        bool Init() override;
                     60:        bool InitRTC() override;
1.1       root       61: 
1.1.1.4 ! root       62:        void MonitorUpdate(TextScreen&) override;
1.1       root       63: 
1.1.1.3   root       64:        void ClockIn() override;
1.1       root       65: 
1.1.1.2   root       66:        // 指定したアドレスからの文字列を読み出す (内蔵 ROM からのアクセス用)
                     67:        std::string PeekString(uint32 addr) const;
                     68:        // 指定したアドレスに文字列を書き込む (内蔵 ROM からのアクセス用)
                     69:        bool WriteString(uint32 addr, const std::string& data);
                     70: 
                     71:        // BusIO インタフェース
                     72:        // (内蔵 ROM からのアクセス用に特別に public にしてある)
                     73:        uint64 Read(uint32 addr);
                     74:        uint64 Write(uint32 addr, uint32 data);
                     75:        uint64 Peek(uint32 addr);
                     76:  protected:
                     77:        // BusIO インタフェース
                     78:        static const uint32 NPORT = 2048;
                     79: 
1.1       root       80:  private:
                     81:        // バイナリ <-> BCD 変換
                     82:        static inline uint8 num2BCD(uint8);
                     83:        static inline uint8 BCD2num(uint8);
                     84: 
                     85:        // コントロールレジスタへの書き込み
                     86:        void WriteCtrl(uint32 data);
                     87: 
1.1.1.3   root       88:        // ファイル
1.1       root       89:        std::string filename {};
1.1.1.3   root       90:        MappedFile file {};
                     91:        uint8 *mem {};
1.1       root       92: 
                     93:        // 時計
                     94:        MK48T02Clock reg {};
                     95: 
                     96:        // レジスタとして読める値を定数にすることで、仮想マシン状態を
                     97:        // 常に同じ状態にするためのパフォーマンス測定用フラグ。
                     98:        // なお NVRAM 部分は影響されない。
                     99:        bool force_fixed = false;
                    100: };

unix.superglobalmegacorp.com

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