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 #define TX_SOURCE_CODE
23 #define TX_THREAD_SMP_SOURCE_CODE
24 
25 
26 /* Include necessary system files.  */
27 
28 #include "tx_api.h"
29 #include "tx_initialize.h"
30 #include "tx_thread.h"
31 
32 
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _tx_initialize_kernel_setup                        PORTABLE SMP     */
38 /*                                                           6.1          */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    William E. Lamie, Microsoft Corporation                             */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    This function is called by the compiler's startup code to make      */
46 /*    ThreadX objects accessible to the compiler's library.  If this      */
47 /*    function is not called by the compiler, all ThreadX initialization  */
48 /*    takes place from the kernel enter function defined previously.      */
49 /*                                                                        */
50 /*  INPUT                                                                 */
51 /*                                                                        */
52 /*    None                                                                */
53 /*                                                                        */
54 /*  OUTPUT                                                                */
55 /*                                                                        */
56 /*    None                                                                */
57 /*                                                                        */
58 /*  CALLS                                                                 */
59 /*                                                                        */
60 /*    _tx_thread_smp_high_level_initialize  SMP initialization            */
61 /*    _tx_thread_smp_current_state_set  Set system state for all cores    */
62 /*    _tx_initialize_low_level          Low-level initialization          */
63 /*    _tx_initialize_high_level         High-level initialization         */
64 /*                                                                        */
65 /*  CALLED BY                                                             */
66 /*                                                                        */
67 /*    startup code                      Compiler startup code             */
68 /*                                                                        */
69 /*  RELEASE HISTORY                                                       */
70 /*                                                                        */
71 /*    DATE              NAME                      DESCRIPTION             */
72 /*                                                                        */
73 /*  09-30-2020     William E. Lamie         Initial Version 6.1           */
74 /*                                                                        */
75 /**************************************************************************/
_tx_initialize_kernel_setup(VOID)76 VOID  _tx_initialize_kernel_setup(VOID)
77 {
78 
79     /* Ensure that the system state variable is set to indicate
80        initialization is in progress.  Note that this variable is
81        later used to represent interrupt nesting.  */
82     _tx_thread_smp_current_state_set(TX_INITIALIZE_IN_PROGRESS);
83 
84     /* Call any port specific preprocessing.  */
85     TX_PORT_SPECIFIC_PRE_INITIALIZATION
86 
87     /* Invoke the low-level initialization to handle all processor specific
88        initialization issues.  */
89     _tx_initialize_low_level();
90 
91     /* Call the high-level SMP  Initialization.  */
92     _tx_thread_smp_high_level_initialize();
93 
94     /* Invoke the high-level initialization to exercise all of the
95        ThreadX components and the application's initialization
96        function.  */
97     _tx_initialize_high_level();
98 
99     /* Call any port specific post-processing.  */
100     TX_PORT_SPECIFIC_POST_INITIALIZATION
101 
102     /* Set the system state to indicate initialization is almost done.  */
103     _tx_thread_system_state[0] =  TX_INITIALIZE_ALMOST_DONE;
104 }
105 
106