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

4.11
Last change on this file since dff1803 was dff1803, checked in by Daniel Hellstrom <daniel@…>, on Dec 3, 2014 at 10:35:52 AM

SPARC: optimize IRQ enable & disable

  • Coding style cleanups.
  • Use OS reserved trap 0x89 for IRQ Disable
  • Use OS reserved trap 0x8A for IRQ Enable
  • Add to SPARC CPU supplement documentation

This will result in faster Disable/Enable? code since the
system trap handler does not need to decode which function
the user wants. Besides the IRQ disable/enabled can now
be inline which avoids the caller to take into account that
o0-o7+g1-g4 registers are destroyed by trap handler.

It was also possible to reduce the interrupt trap handler by
five instructions due to this.

  • Property mode set to 100644
File size: 2.3 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 - halt
25         *
26         *  On entry:
27         *
28         *    l0 = psr (from trap table)
29         *    l1 = pc
30         *    l2 = npc
31         *    g1 = system call id (1)
32         *
33         *  System Call 1 (exit):
34         *    g2 = additional exit code 1
35         *    g3 = additional exit code 2
36         */
37
38        PUBLIC(syscall)
39
40SYM(syscall):
41        ta      0                       ! syscall 1, halt with %g1,%g2,%g3 info
42
43        PUBLIC(sparc_syscall_exit)
44
45SYM(sparc_syscall_exit):
46
47        mov     SYS_exit, %g1
48        mov     %o0, %g2        ! Additional exit code 1
49        mov     %o1, %g3        ! Additional exit code 2
50        ta      SPARC_SWTRAP_SYSCALL
51
52        /*
53         *  system call - Interrupt Disable
54         *
55         *  On entry:
56         *
57         *    l0 = psr (from trap table)
58         *    l1 = pc
59         *    l2 = npc
60         *    l3 = psr | SPARC_PSR_PIL_MASK
61         *
62         *  On exit:
63         *    g1 = old psr (to user)
64         */
65
66.align 32                               ! Align to 32-byte cache-line
67        PUBLIC(syscall_irqdis)
68
69SYM(syscall_irqdis):
70        mov     %l3, %psr                       ! Set PSR. Write delay 3 instr
71        or      %l0, SPARC_PSR_ET_MASK, %g1     ! return old PSR with ET=1
72        nop                                     ! PSR write delay
73        jmp     %l2                             ! Return to after TA 9.
74         rett   %l2 + 4
75
76        /*
77         *  system call - Interrupt Enable
78         *
79         *  On entry:
80         *
81         *    l0 = psr (from trap table)
82         *    l1 = pc
83         *    l2 = npc
84         *    l3 = psr & ~0x0f00
85         *    g1 = new PIL to write (from user)
86         */
87
88.align 32                               ! Align to 32-byte cache-line
89        PUBLIC(syscall_irqen)
90
91SYM(syscall_irqen):
92        and     %g1, SPARC_PSR_PIL_MASK, %l4    ! %l4 = (%g1 & 0xf00)
93        wr      %l3, %l4, %psr                  ! PSR = (PSR & ~0xf00) ^ %l4
94        nop; nop                                ! PSR write delay;
95        jmp     %l2                             ! Return to after TA 10.
96         rett   %l2 + 4
97
98#if defined(RTEMS_PARAVIRT)
99
100        PUBLIC(_SPARC_Get_PSR)
101
102SYM(_SPARC_Get_PSR):
103
104        retl
105         rd     %psr, %o0
106
107        PUBLIC(_SPARC_Set_PSR)
108
109SYM(_SPARC_Set_PSR):
110
111        mov     %o0, %psr
112        nop
113        nop
114        nop
115        retl
116         nop
117
118        PUBLIC(_SPARC_Get_TBR)
119
120SYM(_SPARC_Get_TBR):
121
122        retl
123         rd    %tbr, %o0
124
125        PUBLIC(_SPARC_Set_TBR)
126
127SYM(_SPARC_Set_TBR):
128
129        retl
130         wr    %o0, 0, %tbr
131
132#endif /* defined(RTEMS_PARAVIRT) */
133
134/* end of file */
Note: See TracBrowser for help on using the repository browser.