Skip to content

Commit a436815

Browse files
committed
Add RISC-V32 arch. port layer
- made it complient as per new risc-v64/gnu & threadx style - mv tx_timer_interrupt.c to respective tx_timer_interrupt.S - improved comments - added reademe for risc-v32/gnu port Signed-off-by: Akif Ejaz <akif.ejaz@10xengineers.ai>
1 parent 80257bc commit a436815

11 files changed

Lines changed: 1175 additions & 715 deletions

ports/risc-v32/gnu/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ target_sources(${PROJECT_NAME}
99
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_schedule.S
1010
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_stack_build.S
1111
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_system_return.S
12-
${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_interrupt.c
12+
${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_interrupt.S
1313
# {{END_TARGET_SOURCES}}
1414
)
1515

ports/risc-v32/gnu/inc/tx_port.h

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@
5353
#ifndef TX_PORT_H
5454
#define TX_PORT_H
5555

56-
#ifdef __ASSEMBLER__
57-
58-
59-
#else /*not __ASSEMBLER__ */
56+
#ifndef __ASSEMBLER__
6057

6158
/* Include for memset. */
6259
#include <string.h>
@@ -71,13 +68,16 @@
7168
alternately be defined on the command line. */
7269

7370
#include "tx_user.h"
74-
#endif
71+
#endif /* TX_INCLUDE_USER_DEFINE_FILE */
7572

73+
#endif /* __ASSEMBLER__ */
7674

7775

7876
/* Define ThreadX basic types for this port. */
7977

8078
#define VOID void
79+
80+
#ifndef __ASSEMBLER__
8181
typedef char CHAR;
8282
typedef unsigned char UCHAR;
8383
typedef int INT;
@@ -88,6 +88,8 @@ typedef unsigned long long ULONG64;
8888
typedef short SHORT;
8989
typedef unsigned short USHORT;
9090
#define ULONG64_DEFINED
91+
#endif /* __ASSEMBLER__ */
92+
9193

9294

9395

@@ -233,20 +235,26 @@ typedef unsigned short USHORT;
233235
is used to define a local function save area for the disable and restore
234236
macros. */
235237

238+
/* Expose helper used to perform an atomic read/modify/write of mstatus.
239+
The helper composes and returns the posture per ThreadX contract. */
240+
#ifndef __ASSEMBLER__
241+
UINT _tx_thread_interrupt_control(UINT new_posture);
242+
#endif
243+
236244
#ifdef TX_DISABLE_INLINE
237245

238246
#define TX_INTERRUPT_SAVE_AREA register UINT interrupt_save;
239247

240248
#define TX_DISABLE __asm__ volatile("csrrci %0, mstatus, 8" : "=r" (interrupt_save) :: "memory");
241249
#define TX_RESTORE { \
242-
unsigned long _temp_mstatus; \
243-
__asm__ volatile( \
244-
"csrc mstatus, 8\n" \
245-
"andi %0, %1, 8\n" \
246-
"csrs mstatus, %0" \
247-
: "=&r" (_temp_mstatus) \
248-
: "r" (interrupt_save) \
249-
: "memory"); \
250+
unsigned long _temp_mstatus; \
251+
__asm__ volatile( \
252+
"csrc mstatus, 8\n" \
253+
"andi %0, %1, 8\n" \
254+
"csrs mstatus, %0" \
255+
: "=&r" (_temp_mstatus) \
256+
: "r" (interrupt_save) \
257+
: "memory"); \
250258
}
251259

252260
#else
@@ -271,11 +279,13 @@ typedef unsigned short USHORT;
271279

272280
/* Define the version ID of ThreadX. This may be utilized by the application. */
273281

282+
#ifndef __ASSEMBLER__
274283
#ifdef TX_THREAD_INIT
275284
CHAR _tx_version_id[] =
276285
"Copyright (c) 2024 Microsoft Corporation. * ThreadX RISC-V32/GNU Version 6.4.2 *";
277286
#else
278287
extern CHAR _tx_version_id[];
279-
#endif /* TX_THREAD_INIT */
280-
#endif /* __ASSEMBLER__ */
281-
#endif /* TX_PORT_H */
288+
#endif /* TX_THREAD_INIT */
289+
#endif /* __ASSEMBLER__ */
290+
291+
#endif /* TX_PORT_H */

0 commit comments

Comments
 (0)