Skip to content

Commit

Permalink
Merge pull request #159 from azure-rtos/sclarson/update_rx_modules
Browse files Browse the repository at this point in the history
update RX modules
  • Loading branch information
goldscott authored Feb 2, 2022
2 parents fd40352 + db11aba commit 11303a0
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 60 deletions.
26 changes: 14 additions & 12 deletions ports_module/rxv2/iar/inc/tx_port.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/* PORT SPECIFIC C INFORMATION RELEASE */
/* */
/* tx_port.h RXv2/IAR */
/* 6.1.9 */
/* 6.1.10 */
/* */
/* AUTHOR */
/* */
Expand All @@ -49,9 +49,14 @@
/* */
/* 12-30-2020 William E. Lamie Initial Version 6.1.3 */
/* 06-02-2021 William E. Lamie Modified comments, */
/* resulting in version 6.1.7 */
/* resulting in version 6.1.7 */
/* 10-15-2021 William E. Lamie Modified comment(s), */
/* resulting in version 6.1.9 */
/* 01-31-2022 William E. Lamie Modified comment(s), removed */
/* system state macro, and */
/* added missing interrupt */
/* control defines, */
/* resulting in version 6.1.10 */
/* */
/**************************************************************************/

Expand Down Expand Up @@ -85,6 +90,12 @@ typedef short SHORT;
typedef unsigned short USHORT;


/* Define interrupt control options. */

#define TX_INT_DISABLE 0x00000000
#define TX_INT_ENABLE 0x00010000


/* Define the priority levels for ThreadX. Legal values range
from 32 to 1024 and MUST be evenly divisible by 32. */

Expand Down Expand Up @@ -263,15 +274,6 @@ static void _tx_thread_system_return_inline(void)

#endif


#ifndef TX_THREAD_GET_SYSTEM_STATE

extern volatile ULONG _tx_thread_system_state;
#define TX_THREAD_GET_SYSTEM_STATE() (_tx_thread_system_state | ((~__get_PSW_register()) & (1u << 17u)))
#endif



/* Define the interrupt lockout macros for each ThreadX object. */

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

#ifdef TX_THREAD_INIT
CHAR _tx_version_id[] =
"Copyright (c) Microsoft Corporation. All rights reserved. * ThreadX RXv2/IAR Version 6.1.9 *";
"Copyright (c) Microsoft Corporation. All rights reserved. * ThreadX RXv2/IAR Version 6.1.10 *";
#else
extern CHAR _tx_version_id[];
#endif
Expand Down
10 changes: 6 additions & 4 deletions ports_module/rxv2/iar/module_manager/src/tx_thread_stack_build.s
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
;/* FUNCTION RELEASE */
;/* */
;/* _tx_thread_stack_build RXv2/IAR */
;/* 6.1.9 */
;/* 6.1.10 */
;/* AUTHOR */
;/* */
;/* William E. Lamie, Microsoft Corporation */
Expand Down Expand Up @@ -65,6 +65,8 @@
;/* removed unnecessary stack */
;/* type placement, */
;/* resulting in version 6.1.9 */
;/* 01-31-2022 William E. Lamie Modified comment(s), */
;/* resulting in version 6.1.10 */
;/* */
;/**************************************************************************/
public __tx_thread_stack_build
Expand Down Expand Up @@ -98,7 +100,7 @@ __tx_thread_stack_build:
;
; Stack Bottom: (higher memory address) */
;
MOV.L 16[R1],R3 ; Pickup end of stack area
MOV.L 16[R1],R3 ; Pickup end of stack area
BCLR #0, R3 ; Mask for 4-byte alignment
BCLR #1, R3
;
Expand Down Expand Up @@ -127,11 +129,11 @@ __tx_thread_stack_build:
MOV.L R4,[-R3] ; Initial R7 ...
MOV.L R4,[-R3] ; Initial R6 ...

MOV.L R4,[-R3] ; Accumulator 1
MOV.L R4,[-R3] ; Accumulator 1
MOV.L R4,[-R3]
MOV.L R4,[-R3]

MOV.L R4,[-R3] ; Accumulator 0
MOV.L R4,[-R3] ; Accumulator 0
MOV.L R4,[-R3]
MOV.L R4,[-R3]

Expand Down
114 changes: 70 additions & 44 deletions ports_module/rxv2/iar/module_manager/src/tx_timer_interrupt.s
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
;/**************************************************************************/
;/**************************************************************************/

SWI0 EQU 0x872E0

extern __tx_timer_expiration_process
extern __tx_timer_system_clock
extern __tx_timer_expired_time_slice
Expand All @@ -29,6 +31,9 @@
extern __tx_timer_time_slice
extern __tx_timer_list_end
extern __tx_thread_time_slice
extern __tx_thread_preempt_disable
extern __tx_thread_execute_ptr
extern __tx_thread_current_ptr

section .text:CODE:ROOT

Expand All @@ -37,7 +42,7 @@
;/* FUNCTION RELEASE */
;/* */
;/* _tx_timer_interrupt RXv2/IAR */
;/* 6.1.9 */
;/* 6.1.10 */
;/* AUTHOR */
;/* */
;/* William E. Lamie, Microsoft Corporation */
Expand Down Expand Up @@ -76,6 +81,10 @@
;/* 12-30-2020 William E. Lamie Initial Version 6.1.3 */
;/* 10-15-2021 William E. Lamie Modified comment(s), */
;/* resulting in version 6.1.9 */
;/* 01-31-2022 William E. Lamie Modified comment(s), and */
;/* added missing thread */
;/* preemption logic, */
;/* resulting in version 6.1.10 */
;/* */
;/**************************************************************************/

Expand All @@ -94,38 +103,38 @@ __tx_timer_interrupt:
PUSHM R14-R15
PUSHM R1-R5

MOV.L #__tx_timer_system_clock, R1 ; Pickup address of system clock
MOV.L [R1], R2 ; Pickup system clock
ADD #1, R2 ; Increment system clock
MOV.L R2,[R1] ; Store new system clock
MOV.L #__tx_timer_system_clock, R1 ; Pickup address of system clock
MOV.L [R1], R2 ; Pickup system clock
ADD #1, R2 ; Increment system clock
MOV.L R2,[R1] ; Store new system clock
;
; /* Test for time-slice expiration. */
; if (_tx_timer_time_slice)
; {
;
MOV.L #__tx_timer_time_slice, R1 ; Pickup address of time slice
MOV.L [R1], R2 ; Pickup the current time slice
CMP #0, R2 ; Is a time slice active?
BEQ __tx_timer_no_time_slice ; No, skip timer slice processing
MOV.L #__tx_timer_time_slice, R1 ; Pickup address of time slice
MOV.L [R1], R2 ; Pickup the current time slice
CMP #0, R2 ; Is a time slice active?
BEQ __tx_timer_no_time_slice ; No, skip timer slice processing
;
; /* Decrement the time_slice. */
; _tx_timer_time_slice--;
;
SUB #1, R2 ; Decrement the time-slice
MOV.L R2, [R1] ; Store time-slice
SUB #1, R2 ; Decrement the time-slice
MOV.L R2, [R1] ; Store time-slice
;
; /* Check for expiration. */
; if (__tx_timer_time_slice == 0)
;
CMP #0, R2 ; Has it expired?
BNE __tx_timer_no_time_slice ; No, time-slice has not expired
CMP #0, R2 ; Has it expired?
BNE __tx_timer_no_time_slice ; No, time-slice has not expired
;
; /* Set the time-slice expired flag. */
; _tx_timer_expired_time_slice = TX_TRUE;
;
MOV.L #__tx_timer_expired_time_slice, R1 ; Pickup address of expired time-slice
MOV.L #1, R2 ; Build expired value
MOV.L R2, [R1] ; Set expired time slice variable
MOV.L #__tx_timer_expired_time_slice, R1 ; Pickup address of expired time-slice
MOV.L #1, R2 ; Build expired value
MOV.L R2, [R1] ; Set expired time slice variable
; }
;
__tx_timer_no_time_slice:
Expand All @@ -134,20 +143,20 @@ __tx_timer_no_time_slice:
; if (*_tx_timer_current_ptr)
; {
;
MOV.L #__tx_timer_current_ptr, R1 ; Pickup address of current timer ptr
MOV.L [R1], R2 ; Pickup current pointer
MOV.L #__tx_timer_current_ptr, R1 ; Pickup address of current timer ptr
MOV.L [R1], R2 ; Pickup current pointer
MOV.L [R2+], R1 ; Pickup timer list entry, _tx_timer_current_ptr++
CMP #0, R1 ; Is timer pointer NULL?
BEQ __tx_timer_no_timer ; Yes, no timer has expired
CMP #0, R1 ; Is timer pointer NULL?
BEQ __tx_timer_no_timer ; Yes, no timer has expired

;
; /* Set expiration flag. */
; _tx_timer_expired = TX_TRUE;
;
MOV.L #__tx_timer_expired,R2 ; Build address of expired flag
MOV.L #1, R1 ; Build expired value
MOV.L #__tx_timer_expired,R2 ; Build address of expired flag
MOV.L #1, R1 ; Build expired value
MOV.L R1, [R2]
BRA __tx_timer_done ; Finished with timer processing
BRA __tx_timer_done ; Finished with timer processing
;
; }
; else
Expand All @@ -162,17 +171,17 @@ __tx_timer_no_timer:
; /* Check for wrap-around. */
; if (_tx_timer_current_ptr == _tx_timer_list_end)
;
MOV.L #__tx_timer_list_end, R1 ; Pickup the timer list end ptr
MOV.L [R1], R1 ; Pickup actual timer list end
CMP R1, R2 ; Are we at list end?
BNE __tx_timer_skip_wrap ; No, don't move pointer to the
; top of the list
MOV.L #__tx_timer_list_end, R1 ; Pickup the timer list end ptr
MOV.L [R1], R1 ; Pickup actual timer list end
CMP R1, R2 ; Are we at list end?
BNE __tx_timer_skip_wrap ; No, don't move pointer to the
; top of the list
;
; /* Wrap to beginning of list. */
; _tx_timer_current_ptr = _tx_timer_list_start;
;
MOV.L #__tx_timer_list_start, R2 ; Pickup the timer list start ptr
MOV.L [R2], R2 ; Pickup the start of the list
MOV.L #__tx_timer_list_start, R2 ; Pickup the timer list start ptr
MOV.L [R2], R2 ; Pickup the start of the list
; }
;
__tx_timer_skip_wrap:
Expand All @@ -186,25 +195,25 @@ __tx_timer_done:
; {
;
MOV.L #__tx_timer_expired_time_slice, R1 ; Pickup expired time slice addr
MOV.L [R1], R1 ; Pickup expired time slice
MOV.L #__tx_timer_expired, R2 ; Pickup expired timer flag address
MOV.L [R2], R2 ; Pickup actual flag
OR R1, R2 ; Or flags together
BEQ __tx_timer_nothing_expired ; If Z set, nothing has expired
MOV.L [R1], R1 ; Pickup expired time slice
MOV.L #__tx_timer_expired, R2 ; Pickup expired timer flag address
MOV.L [R2], R2 ; Pickup actual flag
OR R1, R2 ; Or flags together
BEQ __tx_timer_nothing_expired ; If Z set, nothing has expired

__tx_something_expired:
; /* Did a timer expire? */
; if (_tx_timer_expired)
; {
MOV.L #__tx_timer_expired,R1 ; Pickup expired flag address
MOV.L [R1], R1 ; Pickup expired flag
CMP #0,R1 ; Is the expired timer flag set?
BEQ __tx_timer_dont_activate ; No, skip timer activation
MOV.L #__tx_timer_expired,R1 ; Pickup expired flag address
MOV.L [R1], R1 ; Pickup expired flag
CMP #0,R1 ; Is the expired timer flag set?
BEQ __tx_timer_dont_activate ; No, skip timer activation
;
; /* Process timer expiration. */
; _tx_timer_expiration_process();
;
BSR __tx_timer_expiration_process ; Call the timer expiration handling routine
BSR __tx_timer_expiration_process ; Call the timer expiration handling routine
;
; }
__tx_timer_dont_activate:
Expand All @@ -214,14 +223,31 @@ __tx_timer_dont_activate:
; {
;
MOV.L #__tx_timer_expired_time_slice, R1 ; Pickup time-slice expired flag addr
MOV.L [R1], R1 ; Pickup actual flag
CMP #0,R1 ; Has time-slice expired?
BEQ __tx_timer_not_ts_expiration ; No, skip time-slice expiration
MOV.L [R1], R1 ; Pickup actual flag
CMP #0,R1 ; Has time-slice expired?
BEQ __tx_timer_not_ts_expiration ; No, skip time-slice expiration
;
; /* Time slice interrupted thread. */
; _tx_thread_time_slice();

BSR __tx_thread_time_slice ; Call time-slice processing
BSR __tx_thread_time_slice ; Call time-slice processing

; /* Check if we must trigger a context switch. */
MOV.L #__tx_thread_preempt_disable, R1 ; Load prempt disable flag.
MOV.L [R1], R1
CMP #0, R1
BNE __tx_timer_not_ts_expiration ; Skip if prempt disabled.

MOV.L #__tx_thread_execute_ptr, R1
MOV.L [R1], R1
MOV.L #__tx_thread_current_ptr, R2
MOV.L [R2], R2
CMP R1, R2
BEQ __tx_timer_not_ts_expiration

MOV.L #SWI0, R1
MOV.L #1, [R1]

; }
;
__tx_timer_not_ts_expiration:
Expand Down

0 comments on commit 11303a0

Please sign in to comment.