sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // T_VIDEOMEMORY.CPP sl@0: // Overview: sl@0: // Test the video driver kernel extension that provides chunk handle to access video memory. sl@0: // This executable is a second process that is started by the main t_videomemory test process. sl@0: // API Information: sl@0: // HAL, UserSvr sl@0: // Details: sl@0: // - Check that we can get a chunk and that we can read/write the memory belonging to that chunk. sl@0: // - When this process exits, the main process will check that the value has changed in it's copy sl@0: // - of the chunk. sl@0: // Platforms/Drives/Compatibility: sl@0: // All. sl@0: // Assumptions/Requirement/Pre-requisites: sl@0: // Failures and causes: sl@0: // Base Port information: sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "t_videomemory.h" sl@0: sl@0: LOCAL_D RTest test(_L("T_VIDEOMEMPROCESS")); sl@0: sl@0: #ifndef __WINS__ sl@0: #define DUMP(x) test.Printf(_L(#x"= %d =0x%08x\n"), x, x) sl@0: #endif sl@0: sl@0: sl@0: LOCAL_C TInt RunTestsForScreen(TInt aScreenID) sl@0: { sl@0: TInt ret = KErrNone; sl@0: sl@0: test.Next(_L("Checking Display Handle")); sl@0: // Second basic test. Use the HAL to fetch a handle sl@0: // to the display memory. sl@0: // Check that the handle is not zero. sl@0: // Get the base-address of the chunk. sl@0: // Write this base address with a new value. sl@0: // Read with the chunk base address to see that teh new value is there. sl@0: // Read the memory address from the above test and check that it changed sl@0: // to the new value. sl@0: // Note that the memory address from above test MAY NOT BE SET - so sl@0: // check to see if it's non-zero first. sl@0: sl@0: TInt handle = 0; sl@0: volatile TUint32 *pChunkBase = 0; sl@0: ret = HAL::Get(aScreenID, HALData::EDisplayMemoryHandle,handle); sl@0: test ((KErrNone == ret || KErrNotSupported == ret)); sl@0: if (KErrNone == ret) sl@0: { sl@0: test(0 != handle); sl@0: RChunk chunk; sl@0: ret = chunk.SetReturnedHandle(handle); sl@0: test(KErrNone == ret); sl@0: if (KErrNone != ret) sl@0: { sl@0: return ret; sl@0: } sl@0: sl@0: pChunkBase = reinterpret_cast(chunk.Base()); sl@0: test.Printf(_L("Display Memory Address = %08x\n"), reinterpret_cast(pChunkBase)); sl@0: // Now check that we can read and write the memory that the chunk holds: sl@0: // First check that it contains what we expect. sl@0: test(KTestValue3 == *pChunkBase); sl@0: sl@0: // Now check that we can CHANGE it. sl@0: *pChunkBase = KTestValue4; sl@0: test(KTestValue4 == *pChunkBase); sl@0: } sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: // sl@0: // sl@0: { sl@0: test.Title(); sl@0: sl@0: #if defined(__EPOC32__) && defined(__CPU_X86) sl@0: test.Printf(_L("Doesn't run on X86\n")); sl@0: #else sl@0: TInt ret = KErrNone; sl@0: sl@0: TInt screen; sl@0: User::GetTIntParameter(12, screen); sl@0: sl@0: test.Start(_L("Testing Video Memory HAL interfaces (second process)")); sl@0: sl@0: //Hack: Only use screen 0 for now - use passed argument(s) later on. sl@0: ret = RunTestsForScreen(screen); sl@0: test((ret == KErrNone)); sl@0: #endif sl@0: sl@0: return KErrNone; sl@0: }