3030/* AUTHOR */
3131/* */
3232/* Akif Ejaz, 10xEngineers */
33- /* Wei-Chen Lai, National Cheng Kung University */
3433/* */
3534/* DESCRIPTION */
3635/* */
177176 alternately be defined on the command line. */
178177
179178#include "tx_user.h"
180- #endif /* TX_INCLUDE_USER_DEFINE_FILE */
179+ #endif
180+
181181
182- #endif /* __ASSEMBLER__ */
182+ /* Define compiler library include files. */
183183
184184
185185/* Define ThreadX basic types for this port. */
186186
187187#define VOID void
188-
189- #ifndef __ASSEMBLER__
190188typedef char CHAR ;
191189typedef unsigned char UCHAR ;
192190typedef int INT ;
@@ -197,7 +195,8 @@ typedef unsigned long long ULONG64;
197195typedef short SHORT ;
198196typedef unsigned short USHORT ;
199197#define ULONG64_DEFINED
200- #endif /* __ASSEMBLER__ */
198+ #define ALIGN_TYPE_DEFINED
199+ #define ALIGN_TYPE ULONG64
201200
202201
203202
@@ -346,33 +345,21 @@ typedef unsigned short USHORT;
346345
347346#ifdef TX_DISABLE_INLINE
348347
349- unsigned int _tx_thread_interrupt_control (unsigned int new_posture );
348+ ULONG64 _tx_thread_interrupt_control (unsigned int new_posture );
350349
351- #define TX_INTERRUPT_SAVE_AREA register INT interrupt_save;
350+ #define TX_INTERRUPT_SAVE_AREA register ULONG64 interrupt_save;
352351
353352#define TX_DISABLE interrupt_save = _tx_thread_interrupt_control(TX_INT_DISABLE);
354353#define TX_RESTORE _tx_thread_interrupt_control(interrupt_save);
355354
356355#else
357356
358- #define TX_INTERRUPT_SAVE_AREA ULONG interrupt_save;
359-
360- #define TX_DISABLE \
361- __asm__ volatile ( \
362- "csrr %0, mstatus\n\t" \
363- "csrci mstatus, 8" \
364- : "=r" (interrupt_save) \
365- : \
366- : "memory" \
367- );
368-
369- #define TX_RESTORE \
370- __asm__ volatile ( \
371- "csrw mstatus, %0\n\t" \
372- : \
373- : "r" (interrupt_save) \
374- : "memory" \
375- );
357+ #define TX_INTERRUPT_SAVE_AREA ULONG64 interrupt_save;
358+ /* Atomically read mstatus into interrupt_save and clear bit 3 of mstatus. */
359+ #define TX_DISABLE {__asm__ ("csrrci %0, mstatus, 0x08" : "=r" (interrupt_save) : );};
360+ /* We only care about mstatus.mie (bit 3), so mask interrupt_save and write to mstatus. */
361+ #define TX_RESTORE {register ULONG64 __tempmask = interrupt_save & 0x08; \
362+ __asm__ ("csrrs x0, mstatus, %0 \n\t" : : "r" (__tempmask) : );};
376363
377364#endif
378365
@@ -389,13 +376,12 @@ unsigned int _tx_thread_interrupt_control(uns
389376
390377/* Define the version ID of ThreadX. This may be utilized by the application. */
391378
392- #ifndef __ASSEMBLER__
393379#ifdef TX_THREAD_INIT
394380CHAR _tx_version_id [] =
395- "(c) 2024 Microsoft Corp. (c) 2026-present Eclipse ThreadX contributors. * ThreadX RISC-V32/GNU Version 6.5.0.202601 *" ;
381+ "Copyright (c) 2024 Microsoft Corporation. * ThreadX RISC-V32/GNU Version 6.4.2 *" ;
396382#else
397383extern CHAR _tx_version_id [];
398- #endif /* TX_THREAD_INIT */
399- #endif /* __ASSEMBLER__ */
384+ #endif
400385
401- #endif /* TX_PORT_H */
386+ #endif /*not __ASSEMBLER__ */
387+ #endif
0 commit comments