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);