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_thread.h" 28 #include "tx_timer.h" 29 #include "txm_module.h" 30 31 32 /**************************************************************************/ 33 /* */ 34 /* FUNCTION RELEASE */ 35 /* */ 36 /* _txm_module_manager_timer_notify_trampoline PORTABLE C */ 37 /* 6.1 */ 38 /* AUTHOR */ 39 /* */ 40 /* Scott Larson, Microsoft Corporation */ 41 /* */ 42 /* DESCRIPTION */ 43 /* */ 44 /* This function processes the timer expirations from ThreadX. */ 45 /* */ 46 /* INPUT */ 47 /* */ 48 /* id Timer ID */ 49 /* */ 50 /* OUTPUT */ 51 /* */ 52 /* None */ 53 /* */ 54 /* CALLS */ 55 /* */ 56 /* _txm_module_manager_callback_request Send module callback request */ 57 /* */ 58 /* CALLED BY */ 59 /* */ 60 /* ThreadX */ 61 /* */ 62 /* RELEASE HISTORY */ 63 /* */ 64 /* DATE NAME DESCRIPTION */ 65 /* */ 66 /* 09-30-2020 Scott Larson Initial Version 6.1 */ 67 /* */ 68 /**************************************************************************/ _txm_module_manager_timer_notify_trampoline(ULONG id)69VOID _txm_module_manager_timer_notify_trampoline(ULONG id) 70 { 71 72 TX_INTERRUPT_SAVE_AREA 73 74 TXM_MODULE_INSTANCE *module_instance; 75 TXM_MODULE_CALLBACK_MESSAGE callback_message; 76 TX_QUEUE *module_callback_queue; 77 TX_TIMER *timer_ptr; 78 CHAR *internal_ptr; 79 80 81 /* We now know the callback is for a module. */ 82 83 /* Disable interrupts. */ 84 TX_DISABLE 85 86 /* Our expired timer pointer points to the internal timer, 87 * we need to get to the full timer pointer. */ 88 /* Pickup the current internal timer pointer. */ 89 internal_ptr = (CHAR *) _tx_timer_expired_timer_ptr; 90 91 /* Get the timer pointer from the internal pointer. */ 92 TX_USER_TIMER_POINTER_GET((TX_TIMER_INTERNAL *) internal_ptr, timer_ptr); 93 94 /* Pickup the module instance pointer. */ 95 module_instance = (TXM_MODULE_INSTANCE *) timer_ptr -> tx_timer_module_instance; 96 97 /* Determine if this module is still valid. */ 98 if ((module_instance) && (module_instance -> txm_module_instance_id == TXM_MODULE_ID) && 99 (module_instance -> txm_module_instance_state == TXM_MODULE_STARTED)) 100 { 101 102 /* Yes, the module is still valid. */ 103 104 /* Pickup the module's callback message queue. */ 105 module_callback_queue = &(module_instance -> txm_module_instance_callback_request_queue); 106 107 /* Build the queue notification message. */ 108 callback_message.txm_module_callback_message_type = TXM_TIMER_CALLBACK; 109 callback_message.txm_module_callback_message_activation_count = 1; 110 callback_message.txm_module_callback_message_application_function = (VOID (*)(VOID)) timer_ptr -> tx_timer_module_expiration_function; 111 callback_message.txm_module_callback_message_param_1 = (ULONG) id; 112 callback_message.txm_module_callback_message_param_2 = 0; 113 callback_message.txm_module_callback_message_param_3 = 0; 114 callback_message.txm_module_callback_message_param_4 = 0; 115 callback_message.txm_module_callback_message_param_5 = 0; 116 callback_message.txm_module_callback_message_param_6 = 0; 117 callback_message.txm_module_callback_message_param_7 = 0; 118 callback_message.txm_module_callback_message_param_8 = 0; 119 callback_message.txm_module_callback_message_reserved1 = 0; 120 callback_message.txm_module_callback_message_reserved2 = 0; 121 122 /* Restore interrupts. */ 123 TX_RESTORE 124 125 /* Call the general processing that will place the callback on the 126 module's callback request queue. */ 127 _txm_module_manager_callback_request(module_callback_queue, &callback_message); 128 } 129 else 130 { 131 132 /* Module no longer valid. */ 133 134 /* Error, increment the error counter and return. */ 135 _txm_module_manager_callback_error_count++; 136 137 /* Restore interrupts. */ 138 TX_RESTORE 139 } 140 } 141 142