Annotation of nono/vm/nereid.h, revision 1.1.1.3

1.1       root        1: //
                      2: // nono
                      3: // Copyright (C) 2023 nono project
                      4: // Licensed under nono-license.txt
                      5: //
                      6: 
                      7: //
                      8: // Nereid Ethernet/メモリ/USB 複合ボード (のうち Ethernet/バンクメモリ)
                      9: //
                     10: 
                     11: #pragma once
                     12: 
                     13: #include "device.h"
                     14: #include "monitor.h"
                     15: #include <array>
                     16: 
                     17: class BankRAMDevice;
                     18: class NereidBoardDevice;
                     19: class RTL8019ASDevice;
                     20: 
                     21: // Nereid 空間担当
                     22: class NereidDevice : public IODevice
                     23: {
                     24:        using inherited = IODevice;
                     25: 
                     26:  public:
                     27:        NereidDevice();
                     28:        ~NereidDevice() override;
                     29: 
                     30:        bool Create() override;
                     31: 
1.1.1.3 ! root       32:        busdata Read(busaddr addr) override;
        !            33:        busdata Write(busaddr addr, uint32 data) override;
        !            34:        busdata Peek1(uint32 addr) override;
1.1       root       35: 
                     36:        // Nereid が1枚でもささっていれば true。
                     37:        bool IsInstalled() const;
                     38: 
1.1.1.2   root       39:        // Board デバイス取得。
                     40:        NereidBoardDevice *GetBoard(int id) const { return boards[id].get(); }
                     41: 
1.1       root       42:  private:
                     43:        inline uint32 Decoder(uint32 addr) const;
                     44:        DECLARE_MONITOR_CALLBACK(MonitorUpdate);
                     45: 
                     46:        // ボードの有無と配置場所 (有りなら $3 か $b、無しなら -1)
                     47:        std::array<int, 2> loc {};
                     48: 
                     49:        std::array<std::unique_ptr<NereidBoardDevice>, 2> boards {};
                     50: 
                     51:        Monitor monitor { this };
                     52: };
                     53: 
                     54: // Nereid ボード1枚分
                     55: class NereidBoardDevice : public IODevice
                     56: {
                     57:        using inherited = IODevice;
                     58: 
                     59:  public:
1.1.1.3 ! root       60:        explicit NereidBoardDevice(int n_);
1.1       root       61:        ~NereidBoardDevice() override;
                     62: 
                     63:        bool Create() override;
                     64: 
1.1.1.3 ! root       65:        busdata Read(busaddr addr) override;
        !            66:        busdata Write(busaddr addr, uint32 data) override;
        !            67:        busdata Peek1(uint32 addr) override;
1.1       root       68: 
                     69:        // ネットワークが有効なら true を返す
                     70:        bool IsNetEnable() const { return (bool)net; }
                     71:        // バンクメモリの容量 [MB] を返す (負数の場合もあり)
                     72:        int GetBankRAMSize() const { return ramsize_MB; }
                     73: 
                     74:        uint32 GetPage() const;
                     75: 
                     76:  private:
                     77:        inline uint32 Decoder(uint32 addr) const;
                     78: 
                     79:        void SetPage(uint32 data);
                     80: 
                     81:        uint32 GetCtrl() const;
                     82:        void SetCtrl(uint32 data);
                     83: 
                     84:        // 1枚目 or 2枚目
                     85:        uint id {};
                     86: 
                     87:        // バンクメモリ容量 (負数あり)
                     88:        int ramsize_MB {};
                     89: 
                     90:        // デバイス
                     91:        std::unique_ptr<BankRAMDevice> bank /*{}*/;
                     92:        std::unique_ptr<RTL8019ASDevice> net /*{}*/;
                     93: };
                     94: 
                     95: static inline NereidDevice *GetNereidDevice() {
                     96:        return Object::GetObject<NereidDevice>(OBJ_NEREID);
                     97: }

unix.superglobalmegacorp.com

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