os/kernelhwsrv/kerneltest/e32test/video/t_videomemprocess.cpp
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 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // T_VIDEOMEMORY.CPP
    15 // Overview:
    16 // Test the video driver kernel extension that provides chunk handle to access video memory. 
    17 // This executable is a second process that is started by the main t_videomemory test process.
    18 // API Information:
    19 // HAL, UserSvr
    20 // Details:
    21 // - Check that we can get a chunk and that we can read/write the memory belonging to that chunk.
    22 // - When this process exits, the main process will check that the value has changed in it's copy 
    23 // - of the chunk.  
    24 // Platforms/Drives/Compatibility:
    25 // All.
    26 // Assumptions/Requirement/Pre-requisites:
    27 // Failures and causes:
    28 // Base Port information:
    29 // 
    30 //
    31 
    32 #include <e32test.h>
    33 #include <videodriver.h>
    34 #include <hal.h>
    35 #include <e32svr.h>
    36 #include <dispchannel.h>
    37 #include "t_videomemory.h"
    38 
    39 LOCAL_D RTest test(_L("T_VIDEOMEMPROCESS"));
    40 
    41 #ifndef __WINS__
    42 #define DUMP(x) test.Printf(_L(#x"= %d =0x%08x\n"), x, x)
    43 #endif
    44 
    45 
    46 LOCAL_C TInt RunTestsForScreen(TInt aScreenID)
    47 	{
    48 	TInt ret = KErrNone;
    49 	
    50 	test.Next(_L("Checking Display Handle"));
    51 	// Second basic test. Use the HAL to fetch a handle
    52 	// to the display memory. 
    53 	// Check that the handle is not zero. 
    54 	// Get the base-address of the chunk. 
    55 	// Write this base address with a new value.
    56 	// Read with the chunk base address to see that teh new value is there. 
    57 	// Read the memory address from the above test and check that it changed 
    58 	// to the new value.
    59 	// Note that the memory address from above test MAY NOT BE SET - so 
    60 	// check to see if it's non-zero first.
    61 		
    62 	TInt handle = 0;
    63 	volatile TUint32 *pChunkBase = 0;
    64 	ret = HAL::Get(aScreenID, HALData::EDisplayMemoryHandle,handle);
    65 	test ((KErrNone == ret || KErrNotSupported == ret));
    66 	if (KErrNone == ret)
    67 		{
    68 		test(0 != handle);
    69 		RChunk chunk;
    70 		ret = chunk.SetReturnedHandle(handle);
    71 	    test(KErrNone == ret);
    72 		if (KErrNone != ret)
    73 			{
    74 			return ret;
    75 			}
    76 		
    77 		pChunkBase = reinterpret_cast<TUint32 *>(chunk.Base());
    78 		test.Printf(_L("Display Memory Address = %08x\n"), reinterpret_cast<TInt>(pChunkBase));
    79 		// Now check that we can read and write the memory that the chunk holds:
    80 		// First check that it contains what we expect. 
    81 		test(KTestValue3 == *pChunkBase);
    82 
    83 		// Now check that we can CHANGE it. 
    84 		*pChunkBase = KTestValue4;
    85 		test(KTestValue4 == *pChunkBase);
    86 		}
    87 
    88 	return KErrNone;
    89 	}
    90 
    91 
    92 
    93 GLDEF_C TInt E32Main()
    94 //
    95 //
    96     {
    97 	test.Title();
    98 
    99 #if defined(__EPOC32__) && defined(__CPU_X86)
   100 	test.Printf(_L("Doesn't run on X86\n"));
   101 #else
   102 	TInt ret = KErrNone;
   103 	
   104 	TInt screen;
   105 	User::GetTIntParameter(12, screen);
   106 	
   107 	test.Start(_L("Testing Video Memory HAL interfaces (second process)"));
   108 
   109 	//Hack: Only use screen 0 for now - use passed argument(s) later on. 
   110 	ret = RunTestsForScreen(screen);
   111 	test((ret == KErrNone));
   112 #endif
   113 	
   114 	return KErrNone;
   115 }