Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / diag / assembly / include / syscall_handler.s
CommitLineData
86530b38
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: syscall_handler.s
5* Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
6* 4150 Network Circle, Santa Clara, California 95054, U.S.A.
7*
8* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9*
10* This program is free software; you can redistribute it and/or modify
11* it under the terms of the GNU General Public License as published by
12* the Free Software Foundation; version 2 of the License.
13*
14* This program is distributed in the hope that it will be useful,
15* but WITHOUT ANY WARRANTY; without even the implied warranty of
16* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17* GNU General Public License for more details.
18*
19* You should have received a copy of the GNU General Public License
20* along with this program; if not, write to the Free Software
21* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22*
23* For the avoidance of doubt, and except that if any non-GPL license
24* choice is available it will apply instead, Sun elects to use only
25* the General Public License version 2 (GPLv2) at this time for any
26* software where a choice of GPL license versions is made
27* available with the language indicating that GPLv2 or any later version
28* may be used, or where a choice of which version of the GPL is applied is
29* otherwise unspecified.
30*
31* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
32* CA 95054 USA or visit www.sun.com if you need additional information or
33* have any questions.
34*
35*
36* ========== Copyright Header End ============================================
37*/
38syscall_handler:
39 ! get tpc/tnpc/tstate and save them
40 rdpr %tpc, %g1
41 rdpr %tnpc, %g2
42 rdpr %tstate, %g3
43 stx %g1, [%g4] ! save tpc
44 stx %g2, [%g4+8] ! save tnpc
45 stx %g3, [%g4+16] ! save tstate
46 setx kernel_syscall, %g1, %g2
47 wrpr %g2, %g0, %tnpc
48 sllx %g3, 59, %g3 ! extract cwp from tstate
49 srlx %g3, 59, %g3
50 setx cregs_tstate_r64, %g1, %g2
51 srlx %g2, 5, %g2 ! remove cwp from cregs_tstate_r64
52 sllx %g2, 5, %g2
53 or %g3, %g2, %g3
54 wrpr %g3, %g0, %tstate
55
56 ! get primary/secondary context and save them
57 mov 0x8, %g1
58 ldxa [%g1] 0x21, %g2
59 stx %g2, [%g4+24] ! save p context
60 stxa %g0, [%g1] 0x21 ! set p context to zero
61
62 mov 0x10, %g1
63 ldxa [%g1] 0x21, %g3
64 stx %g3, [%g4+32] ! save s context
65 stxa %g0, [%g1] 0x21 ! set s context to zero
66
67 ! go to kernel
68 done
69 nop
70
71
72sysret_handler:
73 ! restore tpc/tnpc/tstate
74 ldx [%g4], %g1 ! get tpc
75 ldx [%g4+8], %g2 ! get tnpc
76 ldx [%g4+16], %g3 ! get tstate
77 wrpr %g1, %g0, %tpc
78 wrpr %g2, %g0, %tnpc
79 wrpr %g3, %g0, %tstate
80
81 ! restore primary/secondary context
82 mov 0x8, %g1
83 ldx [%g4+24], %g2 ! get p context
84 stxa %g2, [%g1] 0x21
85
86 mov 0x10, %g1
87 ldx [%g4+32], %g3 ! get s context
88 stxa %g3, [%g1] 0x21
89
90 ! return to user
91 done
92 nop
93