1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/video/t_videomemprocess.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,115 @@
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 +// T_VIDEOMEMORY.CPP
1.18 +// Overview:
1.19 +// Test the video driver kernel extension that provides chunk handle to access video memory.
1.20 +// This executable is a second process that is started by the main t_videomemory test process.
1.21 +// API Information:
1.22 +// HAL, UserSvr
1.23 +// Details:
1.24 +// - Check that we can get a chunk and that we can read/write the memory belonging to that chunk.
1.25 +// - When this process exits, the main process will check that the value has changed in it's copy
1.26 +// - of the chunk.
1.27 +// Platforms/Drives/Compatibility:
1.28 +// All.
1.29 +// Assumptions/Requirement/Pre-requisites:
1.30 +// Failures and causes:
1.31 +// Base Port information:
1.32 +//
1.33 +//
1.34 +
1.35 +#include <e32test.h>
1.36 +#include <videodriver.h>
1.37 +#include <hal.h>
1.38 +#include <e32svr.h>
1.39 +#include <dispchannel.h>
1.40 +#include "t_videomemory.h"
1.41 +
1.42 +LOCAL_D RTest test(_L("T_VIDEOMEMPROCESS"));
1.43 +
1.44 +#ifndef __WINS__
1.45 +#define DUMP(x) test.Printf(_L(#x"= %d =0x%08x\n"), x, x)
1.46 +#endif
1.47 +
1.48 +
1.49 +LOCAL_C TInt RunTestsForScreen(TInt aScreenID)
1.50 + {
1.51 + TInt ret = KErrNone;
1.52 +
1.53 + test.Next(_L("Checking Display Handle"));
1.54 + // Second basic test. Use the HAL to fetch a handle
1.55 + // to the display memory.
1.56 + // Check that the handle is not zero.
1.57 + // Get the base-address of the chunk.
1.58 + // Write this base address with a new value.
1.59 + // Read with the chunk base address to see that teh new value is there.
1.60 + // Read the memory address from the above test and check that it changed
1.61 + // to the new value.
1.62 + // Note that the memory address from above test MAY NOT BE SET - so
1.63 + // check to see if it's non-zero first.
1.64 +
1.65 + TInt handle = 0;
1.66 + volatile TUint32 *pChunkBase = 0;
1.67 + ret = HAL::Get(aScreenID, HALData::EDisplayMemoryHandle,handle);
1.68 + test ((KErrNone == ret || KErrNotSupported == ret));
1.69 + if (KErrNone == ret)
1.70 + {
1.71 + test(0 != handle);
1.72 + RChunk chunk;
1.73 + ret = chunk.SetReturnedHandle(handle);
1.74 + test(KErrNone == ret);
1.75 + if (KErrNone != ret)
1.76 + {
1.77 + return ret;
1.78 + }
1.79 +
1.80 + pChunkBase = reinterpret_cast<TUint32 *>(chunk.Base());
1.81 + test.Printf(_L("Display Memory Address = %08x\n"), reinterpret_cast<TInt>(pChunkBase));
1.82 + // Now check that we can read and write the memory that the chunk holds:
1.83 + // First check that it contains what we expect.
1.84 + test(KTestValue3 == *pChunkBase);
1.85 +
1.86 + // Now check that we can CHANGE it.
1.87 + *pChunkBase = KTestValue4;
1.88 + test(KTestValue4 == *pChunkBase);
1.89 + }
1.90 +
1.91 + return KErrNone;
1.92 + }
1.93 +
1.94 +
1.95 +
1.96 +GLDEF_C TInt E32Main()
1.97 +//
1.98 +//
1.99 + {
1.100 + test.Title();
1.101 +
1.102 +#if defined(__EPOC32__) && defined(__CPU_X86)
1.103 + test.Printf(_L("Doesn't run on X86\n"));
1.104 +#else
1.105 + TInt ret = KErrNone;
1.106 +
1.107 + TInt screen;
1.108 + User::GetTIntParameter(12, screen);
1.109 +
1.110 + test.Start(_L("Testing Video Memory HAL interfaces (second process)"));
1.111 +
1.112 + //Hack: Only use screen 0 for now - use passed argument(s) later on.
1.113 + ret = RunTestsForScreen(screen);
1.114 + test((ret == KErrNone));
1.115 +#endif
1.116 +
1.117 + return KErrNone;
1.118 +}