;/***************************************************************************
; * Copyright (c) 2024 Microsoft Corporation
; *
; * 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                                                              */
;/**                                                                       */
;/**************************************************************************/
;/**************************************************************************/
;
;
;#define TX_SOURCE_CODE
;
;
;/* Include necessary system files.  */
;
;#include "tx_api.h"
;#include "tx_thread.h"
;#include "tx_timer.h"
;
;
SYS_MODE        DEFINE  0x1F                    ; System mode
;
;
;/**************************************************************************/
;/*                                                                        */
;/*  FUNCTION                                               RELEASE        */
;/*                                                                        */
;/*    _tx_thread_irq_nesting_start                       Cortex-R4/IAR    */
;/*                                                           6.1          */
;/*  AUTHOR                                                                */
;/*                                                                        */
;/*    William E. Lamie, Microsoft Corporation                             */
;/*                                                                        */
;/*  DESCRIPTION                                                           */
;/*                                                                        */
;/*    This function is called by the application from IRQ mode after      */
;/*    _tx_thread_context_save has been called and switches the IRQ        */
;/*    processing to the system mode so nested IRQ interrupt processing    */
;/*    is possible (system mode has its own "lr" register).  Note that     */
;/*    this function assumes that the system mode stack pointer was setup  */
;/*    during low-level initialization (tx_initialize_low_level.s).        */
;/*                                                                        */
;/*    This function returns with IRQ interrupts enabled.                  */
;/*                                                                        */
;/*  INPUT                                                                 */
;/*                                                                        */
;/*    None                                                                */
;/*                                                                        */
;/*  OUTPUT                                                                */
;/*                                                                        */
;/*    None                                                                */
;/*                                                                        */
;/*  CALLS                                                                 */
;/*                                                                        */
;/*    None                                                                */
;/*                                                                        */
;/*  CALLED BY                                                             */
;/*                                                                        */
;/*    ISRs                                                                */
;/*                                                                        */
;/**************************************************************************/
;VOID   _tx_thread_irq_nesting_start(VOID)
;{
    RSEG    .text:CODE:NOROOT(2)
    PUBLIC  _tx_thread_irq_nesting_start
    ARM
_tx_thread_irq_nesting_start
    MOV     r3, lr                              ; Save ISR return address
    CPS     #SYS_MODE                           ; Enter SYS mode
    PUSH    {lr}                                ; Save system mode lr on the system mode stack
    CPSIE   i                                   ; Enable interrupts
    MOV     pc, r3                              ; Return to ISR
;}
;
;
    END

