|
|
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 <array>
15:
16: class BankRAMDevice;
17: class NereidBoardDevice;
18: class RTL8019ASDevice;
19:
20: // Nereid 空間担当
21: class NereidDevice : public IODevice
22: {
23: using inherited = IODevice;
24:
25: public:
26: NereidDevice();
27: ~NereidDevice() override;
28:
29: bool Create() override;
30:
1.1.1.3 root 31: busdata Read(busaddr addr) override;
32: busdata Write(busaddr addr, uint32 data) override;
33: busdata Peek1(uint32 addr) override;
1.1 root 34:
35: // Nereid が1枚でもささっていれば true。
36: bool IsInstalled() const;
37:
1.1.1.2 root 38: // Board デバイス取得。
39: NereidBoardDevice *GetBoard(int id) const { return boards[id].get(); }
40:
1.1 root 41: private:
42: inline uint32 Decoder(uint32 addr) const;
1.1.1.5 ! root 43: DECLARE_MONITOR_SCREEN(MonitorScreen);
1.1 root 44:
45: // ボードの有無と配置場所 (有りなら $3 か $b、無しなら -1)
46: std::array<int, 2> loc {};
47:
48: std::array<std::unique_ptr<NereidBoardDevice>, 2> boards {};
49:
1.1.1.4 root 50: Monitor *monitor {};
1.1 root 51: };
52:
53: // Nereid ボード1枚分
54: class NereidBoardDevice : public IODevice
55: {
56: using inherited = IODevice;
57:
58: public:
1.1.1.3 root 59: explicit NereidBoardDevice(int n_);
1.1 root 60: ~NereidBoardDevice() override;
61:
62: bool Create() override;
63:
1.1.1.3 root 64: busdata Read(busaddr addr) override;
65: busdata Write(busaddr addr, uint32 data) override;
66: busdata Peek1(uint32 addr) override;
1.1 root 67:
68: // ネットワークが有効なら true を返す
69: bool IsNetEnable() const { return (bool)net; }
70: // バンクメモリの容量 [MB] を返す (負数の場合もあり)
71: int GetBankRAMSize() const { return ramsize_MB; }
72:
73: uint32 GetPage() const;
74:
75: private:
76: inline uint32 Decoder(uint32 addr) const;
77:
78: void SetPage(uint32 data);
79:
80: uint32 GetCtrl() const;
81: void SetCtrl(uint32 data);
82:
83: // 1枚目 or 2枚目
84: uint id {};
85:
86: // バンクメモリ容量 (負数あり)
87: int ramsize_MB {};
88:
89: // デバイス
90: std::unique_ptr<BankRAMDevice> bank /*{}*/;
91: std::unique_ptr<RTL8019ASDevice> net /*{}*/;
92: };
93:
1.1.1.5 ! root 94: inline NereidDevice *GetNereidDevice() {
1.1 root 95: return Object::GetObject<NereidDevice>(OBJ_NEREID);
96: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.