26 BufferManagerComponentImpl ::
27 BufferManagerComponentImpl(
28 const char *
const compName
29 ) : BufferManagerComponentBase(compName)
45 void BufferManagerComponentImpl ::
50 BufferManagerComponentBase::init(instance);
53 BufferManagerComponentImpl ::
54 ~BufferManagerComponentImpl()
61 void BufferManagerComponentImpl ::
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 ::
96 this->log_WARNING_HI_ZeroSizeBuffer();
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;
142 this->log_WARNING_HI_NoBuffsAvailable(size);
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 ::
226 this->tlmWrite_HiBuffs(this->m_highWater);
227 this->tlmWrite_CurrBuffs(this->m_currBuffs);
228 this->tlmWrite_TotalBuffs(this->m_numStructs);
229 this->tlmWrite_NoBuffs(this->m_noBuffs);
230 this->tlmWrite_EmptyBuffs(this->m_emptyBuffs);
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 * allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_TYPE &size, bool &recoverable)=0
Allocate memory.
void setup(NATIVE_UINT_TYPE mgrID, NATIVE_UINT_TYPE memID, Fw::MemAllocator &allocator, const BufferBins &bins)
set up configuration
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