--- nono/vm/virtio_entropy.cpp 2026/04/29 17:05:28 1.1.1.1 +++ nono/vm/virtio_entropy.cpp 2026/04/29 17:05:42 1.1.1.3 @@ -10,6 +10,7 @@ #include "virtio_entropy.h" #include "virtio_def.h" +#include "monitor.h" // コンストラクタ VirtIOEntropyDevice::VirtIOEntropyDevice(uint slot_) @@ -20,16 +21,16 @@ VirtIOEntropyDevice::VirtIOEntropyDevice device_id = VirtIO::DEVICE_ID_ENTROPY; int num_max = 4; - vqueues.emplace_back(0, "RequestQ", num_max); + vqueues.emplace_back(this, 0, "RequestQ", num_max); // 割り込み名 strlcpy(intrname, "VIOEnt", sizeof(intrname)); // 完了通知メッセージ msgid = MessageID::VIRTIO_ENTROPY_DONE; - monitor.func = ToMonitorCallback(&VirtIOEntropyDevice::MonitorUpdate); - monitor.SetSize(MONITOR_WIDTH, 2 + 4 * 1 + num_max + 3); - monitor.Regist(ID_MONITOR_VIRTIO_ENTROPY); + monitor = gMonitorManager->Regist(ID_MONITOR_VIRTIO_ENTROPY, this); + monitor->func = ToMonitorCallback(&VirtIOEntropyDevice::MonitorUpdate); + monitor->SetSize(MONITOR_WIDTH, 2 + 4 * 1 + num_max + 3); } // デストラクタ @@ -55,13 +56,10 @@ VirtIOEntropyDevice::MonitorUpdate(Monit void VirtIOEntropyDevice::ProcessDesc(VirtIOReq& req) { - uint32 data = 0; + std::vector buf(roundup(req.wlen, 4)); - while (req.pos < req.len) { - if ((req.pos & 3) == 0) { - data = rnd(); - } - ReqWriteU8(req, data & 0xff); - data >>= 8; + for (auto&& d : buf) { + d = rnd(); } + ReqWriteRegion(req, (const uint8 *)buf.data(), req.wlen); }