* Added a DMAResource::Init() method that gets a device node - for now, it will
reuse the block_io attributes in the node to build the dma_restrictions. * DMAResource::Init() now dumps the dma_resources (should be done with the TRACE() macro later). * Turned off IOScheduler debug output. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26825 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
9e8c301a39
commit
39b5c37418
@ -20,7 +20,7 @@
|
||||
#include <util/AutoLock.h>
|
||||
|
||||
|
||||
#define TRACE_IO_SCHEDULER
|
||||
//#define TRACE_IO_SCHEDULER
|
||||
#ifdef TRACE_IO_SCHEDULER
|
||||
# define TRACE(x...) dprintf(x)
|
||||
#else
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
#include "dma_resources.h"
|
||||
|
||||
#include <block_io.h>
|
||||
|
||||
#include <kernel.h>
|
||||
#include <util/AutoLock.h>
|
||||
|
||||
@ -20,6 +22,8 @@
|
||||
#endif
|
||||
|
||||
|
||||
extern device_manager_info gDeviceManagerModule;
|
||||
|
||||
const size_t kMaxBounceBufferSize = 4 * B_PAGE_SIZE;
|
||||
|
||||
|
||||
@ -94,6 +98,40 @@ DMAResource::~DMAResource()
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
DMAResource::Init(device_node* node, size_t blockSize)
|
||||
{
|
||||
dma_restrictions restrictions;
|
||||
memset(&restrictions, 0, sizeof(dma_restrictions));
|
||||
|
||||
// TODO: add DMA attributes instead of reusing block_io's
|
||||
|
||||
uint32 value;
|
||||
if (gDeviceManagerModule.get_attr_uint32(node,
|
||||
B_BLOCK_DEVICE_DMA_ALIGNMENT, &value, true) == B_OK)
|
||||
restrictions.alignment = value + 1;
|
||||
|
||||
if (gDeviceManagerModule.get_attr_uint32(node,
|
||||
B_BLOCK_DEVICE_DMA_BOUNDARY, &value, true) == B_OK)
|
||||
restrictions.boundary = value + 1;
|
||||
|
||||
if (gDeviceManagerModule.get_attr_uint32(node,
|
||||
B_BLOCK_DEVICE_MAX_SG_BLOCK_SIZE, &value, true) == B_OK)
|
||||
restrictions.max_segment_size = value;
|
||||
|
||||
if (gDeviceManagerModule.get_attr_uint32(node,
|
||||
B_BLOCK_DEVICE_MAX_BLOCKS_ITEM, &value, true) == B_OK)
|
||||
restrictions.max_transfer_size = value * blockSize;
|
||||
|
||||
uint32 bufferCount;
|
||||
if (gDeviceManagerModule.get_attr_uint32(node,
|
||||
B_BLOCK_DEVICE_MAX_SG_BLOCKS, &bufferCount, true) != B_OK)
|
||||
bufferCount = 16;
|
||||
|
||||
return Init(restrictions, blockSize, bufferCount);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
DMAResource::Init(const dma_restrictions& restrictions, size_t blockSize,
|
||||
uint32 bufferCount)
|
||||
@ -123,6 +161,13 @@ DMAResource::Init(const dma_restrictions& restrictions, size_t blockSize,
|
||||
fBounceBufferSize);
|
||||
}
|
||||
|
||||
dprintf("DMAResource@%p: low/high %lx/%lx, max segment count %lu, align %lu, "
|
||||
"boundary %lu, max transfer %lu, max segment size %lu\n", this,
|
||||
fRestrictions.low_address, fRestrictions.high_address,
|
||||
fRestrictions.max_segment_count, fRestrictions.alignment,
|
||||
fRestrictions.boundary, fRestrictions.max_transfer_size,
|
||||
fRestrictions.max_segment_size);
|
||||
|
||||
fScratchVecs = (iovec*)malloc(
|
||||
sizeof(iovec) * fRestrictions.max_segment_count);
|
||||
if (fScratchVecs == NULL)
|
||||
@ -150,9 +195,10 @@ DMAResource::CreateBuffer(size_t size, DMABuffer** _buffer)
|
||||
area_id area = -1;
|
||||
|
||||
if (size != 0) {
|
||||
if (fRestrictions.alignment > B_PAGE_SIZE
|
||||
|| fRestrictions.boundary > B_PAGE_SIZE)
|
||||
panic("not yet implemented");
|
||||
if (fRestrictions.alignment > B_PAGE_SIZE)
|
||||
dprintf("dma buffer restrictions not yet implemented: alignment %lu\n", fRestrictions.alignment);
|
||||
if (fRestrictions.boundary > B_PAGE_SIZE)
|
||||
dprintf("dma buffer restrictions not yet implemented: boundary %lu\n", fRestrictions.boundary);
|
||||
|
||||
size = ROUNDUP(size, B_PAGE_SIZE);
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <util/DoublyLinkedList.h>
|
||||
|
||||
|
||||
struct device_node;
|
||||
struct IOOperation;
|
||||
struct IORequest;
|
||||
|
||||
@ -69,6 +70,7 @@ public:
|
||||
|
||||
status_t Init(const dma_restrictions& restrictions,
|
||||
size_t blockSize, uint32 bufferCount);
|
||||
status_t Init(device_node* node, size_t blockSize);
|
||||
|
||||
status_t CreateBuffer(DMABuffer** _buffer)
|
||||
{ return CreateBuffer(0, _buffer); }
|
||||
|
Loading…
Reference in New Issue
Block a user