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