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