source: mainline/kernel/arch/ia64/src/asm.S@ 9c514be

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 9c514be was a35b458, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 8 years ago

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

  • Property mode set to 100644
File size: 4.6 KB
Line 
1/*
2 * Copyright (c) 2005 Jakub Jermar
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <abi/asmtool.h>
30#include <arch/register.h>
31
32.text
33
34/** Copy memory from/to userspace.
35 *
36 * This memcpy() has been taken from the assembler output of
37 * a plain C implementation of memcpy() modified to have the
38 * failover part.
39 *
40 * @param in0 Destination address.
41 * @param in1 Source address.
42 * @param in2 Number of byte to copy.
43 *
44 */
45FUNCTION_BEGIN(memcpy_from_uspace)
46FUNCTION_BEGIN(memcpy_to_uspace)
47 alloc loc0 = ar.pfs, 3, 1, 0, 0
48
49 adds r14 = 7, in1
50 mov r2 = ar.lc
51 mov r8 = in0 ;;
52 and r14 = -8, r14 ;;
53 cmp.ne p6, p7 = r14, in1
54 (p7) br.cond.dpnt 3f ;;
55
56 0:
57
58 cmp.ne p6, p7 = 0, in2
59 (p7) br.cond.dpnt 2f ;;
60 (p6) adds r14 = -1, in2
61 (p6) mov r16 = r0
62 (p6) mov r17 = r0 ;;
63 (p6) mov ar.lc = r14
64
65 1:
66
67 add r14 = r16, in1
68 add r15 = r16, in0
69 adds r17 = 1, r17 ;;
70 ld1 r14 = [r14]
71 mov r16 = r17 ;;
72 st1 [r15] = r14
73 br.cloop.sptk.few 1b ;;
74
75 2:
76
77 mov ar.lc = r2
78 mov ar.pfs = loc0
79 br.ret.sptk.many rp
80
81 3:
82
83 adds r14 = 7, in0 ;;
84 and r14 = -8, r14 ;;
85 cmp.eq p6, p7 = r14, in0
86 (p7) br.cond.dptk 0b
87 shr.u r18 = in2, 3 ;;
88 cmp.ne p6, p7 = 0, r18
89 (p7) br.cond.dpnt 5f ;;
90 (p6) adds r14 = -1, r18
91 (p6) mov r16 = r0
92 (p6) mov r17 = r0 ;;
93 (p6) mov ar.lc = r14
94
95 4:
96
97 shladd r14 = r16, 3, r0
98 adds r16 = 1, r17 ;;
99 add r15 = in1, r14
100 add r14 = in0, r14
101 mov r17 = r16 ;;
102 ld8 r15 = [r15] ;;
103 st8 [r14] = r15
104 br.cloop.sptk.few 4b
105
106 5:
107
108 and r15 = 7, in2
109 shladd r14 = r18, 3, r0
110 mov r16 = r0
111 mov r18 = r0 ;;
112 cmp.eq p6, p7 = 0, r15
113 add in0 = r14, in0
114 adds r15 = -1, r15
115 add r17 = r14, in1
116 (p6) br.cond.dpnt 2b ;;
117 mov ar.lc = r15
118
119 6:
120
121 add r14 = r16, r17
122 add r15 = r16, in0
123 adds r16 = 1, r18 ;;
124 ld1 r14 = [r14]
125 mov r18 = r16 ;;
126 st1 [r15] = r14
127 br.cloop.sptk.few 6b ;;
128 mov ar.lc = r2
129 mov ar.pfs = loc0
130 br.ret.sptk.many rp
131FUNCTION_END(memcpy_from_uspace)
132FUNCTION_END(memcpy_to_uspace)
133
134SYMBOL(memcpy_from_uspace_failover_address)
135SYMBOL(memcpy_to_uspace_failover_address)
136 /* Return 0 on failure */
137 mov r8 = r0
138 mov ar.pfs = loc0
139 br.ret.sptk.many rp
140
141FUNCTION_BEGIN(cpu_halt)
142 br cpu_halt
143FUNCTION_END(cpu_halt)
144
145/** Switch to userspace - low level code.
146 *
147 * @param in0 Userspace entry point address.
148 * @param in1 Userspace stack pointer address.
149 * @param in2 Userspace register stack pointer address.
150 * @param in3 Userspace address of thread uspace_arg_t structure.
151 * @param in4 Value to be stored in IPSR.
152 * @param in5 Value to be stored in RSC.
153 *
154 */
155FUNCTION_BEGIN(switch_to_userspace)
156 alloc loc0 = ar.pfs, 6, 3, 0, 0
157
158 /* Disable interruption collection and interrupts */
159 rsm (PSR_IC_MASK | PSR_I_MASK)
160 srlz.d ;;
161 srlz.i ;;
162
163 mov cr.ipsr = in4
164 mov cr.iip = in0
165 mov r12 = in1
166
167 xor r1 = r1, r1
168
169 /* r2 is defined to hold pcb_ptr - set it to 0 */
170 xor r2 = r2, r2
171
172 mov loc1 = cr.ifs
173 movl loc2 = PFM_MASK ;;
174 and loc1 = loc2, loc1 ;;
175 mov cr.ifs = loc1 ;; /* prevent decrementing BSP by rfi */
176
177 invala
178
179 mov loc1 = ar.rsc ;;
180 and loc1 = ~3, loc1 ;;
181 mov ar.rsc = loc1 ;; /* put RSE into enforced lazy mode */
182
183 flushrs ;;
184
185 mov ar.bspstore = in2 ;;
186 mov ar.rsc = in5 ;;
187
188 mov r8 = in3
189
190 rfi ;;
191FUNCTION_END(switch_to_userspace)
192
193FUNCTION_BEGIN(early_putchar)
194 br.ret.sptk.many b0
195FUNCTION_END(early_putchar)
Note: See TracBrowser for help on using the repository browser.