28 const char *
const compName
59 if (not this->m_cleaned) {
61 for (U16 entry = 0; entry < this->m_numStructs; entry++) {
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(
140 for (U16 buff = 0; buff < this->m_numStructs; buff++) {
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<FwSizeType>(
sizeof(AllocatedBuffer)) * this->m_bufferBins.
bins[bin].
numBuffers);
187 this->m_numStructs =
static_cast<U16
>(this->m_numStructs + this->m_bufferBins.
bins[bin].
numBuffers);
192 bool recoverable =
false;
195 void *memory = allocator.
allocate(memId,allocatedSize,recoverable);
197 FW_ASSERT(memory !=
nullptr && memorySize == allocatedSize,
198 static_cast<FwAssertArgType>(mgrId),
199 static_cast<FwAssertArgType>(memId),
200 static_cast<FwAssertArgType>(reinterpret_cast<PlatformPointerCastType>(memory)),
201 static_cast<FwAssertArgType>(memorySize),
202 static_cast<FwAssertArgType>(allocatedSize));
204 this->m_buffers =
static_cast<AllocatedBuffer*
>(memory);
207 U8* bufferMem =
reinterpret_cast<U8*
>(&this->m_buffers[this->m_numStructs]);
213 for (U16 binEntry = 0; binEntry < this->m_bufferBins.
bins[bin].
numBuffers; binEntry++) {
216 U32 context = (
static_cast<U32
>(this->m_mgrId) << 16) |
static_cast<U32
>(currStruct);
217 (void)
new(&this->m_buffers[currStruct].buff)
Fw::Buffer(bufferMem,this->m_bufferBins.
bins[bin].
bufferSize,context);
218 this->m_buffers[currStruct].allocated =
false;
219 this->m_buffers[currStruct].memory = bufferMem;
220 this->m_buffers[currStruct].size = this->m_bufferBins.
bins[bin].
bufferSize;
228 U8*
const CURR_PTR = bufferMem;
229 U8*
const END_PTR =
static_cast<U8*
>(memory) + memorySize;
231 static_cast<FwAssertArgType>(mgrId),
232 static_cast<FwAssertArgType>(memId),
233 static_cast<FwAssertArgType>(reinterpret_cast<PlatformPointerCastType>(CURR_PTR)),
234 static_cast<FwAssertArgType>(reinterpret_cast<PlatformPointerCastType>(END_PTR)));
237 currStruct == this->m_numStructs,
238 static_cast<FwAssertArgType>(mgrId),
239 static_cast<FwAssertArgType>(memId),
240 static_cast<FwAssertArgType>(currStruct),
241 static_cast<FwAssertArgType>(this->m_numStructs));
243 this->m_setup =
true;
246 void BufferManagerComponentImpl ::
~BufferManagerComponentImpl()
PlatformSizeType FwSizeType
BufferBin bins[BUFFERMGR_MAX_NUM_BINS]
set of bins to define buffers
virtual void * allocate(const FwEnumStoreType identifier, FwSizeType &size, bool &recoverable)=0
Allocate memory.
void setSize(SizeType size)
Fw::Buffer::SizeType bufferSize
size of the buffers in this bin. Set to zero for unused bins.
static const U16 BUFFERMGR_MAX_NUM_BINS
BufferManagerComponentImpl(const char *const compName)
void log_WARNING_HI_NullEmptyBuffer()
void tlmWrite_NoBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
void tlmWrite_CurrBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
void tlmWrite_HiBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
uint8_t U8
8-bit unsigned integer
void tlmWrite_TotalBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
void setup(U16 mgrID, FwEnumStoreType memID, Fw::MemAllocator &allocator, const BufferBins &bins)
set up configuration
void tlmWrite_EmptyBuffs(U32 arg, Fw::Time _tlmTime=Fw::Time())
PlatformIndexType FwIndexType
RateGroupDivider component implementation.
virtual void deallocate(const FwEnumStoreType identifier, void *ptr)=0
Deallocate memory.
Auto-generated base for BufferManager component.
void log_WARNING_HI_NoBuffsAvailable(U32 size)
U32 SizeType
The size type for a buffer.
U16 numBuffers
number of buffers in this bin. Set to zero for unused bins.
PlatformAssertArgType FwAssertArgType
The type of arguments to assert functions.