--- nono/vm/device.cpp 2026/04/29 17:05:18 1.1.1.9 +++ nono/vm/device.cpp 2026/04/29 17:06:01 1.1.1.14 @@ -17,7 +17,7 @@ // // コンストラクタ -Device::Device(int objid_) +Device::Device(uint objid_) : inherited(objid_) { } @@ -34,16 +34,20 @@ Device::Create() } bool -Device::Init() +Device::Create2() +{ + return true; +} + +void +Device::EarlyInit() { mpu = GetMPUDevice(); scheduler = GetScheduler(); - - return true; } bool -Device::Apply() +Device::Init() { return true; } @@ -69,11 +73,8 @@ Device::putlogn(const char *fmt, ...) co int len; vt = scheduler->GetVirtTime(); - len = snprintf(buf, sizeof(buf), "%4d.%03d'%03d'%03d %08x %s ", - (int)(vt / 1000 / 1000 / 1000), - (int)((vt / 1000 / 1000) % 1000), - (int)((vt / 1000) % 1000), - (int)(vt % 1000), + len = snprintf(buf, sizeof(buf), "%16s %08x %s ", + SecToStr(vt).c_str(), mpu->GetPPC(), GetName().c_str()); @@ -90,7 +91,7 @@ Device::putlogn(const char *fmt, ...) co // // コンストラクタ -IODevice::IODevice(int objid_) +IODevice::IODevice(uint objid_) : inherited(objid_) { } @@ -100,247 +101,50 @@ IODevice::~IODevice() { } -// 初期化 -bool -IODevice::Init() -{ - if (inherited::Init() == false) { - return false; - } - - return true; -} - -uint64 -IODevice::Read8(uint32 addr) -{ - return 0xff; -} - -uint64 -IODevice::Read16(uint32 addr) -{ - return (Read8(addr) << 8) | Read8(addr + 1); -} - -uint64 -IODevice::Read32(uint32 addr) -{ - return (Read16(addr) << 16) | Read16(addr + 2); -} - -uint64 -IODevice::Write8(uint32 addr, uint32 data) -{ - return 0; -} - -uint64 -IODevice::Write16(uint32 addr, uint32 data) +busdata +IODevice::Read(busaddr addr) { - int64 berr; - - berr = Write8(addr, data >> 8); - if (berr < 0) - return berr; - berr = Write8(addr + 1, data & 0xff); - if (berr < 0) - return berr; return 0; } -uint64 -IODevice::Write32(uint32 addr, uint32 data) +busdata +IODevice::Write(busaddr addr, uint32 data) { - int64 berr; - - berr = Write16(addr, data >> 16); - if (berr < 0) - return berr; - berr = Write16(addr + 2, data & 0xffff); - if (berr < 0) - return berr; return 0; } -uint64 -IODevice::Peek8(uint32 addr) -{ - return 0xff; -} - -uint64 -IODevice::Poke8(uint32 addr, uint32 data) -{ - return (uint64)-1; -} - -uint64 -IODevice::Poke(uint32 addr, uint32 data) -{ - return (uint64)-1; -} - - -// -// IOContainerDevice -// - -// コンストラクタ -IOContainerDevice::IOContainerDevice(int objid_) - : inherited(objid_) +busdata +IODevice::ReadBurst16(busaddr addr, uint32 *dst) { + return BusData::BusErr; } -// デストラクタ -IOContainerDevice::~IOContainerDevice() +busdata +IODevice::WriteBurst16(busaddr addr, const uint32 *src) { + return BusData::BusErr; } -// このアドレスを担当する IODevice を再帰的に探して返す。 -IODevice * -IOContainerDevice::FindDevice(uint32 addr) const +busdata +IODevice::Read1(uint32 addr) { - IODevice *d = GetDevice(addr); - IOContainerDevice *cd = dynamic_cast(d); - - if (cd) { - // 次段はコンテナデバイス - return cd->FindDevice(addr); - } else { - // 次段は終端のデバイス - return d; - } -} - - -// -// バスエラー -// - -// コンストラクタ -BusErrDevice::BusErrDevice() - : inherited(OBJ_BUSERR) -{ - ClearAlias(); - AddAlias("BusErr"); -} - -// デストラクタ -BusErrDevice::~BusErrDevice() -{ -} - -uint64 -BusErrDevice::Read8(uint32 addr) -{ - putlog(1, "$%08x.b", addr); - return (uint64)-1; -} - -uint64 -BusErrDevice::Read16(uint32 addr) -{ - putlog(1, "$%08x.w", addr); - return (uint64)-1; -} - -uint64 -BusErrDevice::Read32(uint32 addr) -{ - putlog(1, "$%08x.l", addr); - return (uint64)-1; -} - -uint64 -BusErrDevice::Write8(uint32 addr, uint32 data) -{ - putlog(1, "$%08x.b <- %02X", addr, data); - return (uint64)-1; -} - -uint64 -BusErrDevice::Write16(uint32 addr, uint32 data) -{ - putlog(1, "$%08x.w <- %04X", addr, data); - return (uint64)-1; -} - -uint64 -BusErrDevice::Write32(uint32 addr, uint32 data) -{ - putlog(1, "$%08x.l <- %08X", addr, data); - return (uint64)-1; -} - -uint64 -BusErrDevice::Peek8(uint32 addr) -{ - return (uint64)-1; -} - - -// -// 何もしないデバイス -// - -// コンストラクタ -NopIODevice::NopIODevice() - : inherited(OBJ_NOPIO) -{ - ClearAlias(); - AddAlias("NopIO"); -} - -// デストラクタ -NopIODevice::~NopIODevice() -{ -} - -uint64 -NopIODevice::Read8(uint32 addr) -{ - putlog(1, "$%08x.b", addr); return 0xff; } -uint64 -NopIODevice::Read16(uint32 addr) +busdata +IODevice::Write1(uint32 addr, uint32 data) { - putlog(1, "$%08x.w", addr); - return 0xffff; -} - -uint64 -NopIODevice::Read32(uint32 addr) -{ - putlog(1, "$%08x.l", addr); - return 0xffffffff; -} - -uint64 -NopIODevice::Write8(uint32 addr, uint32 data) -{ - putlog(1, "$%08x.b <- $%02x", addr, data); return 0; } -uint64 -NopIODevice::Write16(uint32 addr, uint32 data) +busdata +IODevice::Peek1(uint32 addr) { - putlog(1, "$%08x.w <- $%04x", addr, data); - return 0; -} - -uint64 -NopIODevice::Write32(uint32 addr, uint32 data) -{ - putlog(1, "$%08x.l <- $%08x", addr, data); - return 0; + return 0xff; } -uint64 -NopIODevice::Peek8(uint32 addr) +bool +IODevice::Poke1(uint32 addr, uint32 data) { - return 0xff; + return false; }