diff options
| author | Yuxin Zhou <[email protected]> | 2022-01-29 00:24:03 +0000 |
|---|---|---|
| committer | Yuxin Zhou <[email protected]> | 2022-01-29 00:24:03 +0000 |
| commit | f7f0957188d48ec5278107dc8fbd2de747fda1b8 (patch) | |
| tree | fee9f4baf5a6a8bb944c5de8ad10fda300027d26 /common_modules/module_manager/src/txm_module_manager_internal_load.c | |
| parent | b216ceb25e2b6ae1ea83c1ae91d114a6fc2fc4ec (diff) | |
Release 6.1.10
Diffstat (limited to 'common_modules/module_manager/src/txm_module_manager_internal_load.c')
| -rw-r--r-- | common_modules/module_manager/src/txm_module_manager_internal_load.c | 170 |
1 files changed, 85 insertions, 85 deletions
diff --git a/common_modules/module_manager/src/txm_module_manager_internal_load.c b/common_modules/module_manager/src/txm_module_manager_internal_load.c index 6b5ae54f..367b557e 100644 --- a/common_modules/module_manager/src/txm_module_manager_internal_load.c +++ b/common_modules/module_manager/src/txm_module_manager_internal_load.c @@ -10,15 +10,15 @@ /**************************************************************************/ -/**************************************************************************/ -/**************************************************************************/ -/** */ -/** ThreadX Component */ -/** */ -/** Module Manager */ -/** */ -/**************************************************************************/ -/**************************************************************************/ +/**************************************************************************/ +/**************************************************************************/ +/** */ +/** ThreadX Component */ +/** */ +/** Module Manager */ +/** */ +/**************************************************************************/ +/**************************************************************************/ #define TX_SOURCE_CODE @@ -31,49 +31,49 @@ #include "txm_module_manager_util.h" -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* _txm_module_manager_internal_load PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _txm_module_manager_internal_load PORTABLE C */ /* 6.1 */ /* AUTHOR */ /* */ /* Scott Larson, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ -/* This function allocates data memory for module and prepares the */ -/* module for execution from the supplied code location. */ -/* */ -/* INPUT */ -/* */ -/* module_instance Module instance pointer */ -/* module_name Module name pointer */ -/* module_location Module code location */ -/* code_size Module code size */ -/* code_allocation_ptr Allocated code location */ -/* code_allocation_size Allocated code size */ -/* */ -/* OUTPUT */ -/* */ -/* status Completion status */ -/* */ -/* CALLS */ -/* */ -/* _tx_byte_allocate Allocate data area */ -/* _tx_mutex_get Get protection mutex */ -/* _tx_mutex_put Release protection mutex */ -/* */ -/* CALLED BY */ -/* */ -/* Application code */ -/* */ -/* RELEASE HISTORY */ -/* */ +/* DESCRIPTION */ +/* */ +/* This function allocates data memory for module and prepares the */ +/* module for execution from the supplied code location. */ +/* */ +/* INPUT */ +/* */ +/* module_instance Module instance pointer */ +/* module_name Module name pointer */ +/* module_location Module code location */ +/* code_size Module code size */ +/* code_allocation_ptr Allocated code location */ +/* code_allocation_size Allocated code size */ +/* */ +/* OUTPUT */ +/* */ +/* status Completion status */ +/* */ +/* CALLS */ +/* */ +/* _tx_byte_allocate Allocate data area */ +/* _tx_mutex_get Get protection mutex */ +/* _tx_mutex_put Release protection mutex */ +/* */ +/* CALLED BY */ +/* */ +/* Application code */ +/* */ +/* RELEASE HISTORY */ +/* */ /* DATE NAME DESCRIPTION */ /* */ -/* 09-30-2020 Scott Larson Initial Version 6.1 */ +/* 09-30-2020 Scott Larson Initial Version 6.1 */ /* */ /**************************************************************************/ UINT _txm_module_manager_internal_load(TXM_MODULE_INSTANCE *module_instance, CHAR *module_name, VOID *module_location, @@ -81,7 +81,7 @@ UINT _txm_module_manager_internal_load(TXM_MODULE_INSTANCE *module_instance, CH { TX_INTERRUPT_SAVE_AREA - + TXM_MODULE_PREAMBLE *module_preamble; TXM_MODULE_INSTANCE *next_module, *previous_module; ULONG shell_function_adjust; @@ -104,11 +104,11 @@ UINT status; /* Check for interrupt call. */ if (TX_THREAD_GET_SYSTEM_STATE() != 0) { - + /* Now, make sure the call is from an interrupt and not initialization. */ if (TX_THREAD_GET_SYSTEM_STATE() < TX_INITIALIZE_IN_PROGRESS) { - + /* Invalid caller of this function, return appropriate error code. */ return(TX_CALLER_ERROR); } @@ -117,15 +117,15 @@ UINT status; /* Determine if the module manager has not been initialized yet. */ if (_txm_module_manager_ready != TX_TRUE) { - + /* Module manager has not been initialized. */ - return(TX_NOT_AVAILABLE); + return(TX_NOT_AVAILABLE); } /* Determine if the module is valid. */ if (module_instance == TX_NULL) { - + /* Invalid module pointer. */ return(TX_PTR_ERROR); } @@ -150,7 +150,7 @@ UINT status; /* Check to make sure there is a valid module to load. */ if (module_preamble -> txm_module_preamble_id != TXM_MODULE_ID) { - + /* Release the protection mutex. */ _tx_mutex_put(&_txm_module_manager_mutex); @@ -175,12 +175,12 @@ UINT status; /* Invalid properties. Return error. */ return(TXM_MODULE_INVALID_PROPERTIES); } - + /* Check for valid module entry offsets. */ if ((module_preamble -> txm_module_preamble_shell_entry_function == 0) || (module_preamble -> txm_module_preamble_start_function == 0)) { - + /* Release the protection mutex. */ _tx_mutex_put(&_txm_module_manager_mutex); @@ -194,7 +194,7 @@ UINT status; (module_preamble -> txm_module_preamble_start_stop_stack_size == 0) || (module_preamble -> txm_module_preamble_callback_stack_size == 0)) { - + /* Release the protection mutex. */ _tx_mutex_put(&_txm_module_manager_mutex); @@ -227,11 +227,11 @@ UINT status; /* Update the data size to account for the default thread stacks. */ TXM_MODULE_MANAGER_UTIL_MATH_ADD_ULONG(data_size, start_stop_stack_size, data_size); TXM_MODULE_MANAGER_UTIL_MATH_ADD_ULONG(data_size, callback_stack_size, data_size); - + /* Setup the default code and data alignments. */ data_alignment = (ULONG) TXM_MODULE_DATA_ALIGNMENT; - /* Get the port-specific alignment for the data size. Note we only want data + /* Get the port-specific alignment for the data size. Note we only want data so we pass values of 1 for code (to avoid any possible div by 0 errors). */ code_size_ignored = 1; code_alignment_ignored = 1; @@ -239,16 +239,16 @@ UINT status; /* Calculate the module's total RAM memory requirement. This entire area is allocated from the module manager's byte pool. The general layout is defined as follows: - + Lowest Address: Start of start/stop thread stack ... [note: thread entry info is embedded near end of stack areas] - End of start/stop thread stack - + End of start/stop thread stack + Start of callback thread stack ... [note: thread entry info is embedded near end of stack areas] - End of callback thread stack - - Module's Data Area + End of callback thread stack + + Module's Data Area ... End of Module's Data Area Highest Address: */ @@ -258,11 +258,11 @@ UINT status; /* Allocate memory for the module. */ status = _tx_byte_allocate(&_txm_module_manager_byte_pool, (VOID **) &memory_ptr, data_allocation_size, TX_NO_WAIT); - + /* Determine if the module memory allocation was successful. */ if (status) { - + /* Release the protection mutex. */ _tx_mutex_put(&_txm_module_manager_mutex); @@ -272,10 +272,10 @@ UINT status; /* Clear the allocated memory. */ TX_MEMSET(memory_ptr, ((UCHAR) 0), data_allocation_size); - + /* Disable interrupts. */ TX_DISABLE - + /* Setup the module instance structure. */ module_instance -> txm_module_instance_id = TXM_MODULE_ID; @@ -285,7 +285,7 @@ UINT status; /* Save the module properties. */ module_instance -> txm_module_instance_property_flags = module_preamble -> txm_module_preamble_property_flags; - /* Set the module data memory allocation. This is the address released + /* Set the module data memory allocation. This is the address released when the module is unloaded. */ module_instance -> txm_module_instance_data_allocation_ptr = (VOID *) memory_ptr; @@ -297,14 +297,14 @@ UINT status; data_start = (data_start + (((ALIGN_TYPE)data_alignment) - 1)) & ~(((ALIGN_TYPE)data_alignment) - 1); memory_ptr = (CHAR *) data_start; module_instance -> txm_module_instance_data_start = (VOID *) memory_ptr; - + /* Compute the end of the data memory allocation. */ module_instance -> txm_module_instance_data_end = (VOID *) (memory_ptr + (data_size - 1)); /* Save the size of the data area. */ module_instance -> txm_module_instance_data_size = data_size; - /* Set the module code memory allocation. This is the address released + /* Set the module code memory allocation. This is the address released when the module is unloaded. */ module_instance -> txm_module_instance_code_allocation_ptr = (VOID *) code_allocation_ptr; @@ -329,7 +329,7 @@ UINT status; /* Save the module application ID in the module instance. */ module_instance -> txm_module_instance_application_module_id = module_preamble -> txm_module_preamble_application_module_id; - + /* Setup the module's start/stop thread stack area. */ module_instance -> txm_module_instance_start_stop_stack_start_address = (VOID *) (memory_ptr); module_instance -> txm_module_instance_start_stop_stack_size = start_stop_stack_size; @@ -358,36 +358,36 @@ UINT status; /* Calculate the function adjustments based on the specific implementation of the module manager/module. */ TXM_MODULE_MANAGER_CALCULATE_ADJUSTMENTS(module_preamble -> txm_module_preamble_property_flags, shell_function_adjust, start_function_adjust, stop_function_adjust, callback_function_adjust) - /* Build actual addresses based on load... Setup all the function pointers. Any adjustments needed to shell entry, start function, and callback function are defined in the + /* Build actual addresses based on load... Setup all the function pointers. Any adjustments needed to shell entry, start function, and callback function are defined in the module preamble. */ - module_instance -> txm_module_instance_shell_entry_function = (VOID (*)(TX_THREAD *, TXM_MODULE_INSTANCE *)) (((CHAR *) module_instance -> txm_module_instance_code_start) + - (module_preamble -> txm_module_preamble_shell_entry_function) + + module_instance -> txm_module_instance_shell_entry_function = (VOID (*)(TX_THREAD *, TXM_MODULE_INSTANCE *)) (((CHAR *) module_instance -> txm_module_instance_code_start) + + (module_preamble -> txm_module_preamble_shell_entry_function) + (shell_function_adjust)); - module_instance -> txm_module_instance_start_thread_entry = (VOID (*)(ULONG)) (((CHAR *) module_instance -> txm_module_instance_code_start) + - (module_preamble -> txm_module_preamble_start_function) + + module_instance -> txm_module_instance_start_thread_entry = (VOID (*)(ULONG)) (((CHAR *) module_instance -> txm_module_instance_code_start) + + (module_preamble -> txm_module_preamble_start_function) + (start_function_adjust)); - module_instance -> txm_module_instance_callback_request_thread_entry = (VOID (*)(ULONG)) (((CHAR *) module_instance -> txm_module_instance_code_start) + + module_instance -> txm_module_instance_callback_request_thread_entry = (VOID (*)(ULONG)) (((CHAR *) module_instance -> txm_module_instance_code_start) + (module_preamble -> txm_module_preamble_callback_function) + - (callback_function_adjust)); + (callback_function_adjust)); /* Determine if there is a stop function for this module. */ if (module_preamble -> txm_module_preamble_stop_function) { - + /* Yes, there is a stop function, build the address. */ - module_instance -> txm_module_instance_stop_thread_entry = (VOID (*)(ULONG)) (((CHAR *) module_instance -> txm_module_instance_code_start) + - (module_preamble -> txm_module_preamble_stop_function) + + module_instance -> txm_module_instance_stop_thread_entry = (VOID (*)(ULONG)) (((CHAR *) module_instance -> txm_module_instance_code_start) + + (module_preamble -> txm_module_preamble_stop_function) + (stop_function_adjust)); } else { - + /* No, there is no stop function. Just set the pointer to NULL. */ module_instance -> txm_module_instance_stop_thread_entry = TX_NULL; } - + /* Load the module control block with port-specific information. */ TXM_MODULE_MANAGER_MODULE_SETUP(module_instance); - + /* Now add the module to the linked list of created modules. */ if (_txm_module_manger_loaded_count++ == 0) { @@ -410,7 +410,7 @@ UINT status; /* Setup this module's created links. */ module_instance -> txm_module_instance_loaded_previous = previous_module; - module_instance -> txm_module_instance_loaded_next = next_module; + module_instance -> txm_module_instance_loaded_next = next_module; } /* Restore interrupts. */ |
