1;/**************************************************************************/
2;/*                                                                        */
3;/*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4;/*                                                                        */
5;/*       This software is licensed under the Microsoft Software License   */
6;/*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7;/*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8;/*       and in the root directory of this software.                      */
9;/*                                                                        */
10;/**************************************************************************/
11;
12;
13;/**************************************************************************/
14;/**************************************************************************/
15;/**                                                                       */
16;/** ThreadX Component                                                     */
17;/**                                                                       */
18;/**   Initialize                                                          */
19;/**                                                                       */
20;/**************************************************************************/
21;/**************************************************************************/
22#ifdef TX_INCLUDE_USER_DEFINE_FILE
23#include "tx_user.h"
24#endif
25
26;/**************************************************************************/
27;/*                                                                        */
28;/*  FUNCTION                                               RELEASE        */
29;/*                                                                        */
30;/*    _tx_initialize_fast_interrupt_setup               ARC_HS/MetaWare   */
31;/*                                                           6.2.1        */
32;/*  AUTHOR                                                                */
33;/*                                                                        */
34;/*    William E. Lamie, Microsoft Corporation                             */
35;/*                                                                        */
36;/*  DESCRIPTION                                                           */
37;/*                                                                        */
38;/*    This function initializes register bank 1 for fast interrupt use.   */
39;/*    The initialization includes setting the stack pointer to the value  */
40;/*    supplied by the caller.                                             */
41;/*                                                                        */
42;/*  INPUT                                                                 */
43;/*                                                                        */
44;/*    stack_ptr                             Pointer to stack for bank 1   */
45;/*                                                                        */
46;/*  OUTPUT                                                                */
47;/*                                                                        */
48;/*    None                                                                */
49;/*                                                                        */
50;/*  CALLS                                                                 */
51;/*                                                                        */
52;/*    None                                                                */
53;/*                                                                        */
54;/*  CALLED BY                                                             */
55;/*                                                                        */
56;/*    Application                                                         */
57;/*                                                                        */
58;/*  RELEASE HISTORY                                                       */
59;/*                                                                        */
60;/*    DATE              NAME                      DESCRIPTION             */
61;/*                                                                        */
62;/*  09-30-2020     William E. Lamie         Initial Version 6.1           */
63;/*  03-08-2023     Cindy Deng               Modified comment(s), added    */
64;/*                                            #include tx_user.h,         */
65;/*                                            resulting in version 6.2.1  */
66;/*                                                                        */
67;/**************************************************************************/
68;VOID   _tx_initialize_fast_interrupt_setup(VOID *stack_ptr)
69;{
70    .global _tx_initialize_fast_interrupt_setup
71    .type   _tx_initialize_fast_interrupt_setup, @function
72_tx_initialize_fast_interrupt_setup:
73;
74;  /* Assume this routine is being called from initialization, with interrupts
75;     disabled and from register bank 0. Also assume that the stack pointer
76;     input is valid, i.e., there is no error checking on the validity of
77;     register_bank.  */
78;
79    sub     sp, sp, 8                                   ; Build a small stack frame to hold the setup information
80    st      gp, [sp, 0]                                 ; Save gp in the frame
81    st      r0, [sp, 4]                                 ; Save sp in the frame
82    mov     ilink, sp                                   ; Move the stack frame into ilink
83    mov     r1, 1                                       ; Select register bank 1
84    asl     r2, r1, 16                                  ; Move the register bank bits over to proper location
85    lr      r3, [status32]                              ; Pickup status32 register
86    or      r3, r3, r2                                  ; Build new status32 register
87    kflag   r3                                          ; Move to the hardware register bank
88    mov     r0, ilink                                   ; Place stack pointer in r0
89    ld      sp, [r0, 4]                                 ; Setup stack pointer for this hardware register bank
90    mov     fp, 0                                       ; Setup fp
91    ld      gp, [r0, 0]                                 ; Setup gp
92    mov     blink, 0                                    ; Setup blink
93    mov     r0, 0                                       ; Clear r0
94    sub     sp, sp, 8                                   ; Reserve space for saving ilink and status32.p0 on thread preemption
95    lr      r3, [status32]                              ; Pickup status32 register
96    bclr    r3, r3, 16                                  ; Build register bank 0 value
97    bclr    r3, r3, 17                                  ;
98    bclr    r3, r3, 18                                  ;
99    kflag   r3                                          ; Move back to register bank 0
100    j_s.d   [blink]                                     ; Return to caller
101    add     sp, sp, 8                                   ;
102;}
103    .end
104