本文整理汇总了C++中IOBuffer::VecCount方法的典型用法代码示例。如果您正苦于以下问题:C++ IOBuffer::VecCount方法的具体用法?C++ IOBuffer::VecCount怎么用?C++ IOBuffer::VecCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOBuffer
的用法示例。
在下文中一共展示了IOBuffer::VecCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: locker
status_t
DMAResource::TranslateNext(IORequest* request, IOOperation* operation,
generic_size_t maxOperationLength)
{
IOBuffer* buffer = request->Buffer();
off_t originalOffset = request->Offset() + request->Length()
- request->RemainingBytes();
off_t offset = originalOffset;
generic_size_t partialBegin = offset & (fBlockSize - 1);
// current iteration state
uint32 vecIndex = request->VecIndex();
uint32 vecOffset = request->VecOffset();
generic_size_t totalLength = min_c(request->RemainingBytes(),
fRestrictions.max_transfer_size);
if (maxOperationLength > 0
&& maxOperationLength < totalLength + partialBegin) {
totalLength = maxOperationLength - partialBegin;
}
MutexLocker locker(fLock);
DMABuffer* dmaBuffer = fDMABuffers.RemoveHead();
if (dmaBuffer == NULL)
return B_BUSY;
dmaBuffer->SetVecCount(0);
generic_io_vec* vecs = NULL;
uint32 segmentCount = 0;
TRACE(" offset %Ld, remaining size: %lu, block size %lu -> partial: %lu\n",
offset, request->RemainingBytes(), fBlockSize, partialBegin);
if (buffer->IsVirtual()) {
// Unless we need the bounce buffer anyway, we have to translate the
// virtual addresses to physical addresses, so we can check the DMA
// restrictions.
TRACE(" buffer is virtual %s\n", buffer->IsUser() ? "user" : "kernel");
// TODO: !partialOperation || totalLength >= fBlockSize
// TODO: Maybe enforce fBounceBufferSize >= 2 * fBlockSize.
if (true) {
generic_size_t transferLeft = totalLength;
vecs = fScratchVecs;
TRACE(" create physical map (for %ld vecs)\n", buffer->VecCount());
for (uint32 i = vecIndex; i < buffer->VecCount(); i++) {
generic_io_vec& vec = buffer->VecAt(i);
generic_addr_t base = vec.base + vecOffset;
generic_size_t size = vec.length - vecOffset;
vecOffset = 0;
if (size > transferLeft)
size = transferLeft;
while (size > 0 && segmentCount
< fRestrictions.max_segment_count) {
physical_entry entry;
uint32 count = 1;
get_memory_map_etc(request->TeamID(), (void*)base, size,
&entry, &count);
vecs[segmentCount].base = entry.address;
vecs[segmentCount].length = entry.size;
transferLeft -= entry.size;
base += entry.size;
size -= entry.size;
segmentCount++;
}
if (transferLeft == 0)
break;
}
totalLength -= transferLeft;
}
vecIndex = 0;
vecOffset = 0;
} else {
// We do already have physical addresses.
locker.Unlock();
vecs = buffer->Vecs();
segmentCount = min_c(buffer->VecCount() - vecIndex,
fRestrictions.max_segment_count);
}
#ifdef TRACE_DMA_RESOURCE
TRACE(" physical count %lu\n", segmentCount);
for (uint32 i = 0; i < segmentCount; i++) {
TRACE(" [%" B_PRIu32 "] %#" B_PRIxGENADDR ", %" B_PRIxGENADDR "\n",
i, vecs[vecIndex + i].base, vecs[vecIndex + i].length);
}
#endif
// check alignment, boundaries, etc. and set vecs in DMA buffer
// Fetch a bounce buffer we can use for the DMABuffer.
// TODO: We should do that lazily when needed!
//.........这里部分代码省略.........