sl@0
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// For the Winscw Emulator only, selects between REF, GCE and non-GCE version of EGL.
|
sl@0
|
15 |
// Notes:
|
sl@0
|
16 |
// The default is the non-GCE based version.
|
sl@0
|
17 |
// To use the REF version GCE needs to be enabled.
|
sl@0
|
18 |
//
|
sl@0
|
19 |
// To select the GCE version do one of:
|
sl@0
|
20 |
// 1. Add a line to the epoc.ini file in \epoc32\data like this:
|
sl@0
|
21 |
// symbian_graphics_use_gce ON
|
sl@0
|
22 |
// or
|
sl@0
|
23 |
// 2. Start epoc.exe with these parameters, (the "--" IS necessary):
|
sl@0
|
24 |
// -Dsymbian_graphics_use_gce=ON --
|
sl@0
|
25 |
// or
|
sl@0
|
26 |
// 3. epoc.exe can be told to switch to a different initialisation file than epoc.ini, with the -M parameter.
|
sl@0
|
27 |
// Progress chaining to the real libEGL is logged in epocwind.out.
|
sl@0
|
28 |
//
|
sl@0
|
29 |
// To select the REF version do one of the steps above, adding
|
sl@0
|
30 |
// symbian_graphics_use_egl_ref in addition to symbian_graphics_use_gce.
|
sl@0
|
31 |
//
|
sl@0
|
32 |
//
|
sl@0
|
33 |
|
sl@0
|
34 |
|
sl@0
|
35 |
#include <emulator.h>
|
sl@0
|
36 |
#include <e32svr.h>
|
sl@0
|
37 |
#include <u32hal.h>
|
sl@0
|
38 |
|
sl@0
|
39 |
|
sl@0
|
40 |
extern "C" {
|
sl@0
|
41 |
|
sl@0
|
42 |
#include "egl_stubs.h"
|
sl@0
|
43 |
|
sl@0
|
44 |
FARPROC vector[MAX_ORDINAL+1]; // 1 additional entry: vector[0] to set the initialised state
|
sl@0
|
45 |
|
sl@0
|
46 |
|
sl@0
|
47 |
#ifdef _DEBUG
|
sl@0
|
48 |
void Stop(char* aErrorMessage)
|
sl@0
|
49 |
#else
|
sl@0
|
50 |
void Stop(char* /*aErrorMessage*/)
|
sl@0
|
51 |
#endif
|
sl@0
|
52 |
{
|
sl@0
|
53 |
int err = GetLastError();
|
sl@0
|
54 |
#ifdef _DEBUG
|
sl@0
|
55 |
RDebug::Printf("%S, (last error = %i)", aErrorMessage, err);
|
sl@0
|
56 |
#endif
|
sl@0
|
57 |
_asm int 3;
|
sl@0
|
58 |
}
|
sl@0
|
59 |
|
sl@0
|
60 |
void fill_vector(HINSTANCE aDll)
|
sl@0
|
61 |
{
|
sl@0
|
62 |
FARPROC address = NULL;
|
sl@0
|
63 |
for (int i=1;i<=MAX_ORDINAL;i++)
|
sl@0
|
64 |
{
|
sl@0
|
65 |
address = GetProcAddress(aDll, (LPCSTR)i);
|
sl@0
|
66 |
if (address == NULL)
|
sl@0
|
67 |
{
|
sl@0
|
68 |
Stop("... has too few exported functions");
|
sl@0
|
69 |
}
|
sl@0
|
70 |
vector[i] = address;
|
sl@0
|
71 |
}
|
sl@0
|
72 |
|
sl@0
|
73 |
// There's an additional _E32Dll entry point after last ordinal position.
|
sl@0
|
74 |
// Read it, but no need to store it
|
sl@0
|
75 |
address = GetProcAddress(aDll, (LPCSTR)(MAX_ORDINAL+1));
|
sl@0
|
76 |
if (address == NULL)
|
sl@0
|
77 |
{
|
sl@0
|
78 |
Stop("... has too few exported functions");
|
sl@0
|
79 |
}
|
sl@0
|
80 |
|
sl@0
|
81 |
// next position should be empty
|
sl@0
|
82 |
address = GetProcAddress(aDll, (LPCSTR)(MAX_ORDINAL+2));
|
sl@0
|
83 |
if (address != NULL)
|
sl@0
|
84 |
{
|
sl@0
|
85 |
Stop("... has too many exported functions");
|
sl@0
|
86 |
}
|
sl@0
|
87 |
// Set initialised
|
sl@0
|
88 |
vector[0] = (FARPROC)1;
|
sl@0
|
89 |
}
|
sl@0
|
90 |
|
sl@0
|
91 |
// redirects DLL calls to GCE or non-GCE implementation
|
sl@0
|
92 |
void init_vector()
|
sl@0
|
93 |
{
|
sl@0
|
94 |
// ask HAL which configuration to use
|
sl@0
|
95 |
TBool gce = EFalse;
|
sl@0
|
96 |
UserSvr::HalFunction(EHalGroupEmulator, EEmulatorHalBoolProperty, (TAny*)"symbian_graphics_use_gce", &gce);
|
sl@0
|
97 |
const char* library = "";
|
sl@0
|
98 |
if (gce)
|
sl@0
|
99 |
{
|
sl@0
|
100 |
// reference EGL is for NGA only
|
sl@0
|
101 |
TBool ref = EFalse;
|
sl@0
|
102 |
UserSvr::HalFunction(EHalGroupEmulator, EEmulatorHalBoolProperty, (TAny*)"symbian_graphics_use_egl_ref", &ref);
|
sl@0
|
103 |
library = ref ? "libegl_ref.dll" : "libegl_gce.dll";
|
sl@0
|
104 |
}
|
sl@0
|
105 |
else
|
sl@0
|
106 |
{
|
sl@0
|
107 |
library = "libegl_nongce.dll";
|
sl@0
|
108 |
}
|
sl@0
|
109 |
|
sl@0
|
110 |
#ifdef _DEBUG
|
sl@0
|
111 |
RDebug::Printf("Redirecting libEGL.dll to \"%s\" ...\n", library);
|
sl@0
|
112 |
#endif
|
sl@0
|
113 |
|
sl@0
|
114 |
Emulator::Escape(); // prevent deadlock between EKA2 scheduler and MS kernel
|
sl@0
|
115 |
// try to load selected DLL
|
sl@0
|
116 |
HINSTANCE instance = LoadLibraryA(library);
|
sl@0
|
117 |
Emulator::Reenter();
|
sl@0
|
118 |
|
sl@0
|
119 |
if (instance == NULL)
|
sl@0
|
120 |
{
|
sl@0
|
121 |
Stop("... unable to load");
|
sl@0
|
122 |
}
|
sl@0
|
123 |
else
|
sl@0
|
124 |
{
|
sl@0
|
125 |
fill_vector(instance);
|
sl@0
|
126 |
#ifdef _DEBUG
|
sl@0
|
127 |
RDebug::Printf("... DLL loaded successfully");
|
sl@0
|
128 |
#endif
|
sl@0
|
129 |
}
|
sl@0
|
130 |
}
|
sl@0
|
131 |
|
sl@0
|
132 |
__declspec(naked) void common_dispatch()
|
sl@0
|
133 |
{
|
sl@0
|
134 |
_asm cmp dword ptr vector,0 // initialised?
|
sl@0
|
135 |
_asm je do_init_vector
|
sl@0
|
136 |
call_though_vector:
|
sl@0
|
137 |
_asm jmp [vector+eax*4]
|
sl@0
|
138 |
|
sl@0
|
139 |
do_init_vector:
|
sl@0
|
140 |
_asm push eax
|
sl@0
|
141 |
_asm push ecx
|
sl@0
|
142 |
_asm push edx
|
sl@0
|
143 |
_asm call init_vector
|
sl@0
|
144 |
_asm pop edx
|
sl@0
|
145 |
_asm pop ecx
|
sl@0
|
146 |
_asm pop eax
|
sl@0
|
147 |
_asm jmp call_though_vector
|
sl@0
|
148 |
}
|
sl@0
|
149 |
|
sl@0
|
150 |
}
|