1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * crt0_r.S: Entry function for SPU-side context restore.
5 * Copyright (C) 2005 IBM
7 * Entry and exit function for SPU-side of the context restore
8 * sequence. Sets up an initial stack frame, then branches to
9 * 'main'. On return, restores all 128 registers from the LSCSA
13 #include <asm/spu_csa.h>
19 .space SIZEOF_SPU_SPILL_REGS, 0x0
24 /* Initialize the stack pointer to point to 16368
25 * (16kb-16). The back chain pointer is initialized
32 /* Allocate a minimum stack frame for the called main.
33 * This is needed so that main has a place to save the
34 * link register when it calls another function.
39 /* Call the program's main function. */
46 /* SPU Context Restore, Step 5: Restore the remaining 112 GPRs. */
47 ila $3, regs_spill + 256
49 lqr $4, restore_reg_insts
52 .balignl 16, 0x40200000
53 restore_reg_insts: /* must be quad-word aligned. */
59 stqr $4, restore_reg_insts
61 brnz $5, restore_reg_loop
63 /* SPU Context Restore Step 17: Restore the first 16 GPRs. */
64 lqa $0, regs_spill + 0
65 lqa $1, regs_spill + 16
66 lqa $2, regs_spill + 32
67 lqa $3, regs_spill + 48
68 lqa $4, regs_spill + 64
69 lqa $5, regs_spill + 80
70 lqa $6, regs_spill + 96
71 lqa $7, regs_spill + 112
72 lqa $8, regs_spill + 128
73 lqa $9, regs_spill + 144
74 lqa $10, regs_spill + 160
75 lqa $11, regs_spill + 176
76 lqa $12, regs_spill + 192
77 lqa $13, regs_spill + 208
78 lqa $14, regs_spill + 224
79 lqa $15, regs_spill + 240
81 /* Under normal circumstances, the 'exit' function
82 * terminates with 'stop SPU_RESTORE_COMPLETE',
83 * indicating that the SPU-side restore code has
86 * However it is possible that instructions immediately
87 * following the 'stop 0x3ffc' have been modified at run
88 * time so as to recreate the exact SPU_Status settings
89 * from the application, e.g. illegal instruciton, halt,
96 stop SPU_RESTORE_COMPLETE
101 /* Pad the size of this crt0.o to be multiple of 16 bytes. */