/*1* Copyright 2010 Tilera Corporation. All Rights Reserved.2*3* This program is free software; you can redistribute it and/or4* modify it under the terms of the GNU General Public License5* as published by the Free Software Foundation, version 2.6*7* This program is distributed in the hope that it will be useful, but8* WITHOUT ANY WARRANTY; without even the implied warranty of9* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or10* NON INFRINGEMENT. See the GNU General Public License for11* more details.12*/1314#include <linux/linkage.h>15#include <linux/unistd.h>16#include <asm/irqflags.h>17#include <asm/processor.h>18#include <arch/abi.h>19#include <arch/spr_def.h>2021#ifdef __tilegx__22#define bnzt bnezt23#endif2425STD_ENTRY(current_text_addr)26{ move r0, lr; jrp lr }27STD_ENDPROC(current_text_addr)2829/*30* Implement execve(). The i386 code has a note that forking from kernel31* space results in no copy on write until the execve, so we should be32* careful not to write to the stack here.33*/34STD_ENTRY(kernel_execve)35moveli TREG_SYSCALL_NR_NAME, __NR_execve36swint137jrp lr38STD_ENDPROC(kernel_execve)3940/*41* We don't run this function directly, but instead copy it to a page42* we map into every user process. See vdso_setup().43*44* Note that libc has a copy of this function that it uses to compare45* against the PC when a stack backtrace ends, so if this code is46* changed, the libc implementation(s) should also be updated.47*/48.pushsection .data49ENTRY(__rt_sigreturn)50moveli TREG_SYSCALL_NR_NAME,__NR_rt_sigreturn51swint152ENDPROC(__rt_sigreturn)53ENTRY(__rt_sigreturn_end)54.popsection5556STD_ENTRY(dump_stack)57{ move r2, lr; lnk r1 }58{ move r4, r52; addli r1, r1, dump_stack - . }59{ move r3, sp; j _dump_stack }60jrp lr /* keep backtracer happy */61STD_ENDPROC(dump_stack)6263STD_ENTRY(KBacktraceIterator_init_current)64{ move r2, lr; lnk r1 }65{ move r4, r52; addli r1, r1, KBacktraceIterator_init_current - . }66{ move r3, sp; j _KBacktraceIterator_init_current }67jrp lr /* keep backtracer happy */68STD_ENDPROC(KBacktraceIterator_init_current)6970/*71* Reset our stack to r1/r2 (sp and ksp0+cpu respectively), then72* free the old stack (passed in r0) and re-invoke cpu_idle().73* We update sp and ksp0 simultaneously to avoid backtracer warnings.74*/75STD_ENTRY(cpu_idle_on_new_stack)76{77move sp, r178mtspr SPR_SYSTEM_SAVE_K_0, r279}80jal free_thread_info81j cpu_idle82STD_ENDPROC(cpu_idle_on_new_stack)8384/* Loop forever on a nap during SMP boot. */85STD_ENTRY(smp_nap)86nap87j smp_nap /* we are not architecturally guaranteed not to exit nap */88jrp lr /* clue in the backtracer */89STD_ENDPROC(smp_nap)9091/*92* Enable interrupts racelessly and then nap until interrupted.93* Architecturally, we are guaranteed that enabling interrupts via94* mtspr to INTERRUPT_CRITICAL_SECTION only interrupts at the next PC.95* This function's _cpu_idle_nap address is special; see intvec.S.96* When interrupted at _cpu_idle_nap, we bump the PC forward 8, and97* as a result return to the function that called _cpu_idle().98*/99STD_ENTRY(_cpu_idle)100movei r1, 1101mtspr INTERRUPT_CRITICAL_SECTION, r1102IRQ_ENABLE(r2, r3) /* unmask, but still with ICS set */103mtspr INTERRUPT_CRITICAL_SECTION, zero104.global _cpu_idle_nap105_cpu_idle_nap:106nap107jrp lr108STD_ENDPROC(_cpu_idle)109110111