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

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 "spscqueue.h"
                     16: 
1.1.1.6   root       17: class ConfigItem;
                     18: 
1.1       root       19: class HostCOMDevice : public HostDevice
                     20: {
                     21:        using inherited = HostDevice;
                     22:        using COMQueue = SPSCQueue<uint8, 1024>;
                     23: 
                     24:        // 統計情報
                     25:        struct stat_t {
                     26:                uint64 tx_bytes;                        // VM からの送信バイト数
                     27:                uint64 rx_bytes;                        // VM が受信したバイト数
                     28:                uint64 txqfull_bytes;           // TxQ が一杯で落としたバイト数
                     29:                uint64 rxqfull_bytes;           // RxQ が一杯で落としたバイト数
                     30:                uint64 write_bytes;                     // ホストへの書き出しバイト数
                     31:                uint64 read_bytes;                      // ホストからの読み込みバイト数
                     32: 
1.1.1.3   root       33:                uint txq_peak;                          // キューのおおよその最大使用量
                     34:                uint rxq_peak;                          // キューのおおよその最大使用量
1.1       root       35:        };
                     36: 
                     37:  public:
1.1.1.6   root       38:        HostCOMDevice(Device *parent_, int n, const std::string& portname_);
1.1       root       39:        ~HostCOMDevice() override;
                     40: 
                     41:        void SetLogLevel(int loglevel_) override;
1.1.1.5   root       42:        bool Create2() override;
1.1       root       43: 
                     44:        void Dispatch(int udata) override;
                     45:        bool Tx(uint32 data);
                     46:        uint32 Rx();
                     47: 
1.1.1.6   root       48:        // ドライバ名を返す。
1.1.1.7 ! root       49:        const std::string& GetDriverName();
1.1.1.6   root       50: 
1.1       root       51:  private:
1.1.1.6   root       52:        bool SelectDriver(bool startup) override;
                     53:        void CreateNone();
                     54:        void CreateStdio(const ConfigItem&, const std::string& key);
                     55:        void CreateTCP();
                     56:        void CreateConsole(const ConfigItem&);
1.1       root       57: 
                     58:        int Read() override;
1.1.1.6   root       59:        void Write() override;
1.1       root       60: 
                     61:        DECLARE_MONITOR_CALLBACK(MonitorUpdate);
                     62: 
                     63:        // キュー
                     64:        COMQueue txq {};
                     65:        COMQueue rxq {};
                     66: 
                     67:        std::unique_ptr<COMDriver> driver {};
                     68: 
                     69:        // 統計情報
                     70:        struct stat_t stat {};
                     71: 
1.1.1.4   root       72:        Monitor *monitor {};
1.1       root       73: };

unix.superglobalmegacorp.com

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