28 const char *
const compName
59 if (not this->m_cleaned) {
62 this->m_buffers[entry].buff.~Buffer();
64 this->m_cleaned =
true;
66 this->m_allocator->
deallocate(this->m_memId,this->m_buffers);
67 this->m_setup =
false;
76 void BufferManagerComponentImpl ::
96 U32
id = context & 0xFFFF;
97 U32 mgrId = context >> 16;
100 id < this->m_numStructs,
101 static_cast<FwAssertArgType>(
id),
102 static_cast<FwAssertArgType>(this->m_numStructs));
104 mgrId == this->m_mgrId,
105 static_cast<FwAssertArgType>(mgrId),
106 static_cast<FwAssertArgType>(
id),
107 static_cast<FwAssertArgType>(this->m_mgrId));
109 true == this->m_buffers[
id].allocated,
110 static_cast<FwAssertArgType>(
id),
111 static_cast<FwAssertArgType>(this->m_mgrId));
113 reinterpret_cast<U8*>(fwBuffer.
getData()) >= this->m_buffers[
id].memory,
114 static_cast<FwAssertArgType>(
id),
117 reinterpret_cast<U8*>(fwBuffer.
getData()) < (this->m_buffers[
id].memory + this->m_buffers[
id].size),
119 static_cast<FwAssertArgType>(this->m_mgrId));
122 fwBuffer.
getSize() <= this->m_buffers[id].size,
124 static_cast<FwAssertArgType>(this->m_mgrId));
126 this->m_buffers[id].allocated =
false;
131 bufferGetCallee_handler(
141 if ((not this->m_buffers[buff].allocated) and (size <= this->m_buffers[buff].size)) {
142 this->m_buffers[buff].allocated =
true;
144 if (this->m_currBuffs > this->m_highWater) {
145 this->m_highWater = this->m_currBuffs;
168 this->m_mgrId = mgrId;
169 this->m_memId = memId;
170 this->m_allocator = &allocator;
172 memset(&this->m_bufferBins,0,
sizeof(this->m_bufferBins));
174 this->m_bufferBins = bins;
178 this->m_numStructs = 0;
184 (static_cast<NATIVE_UINT_TYPE>(
sizeof(AllocatedBuffer)) * this->m_bufferBins.
bins[bin].
numBuffers);
190 bool recoverable =
false;
193 void *memory = allocator.
allocate(memId,allocatedSize,recoverable);
197 memorySize == allocatedSize,
198 static_cast<FwAssertArgType>(memorySize),
199 static_cast<FwAssertArgType>(allocatedSize));
201 this->m_buffers =
static_cast<AllocatedBuffer*
>(memory);
204 U8* bufferMem =
reinterpret_cast<U8*
>(&this->m_buffers[this->m_numStructs]);
213 U32 context = (this->m_mgrId << 16) | currStruct;
214 (void)
new(&this->m_buffers[currStruct].buff)
Fw::Buffer(bufferMem,this->m_bufferBins.
bins[bin].
bufferSize,context);
215 this->m_buffers[currStruct].allocated =
false;
216 this->m_buffers[currStruct].memory = bufferMem;
217 this->m_buffers[currStruct].size = this->m_bufferBins.
bins[bin].
bufferSize;
225 U8*
const CURR_PTR = bufferMem;
226 U8*
const END_PTR =
static_cast<U8*
>(memory) + memorySize;
228 static_cast<FwAssertArgType>(reinterpret_cast<POINTER_CAST>(CURR_PTR)),
229 static_cast<FwAssertArgType>(reinterpret_cast<POINTER_CAST>(END_PTR)));
232 currStruct == this->m_numStructs,
233 static_cast<FwAssertArgType>(currStruct),
234 static_cast<FwAssertArgType>(this->m_numStructs));
236 this->m_setup =
true;
239 void BufferManagerComponentImpl ::
PlatformUIntType NATIVE_UINT_TYPE
PlatformAssertArgType FwAssertArgType
~BufferManagerComponentImpl()
void setup(NATIVE_UINT_TYPE mgrID, NATIVE_UINT_TYPE memID, Fw::MemAllocator &allocator, const BufferBins &bins)
set up configuration
BufferBin bins[BUFFERMGR_MAX_NUM_BINS]
set of bins to define buffers
PlatformIntType NATIVE_INT_TYPE
virtual void * allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_TYPE &size, bool &recoverable)=0
Allocate memory.
BufferManagerComponentImpl(const char *const compName)
void log_WARNING_HI_NullEmptyBuffer()
virtual void deallocate(const NATIVE_UINT_TYPE identifier, void *ptr)=0
Deallocate memory.
void tlmWrite_NoBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
void tlmWrite_CurrBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
NATIVE_UINT_TYPE numBuffers
number of buffers in this bin. Set to zero for unused bins.
void tlmWrite_HiBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
C++-compatible configuration header for fprime configuration.
uint8_t U8
8-bit unsigned integer
void tlmWrite_TotalBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
void tlmWrite_EmptyBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
Auto-generated base for BufferManager component.
NATIVE_UINT_TYPE bufferSize
size of the buffers in this bin. Set to zero for unused bins.
static const NATIVE_UINT_TYPE BUFFERMGR_MAX_NUM_BINS
void log_WARNING_HI_NoBuffsAvailable(U32 size)