28 const char *
const compName
29 ) : BufferManagerComponentBase(compName)
50 BufferManagerComponentBase::init(instance);
65 if (not this->m_cleaned) {
68 this->m_buffers[entry].buff.~Buffer();
70 this->m_cleaned =
true;
72 this->m_allocator->
deallocate(this->m_memId,this->m_buffers);
73 this->m_setup =
false;
82 void BufferManagerComponentImpl ::
94 this->log_WARNING_HI_ZeroSizeBuffer();
100 U32
id = context & 0xFFFF;
101 U32 mgrId = context >> 16;
103 FW_ASSERT(id < this->m_numStructs,
id,this->m_numStructs);
104 FW_ASSERT(mgrId == this->m_mgrId,mgrId,
id,this->m_mgrId);
105 FW_ASSERT(
true == this->m_buffers[
id].allocated,
id,this->m_mgrId);
106 FW_ASSERT(
reinterpret_cast<U8*
>(fwBuffer.
getData()) >= this->m_buffers[
id].memory,
id,this->m_mgrId);
107 FW_ASSERT(
reinterpret_cast<U8*
>(fwBuffer.
getData()) < (this->m_buffers[
id].memory + this->m_buffers[
id].size),
id,this->m_mgrId);
111 this->m_buffers[id].allocated =
false;
116 bufferGetCallee_handler(
126 if ((not this->m_buffers[buff].allocated) and (size < this->m_buffers[buff].size)) {
127 this->m_buffers[buff].allocated =
true;
129 if (this->m_currBuffs > this->m_highWater) {
130 this->m_highWater = this->m_currBuffs;
140 this->log_WARNING_HI_NoBuffsAvailable(size);
153 this->m_mgrId = mgrId;
154 this->m_memId = memId;
155 this->m_allocator = &allocator;
157 memset(&this->m_bufferBins,0,
sizeof(this->m_bufferBins));
159 this->m_bufferBins = bins;
163 this->m_numStructs = 0;
175 bool recoverable =
false;
178 void *memory = allocator.
allocate(memId,allocatedSize,recoverable);
181 FW_ASSERT(memorySize == allocatedSize,memorySize,allocatedSize);
183 this->m_buffers =
static_cast<AllocatedBuffer*
>(memory);
186 U8* bufferMem =
reinterpret_cast<U8*
>(&this->m_buffers[this->m_numStructs]);
195 U32 context = (this->m_mgrId << 16) | currStruct;
196 (void)
new(&this->m_buffers[currStruct].buff)
Fw::Buffer(bufferMem,this->m_bufferBins.
bins[bin].
bufferSize,context);
197 this->m_buffers[currStruct].allocated =
false;
198 this->m_buffers[currStruct].memory = bufferMem;
199 this->m_buffers[currStruct].size = this->m_bufferBins.
bins[bin].
bufferSize;
207 FW_ASSERT(bufferMem == (
static_cast<U8*
>(memory) + memorySize));
208 FW_ASSERT(currStruct == this->m_numStructs,currStruct,this->m_numStructs);
210 this->m_setup =
true;
213 void BufferManagerComponentImpl ::
220 this->tlmWrite_HiBuffs(this->m_highWater);
221 this->tlmWrite_CurrBuffs(this->m_currBuffs);
222 this->tlmWrite_TotalBuffs(this->m_numStructs);
223 this->tlmWrite_NoBuffs(this->m_noBuffs);
224 this->tlmWrite_EmptyBuffs(this->m_emptyBuffs);