source: rtems/c/src/lib/libcpu/sparc/syscall/syscall.S @ 4081032

4.115
Last change on this file since 4081032 was 8df1f408, checked in by Christian Mauderer <Christian.Mauderer@…>, on 06/02/14 at 14:31:51

score/sparc: Add support for paravirtualization

Guest systems in paravirtualization environments run usually in user
mode. Thus it is not possible to directly access the PSR and TBR
registers. Use functions instead of inline assembler to access these
registers if RTEMS_PARAVIRT is defined.

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 *  systrap.S
3 *
4 *  This file contains emulated system calls using software trap 0.
5 *  The following calls are supported:
6 *
7 *    + SYS_exit        (halt)
8 *    + SYS_irqdis      (disable interrupts)
9 *    + SYS_irqset      (set interrupt level)
10 *
11 *  COPYRIGHT:
12 *
13 *  COPYRIGHT (c) 1995. European Space Agency.
14 *
15 *  This terms of the RTEMS license apply to this file.
16 *
17 */
18
19#include <rtems/asm.h>
20#include "syscall.h"
21
22        .seg    "text"
23        /*
24         *  system call
25         *
26         *  On entry:
27         *
28         *    l0 = psr (from trap table)
29         *    l1 = pc
30         *    l2 = npc
31         *    g1 = system call id
32         *
33         *  System Call 1 (exit):
34         *    g2 = additional exit code 1
35         *    g3 = additional exit code 2
36         */
37
38.align 32                               ! Align to 32-byte cache-line
39        PUBLIC(syscall)
40
41SYM(syscall):
42
43        ! "subcc, %g1, 3, %g0" done in trap table
44        bne     2f                      ! syscall 3? enable interrupt
45         and    %i0, SPARC_PSR_PIL_MASK, %l4
46        andn    %l0, SPARC_PSR_PIL_MASK, %l5
47        wr      %l4, %l5, %psr          ! Update PSR according to syscall 3
481:                                      ! leave, with 3 inst PSR-write delay
49        mov     0, %g1                  ! clear %g1
50        or      %l0, SPARC_PSR_ET_MASK, %i0     ! return old psr with ET=1. No
51                                                ! effect on syscall 3
52        jmpl    %l2, %g0
53         rett   %l2 + 4
54
552:      or      %l0, 0x0f00, %l4        ! set PIL=15
56        subcc   %g1, 2, %g0             ! syscall 2? disable interrupts
57        beq,a   1b                      ! Annul delay-slot for syscall 1
58         mov    %l4, %psr               ! Update PSR according to Syscall 2
59        ta      0                       ! syscall 1 (not 2 or 3), halt
60
61        PUBLIC(sparc_disable_interrupts)
62
63SYM(sparc_disable_interrupts):
64
65        mov     SYS_irqdis, %g1
66        retl
67         ta     0
68
69        PUBLIC(sparc_enable_interrupts)
70
71SYM(sparc_enable_interrupts):
72
73        mov     SYS_irqen, %g1
74        retl
75         ta     0
76
77        PUBLIC(sparc_syscall_exit)
78
79SYM(sparc_syscall_exit):
80
81        mov     SYS_exit, %g1
82        mov     %o0, %g2        ! Additional exit code 1
83        mov     %o1, %g3        ! Additional exit code 2
84        ta      0
85
86#if defined(RTEMS_PARAVIRT)
87
88        PUBLIC(_SPARC_Get_PSR)
89
90SYM(_SPARC_Get_PSR):
91
92        retl
93         rd     %psr, %o0
94
95        PUBLIC(_SPARC_Set_PSR)
96
97SYM(_SPARC_Set_PSR):
98
99        mov     %o0, %psr
100        nop
101        nop
102        nop
103        retl
104         nop
105
106        PUBLIC(_SPARC_Get_TBR)
107
108SYM(_SPARC_Get_TBR):
109
110        retl
111         rd    %tbr, %o0
112
113        PUBLIC(_SPARC_Set_TBR)
114
115SYM(_SPARC_Set_TBR):
116
117        retl
118         wr    %o0, 0, %tbr
119
120#endif /* defined(RTEMS_PARAVIRT) */
121
122/* end of file */
Note: See TracBrowser for help on using the repository browser.