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

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

add early_putchar() which can be used to do early kernel console output for debugging purposes
(the availability of this feature depends on each platform and specific configuration, currently it works only on ia32/amd64 with EGA and no framebuffer)
instrument more kernel functions
mark some functions as no_instrument (context_restore(), overlaps(), main_bsp())

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