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 
24 
25 /* Include necessary system files.  */
26 
27 #include "tx_api.h"
28 #include "tx_trace.h"
29 
30 /* Determine if in-line initialization is required.  */
31 #ifdef TX_INLINE_INITIALIZATION
32 #define TX_INVOKE_INLINE_INITIALIZATION
33 #endif
34 
35 #include "tx_initialize.h"
36 #include "tx_thread.h"
37 #include "tx_timer.h"
38 #include "tx_semaphore.h"
39 #include "tx_queue.h"
40 #include "tx_event_flags.h"
41 #include "tx_mutex.h"
42 #include "tx_block_pool.h"
43 #include "tx_byte_pool.h"
44 
45 
46 /* Define the unused memory pointer.  The value of the first available
47    memory address is placed in this variable in the low-level
48    initialization function.  The content of this variable is passed
49    to the application's system definition function.  */
50 
51 VOID     *_tx_initialize_unused_memory;
52 
53 
54 /**************************************************************************/
55 /*                                                                        */
56 /*  FUNCTION                                               RELEASE        */
57 /*                                                                        */
58 /*    _tx_initialize_high_level                           PORTABLE C      */
59 /*                                                           6.1          */
60 /*  AUTHOR                                                                */
61 /*                                                                        */
62 /*    William E. Lamie, Microsoft Corporation                             */
63 /*                                                                        */
64 /*  DESCRIPTION                                                           */
65 /*                                                                        */
66 /*    This function is responsible for initializing all of the other      */
67 /*    components in the ThreadX real-time kernel.                         */
68 /*                                                                        */
69 /*  INPUT                                                                 */
70 /*                                                                        */
71 /*    None                                                                */
72 /*                                                                        */
73 /*  OUTPUT                                                                */
74 /*                                                                        */
75 /*    None                                                                */
76 /*                                                                        */
77 /*  CALLS                                                                 */
78 /*                                                                        */
79 /*    _tx_thread_initialize             Initialize the thread control     */
80 /*                                        component                       */
81 /*    _tx_timer_initialize              Initialize the timer control      */
82 /*                                        component                       */
83 /*    _tx_semaphore_initialize          Initialize the semaphore control  */
84 /*                                        component                       */
85 /*    _tx_queue_initialize              Initialize the queue control      */
86 /*                                        component                       */
87 /*    _tx_event_flags_initialize        Initialize the event flags control*/
88 /*                                        component                       */
89 /*    _tx_block_pool_initialize         Initialize the block pool control */
90 /*                                        component                       */
91 /*    _tx_byte_pool_initialize          Initialize the byte pool control  */
92 /*                                        component                       */
93 /*    _tx_mutex_initialize              Initialize the mutex control      */
94 /*                                        component                       */
95 /*                                                                        */
96 /*  CALLED BY                                                             */
97 /*                                                                        */
98 /*    _tx_initialize_kernel_enter       Kernel entry function             */
99 /*    _tx_initialize_kernel_setup       Early kernel setup function that  */
100 /*                                        is optionally called by         */
101 /*                                        compiler's startup code.        */
102 /*                                                                        */
103 /*  RELEASE HISTORY                                                       */
104 /*                                                                        */
105 /*    DATE              NAME                      DESCRIPTION             */
106 /*                                                                        */
107 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
108 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
109 /*                                            resulting in version 6.1    */
110 /*                                                                        */
111 /**************************************************************************/
_tx_initialize_high_level(VOID)112 VOID    _tx_initialize_high_level(VOID)
113 {
114 
115     /* Initialize event tracing, if enabled.  */
116     TX_TRACE_INITIALIZE
117 
118     /* Initialize the event log, if enabled.  */
119     TX_EL_INITIALIZE
120 
121     /* Call the thread control initialization function.  */
122     _tx_thread_initialize();
123 
124 #ifndef TX_NO_TIMER
125 
126     /* Call the timer control initialization function.  */
127     _tx_timer_initialize();
128 #endif
129 
130 #ifndef TX_DISABLE_REDUNDANT_CLEARING
131 
132     /* Call the semaphore initialization function.  */
133     _tx_semaphore_initialize();
134 
135     /* Call the queue initialization function.  */
136     _tx_queue_initialize();
137 
138     /* Call the event flag initialization function.  */
139     _tx_event_flags_initialize();
140 
141     /* Call the block pool initialization function.  */
142     _tx_block_pool_initialize();
143 
144     /* Call the byte pool initialization function.  */
145     _tx_byte_pool_initialize();
146 
147     /* Call the mutex initialization function.  */
148     _tx_mutex_initialize();
149 #endif
150 }
151 
152