2016-01-30 19:41:04 +01:00
|
|
|
// Copyright 2016 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include "common/common_types.h"
|
|
|
|
|
|
|
|
namespace Memory {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents a device with memory mapped IO.
|
|
|
|
* A device may be mapped to multiple regions of memory.
|
|
|
|
*/
|
|
|
|
class MMIORegion {
|
|
|
|
public:
|
|
|
|
virtual ~MMIORegion() = default;
|
|
|
|
|
2016-04-16 09:46:11 +02:00
|
|
|
virtual bool IsValidAddress(VAddr addr) = 0;
|
|
|
|
|
2016-01-30 19:41:04 +01:00
|
|
|
virtual u8 Read8(VAddr addr) = 0;
|
|
|
|
virtual u16 Read16(VAddr addr) = 0;
|
|
|
|
virtual u32 Read32(VAddr addr) = 0;
|
|
|
|
virtual u64 Read64(VAddr addr) = 0;
|
|
|
|
|
2018-09-06 22:03:28 +02:00
|
|
|
virtual bool ReadBlock(VAddr src_addr, void* dest_buffer, std::size_t size) = 0;
|
2016-04-16 10:14:18 +02:00
|
|
|
|
2016-01-30 19:41:04 +01:00
|
|
|
virtual void Write8(VAddr addr, u8 data) = 0;
|
|
|
|
virtual void Write16(VAddr addr, u16 data) = 0;
|
|
|
|
virtual void Write32(VAddr addr, u32 data) = 0;
|
|
|
|
virtual void Write64(VAddr addr, u64 data) = 0;
|
2016-04-16 10:14:18 +02:00
|
|
|
|
2018-09-06 22:03:28 +02:00
|
|
|
virtual bool WriteBlock(VAddr dest_addr, const void* src_buffer, std::size_t size) = 0;
|
2019-08-11 01:20:09 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class boost::serialization::access;
|
|
|
|
template <class Archive>
|
2019-12-27 22:07:29 +01:00
|
|
|
void serialize(Archive& ar, const unsigned int file_version) {}
|
2016-01-30 19:41:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
using MMIORegionPointer = std::shared_ptr<MMIORegion>;
|
2018-03-09 18:54:43 +01:00
|
|
|
}; // namespace Memory
|