1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* Copyright (c) 2026-present Eclipse ThreadX contributors |
4 |
|
|
* |
5 |
|
|
* This program and the accompanying materials are made available under the |
6 |
|
|
* terms of the MIT License which is available at |
7 |
|
|
* https://opensource.org/licenses/MIT. |
8 |
|
|
* |
9 |
|
|
* SPDX-License-Identifier: MIT |
10 |
|
|
**************************************************************************/ |
11 |
|
|
|
12 |
|
|
|
13 |
|
|
/**************************************************************************/ |
14 |
|
|
/**************************************************************************/ |
15 |
|
|
/** */ |
16 |
|
|
/** USBX Component */ |
17 |
|
|
/** */ |
18 |
|
|
/** Utility */ |
19 |
|
|
/** */ |
20 |
|
|
/**************************************************************************/ |
21 |
|
|
/**************************************************************************/ |
22 |
|
|
|
23 |
|
|
|
24 |
|
|
/* Include necessary system files. */ |
25 |
|
|
|
26 |
|
|
#define UX_SOURCE_CODE |
27 |
|
|
|
28 |
|
|
#include "ux_api.h" |
29 |
|
|
|
30 |
|
|
|
31 |
|
|
#if !defined(UX_STANDALONE) |
32 |
|
|
/**************************************************************************/ |
33 |
|
|
/* */ |
34 |
|
|
/* FUNCTION RELEASE */ |
35 |
|
|
/* */ |
36 |
|
|
/* _ux_utility_thread_create PORTABLE C */ |
37 |
|
|
/* 6.1.11 */ |
38 |
|
|
/* AUTHOR */ |
39 |
|
|
/* */ |
40 |
|
|
/* Chaoqiong Xiao, Microsoft Corporation */ |
41 |
|
|
/* */ |
42 |
|
|
/* DESCRIPTION */ |
43 |
|
|
/* */ |
44 |
|
|
/* This function creates a thread for USBX. */ |
45 |
|
|
/* */ |
46 |
|
|
/* INPUT */ |
47 |
|
|
/* */ |
48 |
|
|
/* thread_ptr Thread control block pointer */ |
49 |
|
|
/* name Pointer to thread name string */ |
50 |
|
|
/* entry_function Entry function of the thread */ |
51 |
|
|
/* entry_input 32-bit input value to thread */ |
52 |
|
|
/* stack_start Pointer to start of stack */ |
53 |
|
|
/* stack_size Stack size in bytes */ |
54 |
|
|
/* priority Priority of thread (0-31) */ |
55 |
|
|
/* preempt_threshold Preemption threshold */ |
56 |
|
|
/* time_slice Thread time-slice value */ |
57 |
|
|
/* auto_start Automatic start selection */ |
58 |
|
|
/* */ |
59 |
|
|
/* OUTPUT */ |
60 |
|
|
/* */ |
61 |
|
|
/* Completion Status */ |
62 |
|
|
/* */ |
63 |
|
|
/* CALLS */ |
64 |
|
|
/* */ |
65 |
|
|
/* tx_thread_create ThreadX create thread function*/ |
66 |
|
|
/* */ |
67 |
|
|
/* CALLED BY */ |
68 |
|
|
/* */ |
69 |
|
|
/* USBX Components */ |
70 |
|
|
/* */ |
71 |
|
|
/**************************************************************************/ |
72 |
|
1609 |
UINT _ux_utility_thread_create(UX_THREAD *thread_ptr, CHAR *name, |
73 |
|
|
VOID (*entry_function)(ULONG), ULONG entry_input, |
74 |
|
|
VOID *stack_start, ULONG stack_size, |
75 |
|
|
UINT priority, UINT preempt_threshold, |
76 |
|
|
ULONG time_slice, UINT auto_start) |
77 |
|
|
{ |
78 |
|
|
|
79 |
|
|
UINT status; |
80 |
|
|
|
81 |
|
|
|
82 |
|
|
/* Call ThreadX to create USBX thread. */ |
83 |
|
1609 |
status = tx_thread_create(thread_ptr,name,entry_function,entry_input, |
84 |
|
|
stack_start,stack_size, priority,preempt_threshold,time_slice,auto_start); |
85 |
|
|
|
86 |
|
|
/* Check for status. */ |
87 |
✓✓ |
1609 |
if (status != UX_SUCCESS) |
88 |
|
|
{ |
89 |
|
|
|
90 |
|
|
/* Error trap. */ |
91 |
|
14 |
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_UTILITY, status); |
92 |
|
|
|
93 |
|
|
/* If trace is enabled, insert this event into the trace buffer. */ |
94 |
|
|
UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_THREAD_ERROR, thread_ptr, 0, 0, UX_TRACE_ERRORS, 0, 0) |
95 |
|
|
|
96 |
|
|
} |
97 |
|
|
/* Return completion status. */ |
98 |
|
1609 |
return(status); |
99 |
|
|
} |
100 |
|
|
#endif |