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;
22
23    extern __tx_initialize_unused_memory
24
25    section .text:CODE:ROOT
26
27;
28;/**************************************************************************/
29;/*                                                                        */
30;/*  FUNCTION                                               RELEASE        */
31;/*                                                                        */
32;/*    _tx_initialize_low_level                             RXv2/IAR       */
33;/*                                                           6.1.10       */
34;/*  AUTHOR                                                                */
35;/*                                                                        */
36;/*    William E. Lamie, Microsoft Corporation                             */
37;/*                                                                        */
38;/*  DESCRIPTION                                                           */
39;/*                                                                        */
40;/*    This function is responsible for any low-level processor            */
41;/*    initialization, including setting up interrupt vectors, setting     */
42;/*    up a periodic timer interrupt source, saving the system stack       */
43;/*    pointer for use in ISR processing later, and finding the first      */
44;/*    available RAM memory address for tx_application_define.             */
45;/*                                                                        */
46;/*  INPUT                                                                 */
47;/*                                                                        */
48;/*    None                                                                */
49;/*                                                                        */
50;/*  OUTPUT                                                                */
51;/*                                                                        */
52;/*    None                                                                */
53;/*                                                                        */
54;/*  CALLS                                                                 */
55;/*                                                                        */
56;/*    None                                                                */
57;/*                                                                        */
58;/*  CALLED BY                                                             */
59;/*                                                                        */
60;/*    _tx_initialize_kernel_enter           ThreadX entry function        */
61;/*                                                                        */
62;/*  RELEASE HISTORY                                                       */
63;/*                                                                        */
64;/*    DATE              NAME                      DESCRIPTION             */
65;/*                                                                        */
66;/*  01-31-2022     William E. Lamie         Initial Version 6.1.10        */
67;/*                                                                        */
68;/**************************************************************************/
69    public __tx_initialize_low_level
70
71__tx_initialize_low_level:
72
73;    /* Save the first available memory address.  */
74;    _tx_initialize_unused_memory =  (VOID_PTR) &free_mem_start;
75;
76    MOV.L    #__tx_free_memory_start, R1        ; Pickup unused memory address
77    MOV.L    #__tx_initialize_unused_memory,R2
78    MOV.L    R1,[R2]                            ; Save first free memory address
79
80;   /* Set priority of SWINT to 1. */
81    MOV.L    #0x87303, r1
82    MOV.L    #1, r2
83    MOV.B    r2, [r1]
84
85;   /* Enable SWINT. */
86    MOV.L    #0x87203, r1
87    MOV.B    [r1], r2
88    OR       #(1 << 3), r2
89    MOV.B    r2, [r1]
90
91    RTS
92
93    section FREEMEM:DATA
94    public __tx_free_memory_start
95__tx_free_memory_start
96    DS32    4
97
98    END
99