os/security/cryptoplugins/cryptospiplugins/test/h4drv/crypto_h4/cryptoh4rng.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2007-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 the License "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  @file
    21  @internalComponent
    22  @released
    23 */
    24 #ifndef __CRYPTOH4RNG__
    25 #define __CRYPTOH4RNG__
    26 #include "cryptojobs.h"
    27 
    28 class DCryptoH4Chan;
    29 class DLddChanRandom;
    30 class CryptoH4JobRandom : public CryptoJobRandom
    31 	{
    32 public:
    33 	CryptoH4JobRandom(DLddChanRandom &aLddChanRandom);
    34 	virtual ~CryptoH4JobRandom();
    35 
    36 	virtual void SetDfcQ(TDfcQue *aDfcQue);
    37 
    38 	virtual void SetDetails(DCryptoJobScheduler *aJobScheduler, MCryptoJobCallbacks *aCallbacks,
    39 							TUint32 aNumOfBytes);
    40 
    41 	virtual void GetToPddBuffer(TUint8 * &aBuf, TUint32 &aBufLen, TBool &aMore);
    42 	virtual void BytesWrittenToPdd(TUint32 aBytes);
    43 
    44 	virtual void GetFromPddBuffer(TUint8 * &aBuf, TUint32 &aBufLen, TBool &aMore);
    45 	virtual void BytesReadFromPdd(TUint32 aBytes);
    46 
    47 
    48 private:	
    49 	// Implementations of virtual base class methods to support DCryptoJobScheduler
    50 	virtual void DoSlice(TBool aFirstSlice);
    51 	virtual TBool DoSaveState();
    52 	virtual void DoRestoreState();
    53 	virtual void DoReleaseHw();
    54 	
    55 	TInt BytesAvailable() const;
    56 	void RegionsAvailable(TUint8 * &aPtr1, TInt &aLen1, 
    57 						  TUint8 * &aPtr2, TInt &aLen2) const;
    58 
    59 	DLddChanRandom &iLddChanRandom;
    60 	
    61 	// Details of job
    62 	TUint32 iRandomBuffer[64]; // Temporary buffer for PDD to write into
    63 	TInt iJobSizeInBytes;
    64 	TInt iSwReadByteOffset;
    65 	TInt iHw32Index;
    66 
    67 	// Hook/enable unhook/disable ISR in top level OMAP h/w
    68 	// Done at job scheduling level
    69 	TBool iIsrHooked;
    70 	void HookIsr();
    71 	void UnHookIsr();
    72 
    73 	// Enable/disable RNG ISR in Mask register
    74 	// Done for each byte of data.
    75 	inline void EnableIsr();
    76 	inline void DisableIsr();
    77 	
    78 	static void Isr(TAny *aPtr);
    79 
    80     static void RandomDfc(TAny* aPtr);
    81 	void DoRandomDfc();
    82     TDfc iRandomDfc;	
    83 	};
    84 #endif