1 | /* Copyright (c) 2001, Stanford University
|
---|
2 | * All rights reserved
|
---|
3 | *
|
---|
4 | * See the file LICENSE.txt for information on redistributing this software.
|
---|
5 | */
|
---|
6 |
|
---|
7 | #include "cr_spu.h"
|
---|
8 | #include "cr_string.h"
|
---|
9 | #include "cr_error.h"
|
---|
10 | #include "cr_mem.h"
|
---|
11 | #include "cr_server.h"
|
---|
12 | #include "feedbackspu.h"
|
---|
13 | #include <fcntl.h>
|
---|
14 | #ifndef WINDOWS
|
---|
15 | #include <unistd.h>
|
---|
16 | #endif
|
---|
17 |
|
---|
18 | feedbackSPU feedback_spu;
|
---|
19 |
|
---|
20 | static SPUFunctions feedback_functions = {
|
---|
21 | NULL, /* CHILD COPY */
|
---|
22 | NULL, /* DATA */
|
---|
23 | _cr_feedback_table /* THE ACTUAL FUNCTIONS */
|
---|
24 | };
|
---|
25 |
|
---|
26 | static SPUFunctions *feedbackSPUInit( int id, SPU *child, SPU *self,
|
---|
27 | unsigned int context_id,
|
---|
28 | unsigned int num_contexts )
|
---|
29 | {
|
---|
30 | (void) context_id;
|
---|
31 | (void) num_contexts;
|
---|
32 |
|
---|
33 | crInitMutex(&feedback_spu.mutex);
|
---|
34 | feedback_spu.id = id;
|
---|
35 | feedback_spu.has_child = 0;
|
---|
36 | if (child)
|
---|
37 | {
|
---|
38 | crSPUInitDispatchTable( &(feedback_spu.child) );
|
---|
39 | crSPUCopyDispatchTable( &(feedback_spu.child), &(child->dispatch_table) );
|
---|
40 | feedback_spu.has_child = 1;
|
---|
41 | }
|
---|
42 | crSPUInitDispatchTable( &(feedback_spu.super) );
|
---|
43 | crSPUCopyDispatchTable( &(feedback_spu.super), &(self->superSPU->dispatch_table) );
|
---|
44 | feedbackspuGatherConfiguration();
|
---|
45 |
|
---|
46 | /* create/init default state tracker */
|
---|
47 | crStateInit(&feedback_spu.StateTracker);
|
---|
48 |
|
---|
49 | feedback_spu.defaultctx = crStateCreateContext(&feedback_spu.StateTracker, NULL, 0, NULL);
|
---|
50 | crStateSetCurrent(&feedback_spu.StateTracker, feedback_spu.defaultctx);
|
---|
51 |
|
---|
52 | feedback_spu.numContexts = 0;
|
---|
53 | crMemZero(feedback_spu.context, CR_MAX_CONTEXTS * sizeof(ContextInfo));
|
---|
54 |
|
---|
55 | return &feedback_functions;
|
---|
56 | }
|
---|
57 |
|
---|
58 | static void feedbackSPUSelfDispatch(SPUDispatchTable *self)
|
---|
59 | {
|
---|
60 | crSPUInitDispatchTable( &(feedback_spu.self) );
|
---|
61 | crSPUCopyDispatchTable( &(feedback_spu.self), self );
|
---|
62 | }
|
---|
63 |
|
---|
64 | static int feedbackSPUCleanup(void)
|
---|
65 | {
|
---|
66 | return 1;
|
---|
67 | }
|
---|
68 |
|
---|
69 | DECLHIDDEN(const SPUREG) g_FeedbackSpuReg =
|
---|
70 | {
|
---|
71 | /** pszName. */
|
---|
72 | "feedback",
|
---|
73 | /** pszSuperName. */
|
---|
74 | "passthrough",
|
---|
75 | /** fFlags. */
|
---|
76 | SPU_NO_PACKER | SPU_NOT_TERMINAL | SPU_MAX_SERVERS_ZERO,
|
---|
77 | /** pfnInit. */
|
---|
78 | feedbackSPUInit,
|
---|
79 | /** pfnDispatch. */
|
---|
80 | feedbackSPUSelfDispatch,
|
---|
81 | /** pfnCleanup. */
|
---|
82 | feedbackSPUCleanup
|
---|
83 | };
|
---|