source: mainline/uspace/lib/c/arch/sparc32/src/fibril.S@ 32573ff

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 32573ff was 38ad239, checked in by Jakub Jermar <jakub@…>, 10 years ago

sparc32: use asmtool.h macros for defining symbols

  • Property mode set to 100644
File size: 2.4 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 <libarch/context_offset.h>
31
32.text
33
34FUNCTION_BEGIN(context_save)
35 #
36 # We rely on the kernel to flush our active register windows to memory
37 # should a thread switch occur.
38 #
39
40 mov 7, %g1
41 1:
42 subcc %g1, 1, %g1
43 bg 1b
44 save %sp, -64, %sp
45
46 mov 7, %g1
47 1:
48 subcc %g1, 1, %g1
49 bg 1b
50 restore
51
52 CONTEXT_SAVE_ARCH_CORE %o0
53 retl
54 mov 1, %o0 ! context_save_arch returns 1
55FUNCTION_END(context_save)
56
57FUNCTION_BEGIN(context_restore)
58 #
59 # Flush all active windows.
60 # This is essential, because CONTEXT_RESTORE_ARCH_CORE overwrites %sp of
61 # CWP - 1 with the value written to %fp of CWP. Flushing all active
62 # windows mitigates this problem as CWP - 1 becomes the overlap window.
63 #
64
65 ## XXX
66 ## flushw
67 ## ta 0x4f
68 ## nop
69 mov 7, %g1
70 1:
71 subcc %g1, 1, %g1
72 bg 1b
73 save %sp, -64, %sp
74
75 mov 7, %g1
76 1:
77 subcc %g1, 1, %g1
78 bg 1b
79 restore
80
81 CONTEXT_RESTORE_ARCH_CORE %o0
82 retl
83 xor %o0, %o0, %o0 ! context_restore_arch returns 0
84FUNCTION_END(context_restore)
Note: See TracBrowser for help on using the repository browser.