Annotation of nono/vm/goldfish_tty.h, revision 1.1.1.2

1.1       root        1: //
                      2: // nono
                      3: // Copyright (C) 2024 nono project
                      4: // Licensed under nono-license.txt
                      5: //
                      6: 
                      7: //
                      8: // Goldfish TTY
                      9: //
                     10: 
                     11: #pragma once
                     12: 
                     13: #include "device.h"
                     14: #include "message.h"
                     15: #include <deque>
                     16: 
                     17: class GFPICDevice;
                     18: class HostCOMDevice;
                     19: class MainbusDevice;
                     20: 
                     21: class GFTTYDevice : public IODevice
                     22: {
                     23:        using inherited = IODevice;
                     24: 
1.1.1.2 ! root       25:        static const uint32 PUT_CHAR    = 0x00U >> 2;
        !            26:        static const uint32 BYTES_READY = 0x04U >> 2;
        !            27:        static const uint32 COMMAND             = 0x08U >> 2;
        !            28:        static const uint32 DATA_PTR    = 0x10U >> 2;
        !            29:        static const uint32 DATA_LEN    = 0x14U >> 2;
        !            30:        static const uint32 VERSION             = 0x20U >> 2;
1.1       root       31: 
                     32:        static const uint32 CMD_INT_DISABLE             = 0x00;
                     33:        static const uint32 CMD_INT_ENABLE              = 0x01;
                     34:        static const uint32 CMD_WRITE_BUFFER    = 0x02;
                     35:        static const uint32 CMD_READ_BUFFER             = 0x03;
                     36: 
1.1.1.2 ! root       37:        static const uint32 GFTTYVersion                = 1;
        !            38: 
1.1       root       39:  public:
                     40:        GFTTYDevice();
                     41:        ~GFTTYDevice() override;
                     42: 
                     43:        bool Create() override;
                     44:        void SetLogLevel(int loglevel_) override;
                     45:        bool Init() override;
                     46:        void ResetHard(bool poweron) override;
                     47: 
1.1.1.2 ! root       48:  protected:
        !            49:        // BusIO インタフェース
        !            50:        static const uint32 NPORT = 0x1000 >> 2;
        !            51:        busdata ReadPort(uint32 offset);
        !            52:        busdata WritePort(uint32 offset, uint32 data);
        !            53:        busdata PeekPort(uint32 offset);
1.1       root       54: 
                     55:  private:
1.1.1.2 ! root       56:        uint32 GetREADY() const;
1.1       root       57:        void Command(uint32);
                     58:        void ChangeInterrupt();
                     59: 
                     60:        // シリアルから1バイト受信のメッセージとイベントコールバック
                     61:        void HostRxCallback();
                     62:        void RxMessage(MessageID, uint32);
                     63: 
                     64:        // 受信キュー
                     65:        std::deque<uint8> rxq {};
                     66: 
                     67:        uint32 dma_ptr {};
                     68:        uint32 dma_len {};
                     69:        bool intr_enable {};
                     70: 
                     71:        std::unique_ptr<HostCOMDevice> hostcom /*{}*/;
                     72: 
                     73:        GFPICDevice *gfpic {};
                     74:        MainbusDevice *mainbus {};
                     75: };
                     76: 
                     77: static inline GFTTYDevice *GetGFTTYDevice() {
                     78:        return Object::GetObject<GFTTYDevice>(OBJ_GFTTY);
                     79: }

unix.superglobalmegacorp.com

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