Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * crt0_s.S: Entry function for SPU-side context save.
0004  *
0005  * Copyright (C) 2005 IBM
0006  *
0007  * Entry function for SPU-side of the context save sequence.
0008  * Saves all 128 GPRs, sets up an initial stack frame, then
0009  * branches to 'main'.
0010  */
0011 
0012 #include <asm/spu_csa.h>
0013 
0014 .data
0015 .align 7
0016 .globl regs_spill
0017 regs_spill:
0018 .space SIZEOF_SPU_SPILL_REGS, 0x0
0019 
0020 .text
0021 .global _start
0022 _start:
0023     /* SPU Context Save Step 1: Save the first 16 GPRs. */
0024     stqa $0, regs_spill + 0
0025     stqa $1, regs_spill + 16
0026     stqa $2, regs_spill + 32
0027     stqa $3, regs_spill + 48
0028     stqa $4, regs_spill + 64
0029     stqa $5, regs_spill + 80
0030     stqa $6, regs_spill + 96
0031     stqa $7, regs_spill + 112
0032     stqa $8, regs_spill + 128
0033     stqa $9, regs_spill + 144
0034     stqa $10, regs_spill + 160
0035     stqa $11, regs_spill + 176
0036     stqa $12, regs_spill + 192
0037     stqa $13, regs_spill + 208
0038     stqa $14, regs_spill + 224
0039     stqa $15, regs_spill + 240
0040 
0041     /* SPU Context Save, Step 8: Save the remaining 112 GPRs. */
0042     ila     $3, regs_spill + 256
0043 save_regs:
0044     lqr     $4, save_reg_insts
0045 save_reg_loop:
0046     ai      $4, $4, 4
0047     .balignl 16, 0x40200000
0048 save_reg_insts:       /* must be quad-word aligned. */
0049     stqd    $16, 0($3)
0050     stqd    $17, 16($3)
0051     stqd    $18, 32($3)
0052     stqd    $19, 48($3)
0053     andi    $5, $4, 0x7F
0054     stqr    $4, save_reg_insts
0055     ai      $3, $3, 64
0056     brnz    $5, save_reg_loop
0057 
0058     /* Initialize the stack pointer to point to 16368
0059      * (16kb-16). The back chain pointer is initialized
0060      * to NULL.
0061      */
0062     il  $0, 0
0063     il  $SP, 16368
0064     stqd    $0, 0($SP)
0065 
0066     /* Allocate a minimum stack frame for the called main.
0067      * This is needed so that main has a place to save the
0068      * link register when it calls another function.
0069      */
0070     stqd    $SP, -160($SP)
0071     ai  $SP, $SP, -160
0072 
0073     /* Call the program's main function. */
0074     brsl    $0, main
0075 
0076     /* In this case main should not return; if it does
0077      * there has been an error in the sequence.  Execute
0078      * stop-and-signal with code=0.
0079      */
0080 .global exit
0081 .global _exit
0082 exit:
0083 _exit:
0084     stop    0x0
0085 
0086     /* Pad the size of this crt0.o to be multiple of 16 bytes. */
0087 .balignl 16, 0x0
0088