solaris_sparc.s revision 1472:c18cbe5936b8
1239671Srwatson!!
2239671Srwatson!! Copyright (c) 2005, 2008 Oracle and/or its affiliates. All rights reserved.
3264897Sbrooks!! DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4239671Srwatson!!
5239671Srwatson!! This code is free software; you can redistribute it and/or modify it
6244899Srwatson!! under the terms of the GNU General Public License version 2 only, as
7244899Srwatson!! published by the Free Software Foundation.
8244899Srwatson!!
9244899Srwatson!! This code is distributed in the hope that it will be useful, but WITHOUT
10239671Srwatson!! ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11239671Srwatson!! FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12239671Srwatson!! version 2 for more details (a copy is included in the LICENSE file that
13239671Srwatson!! accompanied this code).
14239671Srwatson!!
15239671Srwatson!! You should have received a copy of the GNU General Public License version
16239671Srwatson!! 2 along with this work; if not, write to the Free Software Foundation,
17239671Srwatson!! Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18239671Srwatson!!
19239671Srwatson!! Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20239671Srwatson!! or visit www.oracle.com if you need additional information or have any
21239671Srwatson!! questions.
22239671Srwatson!!
23239671Srwatson
24239671Srwatson    !! Prototype: int SafeFetch32 (int * adr, int ErrValue)
25239671Srwatson    !! The "ld" at Fetch32 is potentially faulting instruction.
26239671Srwatson    !! If the instruction traps the trap handler will arrange
27239671Srwatson    !! for control to resume at Fetch32Resume.
28239671Srwatson    !! By convention with the trap handler we ensure there is a non-CTI
29239671Srwatson    !! instruction in the trap shadow.
30239671Srwatson    !!
31239671Srwatson    !! The reader might be tempted to move this service to .il.
32239671Srwatson    !! Don't.  Sun's CC back-end reads and optimize code emitted
33239671Srwatson    !! by the .il "call", in some cases optimizing the code, completely eliding it,
34239671Srwatson    !! or by moving the code from the "call site".
35244899Srwatson
36239671Srwatson     !! ASM better know we may use G6 for our own purposes
37239671Srwatson    .register %g6, #ignore
38239671Srwatson
39239671Srwatson    .globl  SafeFetch32
40239671Srwatson    .align  32
41239671Srwatson    .global Fetch32PFI, Fetch32Resume
42239671SrwatsonSafeFetch32:
43239671Srwatson    mov     %o0, %g1
44239671Srwatson    mov     %o1, %o0
45239671SrwatsonFetch32PFI:
46239671Srwatson    ld      [%g1], %o0          !! <-- Potentially faulting instruction
47239671SrwatsonFetch32Resume:
48245330Srwatson    nop
49239671Srwatson    retl
50239671Srwatson    nop
51239671Srwatson
52239671Srwatson    .globl  SafeFetchN
53239671Srwatson    .align  32
54239671Srwatson    .globl  FetchNPFI, FetchNResume
55239671SrwatsonSafeFetchN:
56239671Srwatson    mov     %o0, %g1
57239671Srwatson    mov     %o1, %o0
58239671SrwatsonFetchNPFI:
59244942Srwatson    ldn     [%g1], %o0
60244899SrwatsonFetchNResume:
61244899Srwatson    nop
62244942Srwatson    retl
63244899Srwatson    nop
64239671Srwatson
65239671Srwatson    !! Possibilities:
66239671Srwatson    !! -- membar
67239671Srwatson    !! -- CAS (SP + BIAS, G0, G0)
68264897Sbrooks    !! -- wr %g0, %asi
69239671Srwatson
70239671Srwatson    .global SpinPause
71239671Srwatson    .align  32
72239671SrwatsonSpinPause:
73239671Srwatson    retl
74245330Srwatson    mov %g0, %o0
75239671Srwatson
76239671Srwatson
77239671Srwatson
78239671Srwatson    .globl _Copy_conjoint_jlongs_atomic
79239671Srwatson    .align 32
80239671Srwatson    .global   _Copy_conjoint_jlongs_atomic
81239671Srwatson _Copy_conjoint_jlongs_atomic:
82239671Srwatson         cmp     %o0, %o1
83239671Srwatson         bleu    4f
84239671Srwatson         sll     %o2, 3, %o4
85239671Srwatson         ba      2f
86239671Srwatson    1:
87239671Srwatson         subcc   %o4, 8, %o4
88239671Srwatson         std     %o2, [%o1]
89239671Srwatson         add     %o0, 8, %o0
90239671Srwatson         add     %o1, 8, %o1
91239671Srwatson    2:
92239671Srwatson         bge,a   1b
93239671Srwatson         ldd     [%o0], %o2
94239671Srwatson         ba      5f
95239671Srwatson         nop
96239671Srwatson    3:
97239671Srwatson         std     %o2, [%o1+%o4]
98239671Srwatson    4:
99239671Srwatson         subcc   %o4, 8, %o4
100239671Srwatson         bge,a   3b
101239671Srwatson         ldd     [%o0+%o4], %o2
102239671Srwatson    5:
103239671Srwatson         retl
104239671Srwatson         nop
105239671Srwatson
106239671Srwatson
107239671Srwatson
108239671Srwatson    .globl _raw_thread_id
109239671Srwatson    .align 32
110239671Srwatson _raw_thread_id:
111239671Srwatson    .register %g7, #scratch
112239671Srwatson        retl
113239671Srwatson        mov     %g7, %o0
114239671Srwatson
115239671Srwatson
116239671Srwatson    .globl _flush_reg_windows
117239671Srwatson    .align 32
118239671Srwatson _flush_reg_windows:
119239671Srwatson        ta 0x03
120239671Srwatson        retl
121239671Srwatson        mov     %fp, %o0
122239671Srwatson
123239671Srwatson
124239671Srwatson