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 /**   Thread - High Level SMP Support                                     */
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_timer.h"
31 #include "tx_thread.h"
32 
33 
34 
35 /**************************************************************************/
36 /*                                                                        */
37 /*  FUNCTION                                               RELEASE        */
38 /*                                                                        */
39 /*    _tx_thread_smp_current_state_set                   PORTABLE SMP     */
40 /*                                                           6.1          */
41 /*  AUTHOR                                                                */
42 /*                                                                        */
43 /*    William E. Lamie, Microsoft Corporation                             */
44 /*                                                                        */
45 /*  DESCRIPTION                                                           */
46 /*                                                                        */
47 /*    This function is sets the current state to all of the cores.        */
48 /*                                                                        */
49 /*  INPUT                                                                 */
50 /*                                                                        */
51 /*    new_state                             New per-system state          */
52 /*                                                                        */
53 /*  OUTPUT                                                                */
54 /*                                                                        */
55 /*    None                                                                */
56 /*                                                                        */
57 /*  CALLS                                                                 */
58 /*                                                                        */
59 /*    None                                                                */
60 /*                                                                        */
61 /*  CALLED BY                                                             */
62 /*                                                                        */
63 /*    _tx_initialize_kernel_enter           ThreadX entry                 */
64 /*                                                                        */
65 /*  RELEASE HISTORY                                                       */
66 /*                                                                        */
67 /*    DATE              NAME                      DESCRIPTION             */
68 /*                                                                        */
69 /*  09-30-2020     William E. Lamie         Initial Version 6.1           */
70 /*                                                                        */
71 /**************************************************************************/
_tx_thread_smp_current_state_set(ULONG new_state)72 void  _tx_thread_smp_current_state_set(ULONG new_state)
73 {
74 
75 UINT    i;
76 
77     /* Initialize the state for each to initialization.  */
78     i =  ((UINT) (TX_THREAD_SMP_MAX_CORES-1));
79     do
80     {
81 
82         /* Set this core's state.  */
83         _tx_thread_system_state[i] =  new_state;
84 
85         if (i == ((UINT) 0))
86         {
87 
88             /* We are finished, exit the loop.  */
89             break;
90         }
91         else
92         {
93 
94             /* Decrement the index.  */
95             i--;
96         }
97     } while (TX_LOOP_FOREVER);
98 }
99 
100