summaryrefslogtreecommitdiff
path: root/ports/risc-v32/gnu/src/tx_thread_interrupt_control.S
diff options
context:
space:
mode:
authorAkif Ejaz <[email protected]>2026-02-16 17:15:13 +0500
committerAkif Ejaz <[email protected]>2026-02-16 17:15:13 +0500
commit757db54d6d10edc655eee9cfe02ecd4d93be5fed (patch)
tree7f24c611a56c57328dafed7f81edf64e250f911f /ports/risc-v32/gnu/src/tx_thread_interrupt_control.S
parentc4ad279b85fcf836c0b42d3e140fc32f0554e7b5 (diff)
Add RISC-V32 arch. port layer
This update adapts the ThreadX low-level kernel routines for RV32, including: - startup and initialization logic - context save/restore implementations - interrupt control and scheduler entry - thread stack build and system return paths - timer interrupt handling - made it complient as per new risc-v64/gnu & threadx style - added reademe for risc-v32/gnu port These changes provide full low-level support needed to run ThreadX on RISC-V32 targets. Signed-off-by: Akif Ejaz <[email protected]>
Diffstat (limited to 'ports/risc-v32/gnu/src/tx_thread_interrupt_control.S')
-rw-r--r--ports/risc-v32/gnu/src/tx_thread_interrupt_control.S94
1 files changed, 94 insertions, 0 deletions
diff --git a/ports/risc-v32/gnu/src/tx_thread_interrupt_control.S b/ports/risc-v32/gnu/src/tx_thread_interrupt_control.S
new file mode 100644
index 00000000..8e28cf74
--- /dev/null
+++ b/ports/risc-v32/gnu/src/tx_thread_interrupt_control.S
@@ -0,0 +1,94 @@
+/***************************************************************************
+ * Copyright (c) 2025 10xEngineers
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the MIT License which is available at
+ * https://opensource.org/licenses/MIT.
+ *
+ * SPDX-License-Identifier: MIT
+ **************************************************************************/
+
+
+/**************************************************************************/
+/**************************************************************************/
+/** */
+/** ThreadX Component */
+/** */
+/** Thread */
+/** */
+/**************************************************************************/
+/**************************************************************************/
+
+
+ .section .text
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _tx_thread_interrupt_control RISC-V32/GNU */
+/* 6.4.x */
+/* AUTHOR */
+/* */
+/* Akif Ejaz, 10xEngineers */
+/* */
+/* DESCRIPTION */
+/* */
+/* This function is responsible for changing the interrupt lockout */
+/* posture of the system. */
+/* */
+/* INPUT */
+/* */
+/* new_posture New interrupt lockout posture */
+/* */
+/* OUTPUT */
+/* */
+/* old_posture Old interrupt lockout posture */
+/* */
+/* CALLS */
+/* */
+/* None */
+/* */
+/* CALLED BY */
+/* */
+/* Application Code */
+/* */
+/* RELEASE HISTORY */
+/* */
+/* DATE NAME DESCRIPTION */
+/* */
+/* 23-12-2025 Akif Ejaz Initial Version 6.4.x */
+/* */
+/**************************************************************************/
+/* UINT _tx_thread_interrupt_control(UINT new_posture)
+{ */
+ .global _tx_thread_interrupt_control
+_tx_thread_interrupt_control:
+
+ /* Pickup current interrupt posture. */
+
+ csrr a1, mstatus // Pickup mstatus
+ andi a1, a1, 0x08 // Mask out all but MIE
+
+ /* Check for the new posture. */
+
+ beqz a0, _tx_thread_interrupt_disable // If 0, disable interrupts
+
+ /* Enable interrupts. */
+
+ csrsi mstatus, 0x08 // Enable interrupts (MIE bit 3)
+ j _tx_thread_interrupt_control_exit // Return to caller
+
+_tx_thread_interrupt_disable:
+
+ /* Disable interrupts. */
+
+ csrci mstatus, 0x08 // Disable interrupts (MIE bit 3)
+
+_tx_thread_interrupt_control_exit:
+
+ /* Return the old interrupt posture. */
+
+ mv a0, a1 // Setup return value
+ ret // Return to caller
+
+/* } */