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