1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
/* Copyright (c) 2001, Stanford University
* All rights reserved
*
* See the file LICENSE.txt for information on redistributing this software.
*/
#include "cr_mem.h"
#include "cr_spu.h"
#include "cr_glstate.h"
#include "packspu.h"
#include "cr_packfunctions.h"
#include <stdio.h>
extern SPUNamedFunctionTable _cr_pack_table[];
SPUFunctions pack_functions = {
NULL, /* CHILD COPY */
NULL, /* DATA */
_cr_pack_table /* THE ACTUAL FUNCTIONS */
};
PackSPU pack_spu;
#ifdef CHROMIUM_THREADSAFE
CRtsd _PackTSD;
CRmutex _PackMutex;
#endif
#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
# include <VBoxCrHgsmi.h>
# include <VBoxUhgsmi.h>
#endif
#if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_WDDM)
static bool isVBoxWDDMCrHgsmi(void)
{
#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
PVBOXUHGSMI pHgsmi = VBoxCrHgsmiCreate();
if (pHgsmi)
{
VBoxCrHgsmiDestroy(pHgsmi);
return true;
}
#endif
return false;
}
#endif /* RT_OS_WINDOWS && VBOX_WITH_WDDM */
static SPUFunctions *
packSPUInit( int id, SPU *child, SPU *self,
unsigned int context_id,
unsigned int num_contexts )
{
ThreadInfo *thread;
(void) context_id;
(void) num_contexts;
(void) child;
(void) self;
#if defined(CHROMIUM_THREADSAFE) && !defined(WINDOWS)
crInitMutex(&_PackMutex);
#endif
#ifdef CHROMIUM_THREADSAFE
crInitTSD(&_PackerTSD);
crInitTSD(&_PackTSD);
#endif
pack_spu.id = id;
packspuSetVBoxConfiguration( child );
#if defined(WINDOWS) && defined(VBOX_WITH_WDDM)
pack_spu.bIsWDDMCrHgsmi = isVBoxWDDMCrHgsmi();
#endif
#ifdef VBOX_WITH_CRPACKSPU_DUMPER
memset(&pack_spu.Dumper, 0, sizeof (pack_spu.Dumper));
#endif
if (!CRPACKSPU_IS_WDDM_CRHGSMI())
{
/* This connects to the server, sets up the packer, etc. */
thread = packspuNewThread(
#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
NULL
#endif
);
if (!thread) {
return NULL;
}
CRASSERT( thread == &(pack_spu.thread[0]) );
pack_spu.idxThreadInUse = 0;
}
packspuCreateFunctions();
crStateInit();
return &pack_functions;
}
static void
packSPUSelfDispatch(SPUDispatchTable *self)
{
crSPUInitDispatchTable( &(pack_spu.self) );
crSPUCopyDispatchTable( &(pack_spu.self), self );
}
static int
packSPUCleanup(void)
{
int i;
#ifdef CHROMIUM_THREADSAFE
crLockMutex(&_PackMutex);
#endif
for (i=0; i<MAX_THREADS; ++i)
{
if (pack_spu.thread[i].inUse && pack_spu.thread[i].packer)
{
crPackDeleteContext(pack_spu.thread[i].packer);
}
}
#ifdef CHROMIUM_THREADSAFE
crFreeTSD(&_PackerTSD);
crFreeTSD(&_PackTSD);
crUnlockMutex(&_PackMutex);
# ifndef WINDOWS
crFreeMutex(&_PackMutex);
# endif
#endif /* CHROMIUM_THREADSAFE */
return 1;
}
extern SPUOptions packSPUOptions[];
int SPULoad( char **name, char **super, SPUInitFuncPtr *init,
SPUSelfDispatchFuncPtr *self, SPUCleanupFuncPtr *cleanup,
SPUOptionsPtr *options, int *flags )
{
*name = "pack";
*super = NULL;
*init = packSPUInit;
*self = packSPUSelfDispatch;
*cleanup = packSPUCleanup;
*options = packSPUOptions;
*flags = (SPU_HAS_PACKER|SPU_IS_TERMINAL|SPU_MAX_SERVERS_ONE);
return 1;
}
|