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                                                              */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 #define TXM_MODULE
24 #include "txm_module.h"
25 #ifndef TXM_THREAD_CREATE_CALL_NOT_USED
26 /**************************************************************************/
27 /*                                                                        */
28 /*  FUNCTION                                               RELEASE        */
29 /*                                                                        */
30 /*    _txe_thread_create                                  PORTABLE C      */
31 /*                                                           6.1.10       */
32 /*  AUTHOR                                                                */
33 /*                                                                        */
34 /*    Scott Larson, Microsoft Corporation                                 */
35 /*                                                                        */
36 /*  DESCRIPTION                                                           */
37 /*                                                                        */
38 /*    This function checks for errors in the thread create function call. */
39 /*                                                                        */
40 /*  INPUT                                                                 */
41 /*                                                                        */
42 /*    thread_ptr                            Thread control block pointer  */
43 /*    name                                  Pointer to thread name string */
44 /*    entry_function                        Entry function of the thread  */
45 /*    entry_input                           32-bit input value to thread  */
46 /*    stack_start                           Pointer to start of stack     */
47 /*    stack_size                            Stack size in bytes           */
48 /*    priority                              Priority of thread (0-31)     */
49 /*    preempt_threshold                     Preemption threshold          */
50 /*    time_slice                            Thread time-slice value       */
51 /*    auto_start                            Automatic start selection     */
52 /*    thread_control_block_size             Size of thread control block  */
53 /*                                                                        */
54 /*  OUTPUT                                                                */
55 /*                                                                        */
56 /*    TX_THREAD_ERROR                       Invalid thread pointer        */
57 /*    TX_PTR_ERROR                          Invalid entry point or stack  */
58 /*                                            address                     */
59 /*    TX_SIZE_ERROR                         Invalid stack size -too small */
60 /*    TX_PRIORITY_ERROR                     Invalid thread priority       */
61 /*    TX_THRESH_ERROR                       Invalid preemption threshold  */
62 /*    status                                Actual completion status      */
63 /*                                                                        */
64 /*  CALLS                                                                 */
65 /*                                                                        */
66 /*    _txm_module_kernel_call_dispatcher                                  */
67 /*                                                                        */
68 /*  CALLED BY                                                             */
69 /*                                                                        */
70 /*    Module application code                                             */
71 /*                                                                        */
72 /*  RELEASE HISTORY                                                       */
73 /*                                                                        */
74 /*    DATE              NAME                      DESCRIPTION             */
75 /*                                                                        */
76 /*  09-30-2020      Scott Larson            Initial Version 6.1           */
77 /*  01-31-2022      Scott Larson            Modified comments and added   */
78 /*                                            CALL_NOT_USED option,       */
79 /*                                            resulting in version 6.1.10 */
80 /*                                                                        */
81 /**************************************************************************/
_txe_thread_create(TX_THREAD * thread_ptr,CHAR * name_ptr,VOID (* entry_function)(ULONG entry_input),ULONG entry_input,VOID * stack_start,ULONG stack_size,UINT priority,UINT preempt_threshold,ULONG time_slice,UINT auto_start,UINT thread_control_block_size)82 UINT _txe_thread_create(TX_THREAD *thread_ptr, CHAR *name_ptr, VOID (*entry_function)(ULONG entry_input), ULONG entry_input, VOID *stack_start, ULONG stack_size, UINT priority, UINT preempt_threshold, ULONG time_slice, UINT auto_start, UINT thread_control_block_size)
83 {
84 
85 UINT return_value;
86 ALIGN_TYPE extra_parameters[9];
87 
88     extra_parameters[0] = (ALIGN_TYPE) entry_function;
89     extra_parameters[1] = (ALIGN_TYPE) entry_input;
90     extra_parameters[2] = (ALIGN_TYPE) stack_start;
91     extra_parameters[3] = (ALIGN_TYPE) stack_size;
92     extra_parameters[4] = (ALIGN_TYPE) priority;
93     extra_parameters[5] = (ALIGN_TYPE) preempt_threshold;
94     extra_parameters[6] = (ALIGN_TYPE) time_slice;
95     extra_parameters[7] = (ALIGN_TYPE) auto_start;
96     extra_parameters[8] = (ALIGN_TYPE) thread_control_block_size;
97 
98     /* Call module manager dispatcher.  */
99     return_value = (UINT) (_txm_module_kernel_call_dispatcher)(TXM_THREAD_CREATE_CALL, (ALIGN_TYPE) thread_ptr, (ALIGN_TYPE) name_ptr, (ALIGN_TYPE) extra_parameters);
100 
101     /* Return value to the caller.  */
102     return(return_value);
103 }
104 #endif
105