navienginebsp/naviengine_assp/pci/test.cpp
changeset 0 5de814552237
equal deleted inserted replaced
-1:000000000000 0:5de814552237
       
     1 /*
       
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <pci.h>
       
    21 #include <naviengine_priv.h>
       
    22 #include <naviengine.h>
       
    23 #include <kernel/cache.h>
       
    24 #include "allocator.h"
       
    25 #include "pci-ne.h"
       
    26 
       
    27 #define TEST(X) __NK_ASSERT_ALWAYS(X)
       
    28 #define TEST_KERRNONE(X) TEST((X)==KErrNone)
       
    29 
       
    30 /**
       
    31 Make sure that I can read and write some values as expected
       
    32 */
       
    33 void TestConfigAccess(TAddrSpace& aCfgSpc)
       
    34 	{
       
    35 	TEST(aCfgSpc.Size()==0x100);
       
    36 
       
    37 	TEST(aCfgSpc.Read32(0x0)==0x00351033);
       
    38 
       
    39 	TEST(aCfgSpc.Read16(0x0)==0x1033);
       
    40 
       
    41 	TEST(aCfgSpc.Read16(0x2)==0x0035);
       
    42 
       
    43 	TEST(aCfgSpc.Read8(0x0)==0x33);
       
    44 
       
    45 	TEST(aCfgSpc.Read8(0x1)==0x10);
       
    46 
       
    47 	TEST(aCfgSpc.Read8(0x02)==0x35);
       
    48 
       
    49 	TEST(aCfgSpc.Read8(0x3)==0x00);
       
    50 
       
    51 	//test writes (there aren't that many contiguous blocks of writable bits in config space, but the BAR will do)
       
    52 	const TUint32 original= aCfgSpc.Read32(KPciBar0);
       
    53 
       
    54 	aCfgSpc.Write32(KPciBar0,0xFFFFFFFF);
       
    55 	const TUint32 filled = aCfgSpc.Read32(KPciBar0);
       
    56 	TEST(filled==0xFFFFF000); //not all of register is writable
       
    57 
       
    58 	aCfgSpc.Write8(KPciBar0+0x3,0xBA);
       
    59 	TEST(aCfgSpc.Read8(KPciBar0+0x3)== 0xBA);
       
    60 	TEST(aCfgSpc.Read32(KPciBar0)== 0xBAFFF000);
       
    61 
       
    62 	aCfgSpc.Write8(KPciBar0+0x2,0x55);
       
    63 	TEST(aCfgSpc.Read8(KPciBar0+0x2)== 0x55);
       
    64 	TEST(aCfgSpc.Read32(KPciBar0)== 0xBA55F000);
       
    65 
       
    66 	aCfgSpc.Write8(KPciBar0+0x1,0x42);
       
    67 	TEST(aCfgSpc.Read8(KPciBar0+0x1)== 0x40); //lower nibble unwriteable
       
    68 	TEST(aCfgSpc.Read32(KPciBar0)== 0xBA554000);
       
    69 
       
    70 	aCfgSpc.Write16(KPciBar0+0x0,0x5000);
       
    71 	TEST(aCfgSpc.Read16(KPciBar0+0x0)== 0x5000);
       
    72 	TEST(aCfgSpc.Read32(KPciBar0)== 0xBA555000);
       
    73 
       
    74 	aCfgSpc.Write16(KPciBar0+0x2,0xAAAA);
       
    75 	TEST(aCfgSpc.Read16(KPciBar0+0x2)== 0xAAAA);
       
    76 	TEST(aCfgSpc.Read32(KPciBar0)== 0xAAAA5000);
       
    77 
       
    78 
       
    79 	//test modifies
       
    80 	aCfgSpc.Modify8(KPciBar0+0x3, 0xFF, 0x3C);
       
    81 	TEST(aCfgSpc.Read8(KPciBar0+0x3) == 0x3C);
       
    82 
       
    83 	aCfgSpc.Modify8(KPciBar0+0x2, 0xFF, 0x3C);
       
    84 	TEST(aCfgSpc.Read8(KPciBar0+0x2) == 0x3C);
       
    85 
       
    86 	//restore original value.
       
    87 	aCfgSpc.Write32(KPciBar0, original);
       
    88 	TEST(aCfgSpc.Read32(KPciBar0)==original);
       
    89 	}
       
    90 
       
    91 
       
    92 TBool TestMemoryAccess(TAddrSpace& memSpace)
       
    93 	{
       
    94 	TEST(memSpace.Size()==0x1000);
       
    95 
       
    96 	//try some writes to the HcControlHeadED register - bits 31:4 are writeable
       
    97 	const TUint KReg=0x20;
       
    98 	const TUint32 initial = memSpace.Read32(KReg);
       
    99 
       
   100 	memSpace.Write32(KReg, 0x0);
       
   101 	TEST(memSpace.Read32(KReg)==0x0);
       
   102 
       
   103 	memSpace.Write32(KReg, 0xFFFFFFFF);
       
   104 	TEST(memSpace.Read32(KReg)==0xFFFFFFF0); //nibble0 read-only
       
   105 
       
   106 	memSpace.Write16(KReg+2, 0xDEAD);
       
   107 	TEST(memSpace.Read32(KReg)==0xDEADFFF0);
       
   108 
       
   109 	memSpace.Write16(KReg, 0xABCD);
       
   110 	TEST(memSpace.Read16(KReg)==0xABC0);
       
   111 	TEST(memSpace.Read16(KReg+2)==0xDEAD);
       
   112 
       
   113 	memSpace.Modify32(KReg, 0x0000FFFF, 0x0F0F0000);
       
   114 	TEST(memSpace.Read32(KReg)==0xDFAF0000);
       
   115 	TEST(memSpace.Read8(KReg+3)==0xDF);
       
   116 
       
   117 	memSpace.Write8(KReg+1,0x42);
       
   118 	TEST(memSpace.Read8(KReg+0)==0x00);
       
   119 	TEST(memSpace.Read8(KReg+1)==0x42);
       
   120 	TEST(memSpace.Read8(KReg+2)==0xAF);
       
   121 	TEST(memSpace.Read8(KReg+3)==0xDF);
       
   122 	TEST(memSpace.Read32(KReg)==0xDFAF4200);
       
   123 
       
   124 	memSpace.Modify8(KReg+3,0xFF,0x10);
       
   125 	TEST(memSpace.Read32(KReg)==0x10AF4200);
       
   126 
       
   127 	//reset to inital value
       
   128 	memSpace.Write32(KReg, initial);
       
   129 	TEST(memSpace.Read32(KReg)==initial);
       
   130 
       
   131 	return ETrue;
       
   132 	}
       
   133 
       
   134 void TestAllocator()
       
   135 	{
       
   136 	__KTRACE_OPT(KPCI, Kern::Printf("Testing address allocator"));
       
   137 	TAddressAllocator allocator(0x80000000); //2 GB
       
   138 	TLinAddr rcvdAddr=NULL;
       
   139 	TEST_KERRNONE(allocator.Allocate(rcvdAddr,0x10) );
       
   140 	TEST(0x0 ==rcvdAddr);
       
   141 	TEST_KERRNONE(allocator.Allocate(rcvdAddr,0x100) );
       
   142 	TEST(0x100 ==rcvdAddr);
       
   143 	TEST_KERRNONE(allocator.Allocate(rcvdAddr,0x10) );
       
   144 	TEST(0x10 ==rcvdAddr);
       
   145 	TEST_KERRNONE(allocator.Allocate(rcvdAddr,0x10) );
       
   146 	TEST(0x20 ==rcvdAddr);
       
   147 	//test deallocating
       
   148 	TEST_KERRNONE(allocator.DeAllocate(0x0));
       
   149 	TEST_KERRNONE(allocator.Allocate(rcvdAddr,0x10) );
       
   150 	TEST(0x000 ==rcvdAddr);
       
   151 
       
   152 	TEST_KERRNONE(allocator.DeAllocate(0x100));
       
   153 	TEST_KERRNONE(allocator.Allocate(rcvdAddr,0x100) );
       
   154 	TEST(0x100 ==rcvdAddr);
       
   155 
       
   156 	TEST_KERRNONE(allocator.DeAllocate(0x10));
       
   157 	TEST_KERRNONE(allocator.Allocate(rcvdAddr,0x10) );
       
   158 	TEST(0x10 ==rcvdAddr);
       
   159 
       
   160 	TEST_KERRNONE(allocator.DeAllocate(0x20));
       
   161 	TEST_KERRNONE(allocator.Allocate(rcvdAddr,0x20) );
       
   162 	TEST(0x20 ==rcvdAddr);
       
   163 
       
   164 	TEST(allocator.DeAllocate(0x40)==KErrNotFound);
       
   165 	TEST_KERRNONE(allocator.DeAllocate(0x100));
       
   166 	TEST_KERRNONE(allocator.DeAllocate(0x20));
       
   167 	TEST_KERRNONE(allocator.DeAllocate(0x0));
       
   168 	TEST_KERRNONE(allocator.DeAllocate(0x10));
       
   169 	}
       
   170 
       
   171 /**
       
   172 Wrapper to get chunk and its virtual address
       
   173 */
       
   174 TInt CreatePciChunk(TInt aFunc, TInt& aSize, TUint32 aAttributes, DPlatChunkHw*& aChunk, TUint32& aPci, TLinAddr& aVirt)
       
   175 	{
       
   176 	TInt r = Pci::CreateChunk(aFunc, aChunk, aSize, aAttributes, aPci);
       
   177 	if(r!=KErrNone)
       
   178 		return r;
       
   179 
       
   180 	aVirt=aChunk->LinearAddress();
       
   181 
       
   182 	return r;
       
   183 	}
       
   184 
       
   185 /**
       
   186 Wrapper to create chunk and append to array
       
   187 */
       
   188 TInt CreatePciChunkAppend(TInt aFunc, TInt aSize, TUint32 aAttributes, RPointerArray<DPlatChunkHw>& aChunks)
       
   189 	{
       
   190 	DPlatChunkHw* chunk=NULL;
       
   191 	TUint32 pci=NULL;
       
   192 	TInt r = Pci::CreateChunk(aFunc, chunk, aSize, aAttributes, pci);
       
   193 	if(KErrNone==r)
       
   194 		{
       
   195 		TEST_KERRNONE(aChunks.Append(chunk));
       
   196 		}
       
   197 	return r;
       
   198 	}
       
   199 
       
   200 TInt CreateSharedChunk(TInt aSize, TUint32& aAttributes, DChunk*& aChunk, TLinAddr& aVirt, TPhysAddr& aPhysicalAddress)
       
   201 	{
       
   202 	TEST(aChunk==NULL);
       
   203 	aSize = Kern::RoundToPageSize(aSize);
       
   204 	TChunkCreateInfo info;
       
   205 	info.iType=TChunkCreateInfo::ESharedKernelSingle;
       
   206 	info.iMaxSize=aSize;
       
   207 	info.iMapAttr=aAttributes;
       
   208 	info.iOwnsMemory=ETrue;
       
   209 
       
   210 	DChunk* pC=NULL;
       
   211 
       
   212 	NKern::ThreadEnterCS();
       
   213 	TInt r=Kern::ChunkCreate(info, pC, aVirt, aAttributes);
       
   214 	if(r!=KErrNone)
       
   215 		{
       
   216 		NKern::ThreadLeaveCS();
       
   217 		return r;
       
   218 		}
       
   219 
       
   220 	r = Kern::ChunkCommitContiguous(pC, 0, aSize, aPhysicalAddress);
       
   221 
       
   222 	if(r==KErrNone)
       
   223 		{
       
   224 		aChunk=pC;
       
   225 		}
       
   226 	else
       
   227 		{
       
   228 		Kern::ChunkClose(pC);
       
   229 		}
       
   230 
       
   231 	NKern::ThreadLeaveCS();
       
   232 	__KTRACE_OPT(KPCI, Kern::Printf("Created SC: size=0x%08x, virtual= 0x%08x, phys=0x%08x", aSize, aVirt, aPhysicalAddress));
       
   233 	return r;
       
   234 	}
       
   235 
       
   236 TInt UnmapAndCloseSC(TInt aFunc, DChunk* aChunk, TPhysAddr aPhysicalAddress)
       
   237 	{
       
   238 	TInt r = Pci::RemoveMapping(aFunc, aPhysicalAddress);
       
   239 	TEST_KERRNONE(r);
       
   240 	NKern::ThreadEnterCS();
       
   241 	TEST(Kern::ChunkClose(aChunk)); //test that ref count has gone to zero
       
   242 	NKern::ThreadLeaveCS();
       
   243 	return r;
       
   244 	}
       
   245 
       
   246 TInt CreateAndMapSC(TInt aFunc, TInt aSize, TUint32 aAttributes, DChunk*& aChunk, TUint32& aPci, TLinAddr& aVirt, TPhysAddr& aPhysicalAddress)
       
   247 	{
       
   248 	TInt r = CreateSharedChunk(aSize, aAttributes, aChunk, aVirt, aPhysicalAddress);
       
   249 	TEST_KERRNONE(r);
       
   250 	TEST(aChunk);
       
   251 	TEST_KERRNONE(r);
       
   252 	r=Pci::CreateMapping(aFunc, aPhysicalAddress, aSize, aPci);
       
   253 	TEST_KERRNONE(r);
       
   254 	return r;
       
   255 	}
       
   256 
       
   257 void TestChunkAllocation(TInt func)
       
   258 	{
       
   259 	__KTRACE_OPT(KPCI, Kern::Printf("test allocating chunks"));
       
   260 	const TUint32 attributes= EMapAttrSupRw|EMapAttrFullyBlocking;
       
   261 
       
   262 	//keep track of the chunks so i can delete them afterwards
       
   263 	RPointerArray<DPlatChunkHw> chunkList(12);
       
   264 
       
   265 	TEST_KERRNONE(CreatePciChunkAppend(func, 0x1000, attributes, chunkList));
       
   266 	TEST_KERRNONE(CreatePciChunkAppend(func, 0x4000, attributes, chunkList));
       
   267 	TEST_KERRNONE(CreatePciChunkAppend(func, 0x1000, attributes, chunkList));
       
   268 	TEST_KERRNONE(CreatePciChunkAppend(func, 0x2000, attributes, chunkList));
       
   269 	TEST_KERRNONE(CreatePciChunkAppend(func, 0x8000, attributes, chunkList));
       
   270 	TEST_KERRNONE(CreatePciChunkAppend(func, 0x10000, attributes, chunkList));
       
   271 
       
   272 	TEST_KERRNONE(CreatePciChunkAppend(func, 0x8000, attributes, chunkList));
       
   273 	TEST_KERRNONE(CreatePciChunkAppend(func, 0x1000, attributes, chunkList));
       
   274 	TEST_KERRNONE(CreatePciChunkAppend(func, 0x4000, attributes, chunkList));
       
   275 	TEST_KERRNONE(CreatePciChunkAppend(func, 0x1000, attributes, chunkList));
       
   276 	TEST_KERRNONE(CreatePciChunkAppend(func, 0x2000, attributes, chunkList));
       
   277 	TEST_KERRNONE(CreatePciChunkAppend(func, 0x80000, attributes, chunkList));
       
   278 
       
   279 	//try to allocate more chunks than there are BARS
       
   280 	TEST(CreatePciChunkAppend(func, 0x1000, attributes, chunkList)==KErrNotFound);
       
   281 	//try to allocate chunk with size less than 1
       
   282 	TEST(CreatePciChunkAppend(func, 0x0, attributes, chunkList)==KErrArgument);
       
   283 
       
   284 	__KTRACE_OPT(KPCI, Kern::Printf("Delete all chunks"));
       
   285 	const TInt count=chunkList.Count();
       
   286 	for(TInt i=0; i<count; ++i)
       
   287 		{
       
   288 		TEST_KERRNONE(Pci::RemoveChunk(func, chunkList[i]));
       
   289 		}
       
   290 	chunkList.Close();
       
   291 	}
       
   292 
       
   293 void TestPciMemoryAccess(TLinAddr aVirt, TUint32 aPciAddress, TUint aSize, TUint32 aAttributes)
       
   294 	{
       
   295 	__KTRACE_OPT(KPCI, Kern::Printf("\nTest accessing memory via PCI: attrs=0x%08x\n", aAttributes));
       
   296 
       
   297 	TEST(aPciAddress<=(0x2000-aSize)); //we need to fit within the first 8k of pci space or we'll be beyond the access window
       
   298 
       
   299 	__KTRACE_OPT(KPCI, Kern::Printf("write chunk from software"));
       
   300 	TUint8* const vByte=(TUint8*)aVirt;
       
   301 	memset(vByte, 0x5A, aSize);
       
   302 
       
   303 	__KTRACE_OPT(KPCI, Kern::Printf("confirm values"));
       
   304 	for(TUint i=0; i<aSize; ++i)
       
   305 		{
       
   306 		const TUint8 result=vByte[i];
       
   307 		TEST(result==0x5A);
       
   308 		}
       
   309 
       
   310 	__KTRACE_OPT(KPCI, Kern::Printf("read back chunk via PCI"));
       
   311 	//A standard DMA write would read from memory and *write* to peripheral
       
   312 	//in this case the PCI is doing a DMA read from memory.
       
   313 	Cache::SyncMemoryBeforeDmaWrite(aVirt, aSize, aAttributes);
       
   314 	TUint8* const pByte = (TUint8*)(KHwUsbHWindow+aPciAddress);
       
   315 	TEST(memcompare(vByte, aSize, pByte, aSize)==0);
       
   316 
       
   317 	//A standard DMA read would *read* from peripheral and write to memory.
       
   318 	Cache::SyncMemoryBeforeDmaRead(aVirt, aSize, aAttributes);
       
   319 	__KTRACE_OPT(KPCI, Kern::Printf("write chunk via PCI"));
       
   320 	memset(pByte,0xA5,aSize);
       
   321 
       
   322 	__KTRACE_OPT(KPCI, Kern::Printf("read back chunk via PCI"));
       
   323 	for(TUint i=0; i<aSize; ++i)
       
   324 		{
       
   325 		const TUint8 result=pByte[i];
       
   326 		TEST(result==0xA5);
       
   327 		}
       
   328 	Cache::SyncMemoryAfterDmaRead(aVirt, aSize);
       
   329 	__KTRACE_OPT(KPCI, Kern::Printf("read back chunk from software"));
       
   330 	TEST(memcompare(vByte, aSize, pByte, aSize)==0);
       
   331 	}
       
   332 
       
   333 void TestAddressConversion(TInt aFunc, TUint32 aPciAddr, TUint32 aPhysAddr, TInt32 aSize)
       
   334 	{
       
   335 	//round up size of region to what its equivilent pci region would be
       
   336 	if(aSize<KMinOutboundWindow)
       
   337 		aSize=KMinOutboundWindow;
       
   338 	else
       
   339 		aSize=Clp2(aSize); //round up to next Power of 2.
       
   340 
       
   341 
       
   342 	__KTRACE_OPT(KPCI, Kern::Printf("testing Pci<-->Phys address conversions: func %d, pci 0x%08x, physical 0x%08x, size 0x%08x ", aFunc, aPciAddr, aPhysAddr, aSize));
       
   343 	for(TInt offset=-1; offset<=aSize; ++offset)
       
   344 		{
       
   345 		const TUint32 expectedPci=aPciAddr+TInt(offset);
       
   346 		TUint32 address=aPhysAddr+TInt(offset);
       
   347 		TInt r=Pci::GetPciAddress(aFunc,address);
       
   348 		//__KTRACE_OPT(KPCI, Kern::Printf("GetPciAddress: offset=0x%08x, r=%d, physical=0x%08x, pci=0x%08x,expectedPci=0x%08x",
       
   349 		//		offset, r, aPhysAddr+offset, address, expectedPci));
       
   350 		if(offset==-1||offset==aSize)
       
   351 			{
       
   352 			TEST(r==KErrNotFound); //test going beyond either side of the memory region
       
   353 			}
       
   354 		else
       
   355 			{
       
   356 			TEST_KERRNONE(r);
       
   357 			TEST(address==expectedPci);
       
   358 			}
       
   359 
       
   360 		const TUint32 expectedPhys=aPhysAddr+offset;
       
   361 		address=aPciAddr+offset;
       
   362 		r=Pci::GetPhysicalAddress(aFunc, address);
       
   363 		//__KTRACE_OPT(KPCI, Kern::Printf("GetPhysicalAddress: offset=0x%08x, r=%d, pci=0x%08x, physical=0x%08x, expectedPhysical=0x%08x",
       
   364 		//		offset, r, aPciAddr+offset, address, expectedPhys));
       
   365 		if(offset==-1||offset==aSize)
       
   366 			{
       
   367 			TEST(r==KErrNotFound);
       
   368 			}
       
   369 		else
       
   370 			{
       
   371 			TEST_KERRNONE(r);
       
   372 			TEST(address==expectedPhys);
       
   373 			}
       
   374 		}
       
   375 	}
       
   376 
       
   377 void TestPciChunkAccesses(TInt aFunc)
       
   378 	{
       
   379 	const TInt sizes[] = {0x1, 0x400, 0x800};
       
   380 	const TUint32 attrs[] = {EMapAttrSupRw|EMapAttrFullyBlocking, EMapAttrSupRw|EMapAttrCachedMax};
       
   381 
       
   382 	__KTRACE_OPT(KPCI, Kern::Printf("Testing PCI chunk access"));
       
   383 	for(TInt i=0; i<3; ++i)
       
   384 		{
       
   385 		for(TInt j=0; j<2; ++j)
       
   386 			{
       
   387 			__KTRACE_OPT(KPCI, Kern::Printf("\nSize=0x%08x, attrs=0x%08x", sizes[i], attrs[j]));
       
   388 			TLinAddr virt=NULL;
       
   389 			TUint32 pci=NULL;
       
   390 			DPlatChunkHw* chunk=NULL;
       
   391 			TInt size=sizes[i];//size may be altered by CreatePciChunk if it is rounded
       
   392 			TInt r = CreatePciChunk(aFunc, size, attrs[j], chunk, pci, virt);
       
   393 			TEST_KERRNONE(r);
       
   394 			TestPciMemoryAccess(virt, pci, size, attrs[j]);
       
   395 			TestAddressConversion(aFunc, pci, chunk->PhysicalAddress(), sizes[i]);
       
   396 
       
   397 			r = Pci::RemoveChunk(aFunc, chunk);
       
   398 			TEST_KERRNONE(r);
       
   399 
       
   400 			}
       
   401 		}
       
   402 	}
       
   403 
       
   404 void TestWindowAccesses(TInt aFunc)
       
   405 	{
       
   406 	const TInt sizes[] = {0x1, 0x400, 0x800};
       
   407 	const TUint32 attrs[] = {EMapAttrSupRw|EMapAttrFullyBlocking, EMapAttrSupRw|EMapAttrCachedMax};
       
   408 
       
   409 	__KTRACE_OPT(KPCI, Kern::Printf("Testing PCI access to externally allocated shared chunks"));
       
   410 	for(TInt i=0; i<3; ++i)
       
   411 		{
       
   412 		for(TInt j=0; j<2; ++j)
       
   413 			{
       
   414 			__KTRACE_OPT(KPCI, Kern::Printf("\nSize=0x%08x, attrs=0x%08x", sizes[i], attrs[j]));
       
   415 			TLinAddr virt=NULL;
       
   416 			TUint32 pci=NULL;
       
   417 			TPhysAddr phys=NULL;
       
   418 			DChunk* chunk=NULL;
       
   419 			TInt r = CreateAndMapSC(aFunc, sizes[i], attrs[j], chunk, pci, virt, phys);
       
   420 			TEST_KERRNONE(r);
       
   421 			TestPciMemoryAccess(virt, pci, sizes[i], attrs[j]);
       
   422 			TestAddressConversion(aFunc, pci, phys, sizes[i]);
       
   423 
       
   424 			r = UnmapAndCloseSC(aFunc, chunk, phys);
       
   425 			TEST_KERRNONE(r);
       
   426 
       
   427 			}
       
   428 		}
       
   429 
       
   430 
       
   431 	}
       
   432 
       
   433 DECLARE_STANDARD_EXTENSION()
       
   434 	{
       
   435 	TInt r=KErrNone;
       
   436 	__KTRACE_OPT(KEXTENSION,Kern::Printf("Starting PCI test extension"));
       
   437 
       
   438 	RArray<TInt> indicies;
       
   439 	TEST(Pci::Probe(indicies, KNecVendorId, KInternalPciBridgeId) == KErrNotFound);
       
   440 	TEST(Pci::Probe(indicies, KNecVendorId, KExternalPciBridgeId) == KErrNotFound);
       
   441 
       
   442 	TEST(Pci::Probe(indicies,0x1033, 0x35) == KErrNone);
       
   443 	TEST(indicies.Count()==1); //only expecting one match
       
   444 	const TInt ohciFunc=indicies[0];
       
   445 	indicies.Close();
       
   446 
       
   447 	TAddrSpace& cs = *Pci::GetConfigSpace(ohciFunc);
       
   448 	TAddrSpace& ms = *Pci::GetMemorySpace(ohciFunc);
       
   449 
       
   450 	TestMemoryAccess(ms);
       
   451 	TestConfigAccess(cs);
       
   452 	TestAllocator();
       
   453 	TestChunkAllocation(ohciFunc);
       
   454 	TestPciChunkAccesses(ohciFunc);
       
   455 	TestWindowAccesses(ohciFunc);
       
   456 
       
   457 	__KTRACE_OPT(KPCI, Kern::Printf("DNaviEnginePci: Dumping OHCI config space"));
       
   458 	TUint size=cs.Size();
       
   459 	for(TUint i=0; i<size; i+=4)
       
   460 		{
       
   461 		__KTRACE_OPT(KPCI, Kern::Printf("%08x %02xH", cs.Read32(i), i));
       
   462 		}
       
   463 
       
   464 	__KTRACE_OPT(KPCI, Kern::Printf("DNaviEnginePci: Dumping OHCI memory space"));
       
   465 	size=ms.Size();
       
   466 	for(TUint i=0; i<size; i+=4)
       
   467 		{
       
   468 		__KTRACE_OPT(KPCI, Kern::Printf("%08x %02xH", ms.Read32(i), i));
       
   469 		}
       
   470 
       
   471 	//this will cause a master abort if it touches any unallocated PCI memory, which is likely.
       
   472 #ifdef CAUSE_ERROR
       
   473 	__KTRACE_OPT(KPCI, Kern::Printf("Dump all of PCI space"));
       
   474 	TUint32* pciSpace=(TUint32*)KHwUsbHWindow;
       
   475 	for(TInt i=0; i<0x2000; ++i)
       
   476 		{
       
   477 		__KTRACE_OPT(KPCI, Kern::Printf("%08x %02xH", pciSpace[i], i));
       
   478 		}
       
   479 #endif
       
   480 	Kern::Printf("Dump PCI bridge registers");
       
   481 	for(TInt i=0; i<0x100; i+=4)
       
   482 		{
       
   483 		__KTRACE_OPT(KPCI, Kern::Printf("%08x %02xH", reinterpret_cast<TUint32*>(KHwPciBridgeUsb)[i], i));
       
   484 		}
       
   485 	return r;
       
   486 	}
       
   487