Fixed build.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37236 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2010-06-23 18:36:40 +00:00
parent 7a0dca5c54
commit 621f42cb59
1 changed files with 57 additions and 57 deletions

View File

@ -9,11 +9,11 @@
#include <device_manager.h> #include <device_manager.h>
#include <vm.h> #include <vm/vm.h>
#include "dma_resources.h" #include "dma_resources.h"
#include "io_requests.h" #include "io_requests.h"
#include "IOScheduler.h" #include "IOSchedulerSimple.h"
#define DMA_TEST_BLOCK_SIZE 512 #define DMA_TEST_BLOCK_SIZE 512
@ -83,7 +83,7 @@ private:
size_t fLength; size_t fLength;
bool fIsWrite; bool fIsWrite;
uint32 fFlags; uint32 fFlags;
iovec fSourceVecs[32]; generic_io_vec fSourceVecs[32];
uint32 fSourceCount; uint32 fSourceCount;
struct target_t { struct target_t {
@ -113,13 +113,14 @@ public:
fContext(context) fContext(context)
{ {
dprintf("----- Run \"%s\" tests ---------------------------\n", name); dprintf("----- Run \"%s\" tests ---------------------------\n", name);
dprintf(" DMA restrictions: address %#lx - %#lx, align %lu, boundary " dprintf(" DMA restrictions: address %#" B_PRIxGENADDR " - %#"
"%lu,\n max transfer %lu, max segs %lu, max seg size %lu, " B_PRIxGENADDR ", align %" B_PRIuGENADDR ", boundary %" B_PRIuGENADDR
"flags %lx\n\n", restrictions.low_address, ",\n max transfer %" B_PRIuGENADDR ", max segs %" B_PRIx32
restrictions.high_address, restrictions.alignment, ", max seg size %" B_PRIxGENADDR ", flags %" B_PRIx32 "\n\n",
restrictions.boundary, restrictions.max_transfer_size, restrictions.low_address, restrictions.high_address,
restrictions.max_segment_count, restrictions.max_segment_size, restrictions.alignment, restrictions.boundary,
restrictions.flags); restrictions.max_transfer_size, restrictions.max_segment_count,
restrictions.max_segment_size, restrictions.flags);
status_t status = fDMAResource.Init(restrictions, blockSize, 10, 10); status_t status = fDMAResource.Init(restrictions, blockSize, 10, 10);
if (status != B_OK) if (status != B_OK)
@ -186,9 +187,9 @@ do_io(void* data, IOOperation* operation)
off_t offset = operation->Offset(); off_t offset = operation->Offset();
for (uint32 i = 0; i < operation->VecCount(); i++) { for (uint32 i = 0; i < operation->VecCount(); i++) {
const iovec& vec = operation->Vecs()[i]; const generic_io_vec& vec = operation->Vecs()[i];
addr_t base = (addr_t)vec.iov_base; generic_addr_t base = vec.base;
size_t length = vec.iov_len; generic_size_t length = vec.length;
if (operation->IsWrite()) if (operation->IsWrite())
vm_memcpy_from_physical(disk + offset, base, length, false); vm_memcpy_from_physical(disk + offset, base, length, false);
@ -253,7 +254,8 @@ TestSuiteContext::Init(size_t size, bool contiguous)
fPhysicalDataBase = (addr_t)entry[0].address; fPhysicalDataBase = (addr_t)entry[0].address;
fSecondPhysicalDataBase = (addr_t)entry[1].address; fSecondPhysicalDataBase = (addr_t)entry[1].address;
dprintf("DMA Test area %p, physical %p, second physical %p\n", dprintf("DMA Test area %p, physical %#" B_PRIxPHYSADDR
", second physical %#" B_PRIxPHYSADDR "\n",
(void*)fDataBase, entry[0].address, entry[1].address); (void*)fDataBase, entry[0].address, entry[1].address);
break; break;
} }
@ -274,8 +276,8 @@ TestSuiteContext::Init(size_t size, bool contiguous)
fPhysicalDataBase = (addr_t)entry.address; fPhysicalDataBase = (addr_t)entry.address;
fSecondPhysicalDataBase = 0; fSecondPhysicalDataBase = 0;
dprintf("DMA Test area %p, physical %p\n", (void*)fDataBase, dprintf("DMA Test area %p, physical %#" B_PRIxPHYSADDR "\n",
entry.address); (void*)fDataBase, entry.address);
} }
fCompareArea = create_area("compare buffer", (void**)&fCompareBase, fCompareArea = create_area("compare buffer", (void**)&fCompareBase,
@ -311,14 +313,14 @@ Test::AddSource(addr_t address, size_t length)
{ {
if (fSuite.IsContiguous() || (fFlags & B_PHYSICAL_IO_REQUEST) != 0 if (fSuite.IsContiguous() || (fFlags & B_PHYSICAL_IO_REQUEST) != 0
|| address < B_PAGE_SIZE) { || address < B_PAGE_SIZE) {
fSourceVecs[fSourceCount].iov_base fSourceVecs[fSourceCount].base
= (void*)(((fFlags & B_PHYSICAL_IO_REQUEST) == 0 = ((fFlags & B_PHYSICAL_IO_REQUEST) == 0
? fSuite.DataBase() : fSuite.PhysicalDataBase()) + address); ? fSuite.DataBase() : fSuite.PhysicalDataBase()) + address;
} else { } else {
fSourceVecs[fSourceCount].iov_base fSourceVecs[fSourceCount].base
= (void*)(fSuite.SecondPhysicalDataBase() + address); = fSuite.SecondPhysicalDataBase() + address;
} }
fSourceVecs[fSourceCount].iov_len = length; fSourceVecs[fSourceCount].length = length;
fSourceCount++; fSourceCount++;
return *this; return *this;
@ -401,9 +403,8 @@ Test::_Prepare()
size_t length = fLength; size_t length = fLength;
for (uint32 i = 0; i < fSourceCount; i++) { for (uint32 i = 0; i < fSourceCount; i++) {
uint8* data = (uint8*)_SourceToVirtual( uint8* data = (uint8*)_SourceToVirtual(fSourceVecs[i].base);
(addr_t)fSourceVecs[i].iov_base); size_t vecLength = min_c(fSourceVecs[i].length, length);
size_t vecLength = min_c(fSourceVecs[i].iov_len, length);
for (uint32 j = 0; j < vecLength; j++) { for (uint32 j = 0; j < vecLength; j++) {
data[j] = (offset + j) % 10 + '0'; data[j] = (offset + j) % 10 + '0';
@ -423,12 +424,10 @@ Test::_Prepare()
size_t length = fLength; size_t length = fLength;
for (uint32 i = 0; i < fSourceCount; i++) { for (uint32 i = 0; i < fSourceCount; i++) {
uint8* compare = (uint8*)_SourceToCompare( uint8* compare = (uint8*)_SourceToCompare(fSourceVecs[i].base);
(addr_t)fSourceVecs[i].iov_base); size_t vecLength = min_c(fSourceVecs[i].length, length);
size_t vecLength = min_c(fSourceVecs[i].iov_len, length);
memcpy(compare, memcpy(compare, (void*)_SourceToVirtual(fSourceVecs[i].base),
(void*)_SourceToVirtual((addr_t)fSourceVecs[i].iov_base),
vecLength); vecLength);
offset += vecLength; offset += vecLength;
length -= vecLength; length -= vecLength;
@ -439,9 +438,8 @@ Test::_Prepare()
size_t length = fLength; size_t length = fLength;
for (uint32 i = 0; i < fSourceCount; i++) { for (uint32 i = 0; i < fSourceCount; i++) {
uint8* compare = (uint8*)_SourceToCompare( uint8* compare = (uint8*)_SourceToCompare(fSourceVecs[i].base);
(addr_t)fSourceVecs[i].iov_base); size_t vecLength = min_c(fSourceVecs[i].length, length);
size_t vecLength = min_c(fSourceVecs[i].iov_len, length);
memcpy(compare, disk + offset, vecLength); memcpy(compare, disk + offset, vecLength);
offset += vecLength; offset += vecLength;
@ -504,9 +502,8 @@ Test::_CheckWrite()
size_t length = fLength; size_t length = fLength;
for (uint32 i = 0; i < fSourceCount; i++) { for (uint32 i = 0; i < fSourceCount; i++) {
uint8* data = (uint8*)_SourceToVirtual( uint8* data = (uint8*)_SourceToVirtual(fSourceVecs[i].base);
(addr_t)fSourceVecs[i].iov_base); size_t vecLength = min_c(fSourceVecs[i].length, length);
size_t vecLength = min_c(fSourceVecs[i].iov_len, length);
for (uint32 j = 0; j < vecLength; j++) { for (uint32 j = 0; j < vecLength; j++) {
if (disk[offset + j] != data[j]) { if (disk[offset + j] != data[j]) {
@ -571,20 +568,23 @@ Test::Run(DMAResource& resource)
DMABuffer* buffer = operation.Buffer(); DMABuffer* buffer = operation.Buffer();
dprintf("IOOperation: offset %Ld, length %lu (%Ld/%lu)\n", dprintf("IOOperation: offset %" B_PRIdOFF ", length %" B_PRIuGENADDR
operation.Offset(), operation.Length(), operation.OriginalOffset(), " (%" B_PRIdOFF "/%" B_PRIuGENADDR ")\n", operation.Offset(),
operation.Length(), operation.OriginalOffset(),
operation.OriginalLength()); operation.OriginalLength());
dprintf(" DMABuffer %p, %lu vecs, bounce buffer: %p (%p) %s\n", buffer, dprintf(" DMABuffer %p, %lu vecs, bounce buffer: %p (%p) %s\n", buffer,
buffer->VecCount(), buffer->BounceBufferAddress(), buffer->VecCount(), buffer->BounceBufferAddress(),
(void*)buffer->PhysicalBounceBufferAddress(), (void*)buffer->PhysicalBounceBufferAddress(),
operation.UsesBounceBuffer() ? "used" : "unused"); operation.UsesBounceBuffer() ? "used" : "unused");
for (uint32 i = 0; i < buffer->VecCount(); i++) { for (uint32 i = 0; i < buffer->VecCount(); i++) {
dprintf(" [%lu] base %p, length %lu%s\n", i, dprintf(" [%" B_PRIu32 "] base %#" B_PRIxGENADDR ", length %"
buffer->VecAt(i).iov_base, buffer->VecAt(i).iov_len, B_PRIuGENADDR "%s\n", i, buffer->VecAt(i).base,
buffer->VecAt(i).length,
buffer->UsesBounceBufferAt(i) ? ", bounce" : ""); buffer->UsesBounceBufferAt(i) ? ", bounce" : "");
} }
dprintf(" remaining bytes: %lu\n", request.RemainingBytes()); dprintf(" remaining bytes: %" B_PRIuGENADDR "\n",
request.RemainingBytes());
// check results // check results
@ -594,25 +594,25 @@ Test::Run(DMAResource& resource)
for (uint32 i = 0; i < result.count; i++) { for (uint32 i = 0; i < result.count; i++) {
const target_t& target = result.targets[i]; const target_t& target = result.targets[i];
const iovec& vec = buffer->VecAt(i); const generic_io_vec& vec = buffer->VecAt(i);
if (target.length != vec.iov_len) if (target.length != vec.length)
_Panic("[%lu] length differs", i); _Panic("[%lu] length differs", i);
void* address; generic_addr_t address;
if (target.uses_bounce_buffer) { if (target.uses_bounce_buffer) {
address = (void*)(target.address address = target.address
+ (addr_t)buffer->PhysicalBounceBufferAddress()); + (addr_t)buffer->PhysicalBounceBufferAddress();
} else if (fSuite.IsContiguous() || target.address < B_PAGE_SIZE) { } else if (fSuite.IsContiguous() || target.address < B_PAGE_SIZE) {
address = (void*)(target.address + fSuite.PhysicalDataBase()); address = target.address + fSuite.PhysicalDataBase();
} else { } else {
address = (void*)(target.address - B_PAGE_SIZE address = target.address - B_PAGE_SIZE
+ fSuite.SecondPhysicalDataBase()); + fSuite.SecondPhysicalDataBase();
} }
if (address != vec.iov_base) { if (address != vec.base) {
_Panic("[%lu] address differs: %p, should be %p", i, _Panic("[%" B_PRIu32 "] address differs: %#" B_PRIxGENADDR
vec.iov_base, address); ", should be %#" B_PRIuGENADDR "", i, vec.base, address);
} }
} }
@ -674,8 +674,8 @@ Test::_Panic(const char* message,...)
dprintf(" flags: %#lx\n", fFlags); dprintf(" flags: %#lx\n", fFlags);
dprintf(" sources:\n"); dprintf(" sources:\n");
for (uint32 i = 0; i < fSourceCount; i++) { for (uint32 i = 0; i < fSourceCount; i++) {
dprintf(" [%p, %lu]\n", fSourceVecs[i].iov_base, dprintf(" [%#" B_PRIxGENADDR ", %" B_PRIuGENADDR "]\n",
fSourceVecs[i].iov_len); fSourceVecs[i].base, fSourceVecs[i].length);
} }
for (uint32 i = 0; i < fResultCount; i++) { for (uint32 i = 0; i < fResultCount; i++) {
const result_t& result = fResults[i]; const result_t& result = fResults[i];
@ -1175,7 +1175,7 @@ dma_test_init_device(void *driverCookie, void **_deviceCookie)
return status; return status;
} }
sIOScheduler = new(std::nothrow) IOScheduler(sDMAResource); sIOScheduler = new(std::nothrow) IOSchedulerSimple(sDMAResource);
if (sIOScheduler == NULL) { if (sIOScheduler == NULL) {
delete sDMAResource; delete sDMAResource;
return B_NO_MEMORY; return B_NO_MEMORY;
@ -1233,7 +1233,7 @@ dma_test_read(void *cookie, off_t pos, void *buffer, size_t *_length)
#if 1 #if 1
IORequest request; IORequest request;
status_t status = request.Init(pos, buffer, length, false, 0); status_t status = request.Init(pos, (addr_t)buffer, length, false, 0);
if (status != B_OK) if (status != B_OK)
return status; return status;
@ -1265,7 +1265,7 @@ dma_test_write(void *cookie, off_t pos, const void *buffer, size_t *_length)
#if 1 #if 1
IORequest request; IORequest request;
status_t status = request.Init(pos, (void*)buffer, length, true, 0); status_t status = request.Init(pos, (addr_t)buffer, length, true, 0);
if (status != B_OK) if (status != B_OK)
return status; return status;