comparison src/video/ps3/SDL_ps3spe.c @ 3150:0cf7bff804ad gsoc2009_ps3

Code reviewed and added SPE API documentation.
author Martin Lowinski <martin@goldtopf.org>
date Sun, 19 Jul 2009 11:31:47 +0000
parents 0d8d1f870964
children cce01ba54174
comparison
equal deleted inserted replaced
3149:b143d794bff1 3150:0cf7bff804ad
25 #include "SDL_ps3spe_c.h" 25 #include "SDL_ps3spe_c.h"
26 26
27 #include "SDL_ps3video.h" 27 #include "SDL_ps3video.h"
28 #include "SDL_ps3render_c.h" 28 #include "SDL_ps3render_c.h"
29 29
30
31 /* This SPE API basically provides 3 ways to run and control a program
32 * on the SPE:
33 * - Start and stop the program (keepalive=0).
34 * SPE_Start() will implicitly boot up the program, create a thread and run
35 * the context.
36 * SPE_Stop() will join the (terminated) thread (may block) and return.
37 * - Boot the program and run it (keepalive=0).
38 * SPE_Boot() will create a context and load the program and finally start
39 * the context with SPE_Start().
40 * SPE_Stop() will savely end the program.
41 * - Boot, Run and send messages to the program (keepalive=1).
42 * Start the program by using one of the methods described above. When
43 * received the READY-message the program is in its infinite loop waiting
44 * for new messages.
45 * Every time you run the program, send SPU_START and the address of the
46 * according struct using SPE_SendMsg().
47 * SPE_WaitForMsg() will than wait for SPU_FIN and is blocking.
48 * SPE_Shutdown() sends SPU_EXIT and finally stops the program.
49 *
50 * Therefor the SPE program
51 * - either runs once and returns
52 * - or runs in an infinite loop and is controlled by messages.
53 */
30 54
31 /* Start the SPE thread */ 55 /* Start the SPE thread */
32 int SPE_Start(spu_data_t * spe_data) 56 int SPE_Start(spu_data_t * spe_data)
33 { 57 {
34 deprintf(2, "[PS3->SPU] Start SPE: %s\n", spe_data->program_name); 58 deprintf(2, "[PS3->SPU] Start SPE: %s\n", spe_data->program_name);
144 return -1; 168 return -1;
145 } 169 }
146 170
147 /* Re-runnable invocation of the spe_context_run call */ 171 /* Re-runnable invocation of the spe_context_run call */
148 void SPE_RunContext(void *thread_argp) 172 void SPE_RunContext(void *thread_argp)
149 { 173 {
150 /* argp is the pointer to argument to be passed to the SPE program */ 174 /* argp is the pointer to argument to be passed to the SPE program */
151 spu_data_t *args = (spu_data_t *) thread_argp; 175 spu_data_t *args = (spu_data_t *) thread_argp;
152 deprintf(3, "[PS3->SPU] void* argp=0x%x\n", (unsigned int)args->argp); 176 deprintf(3, "[PS3->SPU] void* argp=0x%x\n", (unsigned int)args->argp);
153 177
154 /* Run it.. */ 178 /* Run it.. */
155 deprintf(2, "[PS3->SPU] Run SPE program: %s\n", args->program_name); 179 deprintf(2, "[PS3->SPU] Run SPE program: %s\n", args->program_name);
156 if (spe_context_run 180 if (spe_context_run
157 (args->ctx, &args->entry, 0, (void *)args->argp, NULL, 181 (args->ctx, &args->entry, 0, (void *)args->argp, NULL,
158 NULL) < 0) { 182 NULL) < 0) {