|
|
1.1 root 1: //
2: // nono
1.1.1.2 ! root 3: // Copyright (C) 2020 nono project
! 4: // Licensed under nono-license.txt
1.1 root 5: //
6:
7: #pragma once
8:
1.1.1.2 ! root 9: #include "device.h"
1.1 root 10:
1.1.1.2 ! root 11: class LunaPROMEmuDevice : public IODevice
1.1 root 12: {
1.1.1.2 ! root 13: using inherited = IODevice;
1.1 root 14:
15: // このデバイス先頭アドレス
16: static const uint32 baseaddr = 0x41000000;
17:
18: // 謎の I/O 空間
1.1.1.2 ! root 19: static const uint32 ROMIO_BASE = 0x41010000;
! 20: static const uint32 ROMIO_INIT = (ROMIO_BASE + 0);
! 21: static const uint32 ROMIO_KEYIN = (ROMIO_BASE + 4);
! 22: static const uint32 ROMIO_CLOSE = (ROMIO_BASE + 8);
1.1 root 23:
24: public:
25: LunaPROMEmuDevice();
1.1.1.2 ! root 26: ~LunaPROMEmuDevice() override;
1.1 root 27:
1.1.1.2 ! root 28: bool Init() override;
! 29: void ResetHard() override;
1.1 root 30:
1.1.1.2 ! root 31: uint64 Read8(uint32 addr) override;
! 32: uint64 Read16(uint32 addr) override;
! 33: uint64 Read32(uint32 addr) override;
! 34: uint64 Write8(uint32 addr, uint32 data) override;
! 35: uint64 Write16(uint32 addr, uint32 data) override;
! 36: uint64 Write32(uint32 addr, uint32 data) override;
! 37: uint64 Peek8(uint32 addr) override;
1.1 root 38:
39: private:
40: uint64 Decoder(uint32 addr) const;
41:
1.1.1.2 ! root 42: uint32 ROM_Init();
! 43: uint32 ROM_Close();
! 44: uint32 ROM_Keyin();
! 45: void ConsoleUpdate();
! 46: uint32 Command();
! 47: void CommandG(const std::vector<std::string>& arg);
! 48: void CommandGH();
1.1 root 49: uint32 LoadHostFile();
1.1.1.2 ! root 50: void CommandK(const std::vector<std::string>& arg);
1.1 root 51: bool CommandKInput(const std::string& val);
1.1.1.2 ! root 52: uint32 CommandX();
! 53:
! 54: std::unique_ptr<uint8[]> romdata;
1.1 root 55:
56: // NVRAM
57: uint8 CalcNVRAMCsum();
58: void WriteNVRAMCsum();
59: bool VerifyNVRAM();
60: bool InitNVRAM();
61:
62: // NVRAM の設定に従って起動
63: uint32 LoadByNVRAM(const std::string& fname);
64:
1.1.1.2 ! root 65: // 内蔵 ROM 使用後はアクセスできないようにするため
! 66: bool is_closed = false;
! 67:
1.1 root 68: // 'g' コマンドで読み込んだプログラムのエントリポイント。
69: // なければ 0。'x' コマンドで使う。
70: uint32 entrypoint;
71: // エラーメッセージの受け渡し用
72: // 基本的にエラーが起きた時だけ更新するので、ここにエラーメッセージを
73: // 返す可能性がある関数をコールする前に呼び出し側が clear() しておき、
74: // 関数から戻ったら empty() かどうか確認する、errno みたいな使い方。
75: std::string errmsg;
76:
77: // ROM モニタ用コンソール画面
78: TextScreen text;
79:
80: // 入力バッファ
81: std::string inputbuf {};
82: int inputpos {}; // カーソル位置
83: bool is_shift; // SHIFT キー押し下げ中
84:
85: // プロンプトと入力モード
86: std::string prompt {}; // 現在のプロンプト文字列
87: // プロンプトの状態。
88: // 0 が通常プロンプト。
89: // 1 以降は k コマンドのプロンプトを示す
90: int prompt_idx {};
91: const std::string default_prompt = ">"; // デフォルトプロンプト
92:
93: // NVRAM
94: // 本来他デバイスはすべてグローバル参照できるのだが、LUNA の NVRAM は
95: // RTC と兼用になっていて、RTCDevice *gRTC として見えるので
96: // MK48T02Device にするには dynamic_cast する必要がある。
97: MK48T02Device *nvram;
98:
99: // LUNA キーコード -> ASCII 変換テーブル
100: static const uint8 lunakey2asciitable[128];
101: static const uint8 lunakey2shifttable[128];
102: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.