|
|
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);
1.1.1.3 root 58: void Tx(uint32);
1.1 root 59: void ChangeInterrupt();
60:
61: // シリアルから1バイト受信のメッセージとイベントコールバック
1.1.1.4 ! root 62: void HostRxCallback(uint32);
1.1 root 63: void RxMessage(MessageID, uint32);
64:
1.1.1.3 root 65: // パフォーマンス測定用のギミック。
66: int sesame_idx {};
67:
1.1 root 68: // 受信キュー
69: std::deque<uint8> rxq {};
70:
71: uint32 dma_ptr {};
72: uint32 dma_len {};
73: bool intr_enable {};
74:
75: std::unique_ptr<HostCOMDevice> hostcom /*{}*/;
76:
77: GFPICDevice *gfpic {};
78: MainbusDevice *mainbus {};
79: };
80:
81: static inline GFTTYDevice *GetGFTTYDevice() {
82: return Object::GetObject<GFTTYDevice>(OBJ_GFTTY);
83: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.