|
|
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"
10:
11: class RAMDevice
12: : public IODevice
13: {
1.1.1.3 root 14: using inherited = IODevice;
1.1 root 15: public:
16: RAMDevice();
1.1.1.5 root 17: virtual ~RAMDevice() override;
1.1 root 18:
1.1.1.3 root 19: bool Init() override;
1.1.1.7 ! root 20: bool PowerOn() override;
1.1.1.4 root 21: void ResetHard() override;
1.1 root 22:
1.1.1.3 root 23: uint64 Read8(uint32 addr) override;
24: uint64 Read16(uint32 addr) override;
25: uint64 Read32(uint32 addr) override;
26: uint64 Write8(uint32 addr, uint32 data) override;
27: uint64 Write16(uint32 addr, uint32 data) override;
28: uint64 Write32(uint32 addr, uint32 data) override;
29: uint64 Peek8(uint32 addr) override;
1.1.1.2 root 30:
1.1.1.6 root 31: // RAM 容量(バイト単位)を取得
32: int GetSize() const { return ram_size; }
33: // RAM 容量(MB単位)を取得
34: int GetSizeMB() const { return (uint)ram_size / 1024 / 1024; }
35:
1.1.1.4 root 36: // アクセスウェイトを設定
37: void SetWait(uint32 wait);
38:
1.1.1.2 root 39: // ホストの filepath をロードする
1.1.1.6 root 40: uint32 LoadFile(const char *filepath);
1.1.1.2 root 41: // file, filesize で示されるバッファをロードする
1.1.1.6 root 42: uint32 LoadFile(const char *name, const uint8 *file, size_t filesize);
1.1.1.2 root 43: private:
1.1.1.6 root 44: uint32 LoadGzFile(const char *filepath, const uint8 *file, size_t filesize);
45: uint32 Load_aout(const char *name, const uint8 *file, size_t filesize);
46: uint32 Load_elf32(const char *name, const uint8 *file, size_t filesize);
47:
48: // RAM 容量(バイト単位)。ram[] の確保したバイト数
49: int ram_size {};
1.1.1.4 root 50:
51: uint32 read_wait {};
52: uint32 write_wait {};
1.1 root 53: };
54:
1.1.1.7 ! root 55: extern std::unique_ptr<uint8[]> mainram;
1.1.1.2 root 56: extern std::unique_ptr<RAMDevice> gRAM;
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.