29 #define LS_SIZE 0x40000
32 typedef unsigned int u32;
33 typedef unsigned long long u64;
35 #include <spu_intrinsics.h>
39 #define BR_INSTR 0x327fff80
40 #define NOP_INSTR 0x40200000
41 #define HEQ_INSTR 0x7b000000
42 #define STOP_INSTR 0x00000000
43 #define ILLEGAL_INSTR 0x00800000
44 #define RESTORE_COMPLETE 0x00003ffc
46 static inline void fetch_regs_from_mem(
addr64 lscsa_ea)
50 unsigned int tag_id = 0;
51 unsigned int cmd = 0x40;
53 spu_writech(MFC_LSA, ls);
54 spu_writech(MFC_EAH, lscsa_ea.
ui[0]);
55 spu_writech(MFC_EAL, lscsa_ea.
ui[1]);
56 spu_writech(MFC_Size, size);
57 spu_writech(MFC_TagID, tag_id);
58 spu_writech(MFC_Cmd, cmd);
61 static inline void restore_upper_240kb(
addr64 lscsa_ea)
63 unsigned int ls = 16384;
64 unsigned int list = (
unsigned int)&dma_list[0];
65 unsigned int size =
sizeof(dma_list);
66 unsigned int tag_id = 0;
67 unsigned int cmd = 0x44;
73 spu_writech(MFC_LSA, ls);
74 spu_writech(MFC_EAH, lscsa_ea.
ui[0]);
75 spu_writech(MFC_EAL, list);
76 spu_writech(MFC_Size, size);
77 spu_writech(MFC_TagID, tag_id);
78 spu_writech(MFC_Cmd, cmd);
81 static inline void restore_decr(
void)
84 unsigned int decr_running;
97 spu_writech(SPU_WrDec, decr);
101 static inline void write_ppu_mb(
void)
112 spu_writech(SPU_WrOutMbox, data);
115 static inline void write_ppuint_mb(
void)
126 spu_writech(SPU_WrOutIntrMbox, data);
129 static inline void restore_fpcr(
void)
143 static inline void restore_srr0(
void)
153 spu_writech(SPU_WrSRR0, srr0);
156 static inline void restore_event_mask(
void)
159 unsigned int event_mask;
166 spu_writech(SPU_WrEventMask, event_mask);
169 static inline void restore_tag_mask(
void)
172 unsigned int tag_mask;
179 spu_writech(MFC_WrTagMask, tag_mask);
182 static inline void restore_complete(
void)
184 extern void exit_fini(
void);
185 unsigned int *exit_instrs = (
unsigned int *)exit_fini;
187 unsigned int stopped_status;
188 unsigned int stopped_code;
209 switch (stopped_status) {
210 case SPU_STOPPED_STATUS_P_I:
219 case SPU_STOPPED_STATUS_P_H:
228 case SPU_STOPPED_STATUS_S_P:
238 case SPU_STOPPED_STATUS_S_I:
247 case SPU_STOPPED_STATUS_I:
256 case SPU_STOPPED_STATUS_S:
263 case SPU_STOPPED_STATUS_H:
272 case SPU_STOPPED_STATUS_P:
279 case SPU_STOPPED_STATUS_R:
312 lscsa_ea.
ui[0] = spu_readch(SPU_RdSigNotify1);
313 lscsa_ea.
ui[1] = spu_readch(SPU_RdSigNotify2);
314 fetch_regs_from_mem(lscsa_ea);
318 build_dma_list(lscsa_ea);
319 restore_upper_240kb(lscsa_ea);
321 enqueue_putllc(lscsa_ea);
330 restore_event_mask();