1bc294838SSven Schnelle/* SPDX-License-Identifier: GPL-2.0-or-later */ 2bc294838SSven Schnelle 3bc294838SSven Schnelle/* TOC (Transfer of Control) handler. */ 4bc294838SSven Schnelle 5bc294838SSven Schnelle .level 1.1 6bc294838SSven Schnelle 7bc294838SSven Schnelle#include <asm/assembly.h> 8bc294838SSven Schnelle#include <linux/threads.h> 9bc294838SSven Schnelle#include <linux/linkage.h> 10bc294838SSven Schnelle 11bc294838SSven Schnelle .text 12bc294838SSven Schnelle .import toc_intr,code 13*d6ab9fc7SHelge Deller .import toc_stack,data 14bc294838SSven Schnelle .align 16 15bc294838SSven SchnelleENTRY_CFI(toc_handler) 16bc294838SSven Schnelle load32 PA(toc_stack),%sp 17*d6ab9fc7SHelge Deller 18*d6ab9fc7SHelge Deller#ifdef CONFIG_SMP 19*d6ab9fc7SHelge Deller /* get per-cpu toc_stack address. */ 20*d6ab9fc7SHelge Deller mfctl %cr30, %r1 21*d6ab9fc7SHelge Deller tophys %r1,%r2 /* task_struct */ 22*d6ab9fc7SHelge Deller LDREG TASK_TI_CPU(%r2),%r4 /* cpu */ 23*d6ab9fc7SHelge Deller load32 PA(__per_cpu_offset),%r1 24*d6ab9fc7SHelge Deller LDREGX %r4(%r1),%r4 25bc294838SSven Schnelle add %r4,%sp,%sp 26*d6ab9fc7SHelge Deller#endif 27bc294838SSven Schnelle 28bc294838SSven Schnelle /* 29bc294838SSven Schnelle * setup pt_regs on stack and save the 30bc294838SSven Schnelle * floating point registers. PIM_TOC doesn't 31bc294838SSven Schnelle * save fp registers, so we're doing it here. 32bc294838SSven Schnelle */ 33bc294838SSven Schnelle copy %sp,%arg0 34bc294838SSven Schnelle ldo PT_SZ_ALGN(%sp), %sp 35bc294838SSven Schnelle 36bc294838SSven Schnelle /* clear pt_regs */ 37bc294838SSven Schnelle copy %arg0,%r1 38bc294838SSven Schnelle0: cmpb,<<,n %r1,%sp,0b 39bc294838SSven Schnelle stw,ma %r0,4(%r1) 40bc294838SSven Schnelle 41bc294838SSven Schnelle ldo PT_FR0(%arg0),%r25 42bc294838SSven Schnelle save_fp %r25 43bc294838SSven Schnelle 44bc294838SSven Schnelle /* go virtual */ 45bc294838SSven Schnelle load32 PA(swapper_pg_dir),%r4 46bc294838SSven Schnelle mtctl %r4,%cr24 47bc294838SSven Schnelle mtctl %r4,%cr25 48bc294838SSven Schnelle 49bc294838SSven Schnelle /* Clear sr4-sr7 */ 50bc294838SSven Schnelle mtsp %r0, %sr4 51bc294838SSven Schnelle mtsp %r0, %sr5 52bc294838SSven Schnelle mtsp %r0, %sr6 53bc294838SSven Schnelle mtsp %r0, %sr7 54bc294838SSven Schnelle 55bc294838SSven Schnelle tovirt_r1 %sp 56bc294838SSven Schnelle tovirt_r1 %arg0 57bc294838SSven Schnelle virt_map 58bc294838SSven Schnelle 59bc294838SSven Schnelle loadgp 60bc294838SSven Schnelle 61bc294838SSven Schnelle#ifdef CONFIG_64BIT 62bc294838SSven Schnelle ldo -16(%sp),%r29 63bc294838SSven Schnelle#endif 64bc294838SSven Schnelle load32 toc_intr,%r1 65bc294838SSven Schnelle be 0(%sr7,%r1) 66bc294838SSven Schnelle nop 67bc294838SSven SchnelleENDPROC_CFI(toc_handler) 68bc294838SSven Schnelle 69bc294838SSven Schnelle /* 70bc294838SSven Schnelle * keep this checksum here, as it is part of the toc_handler 71bc294838SSven Schnelle * spanned by toc_handler_size (all words in toc_handler are 72bc294838SSven Schnelle * added in PDC and the sum must equal to zero. 73bc294838SSven Schnelle */ 74bc294838SSven SchnelleSYM_DATA(toc_handler_csum, .long 0) 75bc294838SSven SchnelleSYM_DATA(toc_handler_size, .long . - toc_handler) 76