os/kernelhwsrv/kerneltest/e32test/lffs/bf_execute.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Thread for executing benchmark test threads
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
/**
sl@0
    19
 @file bf_execute.cpp
sl@0
    20
*/
sl@0
    21
sl@0
    22
#include <e32std.h>
sl@0
    23
#include <e32std_private.h>
sl@0
    24
#include <e32svr.h>
sl@0
    25
#include "bf_raw.h"
sl@0
    26
sl@0
    27
GLREF_D	TUint32 Count;
sl@0
    28
GLREF_D	TTestInfo	TestInfo;		///< Data passed to exector thread
sl@0
    29
sl@0
    30
GLREF_D	TBusLocalDrive	drive;
sl@0
    31
GLREF_D	TLocalDriveCapsV2Buf driveInfo;
sl@0
    32
GLREF_D	HBufC8*	writeBuffer;
sl@0
    33
GLREF_D	HBufC8*	readBuffer;
sl@0
    34
sl@0
    35
GLREF_D TBool StopTest;
sl@0
    36
sl@0
    37
GLREF_D TInt	mainThreadHandle;
sl@0
    38
sl@0
    39
_LIT( KPanicCat, "bf_raw" );
sl@0
    40
sl@0
    41
GLDEF_C TInt BmWrite(TAny*)
sl@0
    42
	/**
sl@0
    43
	 * Performs writes continuously
sl@0
    44
	 */
sl@0
    45
	{
sl@0
    46
	TPtrC8 wd( writeBuffer->Des().Ptr(), TestInfo.iLength );
sl@0
    47
	while( !StopTest )
sl@0
    48
		{
sl@0
    49
		TInt r = drive.Write( TestInfo.iOffset, wd );
sl@0
    50
		if( KErrNone != r )
sl@0
    51
			{
sl@0
    52
			User::Panic( KPanicCat, r );
sl@0
    53
			}
sl@0
    54
		++Count;
sl@0
    55
		}
sl@0
    56
	return KErrNone;
sl@0
    57
	}
sl@0
    58
sl@0
    59
sl@0
    60
GLDEF_C TInt BmWriteThread(TAny*)
sl@0
    61
	/**
sl@0
    62
	 * Performs writes continuously, telling device driver that a thread
sl@0
    63
	 * read is required
sl@0
    64
	 */
sl@0
    65
	{
sl@0
    66
	TAny* p = writeBuffer;
sl@0
    67
	while( !StopTest )
sl@0
    68
		{
sl@0
    69
		TInt r = drive.Write( TestInfo.iOffset, TestInfo.iLength, p, mainThreadHandle, 0 );
sl@0
    70
		if( KErrNone != r )
sl@0
    71
			{
sl@0
    72
			User::Panic( KPanicCat, r );
sl@0
    73
			}
sl@0
    74
		++Count;
sl@0
    75
		}
sl@0
    76
	return KErrNone;
sl@0
    77
	}
sl@0
    78
sl@0
    79
sl@0
    80
GLDEF_C TInt BmRead(TAny*)
sl@0
    81
	/**
sl@0
    82
	 * Performs reads continously
sl@0
    83
	 */
sl@0
    84
	{
sl@0
    85
	TPtr8 rd = readBuffer->Des();
sl@0
    86
	while( !StopTest )
sl@0
    87
		{
sl@0
    88
		TInt r = drive.Read( TestInfo.iOffset, TestInfo.iLength, rd );
sl@0
    89
		if( KErrNone != r )
sl@0
    90
			{
sl@0
    91
			User::Panic( KPanicCat, r );
sl@0
    92
			}
sl@0
    93
		++Count;
sl@0
    94
		}
sl@0
    95
	return KErrNone;
sl@0
    96
	}
sl@0
    97
sl@0
    98
GLDEF_C TInt BmReadThread(TAny*)
sl@0
    99
	/**
sl@0
   100
	 * Performs reads continously, telling device driver that a thread
sl@0
   101
	 * write is required
sl@0
   102
	 */
sl@0
   103
	{
sl@0
   104
	TPtr8 des = readBuffer->Des();
sl@0
   105
	TAny* p = &des;
sl@0
   106
	while( !StopTest )
sl@0
   107
		{
sl@0
   108
		TInt r = drive.Read( TestInfo.iOffset, TestInfo.iLength, p, mainThreadHandle, 0 );
sl@0
   109
		if( KErrNone != r )
sl@0
   110
			{
sl@0
   111
			User::Panic( KPanicCat, r );
sl@0
   112
			}
sl@0
   113
		++Count;
sl@0
   114
		}
sl@0
   115
	return KErrNone;
sl@0
   116
	}