]> git.karo-electronics.de Git - mv-sheeva.git/blob - arch/tile/kernel/entry.S
arch/tile: add Tilera's <arch/sim.h> header as an open-source header
[mv-sheeva.git] / arch / tile / kernel / entry.S
1 /*
2  * Copyright 2010 Tilera Corporation. All Rights Reserved.
3  *
4  *   This program is free software; you can redistribute it and/or
5  *   modify it under the terms of the GNU General Public License
6  *   as published by the Free Software Foundation, version 2.
7  *
8  *   This program is distributed in the hope that it will be useful, but
9  *   WITHOUT ANY WARRANTY; without even the implied warranty of
10  *   MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11  *   NON INFRINGEMENT.  See the GNU General Public License for
12  *   more details.
13  */
14
15 #include <linux/linkage.h>
16 #include <linux/unistd.h>
17 #include <asm/irqflags.h>
18 #include <arch/abi.h>
19
20 #ifdef __tilegx__
21 #define bnzt bnezt
22 #endif
23
24 STD_ENTRY(current_text_addr)
25         { move r0, lr; jrp lr }
26         STD_ENDPROC(current_text_addr)
27
28 /*
29  * Implement execve().  The i386 code has a note that forking from kernel
30  * space results in no copy on write until the execve, so we should be
31  * careful not to write to the stack here.
32  */
33 STD_ENTRY(kernel_execve)
34         moveli TREG_SYSCALL_NR_NAME, __NR_execve
35         swint1
36         jrp lr
37         STD_ENDPROC(kernel_execve)
38
39 /* Delay a fixed number of cycles. */
40 STD_ENTRY(__delay)
41         { addi r0, r0, -1; bnzt r0, . }
42         jrp lr
43         STD_ENDPROC(__delay)
44
45 /*
46  * We don't run this function directly, but instead copy it to a page
47  * we map into every user process.  See vdso_setup().
48  *
49  * Note that libc has a copy of this function that it uses to compare
50  * against the PC when a stack backtrace ends, so if this code is
51  * changed, the libc implementation(s) should also be updated.
52  */
53         .pushsection .data
54 ENTRY(__rt_sigreturn)
55         moveli TREG_SYSCALL_NR_NAME,__NR_rt_sigreturn
56         swint1
57         ENDPROC(__rt_sigreturn)
58         ENTRY(__rt_sigreturn_end)
59         .popsection
60
61 STD_ENTRY(dump_stack)
62         { move r2, lr; lnk r1 }
63         { move r4, r52; addli r1, r1, dump_stack - . }
64         { move r3, sp; j _dump_stack }
65         jrp lr   /* keep backtracer happy */
66         STD_ENDPROC(dump_stack)
67
68 STD_ENTRY(KBacktraceIterator_init_current)
69         { move r2, lr; lnk r1 }
70         { move r4, r52; addli r1, r1, KBacktraceIterator_init_current - . }
71         { move r3, sp; j _KBacktraceIterator_init_current }
72         jrp lr   /* keep backtracer happy */
73         STD_ENDPROC(KBacktraceIterator_init_current)
74
75 /*
76  * Reset our stack to r1/r2 (sp and ksp0+cpu respectively), then
77  * free the old stack (passed in r0) and re-invoke cpu_idle().
78  * We update sp and ksp0 simultaneously to avoid backtracer warnings.
79  */
80 STD_ENTRY(cpu_idle_on_new_stack)
81         {
82          move sp, r1
83          mtspr SYSTEM_SAVE_1_0, r2
84         }
85         jal free_thread_info
86         j cpu_idle
87         STD_ENDPROC(cpu_idle_on_new_stack)
88
89 /* Loop forever on a nap during SMP boot. */
90 STD_ENTRY(smp_nap)
91         nap
92         j smp_nap /* we are not architecturally guaranteed not to exit nap */
93         jrp lr    /* clue in the backtracer */
94         STD_ENDPROC(smp_nap)
95
96 /*
97  * Enable interrupts racelessly and then nap until interrupted.
98  * This function's _cpu_idle_nap address is special; see intvec.S.
99  * When interrupted at _cpu_idle_nap, we bump the PC forward 8, and
100  * as a result return to the function that called _cpu_idle().
101  */
102 STD_ENTRY(_cpu_idle)
103         {
104          lnk r0
105          movei r1, 1
106         }
107         {
108          addli r0, r0, _cpu_idle_nap - .
109          mtspr INTERRUPT_CRITICAL_SECTION, r1
110         }
111         IRQ_ENABLE(r2, r3)         /* unmask, but still with ICS set */
112         mtspr EX_CONTEXT_1_1, r1   /* PL1, ICS clear */
113         mtspr EX_CONTEXT_1_0, r0
114         iret
115         .global _cpu_idle_nap
116 _cpu_idle_nap:
117         nap
118         jrp lr
119         STD_ENDPROC(_cpu_idle)