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