1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * crt0_s.S: Entry function for SPU-side context save.
4 *
5 * Copyright (C) 2005 IBM
6 *
7 * Entry function for SPU-side of the context save sequence.
8 * Saves all 128 GPRs, sets up an initial stack frame, then
9 * branches to 'main'.
10 */
11
12#include <asm/spu_csa.h>
13
14.data
15.align 7
16.globl regs_spill
17regs_spill:
18.space SIZEOF_SPU_SPILL_REGS, 0x0
19
20.text
21.global _start
22_start:
23 /* SPU Context Save Step 1: Save the first 16 GPRs. */
24 stqa $0, regs_spill + 0
25 stqa $1, regs_spill + 16
26 stqa $2, regs_spill + 32
27 stqa $3, regs_spill + 48
28 stqa $4, regs_spill + 64
29 stqa $5, regs_spill + 80
30 stqa $6, regs_spill + 96
31 stqa $7, regs_spill + 112
32 stqa $8, regs_spill + 128
33 stqa $9, regs_spill + 144
34 stqa $10, regs_spill + 160
35 stqa $11, regs_spill + 176
36 stqa $12, regs_spill + 192
37 stqa $13, regs_spill + 208
38 stqa $14, regs_spill + 224
39 stqa $15, regs_spill + 240
40
41 /* SPU Context Save, Step 8: Save the remaining 112 GPRs. */
42 ila $3, regs_spill + 256
43save_regs:
44 lqr $4, save_reg_insts
45save_reg_loop:
46 ai $4, $4, 4
47 .balignl 16, 0x40200000
48save_reg_insts: /* must be quad-word aligned. */
49 stqd $16, 0($3)
50 stqd $17, 16($3)
51 stqd $18, 32($3)
52 stqd $19, 48($3)
53 andi $5, $4, 0x7F
54 stqr $4, save_reg_insts
55 ai $3, $3, 64
56 brnz $5, save_reg_loop
57
58 /* Initialize the stack pointer to point to 16368
59 * (16kb-16). The back chain pointer is initialized
60 * to NULL.
61 */
62 il $0, 0
63 il $SP, 16368
64 stqd $0, 0($SP)
65
66 /* Allocate a minimum stack frame for the called main.
67 * This is needed so that main has a place to save the
68 * link register when it calls another function.
69 */
70 stqd $SP, -160($SP)
71 ai $SP, $SP, -160
72
73 /* Call the program's main function. */
74 brsl $0, main
75
76 /* In this case main should not return; if it does
77 * there has been an error in the sequence. Execute
78 * stop-and-signal with code=0.
79 */
80.global exit
81.global _exit
82exit:
83_exit:
84 stop 0x0
85
86 /* Pad the size of this crt0.o to be multiple of 16 bytes. */
87.balignl 16, 0x0
88
89

source code of linux/arch/powerpc/platforms/cell/spufs/spu_save_crt0.S