The Pedigree Project 0.1
Public Member Functions | Private Member Functions | Private Attributes | List of all members
MemoryMappedIo Class Reference

Memory mapped I/O range. More...

#include <MemoryMappedIo.h>

+ Inheritance diagram for MemoryMappedIo:
+ Collaboration diagram for MemoryMappedIo:

Public Member Functions

 MemoryMappedIo (const char *pName, uintptr_t offset=0, uintptr_t padding=1)
 
virtual ~MemoryMappedIo ()
 
virtual size_t size () const
 
virtual uint8_t read8 (size_t offset=0)
 
virtual uint16_t read16 (size_t offset=0)
 
virtual uint32_t read32 (size_t offset=0)
 
virtual uint64_t read64 (size_t offset=0)
 
virtual void write8 (uint8_t value, size_t offset=0)
 
virtual void write16 (uint16_t value, size_t offset=0)
 
virtual void write32 (uint32_t value, size_t offset=0)
 
virtual void write64 (uint64_t value, size_t offset=0)
 
virtual operator bool () const
 
- Public Member Functions inherited from IoBase
virtual ~IoBase ()
 
uint64_t read64LowFirst (size_t offset=0)
 
uint64_t read64HighFirst (size_t offset=0)
 
void write64LowFirst (uint64_t value, size_t offset=0)
 
void write64HighFirst (uint64_t value, size_t offset=0)
 
- Public Member Functions inherited from MemoryRegion
 MemoryRegion (const char *pName)
 
virtual ~MemoryRegion ()
 
void free ()
 
void * virtualAddress () const
 
physical_uintptr_t physicalAddress () const
 
size_t size () const
 
const char * name () const
 
 operator bool () const
 
bool physicalBoundsCheck (physical_uintptr_t address)
 
template<typename T >
T * convertPhysicalPointer (physical_uintptr_t address)
 
void setNonRamMemory (bool b)
 
bool getNonRamMemory ()
 
void setForced (bool b)
 
bool getForced ()
 
void setAnonymous (bool b)
 
bool getAnonymous () const
 

Private Member Functions

 MemoryMappedIo (const MemoryMappedIo &)
 
MemoryMappedIo & operator= (const MemoryMappedIo &)
 

Private Attributes

uintptr_t m_Offset
 
size_t m_Padding
 

Additional Inherited Members

- Protected Member Functions inherited from IoBase
 IoBase ()
 

Detailed Description

Memory mapped I/O range.

The MemoryMappedIo handles special MemoryRegions for I/O to hardware devices

Definition at line 32 of file MemoryMappedIo.h.

Constructor & Destructor Documentation

◆ MemoryMappedIo() [1/2]

MemoryMappedIo::MemoryMappedIo ( const char *  pName,
uintptr_t  offset = 0,
uintptr_t  padding = 1 
)

Definition at line 24 of file MemoryMappedIo.cc.

◆ ~MemoryMappedIo()

MemoryMappedIo::~MemoryMappedIo ( )
virtual

The destructor frees the allocated ressources

Definition at line 27 of file MemoryMappedIo.cc.

◆ MemoryMappedIo() [2/2]

MemoryMappedIo::MemoryMappedIo ( const MemoryMappedIo &  )
private

The copy-constructor

Note
NOT implemented

Member Function Documentation

◆ operator bool()

MemoryMappedIo::operator bool ( ) const
virtual

Check whether this class is usable

Returns
true, if the class holds a ressource that is correctly allocated and usable

Implements IoBase.

Definition at line 113 of file MemoryMappedIo.cc.

◆ operator=()

MemoryMappedIo & MemoryMappedIo::operator= ( const MemoryMappedIo &  )
private

The assignment operator

Note
NOT implemented

◆ read16()

uint16_t MemoryMappedIo::read16 ( size_t  offset = 0)
virtual

Read two byte (16bit) from the I/O Port or the memory-mapped I/O region

Parameters
[in]offsetoffset from the I/O base port or the I/O base memory address
Returns
the two byte (16bit) that have been read

Implements IoBase.

Definition at line 43 of file MemoryMappedIo.cc.

References ProcessorBase::halt(), m_Offset, m_Padding, size(), and MemoryRegion::virtualAddress().

◆ read32()

uint32_t MemoryMappedIo::read32 ( size_t  offset = 0)
virtual

Read four byte (32bit) from the I/O Port or the memory-mapped I/O region

Parameters
[in]offsetoffset from the I/O base port or the I/O base memory address
Returns
the four byte (32bit) that have been read

Implements IoBase.

Definition at line 53 of file MemoryMappedIo.cc.

References ProcessorBase::halt(), m_Offset, m_Padding, size(), and MemoryRegion::virtualAddress().

◆ read64()

uint64_t MemoryMappedIo::read64 ( size_t  offset = 0)
virtual

Read eight byte (64bit) from the I/O Port or the memory-mapped I/O region.

Parameters
[in]offsetoffset from the I/O base port or the I/O base memory address
Returns
the eight byte (64bit) that have been read

Implements IoBase.

Definition at line 63 of file MemoryMappedIo.cc.

References ProcessorBase::halt(), m_Offset, m_Padding, size(), and MemoryRegion::virtualAddress().

◆ read8()

uint8_t MemoryMappedIo::read8 ( size_t  offset = 0)
virtual

Read a byte (8bit) from the I/O Port or the memory-mapped I/O region

Parameters
[in]offsetoffset from the I/O base port or the I/O base memory address
Returns
the byte (8bit) that have been read

Implements IoBase.

Definition at line 33 of file MemoryMappedIo.cc.

References ProcessorBase::halt(), m_Offset, m_Padding, size(), and MemoryRegion::virtualAddress().

◆ size()

size_t MemoryMappedIo::size ( ) const
virtual

Get the size of the I/O region in bytes

Implements IoBase.

Definition at line 29 of file MemoryMappedIo.cc.

References MemoryRegion::size().

Referenced by read16(), read32(), read64(), read8(), write16(), write32(), write64(), and write8().

+ Here is the caller graph for this function:

◆ write16()

void MemoryMappedIo::write16 ( uint16_t  value,
size_t  offset = 0 
)
virtual

Write two byte (16bit) to the I/O port or the memory-mapped I/O region

Parameters
[in]valuethe value that should be written
[in]offsetoffset from the I/O base port or the I/O base memory address

Implements IoBase.

Definition at line 83 of file MemoryMappedIo.cc.

References ProcessorBase::halt(), m_Offset, m_Padding, size(), and MemoryRegion::virtualAddress().

◆ write32()

void MemoryMappedIo::write32 ( uint32_t  value,
size_t  offset = 0 
)
virtual

Write four byte (32bit) to the I/O port or the memory-mapped I/O region

Parameters
[in]valuethe value that should be written
[in]offsetoffset from the I/O base port or the I/O base memory address

Implements IoBase.

Definition at line 93 of file MemoryMappedIo.cc.

References ProcessorBase::halt(), m_Offset, m_Padding, size(), and MemoryRegion::virtualAddress().

◆ write64()

void MemoryMappedIo::write64 ( uint64_t  value,
size_t  offset = 0 
)
virtual

Write eight byte (64bit) to the I/O Port or the memory-mapped I/O region.

Parameters
[in]valuethe value that should be written
[in]offsetoffset from the I/O base port or the I/O base memory address

Implements IoBase.

Definition at line 103 of file MemoryMappedIo.cc.

References ProcessorBase::halt(), m_Offset, m_Padding, size(), and MemoryRegion::virtualAddress().

◆ write8()

void MemoryMappedIo::write8 ( uint8_t  value,
size_t  offset = 0 
)
virtual

Write a byte (8bit) to the I/O port or the memory-mapped I/O region

Parameters
[in]valuethe value that should be written
[in]offsetoffset from the I/O base port or the I/O base memory address

Implements IoBase.

Definition at line 73 of file MemoryMappedIo.cc.

References ProcessorBase::halt(), m_Offset, m_Padding, size(), and MemoryRegion::virtualAddress().

Member Data Documentation

◆ m_Offset

uintptr_t MemoryMappedIo::m_Offset
private

MemoryRegion only supports allocation on a page boundary. This variable adds an offset onto each access to make up for this (if required)

Definition at line 67 of file MemoryMappedIo.h.

Referenced by read16(), read32(), read64(), read8(), write16(), write32(), write64(), and write8().

◆ m_Padding

size_t MemoryMappedIo::m_Padding
private

It is possible that registers may not follow one another directly in memory, instead being padded to some boundary.

Definition at line 71 of file MemoryMappedIo.h.

Referenced by read16(), read32(), read64(), read8(), write16(), write32(), write64(), and write8().


The documentation for this class was generated from the following files: