--- nono/vm/romemu_luna.h 2026/04/29 17:04:32 1.1 +++ nono/vm/romemu_luna.h 2026/04/29 17:04:36 1.1.1.2 @@ -1,47 +1,57 @@ // // nono -// Copyright (C) 2020 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt // #pragma once -#include "romimg_luna.h" +#include "device.h" -class LunaPROMEmuDevice : public PROMDevice +class LunaPROMEmuDevice : public IODevice { - typedef PROMDevice inherited; + using inherited = IODevice; // このデバイス先頭アドレス static const uint32 baseaddr = 0x41000000; // 謎の I/O 空間 - static const uint32 ROMIO_BASE = 0x41010000; - static const uint32 ROMIO_IPL_INIT = (ROMIO_BASE + 0); - static const uint32 ROMIO_IPL_PROMPT = (ROMIO_BASE + 4); - static const uint32 ROMIO_IPL_CLOSE = (ROMIO_BASE + 8); + static const uint32 ROMIO_BASE = 0x41010000; + static const uint32 ROMIO_INIT = (ROMIO_BASE + 0); + static const uint32 ROMIO_KEYIN = (ROMIO_BASE + 4); + static const uint32 ROMIO_CLOSE = (ROMIO_BASE + 8); public: LunaPROMEmuDevice(); - virtual ~LunaPROMEmuDevice(); + ~LunaPROMEmuDevice() override; - virtual bool Init(); - virtual void ResetHard(); + bool Init() override; + void ResetHard() override; - virtual uint64 Read32(uint32 addr); + uint64 Read8(uint32 addr) override; + uint64 Read16(uint32 addr) override; + uint64 Read32(uint32 addr) override; + uint64 Write8(uint32 addr, uint32 data) override; + uint64 Write16(uint32 addr, uint32 data) override; + uint64 Write32(uint32 addr, uint32 data) override; + uint64 Peek8(uint32 addr) override; private: uint64 Decoder(uint32 addr) const; - uint32 IPL_Init(); - uint32 IPL_Close(); - uint32 IPL_Prompt(); - uint32 IPL_Command(); - void IPL_CommandG(const std::vector& arg); - void IPL_CommandGH(); + uint32 ROM_Init(); + uint32 ROM_Close(); + uint32 ROM_Keyin(); + void ConsoleUpdate(); + uint32 Command(); + void CommandG(const std::vector& arg); + void CommandGH(); uint32 LoadHostFile(); - void IPL_CommandK(const std::vector& arg); + void CommandK(const std::vector& arg); bool CommandKInput(const std::string& val); - uint32 IPL_CommandX(); + uint32 CommandX(); + + std::unique_ptr romdata; // NVRAM uint8 CalcNVRAMCsum(); @@ -52,8 +62,9 @@ class LunaPROMEmuDevice : public PROMDev // NVRAM の設定に従って起動 uint32 LoadByNVRAM(const std::string& fname); - // 状態マシン - int ipl_state {}; + // 内蔵 ROM 使用後はアクセスできないようにするため + bool is_closed = false; + // 'g' コマンドで読み込んだプログラムのエントリポイント。 // なければ 0。'x' コマンドで使う。 uint32 entrypoint;