|
|
1.1 root 1: //
2: // nono
1.1.1.3 root 3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
1.1 root 5: //
6:
7: #pragma once
8:
9: #include "device.h"
1.1.1.4 root 10: #include <array>
1.1 root 11:
12: class XIOSpaceDevice
13: : public IODevice
14: {
1.1.1.3 root 15: using inherited = IODevice;
1.1 root 16: public:
17: XIOSpaceDevice();
1.1.1.5 ! root 18: virtual ~XIOSpaceDevice() override;
1.1 root 19:
1.1.1.4 root 20: bool Init() override;
21:
1.1.1.3 root 22: uint64 Read8(uint32 addr) override;
23: uint64 Read16(uint32 addr) override;
24: uint64 Read32(uint32 addr) override;
25: uint64 Write8(uint32 addr, uint32 data) override;
26: uint64 Write16(uint32 addr, uint32 data) override;
27: uint64 Write32(uint32 addr, uint32 data) override;
28: uint64 Peek8(uint32 addr) override;
1.1 root 29:
30: private:
31: // アドレス addr に対応する IODevice* を返す。
32: // addr は 24bit マスクされていること。
1.1.1.2 root 33: inline IODevice *SearchDevice(uint32 addr) const
1.1 root 34: {
35: uint idx = addr / 8192;
36: __assume(idx < 2048);
37: return table[idx];
38: }
39:
40: void AddDevice(IODevice *dev);
41:
1.1.1.4 root 42: std::array<IODevice*, 2048> table {};
1.1 root 43: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.