Annotation of nono/vm/sram.h, revision 1.1.1.13

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: 
1.1.1.8   root        7: //
                      8: // SRAM
                      9: //
                     10: 
1.1       root       11: #pragma once
                     12: 
                     13: #include "device.h"
1.1.1.3   root       14: #include "mappedfile.h"
1.1.1.10  root       15: #include <array>
1.1       root       16: 
1.1.1.7   root       17: class SRAMDevice : public IODevice
1.1       root       18: {
1.1.1.3   root       19:        using inherited = IODevice;
1.1.1.8   root       20: 
1.1       root       21:        static const uint32 baseaddr = 0xed0000;
                     22: 
1.1.1.12  root       23:        // サイズは (今のところ?) 16KB 固定。
                     24:        static const uint sramsize = 16 * 1024;
                     25: 
1.1.1.3   root       26:        // Pluto-X によるホストファイル起動アドレス
                     27:        static const uint32 plutoaddr = 0xeac000;
                     28: 
1.1       root       29:  public:
                     30:        SRAMDevice();
1.1.1.11  root       31:        ~SRAMDevice() override;
1.1       root       32: 
1.1.1.3   root       33:        bool Init() override;
1.1.1.8   root       34:        void ResetHard(bool poweron) override;
1.1       root       35: 
1.1.1.12  root       36:        busdata Read(busaddr addr) override;
                     37:        busdata Write(busaddr addr, uint32 data) override;
                     38:        busdata Peek1(uint32 addr) override;
                     39:        bool Poke1(uint32 addr, uint32 data) override;
1.1       root       40: 
1.1.1.10  root       41:        void WriteEnable(bool value);
1.1.1.11  root       42:        bool IsWriteable() const { return writeable; }
1.1.1.10  root       43: 
                     44:        // SRAM $ed0008.L RAM 容量を返す (ホストファイル起動用)
                     45:        uint32 GetRAMSize() const { return Get32(0x0008); }
1.1       root       46: 
1.1.1.9   root       47:        // SRAM $ed000c.L ROM 起動アドレスを返す (romemu 用)
1.1.1.10  root       48:        uint32 GetROMAddr() const { return Get32(0x000c); }
                     49: 
1.1       root       50:  private:
1.1.1.12  root       51:        // SRAM の指定の位置の値を副作用なく読み出す
                     52:        uint32 Get16(uint32 offset) const;
                     53:        uint32 Get32(uint32 offset) const;
                     54: 
1.1.1.9   root       55:        // RAM 容量欄を設定値に同期させる。
                     56:        void SyncRAMSize();
                     57: 
1.1.1.2   root       58:        // アドレスデコーダ
1.1.1.11  root       59:        uint32 Decoder(uint32 addr) const;
1.1.1.2   root       60: 
1.1.1.3   root       61:        // ファイル
                     62:        std::string filename {};
1.1.1.12  root       63:        std::unique_ptr<MappedFile> file {};
1.1.1.3   root       64:        uint8 *mem {};
1.1       root       65: 
1.1.1.4   root       66:        bool writeable {};
1.1.1.13! root       67: 
        !            68:        // SRAM の初期値
        !            69:        static std::array<uint8, 0x58> initialdata;
1.1       root       70: };
                     71: 
1.1.1.10  root       72: static inline SRAMDevice *GetSRAMDevice() {
                     73:        return Object::GetObject<SRAMDevice>(OBJ_SRAM);
                     74: }

unix.superglobalmegacorp.com

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