Annotation of nono/host/hostcom.h, revision 1.1

1.1     ! root        1: //
        !             2: // nono
        !             3: // Copyright (C) 2021 nono project
        !             4: // Licensed under nono-license.txt
        !             5: //
        !             6: 
        !             7: //
        !             8: // シリアルポートのホストデバイス
        !             9: //
        !            10: 
        !            11: #pragma once
        !            12: 
        !            13: #include "hostdevice.h"
        !            14: #include "comdriver.h"
        !            15: #include "monitor.h"
        !            16: #include "spscqueue.h"
        !            17: 
        !            18: class HostCOMDevice : public HostDevice
        !            19: {
        !            20:        using inherited = HostDevice;
        !            21:        using COMQueue = SPSCQueue<uint8, 1024>;
        !            22: 
        !            23:        // 統計情報
        !            24:        struct stat_t {
        !            25:                uint64 tx_bytes;                        // VM からの送信バイト数
        !            26:                uint64 rx_bytes;                        // VM が受信したバイト数
        !            27:                uint64 txqfull_bytes;           // TxQ が一杯で落としたバイト数
        !            28:                uint64 rxqfull_bytes;           // RxQ が一杯で落としたバイト数
        !            29:                uint64 write_bytes;                     // ホストへの書き出しバイト数
        !            30:                uint64 read_bytes;                      // ホストからの読み込みバイト数
        !            31: 
        !            32:                int txq_peak;                           // キューのおおよその最大使用量
        !            33:                int rxq_peak;                           // キューのおおよその最大使用量
        !            34:        };
        !            35: 
        !            36:  public:
        !            37:        HostCOMDevice(const std::string& objname_);
        !            38:        ~HostCOMDevice() override;
        !            39: 
        !            40:        void SetLogLevel(int loglevel_) override;
        !            41:        bool Init() override;
        !            42: 
        !            43:        void Dispatch(int udata) override;
        !            44:        bool Tx(uint32 data);
        !            45:        uint32 Rx();
        !            46: 
        !            47:  private:
        !            48:        bool SelectDriver();
        !            49: 
        !            50:        int Read() override;
        !            51:        void Write(uint32 data) override;
        !            52: 
        !            53:        DECLARE_MONITOR_CALLBACK(MonitorUpdate);
        !            54: 
        !            55:        // キュー
        !            56:        COMQueue txq {};
        !            57:        COMQueue rxq {};
        !            58: 
        !            59:        std::unique_ptr<COMDriver> driver {};
        !            60: 
        !            61:        // 統計情報
        !            62:        struct stat_t stat {};
        !            63: 
        !            64:        Monitor monitor { this };
        !            65: };

unix.superglobalmegacorp.com

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