kernel/dma_resource: Add an assertion to prevent Init() from being called twice.

This commit is contained in:
Augustin Cavalier 2023-05-29 19:44:48 -04:00
parent 92b8f3e74c
commit 831bb20728

View File

@ -93,6 +93,7 @@ DMABuffer::Dump() const
DMAResource::DMAResource() DMAResource::DMAResource()
: :
fBlockSize(0),
fScratchVecs(NULL) fScratchVecs(NULL)
{ {
mutex_init(&fLock, "dma resource"); mutex_init(&fLock, "dma resource");
@ -159,6 +160,7 @@ DMAResource::Init(const dma_restrictions& restrictions,
generic_size_t blockSize, uint32 bufferCount, uint32 bounceBufferCount) generic_size_t blockSize, uint32 bufferCount, uint32 bounceBufferCount)
{ {
ASSERT(restrictions.alignment <= blockSize); ASSERT(restrictions.alignment <= blockSize);
ASSERT(fBlockSize == 0);
fRestrictions = restrictions; fRestrictions = restrictions;
fBlockSize = blockSize == 0 ? 1 : blockSize; fBlockSize = blockSize == 0 ? 1 : blockSize;