Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
openlcb::MemorySpace Class Referenceabstract

Abstract base class for the address spaces exported via the Memory Config Protocol. More...

#include <MemoryConfig.hxx>

Inheritance diagram for openlcb::MemorySpace:
Destructable openlcb::FileMemorySpace openlcb::ReadOnlyMemoryBlock openlcb::ReadWriteMemoryBlock openlcb::TractionCvSpace openlcb::VirtualMemorySpace traction_modem::CvSpace openlcb::ROFileMemorySpace

Public Types

typedef uint32_t address_t
 
typedef uint16_t errorcode_t
 

Public Member Functions

virtual bool set_node (Node *node)
 Specifies which node the next operation pertains.
 
virtual bool read_only ()
 
virtual address_t min_address ()
 
virtual address_t max_address ()=0
 
virtual size_t write (address_t destination, const uint8_t *data, size_t len, errorcode_t *error, Notifiable *again)
 
virtual size_t read (address_t source, uint8_t *dst, size_t len, errorcode_t *error, Notifiable *again)=0
 
virtual errorcode_t freeze ()
 Handles space freeze command.
 
virtual errorcode_t unfreeze ()
 Handles space unfreeze command.
 

Static Public Attributes

static const errorcode_t ERROR_AGAIN = 0x3FFF
 This error code signals that the operation was only partially completed, the again notify was used and will be notified when the operation can be re-tried).
 

Detailed Description

Abstract base class for the address spaces exported via the Memory Config Protocol.

Usage: Instantiate the specific child class of this interface. Register for the address space number needed via ->insert()

Definition at line 64 of file MemoryConfig.hxx.

Member Typedef Documentation

◆ address_t

typedef uint32_t openlcb::MemorySpace::address_t

Definition at line 67 of file MemoryConfig.hxx.

◆ errorcode_t

typedef uint16_t openlcb::MemorySpace::errorcode_t

Definition at line 68 of file MemoryConfig.hxx.

Member Function Documentation

◆ freeze()

virtual errorcode_t openlcb::MemorySpace::freeze ( )
inlinevirtual

Handles space freeze command.

Returns an error code, or 0 for success.

Definition at line 119 of file MemoryConfig.hxx.

◆ max_address()

virtual address_t openlcb::MemorySpace::max_address ( )
pure virtual
Returns
the largest valid address for this block. A read of 1 from this address should succeed in returning the last byte.

Implemented in openlcb::ReadOnlyMemoryBlock, openlcb::ReadWriteMemoryBlock, openlcb::FileMemorySpace, openlcb::TractionCvSpace, openlcb::VirtualMemorySpace, and traction_modem::CvSpace.

◆ min_address()

virtual address_t openlcb::MemorySpace::min_address ( )
inlinevirtual
Returns
the lowest address that's valid for this block.

Reimplemented in openlcb::VirtualMemorySpace.

Definition at line 88 of file MemoryConfig.hxx.

◆ read()

virtual size_t openlcb::MemorySpace::read ( address_t  source,
uint8_t *  dst,
size_t  len,
errorcode_t *  error,
Notifiable again 
)
pure virtual
Returns
the number of bytes successfully read (before hitting end of space). If *error is set to non-null, then the operation has failed. If the operation needs to be continued, then sets error to ERROR_AGAIN, and calls the Notifiable
Parameters
againwhen a re-try makes sense. The caller should call read once more, with the offset adjusted with the previously returned bytes.

Implemented in openlcb::ReadOnlyMemoryBlock, openlcb::ReadWriteMemoryBlock, openlcb::FileMemorySpace, openlcb::TractionCvSpace, openlcb::VirtualMemorySpace, and traction_modem::CvSpace.

◆ read_only()

virtual bool openlcb::MemorySpace::read_only ( )
inlinevirtual
Returns
whether the memory space does not accept writes.

Reimplemented in openlcb::ReadWriteMemoryBlock, openlcb::FileMemorySpace, openlcb::ROFileMemorySpace, openlcb::TractionCvSpace, openlcb::VirtualMemorySpace, and traction_modem::CvSpace.

Definition at line 83 of file MemoryConfig.hxx.

◆ set_node()

virtual bool openlcb::MemorySpace::set_node ( Node node)
inlinevirtual

Specifies which node the next operation pertains.

If it returns false, the operation will be rejected by "unknown memory space ID".

Reimplemented in openlcb::TractionCvSpace.

Definition at line 77 of file MemoryConfig.hxx.

◆ unfreeze()

virtual errorcode_t openlcb::MemorySpace::unfreeze ( )
inlinevirtual

Handles space unfreeze command.

Returns an error code, or 0 for success.

Definition at line 125 of file MemoryConfig.hxx.

◆ write()

virtual size_t openlcb::MemorySpace::write ( address_t  destination,
const uint8_t *  data,
size_t  len,
errorcode_t *  error,
Notifiable again 
)
inlinevirtual
Returns
the number of bytes successfully written (before hitting end of space). If *error is set to non-null, then the operation has failed. If the operation needs to be continued, then sets error to MemorySpace::ERROR_AGAIN, and calls the Notifiable
Parameters
againwhen a re-try makes sense. The caller should call write once more, with the offset adjusted with the previously returned bytes.

Reimplemented in openlcb::ReadWriteMemoryBlock, openlcb::FileMemorySpace, openlcb::TractionCvSpace, openlcb::VirtualMemorySpace, and traction_modem::CvSpace.

Definition at line 103 of file MemoryConfig.hxx.

Member Data Documentation

◆ ERROR_AGAIN

const errorcode_t openlcb::MemorySpace::ERROR_AGAIN = 0x3FFF
static

This error code signals that the operation was only partially completed, the again notify was used and will be notified when the operation can be re-tried).

Definition at line 73 of file MemoryConfig.hxx.


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