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 
23 #define TX_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 C      */
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_initialize_low_level          Low-level initialization          */
61 /*    _tx_initialize_high_level         High-level initialization         */
62 /*                                                                        */
63 /*  CALLED BY                                                             */
64 /*                                                                        */
65 /*    startup code                      Compiler startup code             */
66 /*                                                                        */
67 /*  RELEASE HISTORY                                                       */
68 /*                                                                        */
69 /*    DATE              NAME                      DESCRIPTION             */
70 /*                                                                        */
71 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
72 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
73 /*                                            resulting in 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_system_state =  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     /* Invoke the high-level initialization to exercise all of the
92        ThreadX components and the application's initialization
93        function.  */
94     _tx_initialize_high_level();
95 
96     /* Call any port specific post-processing.  */
97     TX_PORT_SPECIFIC_POST_INITIALIZATION
98 
99     /* Set the system state to indicate initialization is almost done.  */
100     _tx_thread_system_state =  TX_INITIALIZE_ALMOST_DONE;
101 }
102 
103