Skip to content

Commit db11aba

Browse files
author
Scott Larson
committed
update RX modules
1 parent fd40352 commit db11aba

File tree

3 files changed

+90
-60
lines changed

3 files changed

+90
-60
lines changed

ports_module/rxv2/iar/inc/tx_port.h

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/* PORT SPECIFIC C INFORMATION RELEASE */
2727
/* */
2828
/* tx_port.h RXv2/IAR */
29-
/* 6.1.9 */
29+
/* 6.1.10 */
3030
/* */
3131
/* AUTHOR */
3232
/* */
@@ -49,9 +49,14 @@
4949
/* */
5050
/* 12-30-2020 William E. Lamie Initial Version 6.1.3 */
5151
/* 06-02-2021 William E. Lamie Modified comments, */
52-
/* resulting in version 6.1.7 */
52+
/* resulting in version 6.1.7 */
5353
/* 10-15-2021 William E. Lamie Modified comment(s), */
5454
/* resulting in version 6.1.9 */
55+
/* 01-31-2022 William E. Lamie Modified comment(s), removed */
56+
/* system state macro, and */
57+
/* added missing interrupt */
58+
/* control defines, */
59+
/* resulting in version 6.1.10 */
5560
/* */
5661
/**************************************************************************/
5762

@@ -85,6 +90,12 @@ typedef short SHORT;
8590
typedef unsigned short USHORT;
8691

8792

93+
/* Define interrupt control options. */
94+
95+
#define TX_INT_DISABLE 0x00000000
96+
#define TX_INT_ENABLE 0x00010000
97+
98+
8899
/* Define the priority levels for ThreadX. Legal values range
89100
from 32 to 1024 and MUST be evenly divisible by 32. */
90101

@@ -263,15 +274,6 @@ static void _tx_thread_system_return_inline(void)
263274

264275
#endif
265276

266-
267-
#ifndef TX_THREAD_GET_SYSTEM_STATE
268-
269-
extern volatile ULONG _tx_thread_system_state;
270-
#define TX_THREAD_GET_SYSTEM_STATE() (_tx_thread_system_state | ((~__get_PSW_register()) & (1u << 17u)))
271-
#endif
272-
273-
274-
275277
/* Define the interrupt lockout macros for each ThreadX object. */
276278

277279
#define TX_BLOCK_POOL_DISABLE TX_DISABLE
@@ -286,7 +288,7 @@ extern volatile ULONG _tx_thread_system_state;
286288

287289
#ifdef TX_THREAD_INIT
288290
CHAR _tx_version_id[] =
289-
"Copyright (c) Microsoft Corporation. All rights reserved. * ThreadX RXv2/IAR Version 6.1.9 *";
291+
"Copyright (c) Microsoft Corporation. All rights reserved. * ThreadX RXv2/IAR Version 6.1.10 *";
290292
#else
291293
extern CHAR _tx_version_id[];
292294
#endif

ports_module/rxv2/iar/module_manager/src/tx_thread_stack_build.s

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
;/* FUNCTION RELEASE */
2929
;/* */
3030
;/* _tx_thread_stack_build RXv2/IAR */
31-
;/* 6.1.9 */
31+
;/* 6.1.10 */
3232
;/* AUTHOR */
3333
;/* */
3434
;/* William E. Lamie, Microsoft Corporation */
@@ -65,6 +65,8 @@
6565
;/* removed unnecessary stack */
6666
;/* type placement, */
6767
;/* resulting in version 6.1.9 */
68+
;/* 01-31-2022 William E. Lamie Modified comment(s), */
69+
;/* resulting in version 6.1.10 */
6870
;/* */
6971
;/**************************************************************************/
7072
public __tx_thread_stack_build
@@ -98,7 +100,7 @@ __tx_thread_stack_build:
98100
;
99101
; Stack Bottom: (higher memory address) */
100102
;
101-
MOV.L 16[R1],R3 ; Pickup end of stack area
103+
MOV.L 16[R1],R3 ; Pickup end of stack area
102104
BCLR #0, R3 ; Mask for 4-byte alignment
103105
BCLR #1, R3
104106
;
@@ -127,11 +129,11 @@ __tx_thread_stack_build:
127129
MOV.L R4,[-R3] ; Initial R7 ...
128130
MOV.L R4,[-R3] ; Initial R6 ...
129131

130-
MOV.L R4,[-R3] ; Accumulator 1
132+
MOV.L R4,[-R3] ; Accumulator 1
131133
MOV.L R4,[-R3]
132134
MOV.L R4,[-R3]
133135

134-
MOV.L R4,[-R3] ; Accumulator 0
136+
MOV.L R4,[-R3] ; Accumulator 0
135137
MOV.L R4,[-R3]
136138
MOV.L R4,[-R3]
137139

ports_module/rxv2/iar/module_manager/src/tx_timer_interrupt.s

Lines changed: 70 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
;/**************************************************************************/
2121
;/**************************************************************************/
2222

23+
SWI0 EQU 0x872E0
24+
2325
extern __tx_timer_expiration_process
2426
extern __tx_timer_system_clock
2527
extern __tx_timer_expired_time_slice
@@ -29,6 +31,9 @@
2931
extern __tx_timer_time_slice
3032
extern __tx_timer_list_end
3133
extern __tx_thread_time_slice
34+
extern __tx_thread_preempt_disable
35+
extern __tx_thread_execute_ptr
36+
extern __tx_thread_current_ptr
3237

3338
section .text:CODE:ROOT
3439

@@ -37,7 +42,7 @@
3742
;/* FUNCTION RELEASE */
3843
;/* */
3944
;/* _tx_timer_interrupt RXv2/IAR */
40-
;/* 6.1.9 */
45+
;/* 6.1.10 */
4146
;/* AUTHOR */
4247
;/* */
4348
;/* William E. Lamie, Microsoft Corporation */
@@ -76,6 +81,10 @@
7681
;/* 12-30-2020 William E. Lamie Initial Version 6.1.3 */
7782
;/* 10-15-2021 William E. Lamie Modified comment(s), */
7883
;/* resulting in version 6.1.9 */
84+
;/* 01-31-2022 William E. Lamie Modified comment(s), and */
85+
;/* added missing thread */
86+
;/* preemption logic, */
87+
;/* resulting in version 6.1.10 */
7988
;/* */
8089
;/**************************************************************************/
8190

@@ -94,38 +103,38 @@ __tx_timer_interrupt:
94103
PUSHM R14-R15
95104
PUSHM R1-R5
96105

97-
MOV.L #__tx_timer_system_clock, R1 ; Pickup address of system clock
98-
MOV.L [R1], R2 ; Pickup system clock
99-
ADD #1, R2 ; Increment system clock
100-
MOV.L R2,[R1] ; Store new system clock
106+
MOV.L #__tx_timer_system_clock, R1 ; Pickup address of system clock
107+
MOV.L [R1], R2 ; Pickup system clock
108+
ADD #1, R2 ; Increment system clock
109+
MOV.L R2,[R1] ; Store new system clock
101110
;
102111
; /* Test for time-slice expiration. */
103112
; if (_tx_timer_time_slice)
104113
; {
105114
;
106-
MOV.L #__tx_timer_time_slice, R1 ; Pickup address of time slice
107-
MOV.L [R1], R2 ; Pickup the current time slice
108-
CMP #0, R2 ; Is a time slice active?
109-
BEQ __tx_timer_no_time_slice ; No, skip timer slice processing
115+
MOV.L #__tx_timer_time_slice, R1 ; Pickup address of time slice
116+
MOV.L [R1], R2 ; Pickup the current time slice
117+
CMP #0, R2 ; Is a time slice active?
118+
BEQ __tx_timer_no_time_slice ; No, skip timer slice processing
110119
;
111120
; /* Decrement the time_slice. */
112121
; _tx_timer_time_slice--;
113122
;
114-
SUB #1, R2 ; Decrement the time-slice
115-
MOV.L R2, [R1] ; Store time-slice
123+
SUB #1, R2 ; Decrement the time-slice
124+
MOV.L R2, [R1] ; Store time-slice
116125
;
117126
; /* Check for expiration. */
118127
; if (__tx_timer_time_slice == 0)
119128
;
120-
CMP #0, R2 ; Has it expired?
121-
BNE __tx_timer_no_time_slice ; No, time-slice has not expired
129+
CMP #0, R2 ; Has it expired?
130+
BNE __tx_timer_no_time_slice ; No, time-slice has not expired
122131
;
123132
; /* Set the time-slice expired flag. */
124133
; _tx_timer_expired_time_slice = TX_TRUE;
125134
;
126-
MOV.L #__tx_timer_expired_time_slice, R1 ; Pickup address of expired time-slice
127-
MOV.L #1, R2 ; Build expired value
128-
MOV.L R2, [R1] ; Set expired time slice variable
135+
MOV.L #__tx_timer_expired_time_slice, R1 ; Pickup address of expired time-slice
136+
MOV.L #1, R2 ; Build expired value
137+
MOV.L R2, [R1] ; Set expired time slice variable
129138
; }
130139
;
131140
__tx_timer_no_time_slice:
@@ -134,20 +143,20 @@ __tx_timer_no_time_slice:
134143
; if (*_tx_timer_current_ptr)
135144
; {
136145
;
137-
MOV.L #__tx_timer_current_ptr, R1 ; Pickup address of current timer ptr
138-
MOV.L [R1], R2 ; Pickup current pointer
146+
MOV.L #__tx_timer_current_ptr, R1 ; Pickup address of current timer ptr
147+
MOV.L [R1], R2 ; Pickup current pointer
139148
MOV.L [R2+], R1 ; Pickup timer list entry, _tx_timer_current_ptr++
140-
CMP #0, R1 ; Is timer pointer NULL?
141-
BEQ __tx_timer_no_timer ; Yes, no timer has expired
149+
CMP #0, R1 ; Is timer pointer NULL?
150+
BEQ __tx_timer_no_timer ; Yes, no timer has expired
142151
143152
;
144153
; /* Set expiration flag. */
145154
; _tx_timer_expired = TX_TRUE;
146155
;
147-
MOV.L #__tx_timer_expired,R2 ; Build address of expired flag
148-
MOV.L #1, R1 ; Build expired value
156+
MOV.L #__tx_timer_expired,R2 ; Build address of expired flag
157+
MOV.L #1, R1 ; Build expired value
149158
MOV.L R1, [R2]
150-
BRA __tx_timer_done ; Finished with timer processing
159+
BRA __tx_timer_done ; Finished with timer processing
151160
;
152161
; }
153162
; else
@@ -162,17 +171,17 @@ __tx_timer_no_timer:
162171
; /* Check for wrap-around. */
163172
; if (_tx_timer_current_ptr == _tx_timer_list_end)
164173
;
165-
MOV.L #__tx_timer_list_end, R1 ; Pickup the timer list end ptr
166-
MOV.L [R1], R1 ; Pickup actual timer list end
167-
CMP R1, R2 ; Are we at list end?
168-
BNE __tx_timer_skip_wrap ; No, don't move pointer to the
169-
; top of the list
174+
MOV.L #__tx_timer_list_end, R1 ; Pickup the timer list end ptr
175+
MOV.L [R1], R1 ; Pickup actual timer list end
176+
CMP R1, R2 ; Are we at list end?
177+
BNE __tx_timer_skip_wrap ; No, don't move pointer to the
178+
; top of the list
170179
;
171180
; /* Wrap to beginning of list. */
172181
; _tx_timer_current_ptr = _tx_timer_list_start;
173182
;
174-
MOV.L #__tx_timer_list_start, R2 ; Pickup the timer list start ptr
175-
MOV.L [R2], R2 ; Pickup the start of the list
183+
MOV.L #__tx_timer_list_start, R2 ; Pickup the timer list start ptr
184+
MOV.L [R2], R2 ; Pickup the start of the list
176185
; }
177186
;
178187
__tx_timer_skip_wrap:
@@ -186,25 +195,25 @@ __tx_timer_done:
186195
; {
187196
;
188197
MOV.L #__tx_timer_expired_time_slice, R1 ; Pickup expired time slice addr
189-
MOV.L [R1], R1 ; Pickup expired time slice
190-
MOV.L #__tx_timer_expired, R2 ; Pickup expired timer flag address
191-
MOV.L [R2], R2 ; Pickup actual flag
192-
OR R1, R2 ; Or flags together
193-
BEQ __tx_timer_nothing_expired ; If Z set, nothing has expired
198+
MOV.L [R1], R1 ; Pickup expired time slice
199+
MOV.L #__tx_timer_expired, R2 ; Pickup expired timer flag address
200+
MOV.L [R2], R2 ; Pickup actual flag
201+
OR R1, R2 ; Or flags together
202+
BEQ __tx_timer_nothing_expired ; If Z set, nothing has expired
194203

195204
__tx_something_expired:
196205
; /* Did a timer expire? */
197206
; if (_tx_timer_expired)
198207
; {
199-
MOV.L #__tx_timer_expired,R1 ; Pickup expired flag address
200-
MOV.L [R1], R1 ; Pickup expired flag
201-
CMP #0,R1 ; Is the expired timer flag set?
202-
BEQ __tx_timer_dont_activate ; No, skip timer activation
208+
MOV.L #__tx_timer_expired,R1 ; Pickup expired flag address
209+
MOV.L [R1], R1 ; Pickup expired flag
210+
CMP #0,R1 ; Is the expired timer flag set?
211+
BEQ __tx_timer_dont_activate ; No, skip timer activation
203212
;
204213
; /* Process timer expiration. */
205214
; _tx_timer_expiration_process();
206215
;
207-
BSR __tx_timer_expiration_process ; Call the timer expiration handling routine
216+
BSR __tx_timer_expiration_process ; Call the timer expiration handling routine
208217
;
209218
; }
210219
__tx_timer_dont_activate:
@@ -214,14 +223,31 @@ __tx_timer_dont_activate:
214223
; {
215224
;
216225
MOV.L #__tx_timer_expired_time_slice, R1 ; Pickup time-slice expired flag addr
217-
MOV.L [R1], R1 ; Pickup actual flag
218-
CMP #0,R1 ; Has time-slice expired?
219-
BEQ __tx_timer_not_ts_expiration ; No, skip time-slice expiration
226+
MOV.L [R1], R1 ; Pickup actual flag
227+
CMP #0,R1 ; Has time-slice expired?
228+
BEQ __tx_timer_not_ts_expiration ; No, skip time-slice expiration
220229
;
221230
; /* Time slice interrupted thread. */
222231
; _tx_thread_time_slice();
223232

224-
BSR __tx_thread_time_slice ; Call time-slice processing
233+
BSR __tx_thread_time_slice ; Call time-slice processing
234+
235+
; /* Check if we must trigger a context switch. */
236+
MOV.L #__tx_thread_preempt_disable, R1 ; Load prempt disable flag.
237+
MOV.L [R1], R1
238+
CMP #0, R1
239+
BNE __tx_timer_not_ts_expiration ; Skip if prempt disabled.
240+
241+
MOV.L #__tx_thread_execute_ptr, R1
242+
MOV.L [R1], R1
243+
MOV.L #__tx_thread_current_ptr, R2
244+
MOV.L [R2], R2
245+
CMP R1, R2
246+
BEQ __tx_timer_not_ts_expiration
247+
248+
MOV.L #SWI0, R1
249+
MOV.L #1, [R1]
250+
225251
; }
226252
;
227253
__tx_timer_not_ts_expiration:

0 commit comments

Comments
 (0)