|
|
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.10! root 9: #include "rom.h"
1.1 root 10:
1.1.1.10! root 11: class LunaPROMEmuDevice : public ROMDevice
1.1 root 12: {
1.1.1.10! root 13: using inherited = ROMDevice;
1.1 root 14:
1.1.1.7 root 15: protected:
1.1 root 16: // このデバイス先頭アドレス
17: static const uint32 baseaddr = 0x41000000;
18:
19: // 謎の I/O 空間
1.1.1.2 root 20: static const uint32 ROMIO_BASE = 0x41010000;
21: static const uint32 ROMIO_INIT = (ROMIO_BASE + 0);
22: static const uint32 ROMIO_KEYIN = (ROMIO_BASE + 4);
23: static const uint32 ROMIO_CLOSE = (ROMIO_BASE + 8);
1.1.1.6 root 24: static const uint32 ROMIO_ENTRY = (ROMIO_BASE + 12);
1.1 root 25:
1.1.1.9 root 26: // 文字コード
27: // 概ね ASCII だが制御コード部分は必要な文字だけを適当に割り当てる。
28: static const char BS = 0x08;
29: static const char LF = 0x0a;
30: static const char UP = 0x1c;
31: static const char LEFT = 0x1d;
32: static const char RIGHT = 0x1e;
33: static const char DOWN = 0x1f;
34:
1.1.1.7 root 35: // ブート情報格納用
36: struct bootinfo_t {
37: int dkunit {};
38: int dkpart {};
39: std::string dkfile {};
40: };
41:
1.1 root 42: public:
43: LunaPROMEmuDevice();
1.1.1.5 root 44: virtual ~LunaPROMEmuDevice() override;
1.1 root 45:
1.1.1.2 root 46: bool Init() override;
1.1 root 47:
1.1.1.2 root 48: uint64 Read32(uint32 addr) override;
1.1 root 49:
1.1.1.7 root 50: protected:
51: virtual uint32 ROM_Init() = 0;
52: virtual uint32 ROM_Entry() = 0;
53: virtual void ROM_Close();
1.1.1.9 root 54: virtual void GetChar(char);
1.1.1.7 root 55: virtual void Command() = 0;
1.1 root 56:
1.1.1.7 root 57: void InitDevice();
58: void InitScreen(const char *machine_name);
1.1.1.9 root 59: void ClearPrompt();
1.1.1.2 root 60: void ConsoleUpdate();
1.1.1.9 root 61:
62: // NVRAM
63: uint8 CalcNVRAMCsum() const;
64: void WriteNVRAMCsum();
65: bool VerifyNVRAM() const;
66:
1.1 root 67: uint32 LoadHostFile();
1.1.1.7 root 68: uint32 LoadGuestFile(const bootinfo_t&);
1.1.1.2 root 69:
1.1 root 70: // エラーメッセージの受け渡し用
71: // 基本的にエラーが起きた時だけ更新するので、ここにエラーメッセージを
72: // 返す可能性がある関数をコールする前に呼び出し側が clear() しておき、
73: // 関数から戻ったら empty() かどうか確認する、errno みたいな使い方。
1.1.1.4 root 74: std::string errmsg {};
1.1 root 75:
76: // ROM モニタ用コンソール画面
1.1.1.9 root 77: TextScreen text {};
1.1 root 78:
79: // 入力バッファ
80: std::string inputbuf {};
81:
1.1.1.7 root 82: // 現在のプロンプト文字列
83: std::string prompt {};
1.1 root 84:
1.1.1.9 root 85: // プロンプトのある行(最上行が 0)
86: int prompt_y {};
87:
88: // カーソル位置(入力バッファ先頭が0)
89: int inputpos {};
90:
1.1 root 91: // NVRAM
92: // 本来他デバイスはすべてグローバル参照できるのだが、LUNA の NVRAM は
93: // RTC と兼用になっていて、RTCDevice *gRTC として見えるので
94: // MK48T02Device にするには dynamic_cast する必要がある。
1.1.1.4 root 95: MK48T02Device *nvram {};
1.1 root 96:
1.1.1.7 root 97: private:
98: // キー入力
99: void ROM_Keyin();
100:
101: bool is_shift {}; // SHIFT キー押し下げ中
102: int mousecnt {}; // マウス入力をスキップするためのカウンタ
103:
1.1 root 104: // LUNA キーコード -> ASCII 変換テーブル
105: static const uint8 lunakey2asciitable[128];
106: static const uint8 lunakey2shifttable[128];
107: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.