11using namespace MaxOS::memory;
24MemIO::~MemIO() =
default;
36MemIO8Bit::~MemIO8Bit() =
default;
45 (*((
volatile uint8_t*) (
m_address))) = (data);
55 return *((
volatile uint8_t*) (
m_address));
68MemIO16Bit::~MemIO16Bit() =
default;
77 (*((
volatile uint16_t*) (
m_address))) = (data);
87 return *((
volatile uint16_t*) (
m_address));
100MemIO32Bit::~MemIO32Bit() =
default;
109 (*((
volatile uint32_t*) (
m_address))) = (data);
119 return *((
volatile uint32_t*) (
m_address));
132MemIO64Bit::~MemIO64Bit() =
default;
141 (*((
volatile uint64_t*) (
m_address))) = (data);
151 return *((
volatile uint64_t*) (
m_address));
165void*
memcpy(
void* destination,
const void* source, uint64_t num) {
168 if (destination == source)
172 if (destination ==
nullptr || source ==
nullptr)
176 auto* dst = (
unsigned char*) destination;
177 const auto* src = (
const unsigned char*) source;
180 for (
size_t i = 0; i < num; i++)
195void*
memset(
void* ptr,
unsigned char value, uint64_t num) {
201 auto* dst = (
unsigned char*) ptr;
202 for (
size_t i = 0; i < num; i++)
203 dst[i] = (
unsigned char) value;
215void*
memset(
void* ptr, uint32_t value, uint64_t num) {
221 auto* dst = (uint32_t*) ptr;
222 for (
size_t i = 0; i < num; i++)
235void*
memmove(
void* destination,
const void* source, uint64_t num) {
238 if (destination == source)
242 if (destination ==
nullptr || source ==
nullptr)
245 auto* dst = (
unsigned char*) destination;
246 const auto* src = (
const unsigned char*) source;
248 for (
size_t i = 0; i < num; i++)
251 for (
size_t i = num; i != 0; i--)
252 dst[i - 1] = src[i - 1];
265int memcmp(
const void* ptr1,
const void* ptr2, uint64_t num) {
268 if (ptr1 ==
nullptr || ptr2 ==
nullptr)
271 const auto* p1 = (
const unsigned char*) ptr1;
272 const auto* p2 = (
const unsigned char*) ptr2;
273 for (
size_t i = 0; i < num; i++) {
MemIO16Bit(uintptr_t address)
Construct a new Mem IO object for 16 bit reads/writes.
virtual uint16_t read()
Reads data from the memory address.
virtual void write(uint16_t data)
Writes data to the memory address.
virtual uint32_t read()
Reads data from the memory address.
MemIO32Bit(uintptr_t address)
Construct a new Mem IO object for 32 bit reads/writes.
virtual void write(uint32_t data)
Writes data to the memory address.
virtual void write(uint64_t data)
Writes data to the memory address.
MemIO64Bit(uintptr_t address)
Construct a new Mem IO object for 64 bit reads/writes.
virtual uint64_t read()
Reads data from the memory address.
virtual uint8_t read()
Reads data from the memory address.
MemIO8Bit(uintptr_t address)
Construct a new Mem IO object for 8 bit reads/writes.
virtual void write(uint8_t data)
Writes data to the memory address.
base class for all memory IO
uintptr_t m_address
The memory address to read from / write to.
MemIO(uintptr_t address)
Construct a new Mem IO object.
Defines classes for memory input and output operations of various bit widths (8, 16,...
void * memmove(void *destination, const void *source, uint64_t num)
Copies a block of memory from one location to another.
void * memcpy(void *destination, const void *source, uint64_t num)
Copies a block of memory from one location to another.
int memcmp(const void *ptr1, const void *ptr2, uint64_t num)
Compares two blocks of memory.
void * memset(void *ptr, uint32_t value, uint64_t num)
Fills a block of memory with a specified value.