source: rtems/c/src/lib/libcpu/sparc64/shared/syscall/sparc64-syscall.S @ c56982c

4.115
Last change on this file since c56982c was c56982c, checked in by Joel Sherrill <joel.sherrill@…>, on 06/17/10 at 16:16:25

2010-06-17 Joel Sherrill <joel.sherrill@…>

  • .cvsignore, ChangeLog?, Makefile.am, configure.ac, preinstall.am, shared/cache/cache.c, shared/cache/cache_.h, shared/interrupts/installisrentries.c, shared/score/cpu.c, shared/score/interrupt.S, shared/syscall/sparc64-syscall.S, shared/syscall/sparc64-syscall.h: New files.
  • Property mode set to 100644
File size: 3.6 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 *  COPYRIGHT (c) 2010. Gedare Bloom.
15 *
16 *  This terms of the RTEMS license apply to this file.
17 *
18 */
19
20#include <rtems/asm.h>
21#include "sparc64-syscall.h"
22
23
24.seg    "text"
25/*
26 *  system call
27 *
28 *  On entry:
29 *      g4[AG | GL=1] = tstate (from trap table)
30 *      g2[AG | GL=1] = trap vector # (256)
31 *      g3[AG | GL=1] = address of SYM(syscall)
32 *      g4[AG | GL-1] = system call id
33 *    if arch = sun4v:
34 *      We need to back to GL-1 to read the system call id.
35 *   on sun4u:
36 *      We need to go back to the normal globals to read the system call id.
37 *   
38 *    First thing is to return to the previous set of globals, so
39 *    that the system call id can be read.  The syscall code needs
40 *    to re-read tstate.
41 *
42 *    syscall should only ever be entered by ta 0 being called explicitly
43 *    by a function that knows what is happening.  This means the syscall
44 *    code can safely use any scratch registers and the %o registers.
45 */
46
47
48PUBLIC(syscall)
49
50 
51  SYM(syscall):
52    mov   %g0, %g4  ! clear %g4 at this GL
53#if defined (SUN4U)
54    rdpr  %pstate, %g1
55    andn  %g1, SPARC_PSTATE_AG_MASK, %g1
56    wrpr  %g1, %g0, %pstate                 ! go to regular globals
57#elif defined (SUN4V)
58    rdpr  %gl, %g1
59    dec   %g1
60    wrpr  %g0, %g1, %gl                     ! go back to GL = GL - 1
61#endif
62
63    subcc %g4, 2, %g0                     
64    bne   3f
65    rdpr  %tstate, %g5                      ! re-read tstate, use delay slot
66
67    ! syscall 2, disable interrupts
68    rdpr  %pil, %g1
69    and   %g5, SPARC_TSTATE_IE_MASK, %o0
70    or    %o0, %g1, %o0                     ! return TSTATE_IE | PIL
71    wrpr  %g0, 0xf, %pil                    ! set PIL to 15
72    andn  %g5, SPARC_TSTATE_IE_MASK, %g1
73    wrpr  %g0, %g1, %tstate                 ! disable interrupts in trap state
74    ba,a  9f
75
76    3:  ! syscall 3, enable interrupts
77    subcc %g4, 3, %g0                     
78    bne   1f
79    and   %o0, 0xf, %g1
80    wrpr  %g0, %g1, %pil                    ! restore PIL
81!    and   %o0, SPARC_TSTATE_IE_MASK, %g1
82!    or    %g5, %g1, %g1                     ! restore saved IE
83    or    %g5, SPARC_TSTATE_IE_MASK, %g1    ! restore IE (safe?)
84    wrpr  %g0, %g1, %tstate     
85    ba,a  9f
86
87    1:         
88    ba,a  1b                                ! spin. taking a trap here -> htrap
89
90    9:                                      ! leave
91    mov  0, %g4                             ! clear %g4
92    DONE
93
94PUBLIC(sparc_disable_interrupts)
95
96  SYM(sparc_disable_interrupts):
97    mov  SYS_irqdis, %g4
98    ta  0
99#if 0
100    rdpr  %pstate, %g5
101    rdpr  %pil, %g1
102    and   %g5, SPARC_PSTATE_IE_MASK, %o0
103    or    %o0, %g1, %o0                     ! return PSTATE_IE | PIL
104    wrpr  %g0, 0xf, %pil                    ! set PIL to 15
105    andn  %g5, SPARC_PSTATE_IE_MASK, %g1
106    wrpr  %g0, %g1, %pstate                 ! disable interrupts
107#endif
108    retl 
109    nop
110
111PUBLIC(sparc_enable_interrupts)
112
113  SYM(sparc_enable_interrupts):
114    mov  SYS_irqen, %g4
115    ta  0
116#if 0
117    rdpr  %pstate, %g5
118    and   %o0, 0xf, %g1
119    wrpr  %g0, %g1, %pil                    ! restore PIL
120    and   %o0, SPARC_PSTATE_IE_MASK, %g1
121    or    %g5, %g1, %g1                     ! restore saved IE
122!    or    %g5, SPARC_PSTATE_IE_MASK, %g1    ! set IE regardless of old (safe?)
123    wrpr  %g0, %g1, %pstate
124#endif
125    retl 
126    nop
127
128    /* end of file */
Note: See TracBrowser for help on using the repository browser.