Annotation of nono/vm/virtio_entropy.cpp, revision 1.1.1.1

1.1       root        1: //
                      2: // nono
                      3: // Copyright (C) 2024 nono project
                      4: // Licensed under nono-license.txt
                      5: //
                      6: 
                      7: //
                      8: // VirtIO エントロピーデバイス
                      9: //
                     10: 
                     11: #include "virtio_entropy.h"
                     12: #include "virtio_def.h"
                     13: 
                     14: // コンストラクタ
                     15: VirtIOEntropyDevice::VirtIOEntropyDevice(uint slot_)
                     16:        : inherited(OBJ_VIRTIO_ENTROPY, slot_)
                     17: {
                     18:        // 短縮形
                     19:        AddAlias("vent");
                     20: 
                     21:        device_id = VirtIO::DEVICE_ID_ENTROPY;
                     22:        int num_max = 4;
                     23:        vqueues.emplace_back(0, "RequestQ", num_max);
                     24: 
                     25:        // 割り込み名
                     26:        strlcpy(intrname, "VIOEnt", sizeof(intrname));
                     27:        // 完了通知メッセージ
                     28:        msgid = MessageID::VIRTIO_ENTROPY_DONE;
                     29: 
                     30:        monitor.func = ToMonitorCallback(&VirtIOEntropyDevice::MonitorUpdate);
                     31:        monitor.SetSize(MONITOR_WIDTH, 2 + 4 * 1 + num_max + 3);
                     32:        monitor.Regist(ID_MONITOR_VIRTIO_ENTROPY);
                     33: }
                     34: 
                     35: // デストラクタ
                     36: VirtIOEntropyDevice::~VirtIOEntropyDevice()
                     37: {
                     38: }
                     39: 
                     40: void
                     41: VirtIOEntropyDevice::MonitorUpdate(Monitor *, TextScreen& screen)
                     42: {
                     43:        int y = 0;
                     44: 
                     45:        screen.Clear();
                     46: 
                     47:        y = MonitorUpdateDev(screen, y);
                     48:        y++;
                     49:        y = MonitorUpdateVirtQueue(screen, y, vqueues[0]);
                     50:        y++;
                     51:        y = MonitorUpdateVirtQDesc(screen, y, vqueues[0]);
                     52: }
                     53: 
                     54: // ディスクリプタを一つ処理する。
                     55: void
                     56: VirtIOEntropyDevice::ProcessDesc(VirtIOReq& req)
                     57: {
                     58:        uint32 data = 0;
                     59: 
                     60:        while (req.pos < req.len) {
                     61:                if ((req.pos & 3) == 0) {
                     62:                        data = rnd();
                     63:                }
                     64:                ReqWriteU8(req, data & 0xff);
                     65:                data >>= 8;
                     66:        }
                     67: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.