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