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                             RXv1/IAR       */
33;/*                                                           6.1.11       */
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;/*  08-02-2021     William E. Lamie         Initial Version 6.1.8         */
67;/*  10-15-2021     William E. Lamie         Modified comment(s),          */
68;/*                                            resulting in version 6.1.9  */
69;/*  01-31-2022     William E. Lamie         Modified comment(s),          */
70;/*                                            resulting in version 6.1.10 */
71;/*  04-25-2022     William E. Lamie         Modified comment(s),          */
72;/*                                            resulting in version 6.1.11 */
73;/*                                                                        */
74;/**************************************************************************/
75    public __tx_initialize_low_level
76
77__tx_initialize_low_level:
78
79;    /* Save the first available memory address.  */
80;    _tx_initialize_unused_memory =  (VOID_PTR) &free_mem_start;
81;
82    MOV.L    #__tx_free_memory_start, R1        ; Pickup unused memory address
83    MOV.L    #__tx_initialize_unused_memory,R2
84    MOV.L    R1,[R2]                            ; Save first free memory address
85
86;   /* Set priority of SWINT to 1. */
87    MOV.L    #0x87303, r1
88    MOV.L    #1, r2
89    MOV.B    r2, [r1]
90
91;   /* Enable SWINT. */
92    MOV.L    #0x87203, r1
93    MOV.B    [r1], r2
94    OR       #(1 << 3), r2
95    MOV.B    r2, [r1]
96
97    RTS
98
99    section FREEMEM:DATA
100    public __tx_free_memory_start
101__tx_free_memory_start
102    DS32    4
103
104    END
105