source:
rtems/cpukit/score/cpu/sparc/sparc-counter-asm.S
@
b2da982
Last change on this file since b2da982 was b2da982, checked in by Daniel Hellstrom <daniel@…>, on 04/21/20 at 09:57:50 | |
---|---|
sparc_fix_ut700 | sparc_fix_ut699) \ + builtin_define ("FIX_LEON3FT_TN0018"); \
Workaround Implementation
In general there are two approaches that the workaround uses:
Where A) comes at a higher performance cost than B), so B) is used
A)
B)
RTEMS SPARC traps workaround implementation:
Any custom trap handlers may also have to be updated. To simplify that,
Close #4155. |
|
|
File size: 3.1 KB |
Line | |
---|---|
1 | /* |
2 | * Copyright (c) 2016, 2018 embedded brains GmbH. All rights reserved. |
3 | * |
4 | * embedded brains GmbH |
5 | * Dornierstr. 4 |
6 | * 82178 Puchheim |
7 | * Germany |
8 | * <rtems@embedded-brains.de> |
9 | * |
10 | * The license and distribution terms for this file may be |
11 | * found in the file LICENSE in this distribution or at |
12 | * http://www.rtems.org/license/LICENSE. |
13 | */ |
14 | |
15 | #ifdef HAVE_CONFIG_H |
16 | #include "config.h" |
17 | #endif |
18 | |
19 | #include <rtems/asm.h> |
20 | |
21 | /* |
22 | * All functions except _SPARC_Counter_read_clock() in this module are |
23 | * sometimes called with traps disabled. |
24 | */ |
25 | |
26 | .section ".text" |
27 | .align 4 |
28 | |
29 | PUBLIC(_SPARC_Counter_read_default) |
30 | SYM(_SPARC_Counter_read_default): |
31 | sethi %hi(_SPARC_Counter + 12), %o1 |
32 | ld [%o1 + %lo(_SPARC_Counter + 12)], %o0 |
33 | add %o0, 1, %o0 |
34 | st %o0, [%o1 + %lo(_SPARC_Counter + 12)] |
35 | jmp %o7 + 8 |
36 | nop |
37 | |
38 | PUBLIC(_SPARC_Counter_read_up) |
39 | PUBLIC(_SPARC_Get_timecount_up) |
40 | SYM(_SPARC_Counter_read_up): |
41 | SYM(_SPARC_Get_timecount_up): |
42 | sethi %hi(_SPARC_Counter + 8), %o0 |
43 | ld [%o0 + %lo(_SPARC_Counter + 8)], %o0 |
44 | jmp %o7 + 8 |
45 | ld [%o0], %o0 |
46 | |
47 | PUBLIC(_SPARC_Counter_read_down) |
48 | PUBLIC(_SPARC_Get_timecount_down) |
49 | SYM(_SPARC_Counter_read_down): |
50 | SYM(_SPARC_Get_timecount_down): |
51 | sethi %hi(_SPARC_Counter + 8), %o0 |
52 | ld [%o0 + %lo(_SPARC_Counter + 8)], %o0 |
53 | ld [%o0], %o0 |
54 | jmp %o7 + 8 |
55 | xnor %g0, %o0, %o0 |
56 | |
57 | /* |
58 | * For the corresponding C code is something like this: |
59 | * |
60 | * CPU_Counter_ticks _SPARC_Counter_read_clock_isr_disabled( void ) |
61 | * { |
62 | * const SPARC_Counter *ctr; |
63 | * CPU_Counter_ticks ticks; |
64 | * CPU_Counter_ticks accumulated; |
65 | * |
66 | * ctr = &_SPARC_Counter; |
67 | * ticks = *ctr->counter_register; |
68 | * accumulated = ctr->accumulated; |
69 | * |
70 | * if ( ( *ctr->pending_register & ctr->pending_mask ) != 0 ) { |
71 | * ticks = *ctr->counter_register; |
72 | * accumulated += ctr->interval; |
73 | * } |
74 | * |
75 | * return accumulated - ticks; |
76 | * } |
77 | */ |
78 | PUBLIC(_SPARC_Counter_read_clock_isr_disabled) |
79 | SYM(_SPARC_Counter_read_clock_isr_disabled): |
80 | sethi %hi(_SPARC_Counter), %o5 |
81 | or %o5, %lo(_SPARC_Counter), %o5 |
82 | ld [%o5 + 8], %o3 |
83 | ld [%o5 + 12], %o4 |
84 | ld [%o5 + 16], %o2 |
85 | ld [%o3], %o0 |
86 | ld [%o4], %o1 |
87 | btst %o1, %o2 |
88 | bne .Lpending_isr_disabled |
89 | ld [%o5 + 20], %o4 |
90 | jmp %o7 + 8 |
91 | sub %o4, %o0, %o0 |
92 | .Lpending_isr_disabled: |
93 | ld [%o5 + 24], %o5 |
94 | ld [%o3], %o0 |
95 | add %o4, %o5, %o4 |
96 | jmp %o7 + 8 |
97 | sub %o4, %o0, %o0 |
98 | |
99 | /* |
100 | * For the corresponding C code see |
101 | * _SPARC_Counter_read_clock_isr_disabled() above. |
102 | */ |
103 | PUBLIC(_SPARC_Counter_read_clock) |
104 | PUBLIC(_SPARC_Get_timecount_clock) |
105 | SYM(_SPARC_Counter_read_clock): |
106 | SYM(_SPARC_Get_timecount_clock): |
107 | sethi %hi(_SPARC_Counter), %o5 |
108 | or %o5, %lo(_SPARC_Counter), %o5 |
109 | ta SPARC_SWTRAP_IRQDIS |
110 | ld [%o5 + 8], %o3 |
111 | ld [%o5 + 12], %o4 |
112 | ld [%o5 + 16], %o2 |
113 | ld [%o3], %o0 |
114 | ld [%o4], %o1 |
115 | btst %o1, %o2 |
116 | bne .Lpending |
117 | ld [%o5 + 20], %o4 |
118 | ta SPARC_SWTRAP_IRQEN |
119 | #ifdef __FIX_LEON3FT_TN0018 |
120 | /* A nop is added to work around the GRLIB-TN-0018 errata */ |
121 | nop |
122 | #endif |
123 | jmp %o7 + 8 |
124 | sub %o4, %o0, %o0 |
125 | .Lpending: |
126 | ld [%o5 + 24], %o5 |
127 | ld [%o3], %o0 |
128 | ta SPARC_SWTRAP_IRQEN |
129 | add %o4, %o5, %o4 |
130 | jmp %o7 + 8 |
131 | sub %o4, %o0, %o0 |
132 | |
133 | PUBLIC(_SPARC_Counter_read_asr23) |
134 | PUBLIC(_SPARC_Get_timecount_asr23) |
135 | SYM(_SPARC_Counter_read_asr23): |
136 | SYM(_SPARC_Get_timecount_asr23): |
137 | jmp %o7 + 8 |
138 | mov %asr23, %o0 |