28 const char *
const compName
67 if (not this->m_cleaned) {
70 this->m_buffers[entry].buff.~Buffer();
72 this->m_cleaned =
true;
74 this->m_allocator->
deallocate(this->m_memId,this->m_buffers);
75 this->m_setup =
false;
84 void BufferManagerComponentImpl ::
102 U32
id = context & 0xFFFF;
103 U32 mgrId = context >> 16;
105 FW_ASSERT(id < this->m_numStructs,
id,this->m_numStructs);
106 FW_ASSERT(mgrId == this->m_mgrId,mgrId,
id,this->m_mgrId);
107 FW_ASSERT(
true == this->m_buffers[
id].allocated,
id,this->m_mgrId);
108 FW_ASSERT(
reinterpret_cast<U8*
>(fwBuffer.
getData()) >= this->m_buffers[
id].memory,
id,this->m_mgrId);
109 FW_ASSERT(
reinterpret_cast<U8*
>(fwBuffer.
getData()) < (this->m_buffers[
id].memory + this->m_buffers[
id].size),
id,this->m_mgrId);
113 this->m_buffers[id].allocated =
false;
118 bufferGetCallee_handler(
128 if ((not this->m_buffers[buff].allocated) and (size <= this->m_buffers[buff].size)) {
129 this->m_buffers[buff].allocated =
true;
131 if (this->m_currBuffs > this->m_highWater) {
132 this->m_highWater = this->m_currBuffs;
155 this->m_mgrId = mgrId;
156 this->m_memId = memId;
157 this->m_allocator = &allocator;
159 memset(&this->m_bufferBins,0,
sizeof(this->m_bufferBins));
161 this->m_bufferBins = bins;
165 this->m_numStructs = 0;
177 bool recoverable =
false;
180 void *memory = allocator.
allocate(memId,allocatedSize,recoverable);
183 FW_ASSERT(memorySize == allocatedSize,memorySize,allocatedSize);
185 this->m_buffers =
static_cast<AllocatedBuffer*
>(memory);
188 U8* bufferMem =
reinterpret_cast<U8*
>(&this->m_buffers[this->m_numStructs]);
197 U32 context = (this->m_mgrId << 16) | currStruct;
198 (void)
new(&this->m_buffers[currStruct].buff)
Fw::Buffer(bufferMem,this->m_bufferBins.
bins[bin].
bufferSize,context);
199 this->m_buffers[currStruct].allocated =
false;
200 this->m_buffers[currStruct].memory = bufferMem;
201 this->m_buffers[currStruct].size = this->m_bufferBins.
bins[bin].
bufferSize;
209 U8*
const CURR_PTR = bufferMem;
210 U8*
const END_PTR =
static_cast<U8*
>(memory) + memorySize;
214 FW_ASSERT(currStruct == this->m_numStructs,currStruct,this->m_numStructs);
216 this->m_setup =
true;
219 void BufferManagerComponentImpl ::
PlatformPointerCastType POINTER_CAST
PlatformIntType NATIVE_INT_TYPE
uint8_t U8
8-bit unsigned integer
PlatformUIntType NATIVE_UINT_TYPE
C++-compatible configuration header for fprime configuration.
virtual void deallocate(const NATIVE_UINT_TYPE identifier, void *ptr)=0
Deallocate memory.
virtual void * allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_TYPE &size, bool &recoverable)=0
Allocate memory.
void init()
Object initializer.
Auto-generated base for BufferManager component.
void log_WARNING_HI_ZeroSizeBuffer()
void tlmWrite_HiBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
void log_WARNING_HI_NoBuffsAvailable(U32 size)
void tlmWrite_EmptyBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
void tlmWrite_NoBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
void tlmWrite_TotalBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
void tlmWrite_CurrBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
~BufferManagerComponentImpl()
void setup(NATIVE_UINT_TYPE mgrID, NATIVE_UINT_TYPE memID, Fw::MemAllocator &allocator, const BufferBins &bins)
set up configuration
BufferManagerComponentImpl(const char *const compName)
static const NATIVE_UINT_TYPE BUFFERMGR_MAX_NUM_BINS
NATIVE_UINT_TYPE numBuffers
number of buffers in this bin. Set to zero for unused bins.
NATIVE_UINT_TYPE bufferSize
size of the buffers in this bin. Set to zero for unused bins.
BufferBin bins[BUFFERMGR_MAX_NUM_BINS]
set of bins to define buffers