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 #include "tx_api.h" 26 #include "tx_queue.h" 27 #include "tx_thread.h" 28 #include "txm_module.h" 29 30 #ifndef TX_DISABLE_NOTIFY_CALLBACKS 31 /**************************************************************************/ 32 /* */ 33 /* FUNCTION RELEASE */ 34 /* */ 35 /* _txm_module_manager_thread_notify_trampoline PORTABLE C */ 36 /* 6.1 */ 37 /* AUTHOR */ 38 /* */ 39 /* Scott Larson, Microsoft Corporation */ 40 /* */ 41 /* DESCRIPTION */ 42 /* */ 43 /* This function processes the thread entry/exit notification call */ 44 /* from ThreadX. */ 45 /* */ 46 /* INPUT */ 47 /* */ 48 /* thread_ptr Thread pointer */ 49 /* type Entry or exit type */ 50 /* */ 51 /* OUTPUT */ 52 /* */ 53 /* None */ 54 /* */ 55 /* CALLS */ 56 /* */ 57 /* _txm_module_manager_callback_request Send module callback request */ 58 /* */ 59 /* CALLED BY */ 60 /* */ 61 /* ThreadX */ 62 /* */ 63 /* RELEASE HISTORY */ 64 /* */ 65 /* DATE NAME DESCRIPTION */ 66 /* */ 67 /* 09-30-2020 Scott Larson Initial Version 6.1 */ 68 /* */ 69 /**************************************************************************/ _txm_module_manager_thread_notify_trampoline(TX_THREAD * thread_ptr,UINT type)70VOID _txm_module_manager_thread_notify_trampoline(TX_THREAD *thread_ptr, UINT type) 71 { 72 73 TX_INTERRUPT_SAVE_AREA 74 75 TXM_MODULE_INSTANCE *module_instance; 76 TXM_MODULE_CALLBACK_MESSAGE callback_message; 77 TX_QUEUE *module_callback_queue; 78 TXM_MODULE_THREAD_ENTRY_INFO *thread_info; 79 80 81 /* We now know the callback is for a module. */ 82 83 /* Disable interrupts. */ 84 TX_DISABLE 85 86 /* Determine if the thread is valid. */ 87 if ((thread_ptr) && (thread_ptr -> tx_thread_id == TX_THREAD_ID)) 88 { 89 90 /* Pickup the module instance pointer. */ 91 module_instance = (TXM_MODULE_INSTANCE *) thread_ptr -> tx_thread_module_instance_ptr; 92 93 /* Pickup the module's thread pointer. */ 94 thread_info = (TXM_MODULE_THREAD_ENTRY_INFO *) thread_ptr -> tx_thread_module_entry_info_ptr; 95 96 /* Determine if this module is still valid. */ 97 if ((module_instance) && (module_instance -> txm_module_instance_id == TXM_MODULE_ID) && 98 (module_instance -> txm_module_instance_state == TXM_MODULE_STARTED)) 99 { 100 101 /* Yes, the module is still valid. */ 102 103 /* Pickup the module's callback message queue. */ 104 module_callback_queue = &(module_instance -> txm_module_instance_callback_request_queue); 105 106 /* Build the queue notification message. */ 107 callback_message.txm_module_callback_message_type = TXM_THREAD_ENTRY_EXIT_CALLBACK; 108 callback_message.txm_module_callback_message_activation_count = 1; 109 callback_message.txm_module_callback_message_application_function = (VOID (*)(VOID)) thread_info -> txm_module_thread_entry_info_exit_notify; 110 callback_message.txm_module_callback_message_param_1 = (ALIGN_TYPE) thread_ptr; 111 callback_message.txm_module_callback_message_param_2 = (ALIGN_TYPE) type; 112 callback_message.txm_module_callback_message_param_3 = 0; 113 callback_message.txm_module_callback_message_param_4 = 0; 114 callback_message.txm_module_callback_message_param_5 = 0; 115 callback_message.txm_module_callback_message_param_6 = 0; 116 callback_message.txm_module_callback_message_param_7 = 0; 117 callback_message.txm_module_callback_message_param_8 = 0; 118 callback_message.txm_module_callback_message_reserved1 = 0; 119 callback_message.txm_module_callback_message_reserved2 = 0; 120 121 /* Restore interrupts. */ 122 TX_RESTORE 123 124 /* Call the general processing that will place the callback on the 125 module's callback request queue. */ 126 _txm_module_manager_callback_request(module_callback_queue, &callback_message); 127 } 128 else 129 { 130 131 /* Module no longer valid. */ 132 133 /* Error, increment the error counter and return. */ 134 _txm_module_manager_callback_error_count++; 135 136 /* Restore interrupts. */ 137 TX_RESTORE 138 } 139 } 140 else 141 { 142 143 /* Thread pointer is not valid. */ 144 145 /* Error, increment the error counter and return. */ 146 _txm_module_manager_callback_error_count++; 147 148 /* Restore interrupts. */ 149 TX_RESTORE 150 } 151 } 152 #endif 153 154