1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/device/d_ldd2.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,140 @@
1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// e32test\device\d_ldd2.cpp
1.18 +// Secondary LDD for testing linking one driver to another
1.19 +//
1.20 +//
1.21 +
1.22 +#include <kernel/kernel.h>
1.23 +#include "d_ldd2.h"
1.24 +
1.25 +TInt AFunction()
1.26 + {
1.27 + return KErrNone;
1.28 + }
1.29 +
1.30 +TInt data=0x100;
1.31 +TAny* dataptr=(TAny*)&AFunction;
1.32 +TInt TheBss;
1.33 +
1.34 +class TGlobal
1.35 + {
1.36 +public:
1.37 + TGlobal();
1.38 + ~TGlobal();
1.39 + void Update(TUint32 a);
1.40 + TInt Verify();
1.41 +public:
1.42 + TUint32 iInt;
1.43 + TAny* iPtr;
1.44 + };
1.45 +
1.46 +TGlobal Global;
1.47 +
1.48 +TGlobal::TGlobal()
1.49 + {
1.50 + __KTRACE_OPT(KDEVICE,Kern::Printf("TGlobal::TGlobal()"));
1.51 + iPtr = Kern::Alloc(65536);
1.52 + Update(487);
1.53 + }
1.54 +
1.55 +TGlobal::~TGlobal()
1.56 + {
1.57 + __KTRACE_OPT(KDEVICE,Kern::Printf("TGlobal::~TGlobal()"));
1.58 + Kern::Free(iPtr);
1.59 + }
1.60 +
1.61 +void TGlobal::Update(TUint32 a)
1.62 + {
1.63 + iInt = a;
1.64 + if (iPtr)
1.65 + {
1.66 + TUint32* p = (TUint32*)iPtr;
1.67 + TUint32* pE = p + 65536/4;
1.68 + while (p<pE)
1.69 + {
1.70 + a = (a*69069u)+41;
1.71 + *p++ = a;
1.72 + }
1.73 + }
1.74 + }
1.75 +
1.76 +TInt TGlobal::Verify()
1.77 + {
1.78 + TUint32 x = iInt;
1.79 + if (iPtr)
1.80 + {
1.81 + TUint32* p = (TUint32*)iPtr;
1.82 + TUint32* pE = p + 65536/4;
1.83 + while (p<pE)
1.84 + {
1.85 + x = (x*69069u)+41;
1.86 + if (*p++ != x)
1.87 + return KErrGeneral;
1.88 + }
1.89 + return KErrNone;
1.90 + }
1.91 + return KErrNoMemory;
1.92 + }
1.93 +
1.94 +EXPORT_C TInt LinkedTest1()
1.95 + {
1.96 + return (TInt)dataptr;
1.97 + }
1.98 +
1.99 +EXPORT_C TInt LinkedTest2()
1.100 + {
1.101 + return data++;
1.102 + }
1.103 +
1.104 +EXPORT_C TInt LinkedTest3()
1.105 + {
1.106 + return data--;
1.107 + }
1.108 +
1.109 +EXPORT_C TInt LinkedTest4()
1.110 + {
1.111 + return data;
1.112 + }
1.113 +
1.114 +EXPORT_C TInt LinkedTest5()
1.115 + {
1.116 + return TheBss;
1.117 + }
1.118 +
1.119 +EXPORT_C TInt LinkedTest6(TInt aValue)
1.120 + {
1.121 + TheBss = aValue;
1.122 + return KErrNone;
1.123 + }
1.124 +
1.125 +EXPORT_C TUint32 LinkedTest7()
1.126 + {
1.127 + return (TInt)Global.iInt;
1.128 + }
1.129 +
1.130 +EXPORT_C void LinkedTest8(TUint32 aValue)
1.131 + {
1.132 + Global.Update(aValue);
1.133 + }
1.134 +
1.135 +EXPORT_C TInt LinkedTest9()
1.136 + {
1.137 + return Global.Verify();
1.138 + }
1.139 +
1.140 +DECLARE_STANDARD_LDD()
1.141 + {
1.142 + return NULL;
1.143 + }