1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/dmav2/t_dma2.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,719 @@
1.4 +/*
1.5 +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +#ifndef __T_DMA2_H__
1.21 +#define __T_DMA2_H__
1.22 +
1.23 +#include "cap_reqs.h"
1.24 +#include "test_thread.h"
1.25 +#include "d_dma2.h"
1.26 +#include <e32std.h>
1.27 +
1.28 +
1.29 +class TTestCase;
1.30 +// Global array of test cases
1.31 +extern RPointerArray<TTestCase> TestArray;
1.32 +
1.33 +
1.34 +extern TBool gVerboseOutput; // Verbose output control
1.35 +
1.36 +
1.37 +const TInt KParameterTextLenMax = 80; // command-line param length
1.38 +
1.39 +/**
1.40 +This function prints out the PSL test Information
1.41 +*/
1.42 +void Print(const TDmaV2TestInfo& aInfo);
1.43 +
1.44 +/**
1.45 +Runs all framework self tests
1.46 +*/
1.47 +void SelfTests();
1.48 +
1.49 +void ApiTests();
1.50 +
1.51 +class CSingleTransferTest;
1.52 +class CIsrRequeTest;
1.53 +class CMultiTransferTest;
1.54 +
1.55 +
1.56 +/**
1.57 +An interface to a classs that sets up the buffers before a test
1.58 +*/
1.59 +//TODO both pre and post transfer checks should perhaps derive from an
1.60 +//abstract visitor base
1.61 +class MPreTransfer
1.62 + {
1.63 +public:
1.64 + virtual ~MPreTransfer()
1.65 + {}
1.66 + virtual void Setup(const CSingleTransferTest& aTest) const = 0;
1.67 + virtual void Setup(const CIsrRequeTest& aTest) const = 0;
1.68 + virtual void Setup(const CMultiTransferTest& aTest) const = 0;
1.69 + };
1.70 +
1.71 +/**
1.72 +An interface for a check which takes place at the end of a DMA
1.73 +transfer test to verify the transfer was as expected.
1.74 +*/
1.75 +class MPostTransferCheck
1.76 + {
1.77 +public:
1.78 + virtual ~MPostTransferCheck()
1.79 + {}
1.80 + virtual TInt Check(const CSingleTransferTest& aTest) const = 0;
1.81 + virtual TInt Check(const CIsrRequeTest& aTest) const = 0;
1.82 + virtual TInt Check(CMultiTransferTest& aTest) const = 0;
1.83 + };
1.84 +
1.85 +class TCompare2D : public MPostTransferCheck
1.86 + {
1.87 +public:
1.88 + TCompare2D()
1.89 + {}
1.90 +
1.91 + virtual TInt Check(const CSingleTransferTest& aTest) const;
1.92 + virtual TInt Check(const CIsrRequeTest& aTest) const;
1.93 + virtual TInt Check(CMultiTransferTest& aTest) const;
1.94 +
1.95 + };
1.96 +
1.97 +class TAlwaysFail : public MPostTransferCheck
1.98 + {
1.99 +public:
1.100 + virtual TInt Check(const CSingleTransferTest& /*aTest*/) const
1.101 + {return KErrUnknown;}
1.102 + virtual TInt Check(const CIsrRequeTest&) const
1.103 + {return KErrUnknown;}
1.104 + virtual TInt Check(CMultiTransferTest&) const
1.105 + {return KErrUnknown;}
1.106 + };
1.107 +
1.108 +class TAlwaysPass : public MPostTransferCheck
1.109 + {
1.110 +public:
1.111 + virtual TInt Check(const CSingleTransferTest& /*aTest*/) const
1.112 + {return KErrNone;}
1.113 + virtual TInt Check(const CIsrRequeTest&) const
1.114 + {return KErrNone;}
1.115 + virtual TInt Check(CMultiTransferTest&) const
1.116 + {return KErrNone;}
1.117 + };
1.118 +
1.119 +/**
1.120 +Compare that all the various source buffers of a test match
1.121 +its destination buffers
1.122 +*/
1.123 +class TCompareSrcDst : public MPostTransferCheck
1.124 + {
1.125 +public:
1.126 + TCompareSrcDst()
1.127 + {}
1.128 +
1.129 + virtual TInt Check(const CSingleTransferTest& aTest) const;
1.130 + virtual TInt Check(const CIsrRequeTest& aTest) const;
1.131 + virtual TInt Check(CMultiTransferTest& aTest) const;
1.132 +
1.133 +protected:
1.134 + TInt Check(const TIsrRequeArgsSet& aRequeueArgSet, TUint8* aChunkBase, const TDmaTransferArgs& aTferArgs) const;
1.135 + TInt Check(const TIsrRequeArgs& aRequeueArgs) const;
1.136 + TInt Check(const TDmaTransferArgs& aTransferArgs, TUint8* aChunkBase) const;
1.137 + };
1.138 +
1.139 +/**
1.140 +Base class for all DMA tests
1.141 +*/
1.142 +class CDmaTest : public CTest
1.143 + {
1.144 +public:
1.145 + CDmaTest(const TDesC& aName, TInt aIterations, const MPreTransfer* aPreTransfer, const MPostTransferCheck* aPostTransfer)
1.146 + : CTest(aName, aIterations), iPreTransfer(aPreTransfer), iPostTransferCheck(aPostTransfer)
1.147 + {}
1.148 +
1.149 + void OpenDmaSession();
1.150 + void CloseDmaSession();
1.151 +
1.152 + virtual void PrintTestInfo() const;
1.153 + virtual TBool Result() = 0;
1.154 +
1.155 + const RChunk& Chunk() const
1.156 + {return iChunk;}
1.157 +
1.158 + /**
1.159 + Tells the test which DMA channel it should run on
1.160 + */
1.161 + void SetChannelCookie(TUint32 aCookie)
1.162 + {iChannelCookie = aCookie;}
1.163 +
1.164 + virtual void PreTransferSetup() =0;
1.165 + virtual TInt DoPostTransferCheck() =0;
1.166 +protected:
1.167 + RDmaSession iDmaSession;
1.168 + RChunk iChunk;
1.169 +
1.170 + /**
1.171 + Identifies the channel to open (as understood by a DMA PSL)
1.172 + */
1.173 + TUint iChannelCookie;
1.174 + const MPreTransfer* iPreTransfer;
1.175 +
1.176 + const MPostTransferCheck* iPostTransferCheck; //!< Some check to be run after the transfer
1.177 + };
1.178 +
1.179 +/**
1.180 +Holds return codes for the various functions which must be called
1.181 +to create, fragment, and queue a DMA request
1.182 +*/
1.183 +struct TRequestResults
1.184 + {
1.185 + TRequestResults
1.186 + (
1.187 + TInt aCreate = KErrNone,
1.188 + TInt aFragmentCount = 0,
1.189 + TInt aFragmentationResult = KErrNone,
1.190 + TInt aQueueResult = KErrNone
1.191 + )
1.192 + :iCreate(aCreate), iFragmentCount(aFragmentCount), iFragmentationResult(aFragmentationResult), iQueueResult(aQueueResult)
1.193 + {}
1.194 +
1.195 + /**
1.196 + Constructs with error results
1.197 + */
1.198 + TRequestResults(TFalse)
1.199 + :iCreate(KErrUnknown), iFragmentCount(0), iFragmentationResult(KErrUnknown), iQueueResult(KErrUnknown)
1.200 + {}
1.201 +
1.202 + inline TRequestResults& CreationResult(TInt aErrorCode) {iCreate = aErrorCode; return *this;}
1.203 + inline TRequestResults& FragmentCount(TInt aCount) {iFragmentCount = aCount; return *this;}
1.204 + inline TRequestResults& FragmentationResult(TInt aErrorCode) {iFragmentationResult = aErrorCode; return *this;}
1.205 + inline TRequestResults& QueueResult(TInt aErrorCode) {iQueueResult = aErrorCode; return *this;}
1.206 +
1.207 + TInt iCreate;
1.208 + TInt iFragmentCount; //!< 0 means any result permitted
1.209 + TInt iFragmentationResult;
1.210 + TInt iQueueResult;
1.211 + };
1.212 +
1.213 +/**
1.214 +Holds all the results for a DMA CSingleTransferTest
1.215 +*/
1.216 +struct TResultSet
1.217 + {
1.218 + /**
1.219 + No errors expected
1.220 + */
1.221 + TResultSet(TInt aChannelOpenResult = KErrNone,
1.222 + const TRequestResults aRequestResults = TRequestResults(),
1.223 + TInt aPostTransferCheck = KErrNone,
1.224 + const TCallbackRecord aCallbackRecord = TCallbackRecord(TCallbackRecord::EThread,1)
1.225 + )
1.226 + :
1.227 + iChannelOpenResult(aChannelOpenResult),
1.228 + iRequestResult(aRequestResults),
1.229 + iPostTransferCheck(aPostTransferCheck),
1.230 + iCallbackRecord(aCallbackRecord)
1.231 + {}
1.232 +
1.233 + explicit TResultSet(const TCallbackRecord& aRecord)
1.234 + :iChannelOpenResult(KErrNone),
1.235 + iRequestResult(),
1.236 + iPostTransferCheck(KErrNone),
1.237 + iCallbackRecord(aRecord)
1.238 + {}
1.239 +
1.240 + /**
1.241 + Errors expected
1.242 + */
1.243 + TResultSet(TFalse)
1.244 + :iChannelOpenResult(KErrUnknown),
1.245 + iRequestResult(EFalse),
1.246 + iPostTransferCheck(KErrUnknown),
1.247 + iCallbackRecord(TCallbackRecord::Empty())
1.248 + {}
1.249 +
1.250 + void Print() const;
1.251 + TBool operator == (const TResultSet& aOther) const;
1.252 +
1.253 + /** Set channel opening result */
1.254 + TResultSet& ChannelOpenResult(TInt aResult) {iChannelOpenResult = aResult; return *this;}
1.255 + TResultSet& PostTransferResult(TInt aResult) {iPostTransferCheck = aResult; return *this;}
1.256 + /** Set request results */
1.257 + TResultSet& RequestResult(const TRequestResults& aResults) {iRequestResult = aResults; return *this;}
1.258 + /** Set Callback record */
1.259 + TResultSet& CallbackRecord(const TCallbackRecord& aCallbackRecord) {iCallbackRecord = aCallbackRecord; return *this;}
1.260 +
1.261 + TInt iChannelOpenResult;
1.262 + TRequestResults iRequestResult;
1.263 + TInt iPostTransferCheck;
1.264 + TCallbackRecord iCallbackRecord;
1.265 + };
1.266 +
1.267 +/**
1.268 +Fills each source buffer with an increasing value and clears each destination
1.269 +*/
1.270 +class TPreTransferIncrBytes : public MPreTransfer
1.271 + {
1.272 +public:
1.273 + TPreTransferIncrBytes()
1.274 + {}
1.275 +
1.276 + virtual void Setup(const CSingleTransferTest& aTest) const;
1.277 + virtual void Setup(const CIsrRequeTest& aTest) const;
1.278 + virtual void Setup(const CMultiTransferTest& aTest) const;
1.279 +protected:
1.280 + virtual void Setup(const TAddressParms& aParams) const;
1.281 + TBool CheckBuffers(const CIsrRequeTest& aTest) const;
1.282 + TBool CheckBuffers(const RArray<const TAddressParms> aTransferParams) const;
1.283 + };
1.284 +
1.285 +const TPreTransferIncrBytes KPreTransferIncrBytes;
1.286 +const TCompareSrcDst KCompareSrcDst;
1.287 +const TCompare2D KCompare2D;
1.288 +
1.289 +
1.290 +/**
1.291 +Iterates over the bytes in buffer, in the order
1.292 +the supllied DMA config would access them
1.293 +*/
1.294 +class TTransferIter
1.295 + {
1.296 +public:
1.297 + TTransferIter()
1.298 + :iCfg(NULL), iPtr(NULL)
1.299 + {}
1.300 +
1.301 + TTransferIter(const TDmaTransferConfig& aCfg, TUint8* aChunkBase=NULL)
1.302 + :iElem(0), iFrame(0), iCfg(&aCfg), iChunkBase(aChunkBase), iPtr(Start()), iBytes(0)
1.303 + {}
1.304 +
1.305 + void operator++ ();
1.306 + TUint8& operator* ()
1.307 + {
1.308 + Invariant();
1.309 + return *iPtr;
1.310 + }
1.311 +
1.312 + TBool operator!= (const TTransferIter& aOther)
1.313 + {
1.314 + return (iPtr != aOther.iPtr);
1.315 + }
1.316 +
1.317 + static void SelfTest();
1.318 +private:
1.319 + TUint8* Start() const
1.320 + {
1.321 + return iChunkBase + iCfg->iAddr;
1.322 + }
1.323 +
1.324 + void Invariant() const;
1.325 +
1.326 + TUint iElem; //!< The current element
1.327 + TUint iFrame; //!< The current frame
1.328 +
1.329 + const TDmaTransferConfig* const iCfg;
1.330 + TUint8* iChunkBase;
1.331 +
1.332 + TUint8* iPtr; //<! Pointer to the current byte
1.333 +
1.334 + TInt iBytes; //!< The number of bytes traversed
1.335 + };
1.336 +
1.337 +/**
1.338 +Performs a single DMA transfer using the member TDmaTransferArgs on
1.339 +one channel. At each stage of the transfer results are recorded in a
1.340 +TResultSet struct: at the end these are compared with a set of expected
1.341 +results.
1.342 +*/
1.343 +class CSingleTransferTest : public CDmaTest
1.344 + {
1.345 +public:
1.346 + CSingleTransferTest(
1.347 + const TDesC& aName, TInt aIterations,
1.348 + const TDmaTransferArgs& aArgs,
1.349 + const TResultSet& aExpected,
1.350 + TUint aMaxFragmentSize = 0,
1.351 + const MPostTransferCheck* aPostTferChk = &KCompareSrcDst,
1.352 + const MPreTransfer* aPreTfer = &KPreTransferIncrBytes
1.353 + )
1.354 + : CDmaTest(aName, aIterations, aPreTfer, aPostTferChk),
1.355 + iTransferArgs(aArgs),iExpected(aExpected),iActual(EFalse),
1.356 + iUseNewRequest(ETrue),
1.357 + iUseNewFragment(ETrue),
1.358 + iMaxFragmentSize(aMaxFragmentSize)
1.359 + {}
1.360 +
1.361 + /**
1.362 + Perform each stage of trasnfer
1.363 + */
1.364 + virtual void RunTest();
1.365 + virtual void PrintTestType() const;
1.366 +
1.367 + virtual CTest* Clone() const {return new CSingleTransferTest(*this);}
1.368 +
1.369 + /**
1.370 + Compares the actual vs the exepected results and reports
1.371 + of the test passed
1.372 + @return ETrue for a pass, EFalse for a fail
1.373 + */
1.374 + virtual TBool Result();
1.375 +
1.376 + /**
1.377 + An accessor function for the object's TDmaTransferArgs
1.378 + */
1.379 + const TDmaTransferArgs& TransferArgs() const
1.380 + {return iTransferArgs;}
1.381 +
1.382 + // The below methods are setters, which may be chained together
1.383 + // ie. The Named Parameter Idiom
1.384 + // @see http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.18
1.385 + inline CSingleTransferTest& UseNewRequest(TBool aFlag) {iUseNewRequest=aFlag; return *this;}
1.386 + inline CSingleTransferTest& UseNewFragment(TBool aFlag) {iUseNewFragment=aFlag; return *this;}
1.387 + inline CSingleTransferTest& UseNewDmaApi(TBool aFlag) {UseNewRequest(aFlag); UseNewFragment(aFlag); return *this;}
1.388 +
1.389 +protected:
1.390 + virtual void OpenChannel();
1.391 + virtual void PreTransferSetup();
1.392 + virtual void CreateDmaRequest();
1.393 + virtual void Fragment();
1.394 + virtual void Queue();
1.395 + virtual void PostTransferCheck();
1.396 + virtual TInt DoPostTransferCheck();
1.397 + virtual void FreeRequest();
1.398 + virtual void CloseChannel();
1.399 +
1.400 +protected:
1.401 + /**
1.402 + A handle to kernel side TDmaChannel object received after a channel is opened.
1.403 + */
1.404 + TUint iChannelSessionCookie;
1.405 + /**
1.406 + A handle to kernel side DDmaRequest object.
1.407 + */
1.408 + TUint iRequestSessionCookie;
1.409 +
1.410 + const TDmaTransferArgs& iTransferArgs;
1.411 +
1.412 + /**
1.413 + Expected transfer results
1.414 + */
1.415 + TResultSet iExpected;
1.416 +
1.417 + /**
1.418 + Filled with actual transfer results
1.419 + */
1.420 + TResultSet iActual;
1.421 +
1.422 + TBool iUseNewRequest; //!< If true then CSingleTransferTest will create a DDmaRequest with the v2 ctor
1.423 + TBool iUseNewFragment; //!< If true then CSingleTransferTest will use v2 Fragment API
1.424 + const TUint iMaxFragmentSize;
1.425 + };
1.426 +
1.427 +/**
1.428 +This class will be used for tests which benchmark certain DMA operations
1.429 +*/
1.430 +class CDmaBenchmark : public CSingleTransferTest
1.431 + {
1.432 +public:
1.433 + CDmaBenchmark(const TDesC& aName, TInt aIterations, const TResultSet& aExpectedResults, const TDmaTransferArgs& aTransferArgs, TUint aMaxFragmentSize);
1.434 + ~CDmaBenchmark();
1.435 +
1.436 + virtual TBool Result();
1.437 +
1.438 + static void SelfTest();
1.439 +
1.440 +protected:
1.441 + /**
1.442 + @return The mean average of the result array
1.443 + */
1.444 + TUint64 MeanResult();
1.445 +
1.446 + //TODO must be included within copy ctor or all instances will
1.447 + //share on result set!
1.448 + RArray<TUint64> iResultArray;
1.449 +
1.450 + };
1.451 +
1.452 +/**
1.453 +Fragments requests (only) and records duration
1.454 +TODO make sure we are using old style DDmaRequest
1.455 +*/
1.456 +class CDmaBmFragmentation : public CDmaBenchmark
1.457 + {
1.458 +public:
1.459 + CDmaBmFragmentation(const TDesC& aName, TInt aIterations, const TDmaTransferArgs& aTransferArgs, TUint aMaxFragmentSize);
1.460 + virtual CTest* Clone() const {return new CDmaBmFragmentation(*this);}
1.461 + virtual TInt DoPostTransferCheck()
1.462 + {TEST_FAULT; return KErrNotSupported;}
1.463 +
1.464 + virtual void RunTest();
1.465 + virtual void PrintTestType() const;
1.466 +
1.467 +protected:
1.468 + void Fragment();
1.469 + static const TResultSet ExpectedResults;
1.470 + };
1.471 +
1.472 +/**
1.473 +Performs a transfer using an old style DDmaRequest and
1.474 +records the duration
1.475 +*/
1.476 +class CDmaBmTransfer : public CDmaBenchmark
1.477 + {
1.478 +public:
1.479 + CDmaBmTransfer(const TDesC& aName, TInt aIterations, const TDmaTransferArgs& aTransferArgs, TUint aMaxFragmentSize);
1.480 + virtual CTest* Clone() const {return new CDmaBmTransfer(*this);}
1.481 + virtual TInt DoPostTransferCheck()
1.482 + {TEST_FAULT; return KErrNotSupported;}
1.483 +
1.484 + virtual void RunTest();
1.485 + virtual void PrintTestType() const;
1.486 +
1.487 + inline CDmaBmTransfer& UseNewDmaApi(TBool aFlag) {CSingleTransferTest::UseNewDmaApi(aFlag); return *this;}
1.488 + inline CDmaBmTransfer& ExpectedResults(const TResultSet& aArgs) {iExpected=aArgs; return *this;}
1.489 +protected:
1.490 + void Queue();
1.491 + };
1.492 +
1.493 +
1.494 +
1.495 +/**
1.496 +Will create and queue multiple requests
1.497 +
1.498 +Unlike CSingleTransferTest the class does not permit the use of TResultSet to
1.499 +define expected results (for neagative testing)
1.500 +*/
1.501 +class CMultiTransferTest : public CDmaTest
1.502 + {
1.503 +public:
1.504 + CMultiTransferTest(const TDesC& aName, TInt aIterations, const TDmaTransferArgs* aTransferArgs, const TResultSet* aResultSets, TInt aCount);
1.505 + CMultiTransferTest(const CMultiTransferTest& aOther);
1.506 + virtual ~CMultiTransferTest();
1.507 + virtual CTest* Clone() const {return new CMultiTransferTest(*this);}
1.508 +
1.509 + virtual TBool Result();
1.510 + virtual void RunTest();
1.511 + virtual void PrintTestType() const;
1.512 +
1.513 + inline CMultiTransferTest& PauseWhileQueuing() {iPauseWhileQueuing = ETrue; return *this;}
1.514 + inline CMultiTransferTest& SetPreTransferTest(const MPreTransfer* aPreTfer) {iPreTransfer = aPreTfer; return *this;}
1.515 + inline CMultiTransferTest& SetPostTransferTest(const MPostTransferCheck* aPostTfer) {iPostTransferCheck = aPostTfer; return *this;}
1.516 +
1.517 + const TDmaTransferArgs& TransferArgs(TInt aIndex) const;
1.518 + inline TInt TransferCount() const {return iTransferArgsCount;}
1.519 +
1.520 + void SetPostTransferResult(TInt aIndex, TInt aErrorCode);
1.521 +protected:
1.522 + void OpenChannel();
1.523 + TInt CloseChannel();
1.524 + void CreateDmaRequests();
1.525 + void Fragment();
1.526 + void QueueRequests();
1.527 +
1.528 + virtual void PreTransferSetup();
1.529 + virtual TInt DoPostTransferCheck();
1.530 +
1.531 + TBool Result(TInt aTransfer);
1.532 +
1.533 + const TDmaTransferArgs* const iTransferArgs; //pointer to an array of transfer args
1.534 + const TInt iTransferArgsCount;
1.535 +
1.536 +
1.537 + TBool iNewDmaApi; //!< If true then CMultiTransferTest will use new style API
1.538 +
1.539 + /**
1.540 + A handle to kernel side TDmaChannel object received after a channel is opened.
1.541 + */
1.542 + TUint iChannelSessionCookie;
1.543 + RArray<TUint> iRequestCookies;
1.544 +
1.545 + const TResultSet* const iExpectedArray; // array will be of length iTransferArgsCount
1.546 + RArray<TResultSet> iActualResults;
1.547 +
1.548 + /**
1.549 + If set, the test will pause the channel before queuing requests, and
1.550 + resume once they are all queued
1.551 + */
1.552 + TBool iPauseWhileQueuing;
1.553 + };
1.554 +
1.555 +/**
1.556 +Used for testing TDmaChannel::IsrRedoRequest
1.557 +
1.558 +Extends CSingle transfer by adding the capability to queue with
1.559 +additonal transfer parameters (TIsrRequeArgs) which are passed
1.560 +to IsrRedoRequest in ISR callback
1.561 +*/
1.562 +class CIsrRequeTest : public CSingleTransferTest
1.563 + {
1.564 +public:
1.565 + CIsrRequeTest(const TDesC& aName, TInt aIterations, const TDmaTransferArgs& aArgs,
1.566 + TIsrRequeArgs* aRequeueArgs, TInt aCount,
1.567 + const TResultSet& aExpected, const MPreTransfer* aPreTfer,
1.568 + const MPostTransferCheck* aPostTferChk, TUint aMaxFragmentSize=0);
1.569 +
1.570 + virtual void PrintTestType() const;
1.571 +
1.572 + virtual void Queue();
1.573 +
1.574 + /**
1.575 + Compares the actual vs the exepected results and reports
1.576 + of the test passed
1.577 + @return ETrue for a pass, EFalse for a fail
1.578 + */
1.579 + //virtual TBool Result();
1.580 +
1.581 +
1.582 + virtual CTest* Clone() const {return new CIsrRequeTest(*this);}
1.583 +
1.584 + const TIsrRequeArgsSet& GetRequeueArgs() const
1.585 + {return iRequeArgSet;}
1.586 +
1.587 +
1.588 +protected:
1.589 + virtual TInt DoPostTransferCheck();
1.590 + virtual void PreTransferSetup();
1.591 +
1.592 + TIsrRequeArgsSet iRequeArgSet;
1.593 + };
1.594 +
1.595 +/**
1.596 +A channel record collects DMA channel capabilities and other PSL information
1.597 +before running tests.
1.598 +*/
1.599 +class TChannelRecord
1.600 + {
1.601 +public:
1.602 + TChannelRecord(){}
1.603 + ~TChannelRecord(){}
1.604 +
1.605 + /**
1.606 + DMA Channel Cookie
1.607 + */
1.608 + TUint iCookie;
1.609 +
1.610 + /**
1.611 + DMA Channel Capabilities
1.612 + */
1.613 + TDmacTestCaps iChannelCaps;
1.614 + };
1.615 +
1.616 +/**
1.617 +A test case collects together a DMA test (CDmaTest), its hardware prerequisites,
1.618 +and other information about how the test should be run.
1.619 +*/
1.620 +class TTestCase
1.621 + {
1.622 +public:
1.623 + //TODO it might be better to group sets of TDmaCapability
1.624 + //into their own class eg. TDmaCapSet.
1.625 + TTestCase(CDmaTest* aTest,
1.626 + TBool aConcurrent = EFalse,
1.627 + const TDmaCapability = TDmaCapability(),
1.628 + const TDmaCapability = TDmaCapability(),
1.629 + const TDmaCapability = TDmaCapability(),
1.630 + const TDmaCapability = TDmaCapability(),
1.631 + const TDmaCapability = TDmaCapability()
1.632 + );
1.633 +
1.634 + static void SelfTest();
1.635 +
1.636 + /**
1.637 + Compares the requirements held in the class
1.638 + against those described in aChannelCaps and makes a decision
1.639 + as to whether this test case should be run, skipped, or failed.
1.640 + */
1.641 + TResult TestCaseValid(const SDmacCaps& aChannelCaps) const;
1.642 + TResult TestCaseValid(const TDmacTestCaps& aChannelCaps) const;
1.643 +
1.644 + enum {KMaxChannelCaps=5};
1.645 + TDmaCapability iChannelCaps[KMaxChannelCaps];
1.646 + TUint iChannelType;
1.647 + TInt iTimeout;
1.648 + CDmaTest* iTest;
1.649 + TBool iConcurrentTest;
1.650 + TBool iDmaV2Only; //!< If true then this test cannot be run on DMA v1 framework
1.651 + };
1.652 +
1.653 +/**
1.654 +A TestRunner manages the whole testing process.Before running any test cases it will open its own RDmaSession
1.655 +handle, not associated with a DMA channel, so that it can recover the TDmaTestInfo object (as used by the
1.656 +existing DMA framework) which says what channels are available to be tested.It will use TTestThread objects
1.657 +to run tests in new threads.TTestThread contains a number of useful features such as waiting for thread exit
1.658 +and accepting a TFunctor object to be run in a new thread.
1.659 +*/
1.660 +class TTestRunner
1.661 +{
1.662 +public:
1.663 + TTestRunner();
1.664 + ~TTestRunner();
1.665 +
1.666 + /**
1.667 + This function will populate TTestRunner with an array of test cases which
1.668 + would be a collection of DMA test,its hardware prerequisites,and other
1.669 + information about how the test
1.670 +
1.671 + @aTTestCases on return, this contains an the DMA test cases
1.672 + */
1.673 + void AddTestCases(RPointerArray<TTestCase>& aTTestCases);
1.674 +
1.675 + /**
1.676 + This will iterate over all test cases held by the test runner and
1.677 + for each one will judge which DMA channels it can be run on, running
1.678 + the test if possible.
1.679 + */
1.680 + void RunTests();
1.681 +
1.682 +private:
1.683 + /**
1.684 + This functions retrieves the PSL cookies from all the DMA channels
1.685 + and stores them in a single array. It will use information from
1.686 + the PslTestInfo.
1.687 + */
1.688 + void GetPslCookie();
1.689 +
1.690 + /**
1.691 + This function will generate the DMA channel records.i.e channel cookies,Caps.
1.692 + */
1.693 + void GenerateChannelRecord();
1.694 +
1.695 + /**
1.696 + Holds the PslTestInfo
1.697 + */
1.698 + TDmaV2TestInfo iPslTestInfo;
1.699 +
1.700 + /**
1.701 + A handle to RDmaSession
1.702 + */
1.703 + RDmaSession iDmaSession;
1.704 +
1.705 + /**
1.706 + Array of DMA test cases
1.707 + */
1.708 + RPointerArray<TTestCase> iTestCases;
1.709 +
1.710 + /**
1.711 + Array of DMA channel records,channel capabilities and other PSL information
1.712 + */
1.713 + RArray<TChannelRecord> iChannelRecords;
1.714 +
1.715 + /**
1.716 + Array of DMA channel cookies
1.717 + */
1.718 + RArray<TUint> iPslCookies;
1.719 +};
1.720 +
1.721 +
1.722 +#endif // #ifndef __T_DMA2_H__