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

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.6   root       57:        virtual ~MK48T02Device() override;
1.1       root       58: 
1.1.1.3   root       59:        bool Init() override;
1.1.1.4   root       60:        void MonitorUpdate(TextScreen&) override;
1.1       root       61: 
1.1.1.3   root       62:        void ClockIn() override;
1.1       root       63: 
1.1.1.2   root       64:        // 指定したアドレスからの文字列を読み出す (内蔵 ROM からのアクセス用)
                     65:        std::string PeekString(uint32 addr) const;
                     66:        // 指定したアドレスに文字列を書き込む (内蔵 ROM からのアクセス用)
                     67:        bool WriteString(uint32 addr, const std::string& data);
                     68: 
                     69:        // BusIO インタフェース
                     70:        // (内蔵 ROM からのアクセス用に特別に public にしてある)
1.1.1.7   root       71:        uint64 Read(uint32 offset);
                     72:        uint64 Write(uint32 offset, uint32 data);
                     73:        uint64 Peek(uint32 offset);
                     74: 
1.1.1.2   root       75:  protected:
                     76:        // BusIO インタフェース
                     77:        static const uint32 NPORT = 2048;
                     78: 
1.1       root       79:  private:
                     80:        // バイナリ <-> BCD 変換
                     81:        static inline uint8 num2BCD(uint8);
                     82:        static inline uint8 BCD2num(uint8);
                     83: 
                     84:        // コントロールレジスタへの書き込み
                     85:        void WriteCtrl(uint32 data);
                     86: 
1.1.1.3   root       87:        // ファイル
1.1       root       88:        std::string filename {};
1.1.1.3   root       89:        MappedFile file {};
                     90:        uint8 *mem {};
1.1       root       91: 
                     92:        // 時計
                     93:        MK48T02Clock reg {};
                     94: 
                     95:        // レジスタとして読める値を定数にすることで、仮想マシン状態を
                     96:        // 常に同じ状態にするためのパフォーマンス測定用フラグ。
                     97:        // なお NVRAM 部分は影響されない。
1.1.1.5   root       98:        bool force_fixed {};
1.1       root       99: };

unix.superglobalmegacorp.com

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