1 | /* $Id: expandospu_init.c 54905 2015-03-23 11:20:58Z vboxsync $ */
|
---|
2 | /* Copyright (c) 2001, Stanford University
|
---|
3 | * All rights reserved
|
---|
4 | *
|
---|
5 | * See the file LICENSE.txt for information on redistributing this software.
|
---|
6 | */
|
---|
7 |
|
---|
8 | #include <stdio.h>
|
---|
9 | #include "cr_spu.h"
|
---|
10 | #include "cr_dlm.h"
|
---|
11 | #include "cr_hash.h"
|
---|
12 | #include "expandospu.h"
|
---|
13 |
|
---|
14 | ExpandoSPU expando_spu;
|
---|
15 |
|
---|
16 | static SPUFunctions expando_functions = {
|
---|
17 | NULL, /* CHILD COPY */
|
---|
18 | NULL, /* DATA */
|
---|
19 | _cr_expando_table /* THE ACTUAL FUNCTIONS */
|
---|
20 | };
|
---|
21 |
|
---|
22 | static SPUFunctions *
|
---|
23 | expandoSPUInit( int id, SPU *child, SPU *self,
|
---|
24 | unsigned int context_id,
|
---|
25 | unsigned int num_contexts )
|
---|
26 | {
|
---|
27 |
|
---|
28 | (void) self;
|
---|
29 | (void) context_id;
|
---|
30 | (void) num_contexts;
|
---|
31 |
|
---|
32 | expando_spu.id = id;
|
---|
33 | expando_spu.has_child = 0;
|
---|
34 | expando_spu.server = NULL;
|
---|
35 | if (child)
|
---|
36 | {
|
---|
37 | crSPUInitDispatchTable( &(expando_spu.child) );
|
---|
38 | crSPUCopyDispatchTable( &(expando_spu.child), &(child->dispatch_table) );
|
---|
39 | expando_spu.has_child = 1;
|
---|
40 | }
|
---|
41 | crSPUInitDispatchTable( &(expando_spu.super) );
|
---|
42 | crSPUCopyDispatchTable( &(expando_spu.super), &(self->superSPU->dispatch_table) );
|
---|
43 | expandospuGatherConfiguration();
|
---|
44 |
|
---|
45 | /* Expando-specific initialization */
|
---|
46 | expando_spu.contextTable = crAllocHashtable();
|
---|
47 |
|
---|
48 | /* We'll be using the state tracker for each context */
|
---|
49 | crStateInit();
|
---|
50 |
|
---|
51 | return &expando_functions;
|
---|
52 | }
|
---|
53 |
|
---|
54 | static void
|
---|
55 | expandoSPUSelfDispatch(SPUDispatchTable *self)
|
---|
56 | {
|
---|
57 | crSPUInitDispatchTable( &(expando_spu.self) );
|
---|
58 | crSPUCopyDispatchTable( &(expando_spu.self), self );
|
---|
59 |
|
---|
60 | expando_spu.server = (CRServer *)(self->server);
|
---|
61 | }
|
---|
62 |
|
---|
63 |
|
---|
64 | static int
|
---|
65 | expandoSPUCleanup(void)
|
---|
66 | {
|
---|
67 | crFreeHashtable(expando_spu.contextTable, expando_free_context_state);
|
---|
68 | crStateDestroy();
|
---|
69 | return 1;
|
---|
70 | }
|
---|
71 |
|
---|
72 | int
|
---|
73 | SPULoad( char **name, char **super, SPUInitFuncPtr *init,
|
---|
74 | SPUSelfDispatchFuncPtr *self, SPUCleanupFuncPtr *cleanup,
|
---|
75 | SPUOptionsPtr *options, int *flags )
|
---|
76 | {
|
---|
77 | *name = "expando";
|
---|
78 | //*super = "passthrough";
|
---|
79 | *super = "render";
|
---|
80 | *init = expandoSPUInit;
|
---|
81 | *self = expandoSPUSelfDispatch;
|
---|
82 | *cleanup = expandoSPUCleanup;
|
---|
83 | *options = expandoSPUOptions;
|
---|
84 | *flags = (SPU_NO_PACKER|SPU_NOT_TERMINAL|SPU_MAX_SERVERS_ZERO);
|
---|
85 |
|
---|
86 | return 1;
|
---|
87 | }
|
---|