First public contribution.
1 // Copyright (c) 2006-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 "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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // For the Winscw Emulator only, selects between REF, GCE and non-GCE version of EGL.
16 // The default is the non-GCE based version.
17 // To use the REF version GCE needs to be enabled.
19 // To select the GCE version do one of:
20 // 1. Add a line to the epoc.ini file in \epoc32\data like this:
21 // symbian_graphics_use_gce ON
23 // 2. Start epoc.exe with these parameters, (the "--" IS necessary):
24 // -Dsymbian_graphics_use_gce=ON --
26 // 3. epoc.exe can be told to switch to a different initialisation file than epoc.ini, with the -M parameter.
27 // Progress chaining to the real libEGL is logged in epocwind.out.
29 // To select the REF version do one of the steps above, adding
30 // symbian_graphics_use_egl_ref in addition to symbian_graphics_use_gce.
42 #include "egl_stubs.h"
44 FARPROC vector[MAX_ORDINAL+1]; // 1 additional entry: vector[0] to set the initialised state
48 void Stop(char* aErrorMessage)
50 void Stop(char* /*aErrorMessage*/)
53 int err = GetLastError();
55 RDebug::Printf("%S, (last error = %i)", aErrorMessage, err);
60 void fill_vector(HINSTANCE aDll)
62 FARPROC address = NULL;
63 for (int i=1;i<=MAX_ORDINAL;i++)
65 address = GetProcAddress(aDll, (LPCSTR)i);
68 Stop("... has too few exported functions");
73 // There's an additional _E32Dll entry point after last ordinal position.
74 // Read it, but no need to store it
75 address = GetProcAddress(aDll, (LPCSTR)(MAX_ORDINAL+1));
78 Stop("... has too few exported functions");
81 // next position should be empty
82 address = GetProcAddress(aDll, (LPCSTR)(MAX_ORDINAL+2));
85 Stop("... has too many exported functions");
88 vector[0] = (FARPROC)1;
91 // redirects DLL calls to GCE or non-GCE implementation
94 // ask HAL which configuration to use
96 UserSvr::HalFunction(EHalGroupEmulator, EEmulatorHalBoolProperty, (TAny*)"symbian_graphics_use_gce", &gce);
97 const char* library = "";
100 // reference EGL is for NGA only
102 UserSvr::HalFunction(EHalGroupEmulator, EEmulatorHalBoolProperty, (TAny*)"symbian_graphics_use_egl_ref", &ref);
103 library = ref ? "libegl_ref.dll" : "libegl_gce.dll";
107 library = "libegl_nongce.dll";
111 RDebug::Printf("Redirecting libEGL.dll to \"%s\" ...\n", library);
114 Emulator::Escape(); // prevent deadlock between EKA2 scheduler and MS kernel
115 // try to load selected DLL
116 HINSTANCE instance = LoadLibraryA(library);
119 if (instance == NULL)
121 Stop("... unable to load");
125 fill_vector(instance);
127 RDebug::Printf("... DLL loaded successfully");
132 __declspec(naked) void common_dispatch()
134 _asm cmp dword ptr vector,0 // initialised?
135 _asm je do_init_vector
137 _asm jmp [vector+eax*4]
143 _asm call init_vector
147 _asm jmp call_though_vector