]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - arch/tile/kernel/entry.S
arch/tile: parameterize system PLs to support KVM port
[mirror_ubuntu-artful-kernel.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 <asm/processor.h>
19 #include <arch/abi.h>
20 #include <arch/spr_def.h>
21
22 #ifdef __tilegx__
23 #define bnzt bnezt
24 #endif
25
26 STD_ENTRY(current_text_addr)
27 { move r0, lr; jrp lr }
28 STD_ENDPROC(current_text_addr)
29
30 /*
31 * Implement execve(). The i386 code has a note that forking from kernel
32 * space results in no copy on write until the execve, so we should be
33 * careful not to write to the stack here.
34 */
35 STD_ENTRY(kernel_execve)
36 moveli TREG_SYSCALL_NR_NAME, __NR_execve
37 swint1
38 jrp lr
39 STD_ENDPROC(kernel_execve)
40
41 /* Delay a fixed number of cycles. */
42 STD_ENTRY(__delay)
43 { addi r0, r0, -1; bnzt r0, . }
44 jrp lr
45 STD_ENDPROC(__delay)
46
47 /*
48 * We don't run this function directly, but instead copy it to a page
49 * we map into every user process. See vdso_setup().
50 *
51 * Note that libc has a copy of this function that it uses to compare
52 * against the PC when a stack backtrace ends, so if this code is
53 * changed, the libc implementation(s) should also be updated.
54 */
55 .pushsection .data
56 ENTRY(__rt_sigreturn)
57 moveli TREG_SYSCALL_NR_NAME,__NR_rt_sigreturn
58 swint1
59 ENDPROC(__rt_sigreturn)
60 ENTRY(__rt_sigreturn_end)
61 .popsection
62
63 STD_ENTRY(dump_stack)
64 { move r2, lr; lnk r1 }
65 { move r4, r52; addli r1, r1, dump_stack - . }
66 { move r3, sp; j _dump_stack }
67 jrp lr /* keep backtracer happy */
68 STD_ENDPROC(dump_stack)
69
70 STD_ENTRY(KBacktraceIterator_init_current)
71 { move r2, lr; lnk r1 }
72 { move r4, r52; addli r1, r1, KBacktraceIterator_init_current - . }
73 { move r3, sp; j _KBacktraceIterator_init_current }
74 jrp lr /* keep backtracer happy */
75 STD_ENDPROC(KBacktraceIterator_init_current)
76
77 /*
78 * Reset our stack to r1/r2 (sp and ksp0+cpu respectively), then
79 * free the old stack (passed in r0) and re-invoke cpu_idle().
80 * We update sp and ksp0 simultaneously to avoid backtracer warnings.
81 */
82 STD_ENTRY(cpu_idle_on_new_stack)
83 {
84 move sp, r1
85 mtspr SPR_SYSTEM_SAVE_K_0, r2
86 }
87 jal free_thread_info
88 j cpu_idle
89 STD_ENDPROC(cpu_idle_on_new_stack)
90
91 /* Loop forever on a nap during SMP boot. */
92 STD_ENTRY(smp_nap)
93 nap
94 j smp_nap /* we are not architecturally guaranteed not to exit nap */
95 jrp lr /* clue in the backtracer */
96 STD_ENDPROC(smp_nap)
97
98 /*
99 * Enable interrupts racelessly and then nap until interrupted.
100 * This function's _cpu_idle_nap address is special; see intvec.S.
101 * When interrupted at _cpu_idle_nap, we bump the PC forward 8, and
102 * as a result return to the function that called _cpu_idle().
103 */
104 STD_ENTRY(_cpu_idle)
105 {
106 lnk r0
107 movei r1, KERNEL_PL
108 }
109 {
110 addli r0, r0, _cpu_idle_nap - .
111 mtspr INTERRUPT_CRITICAL_SECTION, r1
112 }
113 IRQ_ENABLE(r2, r3) /* unmask, but still with ICS set */
114 mtspr SPR_EX_CONTEXT_K_1, r1 /* Kernel PL, ICS clear */
115 mtspr SPR_EX_CONTEXT_K_0, r0
116 iret
117 .global _cpu_idle_nap
118 _cpu_idle_nap:
119 nap
120 jrp lr
121 STD_ENDPROC(_cpu_idle)