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 /**   Module Manager                                                      */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 #define TX_SOURCE_CODE
24 
25 
26 #include "tx_api.h"
27 #include "tx_event_flags.h"
28 #include "tx_thread.h"
29 #include "txm_module.h"
30 
31 
32 #ifndef TX_DISABLE_NOTIFY_CALLBACKS
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _txm_module_manager_event_flags_notify_trampoline   PORTABLE C      */
38 /*                                                           6.1          */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Scott Larson, Microsoft Corporation                                 */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    This function processes the event flags set notification call from  */
46 /*    ThreadX.                                                            */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    group_ptr                         Event flags group pointer         */
51 /*                                                                        */
52 /*  OUTPUT                                                                */
53 /*                                                                        */
54 /*    None                                                                */
55 /*                                                                        */
56 /*  CALLS                                                                 */
57 /*                                                                        */
58 /*    _txm_module_manager_callback_request  Send module callback request  */
59 /*                                                                        */
60 /*  CALLED BY                                                             */
61 /*                                                                        */
62 /*    ThreadX                                                             */
63 /*                                                                        */
64 /*  RELEASE HISTORY                                                       */
65 /*                                                                        */
66 /*    DATE              NAME                      DESCRIPTION             */
67 /*                                                                        */
68 /*  09-30-2020      Scott Larson            Initial Version 6.1           */
69 /*                                                                        */
70 /**************************************************************************/
_txm_module_manager_event_flags_notify_trampoline(TX_EVENT_FLAGS_GROUP * group_ptr)71 VOID  _txm_module_manager_event_flags_notify_trampoline(TX_EVENT_FLAGS_GROUP *group_ptr)
72 {
73 
74 TX_INTERRUPT_SAVE_AREA
75 
76 TXM_MODULE_INSTANCE         *module_instance;
77 TXM_MODULE_CALLBACK_MESSAGE  callback_message;
78 TX_QUEUE                    *module_callback_queue;
79 
80 
81     /* We now know the callback is for a module.  */
82 
83     /* Disable interrupts.  */
84     TX_DISABLE
85 
86     /* Pickup the module instance pointer.  */
87     module_instance =  (TXM_MODULE_INSTANCE *) group_ptr -> tx_event_flags_group_module_instance;
88 
89     /* Determine if this module is still valid.  */
90     if ((module_instance) && (module_instance -> txm_module_instance_id == TXM_MODULE_ID) &&
91         (module_instance -> txm_module_instance_state == TXM_MODULE_STARTED))
92     {
93 
94         /* Yes, the module is still valid.  */
95 
96         /* Pickup the module's callback message queue.  */
97         module_callback_queue =  &(module_instance -> txm_module_instance_callback_request_queue);
98 
99         /* Build the queue notification message.  */
100         callback_message.txm_module_callback_message_type =                  TXM_EVENTS_SET_CALLBACK;
101         callback_message.txm_module_callback_message_activation_count =      1;
102         callback_message.txm_module_callback_message_application_function =  (VOID (*)(VOID)) group_ptr -> tx_event_flags_group_set_module_notify;
103         callback_message.txm_module_callback_message_param_1 =               (ALIGN_TYPE) group_ptr;
104         callback_message.txm_module_callback_message_param_2 =               0;
105         callback_message.txm_module_callback_message_param_3 =               0;
106         callback_message.txm_module_callback_message_param_4 =               0;
107         callback_message.txm_module_callback_message_param_5 =               0;
108         callback_message.txm_module_callback_message_param_6 =               0;
109         callback_message.txm_module_callback_message_param_7 =               0;
110         callback_message.txm_module_callback_message_param_8 =               0;
111         callback_message.txm_module_callback_message_reserved1 =             0;
112         callback_message.txm_module_callback_message_reserved2 =             0;
113 
114         /* Restore interrupts.  */
115         TX_RESTORE
116 
117         /* Call the general processing that will place the callback on the
118            module's callback request queue.  */
119         _txm_module_manager_callback_request(module_callback_queue, &callback_message);
120     }
121     else
122     {
123 
124         /* Module no longer valid.  */
125 
126         /* Error, increment the error counter and return.  */
127         _txm_module_manager_callback_error_count++;
128 
129         /* Restore interrupts.  */
130         TX_RESTORE
131     }
132 }
133 #endif
134