File:  [Isaki's NoNo m68k/m88k emulator] / nono / vm / ram.h
Revision 1.1.1.9 (vendor branch): download - view: text, annotated - select for diffs
Wed Apr 29 17:05:09 2026 UTC (2 months, 3 weeks ago) by root
Branches: MAIN, Isaki
CVS tags: v016, v015, HEAD
nono 0.3.0

//
// nono
// Copyright (C) 2020 nono project
// Licensed under nono-license.txt
//

//
// メインメモリ
//

#pragma once

#include "device.h"

class RAMDevice : public IODevice
{
	using inherited = IODevice;
 public:
	RAMDevice();
	virtual ~RAMDevice() override;

	bool Init() override;
	void ResetHard(bool poweron) override;

	uint64 Read8(uint32 addr) override;
	uint64 Read16(uint32 addr) override;
	uint64 Read32(uint32 addr) override;
	uint64 Write8(uint32 addr, uint32 data) override;
	uint64 Write16(uint32 addr, uint32 data) override;
	uint64 Write32(uint32 addr, uint32 data) override;
	uint64 Peek8(uint32 addr) override;

	// RAM 容量(バイト単位)を取得
	int GetSize() const	{ return ram_size; }
	// RAM 容量(MB単位)を取得
	int GetSizeMB() const { return (uint)ram_size / 1024 / 1024; }

	// アクセスウェイトを設定
	void SetWait(uint32 wait);

	// ホストの filepath をロードする
	uint32 LoadFile(const char *filepath);
	// file, filesize で示されるバッファをロードする
	uint32 LoadFile(const char *name, const uint8 *file, size_t filesize);

 private:
	uint32 LoadGzFile(const char *filepath, const uint8 *file, size_t filesize);
	uint32 Load_aout(const char *name, const uint8 *file, size_t filesize);
	uint32 Load_elf32(const char *name, const uint8 *file, size_t filesize);
	bool Load_elf32_exec(const char *name, const uint8 *file, size_t filesize);
	uint32 Load_elf32_rel(const char *name, const uint8 *file, size_t filesize);

	// RAM 容量(バイト単位)。ram[] の確保したバイト数
	int ram_size {};

	uint32 read_wait {};
	uint32 write_wait {};
};

extern std::unique_ptr<uint8[]> mainram;
extern RAMDevice *gRAM;

unix.superglobalmegacorp.com

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