source: mainline/kernel/arch/ia64/src/asm.S@ 26aafe8

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 26aafe8 was cb4f078, checked in by Martin Decky <martin@…>, 14 years ago

unify kernel byte string implementations

  • Property mode set to 100644
File size: 4.6 KB
RevLine 
[54171e8]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 */
[9db5b66]28
[b994a60]29#include <arch/register.h>
30
[9db5b66]31.text
[54171e8]32.global memcpy_from_uspace
33.global memcpy_to_uspace
34.global memcpy_from_uspace_failover_address
35.global memcpy_to_uspace_failover_address
[9db5b66]36
[e3c762cd]37/** Copy memory from/to userspace.
[ffdfcf0]38 *
39 * This memcpy() has been taken from the assembler output of
[cb4f078]40 * a plain C implementation of memcpy() modified to have the
41 * failover part.
[e3c762cd]42 *
43 * @param in0 Destination address.
44 * @param in1 Source address.
45 * @param in2 Number of byte to copy.
[54171e8]46 *
[e3c762cd]47 */
48memcpy_from_uspace:
49memcpy_to_uspace:
[ffdfcf0]50 alloc loc0 = ar.pfs, 3, 1, 0, 0
[54171e8]51
[e269c53]52 adds r14 = 7, in1
53 mov r2 = ar.lc
[c640876]54 mov r8 = in0 ;;
[e269c53]55 and r14 = -8, r14 ;;
56 cmp.ne p6, p7 = r14, in1
[54171e8]57 (p7) br.cond.dpnt 3f ;;
[e3c762cd]58
[54171e8]59 0:
60
61 cmp.ne p6, p7 = 0, in2
62 (p7) br.cond.dpnt 2f ;;
63 (p6) adds r14 = -1, in2
64 (p6) mov r16 = r0
65 (p6) mov r17 = r0 ;;
66 (p6) mov ar.lc = r14
67
68 1:
69
70 add r14 = r16, in1
71 add r15 = r16, in0
72 adds r17 = 1, r17 ;;
73 ld1 r14 = [r14]
74 mov r16 = r17 ;;
75 st1 [r15] = r14
76 br.cloop.sptk.few 1b ;;
77
78 2:
79
80 mov ar.lc = r2
81 mov ar.pfs = loc0
82 br.ret.sptk.many rp
83
84 3:
85
86 adds r14 = 7, in0 ;;
87 and r14 = -8, r14 ;;
88 cmp.eq p6, p7 = r14, in0
89 (p7) br.cond.dptk 0b
90 shr.u r18 = in2, 3 ;;
91 cmp.ne p6, p7 = 0, r18
92 (p7) br.cond.dpnt 5f ;;
93 (p6) adds r14 = -1, r18
94 (p6) mov r16 = r0
95 (p6) mov r17 = r0 ;;
96 (p6) mov ar.lc = r14
97
98 4:
99
100 shladd r14 = r16, 3, r0
101 adds r16 = 1, r17 ;;
102 add r15 = in1, r14
103 add r14 = in0, r14
104 mov r17 = r16 ;;
105 ld8 r15 = [r15] ;;
106 st8 [r14] = r15
107 br.cloop.sptk.few 4b
108
109 5:
110
111 and r15 = 7, in2
112 shladd r14 = r18, 3, r0
113 mov r16 = r0
114 mov r18 = r0 ;;
115 cmp.eq p6, p7 = 0, r15
116 add in0 = r14, in0
117 adds r15 = -1, r15
118 add r17 = r14, in1
119 (p6) br.cond.dpnt 2b ;;
120 mov ar.lc = r15
121
122 6:
123
124 add r14 = r16, r17
125 add r15 = r16, in0
126 adds r16 = 1, r18 ;;
127 ld1 r14 = [r14]
128 mov r18 = r16 ;;
129 st1 [r15] = r14
130 br.cloop.sptk.few 6b ;;
131 mov ar.lc = r2
132 mov ar.pfs = loc0
133 br.ret.sptk.many rp
134
[e3c762cd]135memcpy_from_uspace_failover_address:
136memcpy_to_uspace_failover_address:
[54171e8]137 /* Return 0 on failure */
138 mov r8 = r0
[ffdfcf0]139 mov ar.pfs = loc0
140 br.ret.sptk.many rp
[2b50d7c]141
142.global cpu_halt
143cpu_halt:
144 br cpu_halt
[b994a60]145
146/** Switch to userspace - low level code.
147 *
148 * @param in0 Userspace entry point address.
149 * @param in1 Userspace stack pointer address.
150 * @param in2 Userspace register stack pointer address.
[0f250f9]151 * @param in3 Userspace address of thread uspace_arg_t structure.
152 * @param in4 Value to be stored in IPSR.
153 * @param in5 Value to be stored in RSC.
[54171e8]154 *
[b994a60]155 */
156.global switch_to_userspace
157switch_to_userspace:
[0f250f9]158 alloc loc0 = ar.pfs, 6, 3, 0, 0
[54171e8]159
160 /* Disable interruption collection and interrupts */
161 rsm (PSR_IC_MASK | PSR_I_MASK)
[b994a60]162 srlz.d ;;
163 srlz.i ;;
164
[0f250f9]165 mov cr.ipsr = in4
[b994a60]166 mov cr.iip = in0
167 mov r12 = in1
[54171e8]168
[b994a60]169 xor r1 = r1, r1
170
[c98e6ee]171 /* r2 is defined to hold pcb_ptr - set it to 0 */
172 xor r2 = r2, r2
173
[b994a60]174 mov loc1 = cr.ifs
175 movl loc2 = PFM_MASK ;;
176 and loc1 = loc2, loc1 ;;
[54171e8]177 mov cr.ifs = loc1 ;; /* prevent decrementing BSP by rfi */
178
[b994a60]179 invala
180
181 mov loc1 = ar.rsc ;;
[54171e8]182 and loc1 = ~3, loc1 ;;
183 mov ar.rsc = loc1 ;; /* put RSE into enforced lazy mode */
184
[b994a60]185 flushrs ;;
186
187 mov ar.bspstore = in2 ;;
[0f250f9]188 mov ar.rsc = in5 ;;
189
190 mov r8 = in3
[b994a60]191
192 rfi ;;
[da52547]193
194.global early_putchar
195early_putchar:
196 br.ret.sptk.many b0
Note: See TracBrowser for help on using the repository browser.