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