source: mainline/kernel/arch/sparc64/src/sun4u/asm.S@ 2cf8f994

Last change on this file since 2cf8f994 was a35b458, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 8 years ago

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

  • Property mode set to 100644
File size: 3.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 <abi/asmtool.h>
30#include <arch/arch.h>
31#include <arch/stack.h>
32#include <arch/regdef.h>
33#include <arch/mm/mmu.h>
34
35.text
36
37.register %g2, #scratch
38.register %g3, #scratch
39
40.macro WRITE_ALTERNATE_REGISTER reg, bit
41 rdpr %pstate, %g1 ! save PSTATE.PEF
42 wrpr %g0, (\bit | PSTATE_PRIV_BIT), %pstate
43 mov %o0, \reg
44 wrpr %g0, PSTATE_PRIV_BIT, %pstate
45 retl
46 wrpr %g1, 0, %pstate ! restore PSTATE.PEF
47.endm
48
49.macro READ_ALTERNATE_REGISTER reg, bit
50 rdpr %pstate, %g1 ! save PSTATE.PEF
51 wrpr %g0, (\bit | PSTATE_PRIV_BIT), %pstate
52 mov \reg, %o0
53 wrpr %g0, PSTATE_PRIV_BIT, %pstate
54 retl
55 wrpr %g1, 0, %pstate ! restore PSTATE.PEF
56.endm
57
58FUNCTION_BEGIN(write_to_ag_g6)
59 WRITE_ALTERNATE_REGISTER %g6, PSTATE_AG_BIT
60FUNCTION_END(write_to_ag_g6)
61
62FUNCTION_BEGIN(write_to_ag_g7)
63 WRITE_ALTERNATE_REGISTER %g7, PSTATE_AG_BIT
64FUNCTION_END(write_to_ag_g7)
65
66FUNCTION_BEGIN(write_to_ig_g6)
67 WRITE_ALTERNATE_REGISTER %g6, PSTATE_IG_BIT
68FUNCTION_END(write_to_ig_g6)
69
70FUNCTION_BEGIN(read_from_ag_g6)
71 READ_ALTERNATE_REGISTER %g6, PSTATE_AG_BIT
72FUNCTION_END(read_from_ag_g6)
73
74FUNCTION_BEGIN(read_from_ag_g7)
75 READ_ALTERNATE_REGISTER %g7, PSTATE_AG_BIT
76FUNCTION_END(read_from_ag_g7)
77
78/** Switch to userspace.
79 *
80 * %o0 Userspace entry address.
81 * %o1 Userspace stack pointer address.
82 * %o2 Userspace address of uarg structure.
83 */
84FUNCTION_BEGIN(switch_to_userspace)
85 save %o1, -(STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE), %sp
86 flushw
87 wrpr %g0, 0, %cleanwin ! avoid information leak
88
89 mov %i2, %o0 ! uarg
90 xor %o1, %o1, %o1 ! %o1 is defined to hold pcb_ptr
91 ! set it to 0
92
93 clr %i2
94 clr %i3
95 clr %i4
96 clr %i5
97 clr %i6
98
99 wrpr %g0, 1, %tl ! enforce mapping via nucleus
100
101 rdpr %cwp, %g1
102 wrpr %g1, TSTATE_IE_BIT, %tstate
103 wrpr %i0, 0, %tnpc
104
105 /*
106 * Set primary context according to secondary context.
107 * Secondary context has been already installed by
108 * higher-level functions.
109 */
110 wr %g0, ASI_DMMU, %asi
111 ldxa [VA_SECONDARY_CONTEXT_REG] %asi, %g1
112 stxa %g1, [VA_PRIMARY_CONTEXT_REG] %asi
113 flush %i7
114
115 /*
116 * Spills and fills will be handled by the userspace handlers.
117 */
118 wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(1), %wstate
119
120 done ! jump to userspace
121FUNCTION_END(switch_to_userspace)
122
Note: See TracBrowser for help on using the repository browser.