30 #include <sys/types.h>
54 static int set_regs(
struct spe_context *spe,
void *regs)
65 rc = write(fd_regs, regs, 2048);
75 static int issue_isolated_exit(
struct spe_context *spe)
80 if (cntl_area == MAP_FAILED) {
92 static inline void freespeinfo()
100 unsigned int runflags,
void *argp,
void *envp,
103 int retval = 0, run_rc;
104 unsigned int run_status, tmp_entry;
106 struct spe_context_info this_context_info __attribute__((cleanup(cleanupspeinfo)));
111 stopinfo = &stopinfo_buf;
130 addr64 argp64, envp64, tid64, ls64;
131 unsigned int regs[128][4];
134 argp64.
ull = (uint64_t)(
unsigned long)argp;
135 envp64.
ull = (uint64_t)(
unsigned long)envp;
136 tid64.
ull = (uint64_t)(
unsigned long)spe;
139 memset(regs, 0,
sizeof(regs));
142 regs[1][0] = (
unsigned int)
LS_SIZE - 16;
150 memcpy(regs[3], argp,
sizeof(
unsigned int) * 12);
152 regs[3][0] = tid64.
ui[0];
153 regs[3][1] = tid64.
ui[1];
155 regs[4][0] = argp64.
ui[0];
156 regs[4][1] = argp64.
ui[1];
158 regs[5][0] = envp64.
ui[0];
159 regs[5][1] = envp64.
ui[1];
164 regs[6][0] = ls64.
ui[0];
165 regs[6][1] = ls64.
ui[1];
167 if (set_regs(spe, regs))
179 newinfo = &this_context_info;
194 &tmp_entry, &run_status);
200 DEBUG_PRINTF(
"spu_run returned run_rc=0x%08x, entry=0x%04x, "
201 "ext_status=0x%04x.\n", run_rc, tmp_entry, run_status);
233 "instruction. %d\n", run_rc);
257 int stopcode = (run_rc >> 16) & 0x3fff;
265 int callback_rc, callback_number = stopcode & 0xff;
268 DEBUG_PRINTF(
"SPE library call: %d\n", callback_number);
270 callback_number, *entry);
298 if (!issue_isolated_exit(spe))
339 DEBUG_PRINTF(
"SPU is waiting on channel. %d\n", run_rc);
348 "channel. %d\n", run_rc);
355 DEBUG_PRINTF(
"spu_run returned invalid data: 0x%04x\n", run_rc);
int _base_spe_handle_library_callback(struct spe_context *spe, int callnum, unsigned int npc)
union spe_stop_info::@0 result
#define SPE_RUNTIME_EXCEPTION
#define SPE_RUNTIME_FATAL
__thread struct spe_context_info * __spe_current_active_context
#define SPE_PROGRAM_ISOLATED_STOP
#define DEBUG_PRINTF(fmt, args...)
#define SPE_EVENTS_ENABLE
#define SPE_CALLBACK_ERROR
#define SPE_ISOLATION_ERROR
int _base_spe_context_run(spe_context_ptr_t spe, unsigned int *entry, unsigned int runflags, void *argp, void *envp, spe_stop_info_t *stopinfo)
int spe_runtime_exception
#define SPE_SPU_WAITING_ON_CHANNEL
#define SPE_RUNTIME_ERROR
#define SPE_PROGRAM_LIBRARY_CALL
#define SPE_SPU_INVALID_INSTR
#define SPE_PROGRAM_ISO_LOAD_COMPLETE
struct spe_context_base_priv * base_private
#define SPE_SPU_INVALID_CHANNEL
#define SPE_STOP_AND_SIGNAL
#define SPE_ISOLATE_EMULATE
#define SPE_SPU_STOPPED_BY_STOP
#define SPE_PROGRAM_NORMAL_END
#define SPE_DEFAULT_ENTRY
#define SPE_RUN_USER_REGS
struct spe_context_info * prev
void _base_spe_program_load_complete(spe_context_ptr_t spectx)