linux_sparc.s revision 1472:c18cbe5936b8
1155131Srwatson#
2155131Srwatson# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
3155131Srwatson# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4155131Srwatson#
5155131Srwatson# This code is free software; you can redistribute it and/or modify it
6155131Srwatson# under the terms of the GNU General Public License version 2 only, as
7155131Srwatson# published by the Free Software Foundation.
8155131Srwatson#
9155131Srwatson# This code is distributed in the hope that it will be useful, but WITHOUT
10155131Srwatson# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11155131Srwatson# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12155131Srwatson# version 2 for more details (a copy is included in the LICENSE file that
13155131Srwatson# accompanied this code).
14155131Srwatson#
15155131Srwatson# You should have received a copy of the GNU General Public License version
16155131Srwatson# 2 along with this work; if not, write to the Free Software Foundation,
17155131Srwatson# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18155131Srwatson#
19155131Srwatson# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20155131Srwatson# or visit www.oracle.com if you need additional information or have any
21155131Srwatson# questions.
22155131Srwatson#
23155131Srwatson
24155131Srwatson    # Prototype: int SafeFetch32 (int * adr, int ErrValue)
25155131Srwatson    # The "ld" at Fetch32 is potentially faulting instruction.
26155131Srwatson    # If the instruction traps the trap handler will arrange
27155131Srwatson    # for control to resume at Fetch32Resume.
28155131Srwatson    # By convention with the trap handler we ensure there is a non-CTI
29155131Srwatson    # instruction in the trap shadow.
30155131Srwatson
31155131Srwatson
32155131Srwatson    .globl  SafeFetch32, Fetch32PFI, Fetch32Resume
33155131Srwatson    .globl  SafeFetchN
34155131Srwatson    .align  32
35155131Srwatson    .type    SafeFetch32,@function
36155131SrwatsonSafeFetch32:
37155131Srwatson    mov     %o0, %g1
38155131Srwatson    mov     %o1, %o0
39155131SrwatsonFetch32PFI:
40155131Srwatson    # <-- Potentially faulting instruction
41155131Srwatson    ld      [%g1], %o0
42155131SrwatsonFetch32Resume:
43155131Srwatson    nop
44155131Srwatson    retl
45155131Srwatson    nop
46155131Srwatson
47155131Srwatson    .globl  SafeFetchN, FetchNPFI, FetchNResume
48155131Srwatson    .type    SafeFetchN,@function
49155131Srwatson    .align  32
50155131SrwatsonSafeFetchN:
51155131Srwatson    mov     %o0, %g1
52155131Srwatson    mov     %o1, %o0
53155131SrwatsonFetchNPFI:
54155131Srwatson    ldn     [%g1], %o0
55155131SrwatsonFetchNResume:
56155131Srwatson    nop
57155131Srwatson    retl
58155131Srwatson    nop
59155131Srwatson
60155131Srwatson    # Possibilities:
61155131Srwatson    # -- membar
62155131Srwatson    # -- CAS (SP + BIAS, G0, G0)
63155131Srwatson    # -- wr %g0, %asi
64155131Srwatson
65155131Srwatson    .globl SpinPause
66155131Srwatson    .type   SpinPause,@function
67155131Srwatson    .align  32
68SpinPause:
69    retl
70    mov %g0, %o0
71
72   .globl _Copy_conjoint_jlongs_atomic
73   .type   _Copy_conjoint_jlongs_atomic,@function
74_Copy_conjoint_jlongs_atomic:
75        cmp     %o0, %o1
76	bleu    4f
77	sll     %o2, 3, %o4
78        ba      2f
79   1:
80	subcc   %o4, 8, %o4
81	std     %o2, [%o1]
82	add     %o0, 8, %o0
83	add     %o1, 8, %o1
84   2:
85	bge,a   1b
86	ldd     [%o0], %o2
87	ba      5f
88        nop
89   3:
90	std     %o2, [%o1+%o4]
91   4:
92	subcc   %o4, 8, %o4
93	bge,a   3b
94	ldd     [%o0+%o4], %o2
95   5:
96	retl
97	nop
98
99
100    .globl _flush_reg_windows
101    .align 32
102 _flush_reg_windows:
103        ta 0x03
104        retl
105        mov     %fp, %o0
106