ESP32 PSRAM Library
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
esp32_psram::HimemBlock Class Reference

Manages a block of himem memory with mapping functionality. More...

#include <VectorHIMEM.h>

Public Member Functions

 HimemBlock ()
 Default constructor.
 
 HimemBlock (const HimemBlock &)=delete
 Copy constructor (deleted)
 
 HimemBlock (HimemBlock &&other) noexcept
 Move constructor.
 
 ~HimemBlock ()
 Destructor - ensures memory is properly freed.
 
bool allocate (size_t block_size)
 Allocate a block of himem. More...
 
void free ()
 Free the himem block.
 
size_t get_size () const
 Get the size of the allocated block. More...
 
HimemBlockoperator= (const HimemBlock &)=delete
 Copy assignment operator (deleted)
 
HimemBlockoperator= (HimemBlock &&other) noexcept
 Move assignment operator.
 
size_t read (void *dest, size_t offset, size_t length)
 Read data from HIMEM at specified offset. More...
 
void unmap ()
 Unmap the himem block.
 
size_t write (const void *src, size_t offset, size_t length)
 Write data to HIMEM at specified offset. More...
 

Protected Member Functions

bool ensure_block_mapped (size_t block_index)
 Ensure a specific block is mapped into memory. More...
 

Protected Attributes

size_t current_mapped_block
 
esp_himem_handle_t handle = 0
 
void * mapped_ptr = nullptr
 
esp_himem_rangehandle_t range = 0
 
size_t size = 0
 

Detailed Description

Manages a block of himem memory with mapping functionality.

Member Function Documentation

◆ allocate()

bool esp32_psram::HimemBlock::allocate ( size_t  block_size)
inline

Allocate a block of himem.

Parameters
block_sizeSize of memory to allocate in bytes
Returns
true if allocation was successful, false otherwise

◆ ensure_block_mapped()

bool esp32_psram::HimemBlock::ensure_block_mapped ( size_t  block_index)
inlineprotected

Ensure a specific block is mapped into memory.

Parameters
block_indexThe index of the block to map
Returns
true if mapping successful, false otherwise

◆ get_size()

size_t esp32_psram::HimemBlock::get_size ( ) const
inline

Get the size of the allocated block.

Returns
Size of the allocated block in bytes

◆ read()

size_t esp32_psram::HimemBlock::read ( void *  dest,
size_t  offset,
size_t  length 
)
inline

Read data from HIMEM at specified offset.

Parameters
destDestination buffer
offsetOffset in HIMEM to read from
lengthNumber of bytes to read
Returns
Number of bytes actually read

◆ write()

size_t esp32_psram::HimemBlock::write ( const void *  src,
size_t  offset,
size_t  length 
)
inline

Write data to HIMEM at specified offset.

Parameters
srcSource buffer
offsetOffset in HIMEM to write to
lengthNumber of bytes to write
Returns
Number of bytes actually written

Member Data Documentation

◆ current_mapped_block

size_t esp32_psram::HimemBlock::current_mapped_block
protected
Initial value:
=
SIZE_MAX

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