summaryrefslogtreecommitdiff
path: root/ports/win32
diff options
context:
space:
mode:
Diffstat (limited to 'ports/win32')
-rw-r--r--ports/win32/vs_2019/example_build/sample_threadx/sample_threadx.c46
-rw-r--r--ports/win32/vs_2019/inc/tx_port.h89
-rw-r--r--ports/win32/vs_2019/readme_threadx.txt56
-rw-r--r--ports/win32/vs_2019/src/tx_initialize_low_level.c95
-rw-r--r--ports/win32/vs_2019/src/tx_thread_context_restore.c75
-rw-r--r--ports/win32/vs_2019/src/tx_thread_context_save.c69
-rw-r--r--ports/win32/vs_2019/src/tx_thread_interrupt_control.c101
-rw-r--r--ports/win32/vs_2019/src/tx_thread_schedule.c111
-rw-r--r--ports/win32/vs_2019/src/tx_thread_stack_build.c69
-rw-r--r--ports/win32/vs_2019/src/tx_thread_system_return.c121
-rw-r--r--ports/win32/vs_2019/src/tx_timer_interrupt.c75
11 files changed, 431 insertions, 476 deletions
diff --git a/ports/win32/vs_2019/example_build/sample_threadx/sample_threadx.c b/ports/win32/vs_2019/example_build/sample_threadx/sample_threadx.c
index 46d2aff4..4bd7f5bc 100644
--- a/ports/win32/vs_2019/example_build/sample_threadx/sample_threadx.c
+++ b/ports/win32/vs_2019/example_build/sample_threadx/sample_threadx.c
@@ -1,5 +1,5 @@
/* This is a small demo of the high-performance ThreadX kernel. It includes examples of eight
- threads of different priorities, using a message queue, semaphore, mutex, event flags group,
+ threads of different priorities, using a message queue, semaphore, mutex, event flags group,
byte pool, and block pool. */
#include "tx_api.h"
@@ -81,42 +81,42 @@ CHAR *pointer = TX_NULL;
tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);
/* Create the main thread. */
- tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,
- pointer, DEMO_STACK_SIZE,
+ tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,
+ pointer, DEMO_STACK_SIZE,
1, 1, TX_NO_TIME_SLICE, TX_AUTO_START);
/* Allocate the stack for thread 1. */
tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);
- /* Create threads 1 and 2. These threads pass information through a ThreadX
+ /* Create threads 1 and 2. These threads pass information through a ThreadX
message queue. It is also interesting to note that these threads have a time
slice. */
- tx_thread_create(&thread_1, "thread 1", thread_1_entry, 1,
- pointer, DEMO_STACK_SIZE,
+ tx_thread_create(&thread_1, "thread 1", thread_1_entry, 1,
+ pointer, DEMO_STACK_SIZE,
16, 16, 4, TX_AUTO_START);
/* Allocate the stack for thread 2. */
tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);
- tx_thread_create(&thread_2, "thread 2", thread_2_entry, 2,
- pointer, DEMO_STACK_SIZE,
+ tx_thread_create(&thread_2, "thread 2", thread_2_entry, 2,
+ pointer, DEMO_STACK_SIZE,
16, 16, 4, TX_AUTO_START);
/* Allocate the stack for thread 3. */
tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);
- /* Create threads 3 and 4. These threads compete for a ThreadX counting semaphore.
+ /* Create threads 3 and 4. These threads compete for a ThreadX counting semaphore.
An interesting thing here is that both threads share the same instruction area. */
- tx_thread_create(&thread_3, "thread 3", thread_3_and_4_entry, 3,
- pointer, DEMO_STACK_SIZE,
+ tx_thread_create(&thread_3, "thread 3", thread_3_and_4_entry, 3,
+ pointer, DEMO_STACK_SIZE,
8, 8, TX_NO_TIME_SLICE, TX_AUTO_START);
/* Allocate the stack for thread 4. */
tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);
- tx_thread_create(&thread_4, "thread 4", thread_3_and_4_entry, 4,
- pointer, DEMO_STACK_SIZE,
+ tx_thread_create(&thread_4, "thread 4", thread_3_and_4_entry, 4,
+ pointer, DEMO_STACK_SIZE,
8, 8, TX_NO_TIME_SLICE, TX_AUTO_START);
/* Allocate the stack for thread 5. */
@@ -124,23 +124,23 @@ CHAR *pointer = TX_NULL;
/* Create thread 5. This thread simply pends on an event flag which will be set
by thread_0. */
- tx_thread_create(&thread_5, "thread 5", thread_5_entry, 5,
- pointer, DEMO_STACK_SIZE,
+ tx_thread_create(&thread_5, "thread 5", thread_5_entry, 5,
+ pointer, DEMO_STACK_SIZE,
4, 4, TX_NO_TIME_SLICE, TX_AUTO_START);
/* Allocate the stack for thread 6. */
tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);
/* Create threads 6 and 7. These threads compete for a ThreadX mutex. */
- tx_thread_create(&thread_6, "thread 6", thread_6_and_7_entry, 6,
- pointer, DEMO_STACK_SIZE,
+ tx_thread_create(&thread_6, "thread 6", thread_6_and_7_entry, 6,
+ pointer, DEMO_STACK_SIZE,
8, 8, TX_NO_TIME_SLICE, TX_AUTO_START);
/* Allocate the stack for thread 7. */
tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);
- tx_thread_create(&thread_7, "thread 7", thread_6_and_7_entry, 7,
- pointer, DEMO_STACK_SIZE,
+ tx_thread_create(&thread_7, "thread 7", thread_6_and_7_entry, 7,
+ pointer, DEMO_STACK_SIZE,
8, 8, TX_NO_TIME_SLICE, TX_AUTO_START);
/* Allocate the message queue. */
@@ -254,11 +254,11 @@ UINT status;
/* Retrieve a message from the queue. */
status = tx_queue_receive(&queue_0, &received_message, TX_WAIT_FOREVER);
- /* Check completion status and make sure the message is what we
+ /* Check completion status and make sure the message is what we
expected. */
if ((status != TX_SUCCESS) || (received_message != thread_2_messages_received))
break;
-
+
/* Otherwise, all is okay. Increment the received message count. */
thread_2_messages_received++;
}
@@ -317,7 +317,7 @@ ULONG actual_flags;
thread_5_counter++;
/* Wait for event flag 0. */
- status = tx_event_flags_get(&event_flags_0, 0x1, TX_OR_CLEAR,
+ status = tx_event_flags_get(&event_flags_0, 0x1, TX_OR_CLEAR,
&actual_flags, TX_WAIT_FOREVER);
/* Check status. */
@@ -370,7 +370,7 @@ UINT status;
if (status != TX_SUCCESS)
break;
- /* Release the mutex again. This will actually
+ /* Release the mutex again. This will actually
release ownership since it was obtained twice. */
status = tx_mutex_put(&mutex_0);
diff --git a/ports/win32/vs_2019/inc/tx_port.h b/ports/win32/vs_2019/inc/tx_port.h
index e96bbf8a..2cd61b43 100644
--- a/ports/win32/vs_2019/inc/tx_port.h
+++ b/ports/win32/vs_2019/inc/tx_port.h
@@ -1,17 +1,18 @@
/***************************************************************************
- * Copyright (c) 2024 Microsoft Corporation
- *
+ * Copyright (c) 2024 Microsoft Corporation
+ * Copyright (c) 2026-present Eclipse ThreadX contributors
+ *
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
- *
+ *
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
-/** */
+/** */
/** ThreadX Component */
/** */
/** Port Specific */
@@ -20,11 +21,11 @@
/**************************************************************************/
-/**************************************************************************/
-/* */
-/* PORT SPECIFIC C INFORMATION RELEASE */
-/* */
-/* tx_port.h Win32/Visual */
+/**************************************************************************/
+/* */
+/* PORT SPECIFIC C INFORMATION RELEASE */
+/* */
+/* tx_port.h Win32/Visual */
/* 6.1 */
/* */
/* AUTHOR */
@@ -32,21 +33,15 @@
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
-/* */
-/* This file contains data type definitions that make the ThreadX */
-/* real-time kernel function identically on a variety of different */
-/* processor architectures. For example, the size or number of bits */
-/* in an "int" data type vary between microprocessor architectures and */
-/* even C compilers for the same microprocessor. ThreadX does not */
-/* directly use native C data types. Instead, ThreadX creates its */
-/* own special types that can be mapped to actual data types by this */
-/* file to guarantee consistency in the interface and functionality. */
-/* */
-/* RELEASE HISTORY */
-/* */
-/* DATE NAME DESCRIPTION */
/* */
-/* 09-30-2020 William E. Lamie Initial Version 6.1 */
+/* This file contains data type definitions that make the ThreadX */
+/* real-time kernel function identically on a variety of different */
+/* processor architectures. For example, the size or number of bits */
+/* in an "int" data type vary between microprocessor architectures and */
+/* even C compilers for the same microprocessor. ThreadX does not */
+/* directly use native C data types. Instead, ThreadX creates its */
+/* own special types that can be mapped to actual data types by this */
+/* file to guarantee consistency in the interface and functionality. */
/* */
/**************************************************************************/
@@ -59,7 +54,7 @@
#ifdef TX_INCLUDE_USER_DEFINE_FILE
-/* Yes, include the user defines in tx_user.h. The defines in this file may
+/* Yes, include the user defines in tx_user.h. The defines in this file may
alternately be defined on the command line. */
#include "tx_user.h"
@@ -114,7 +109,7 @@
#endif
-/* Define ThreadX basic types for this port. */
+/* Define ThreadX basic types for this port. */
#define VOID void
typedef char CHAR;
@@ -128,7 +123,7 @@ typedef unsigned short USHORT;
/* Add Win32 debug insert prototype. */
-
+
void _tx_win32_debug_entry_insert(char *action, char *file, unsigned long line);
#ifndef TX_WIN32_DEBUG_ENABLE
@@ -155,7 +150,7 @@ void _tx_win32_debug_entry_insert(char *action, char *file, unsigned long lin
*ptr++ = value; \
} \
}
-
+
/* Include windows include file. */
@@ -185,19 +180,19 @@ void _tx_win32_debug_entry_insert(char *action, char *file, unsigned long lin
#define TX_TIMER_THREAD_STACK_SIZE 400 /* Default timer thread stack size - Not used in Win32 port! */
#endif
-#ifndef TX_TIMER_THREAD_PRIORITY
-#define TX_TIMER_THREAD_PRIORITY 0 /* Default timer thread priority */
+#ifndef TX_TIMER_THREAD_PRIORITY
+#define TX_TIMER_THREAD_PRIORITY 0 /* Default timer thread priority */
#endif
-/* Define various constants for the ThreadX port. */
+/* Define various constants for the ThreadX port. */
#define TX_INT_DISABLE 1 /* Disable interrupts */
#define TX_INT_ENABLE 0 /* Enable interrupts */
-/* Define the clock source for trace event entry time stamp. The following two item are port specific.
- For example, if the time source is at the address 0x0a800024 and is 16-bits in size, the clock
+/* Define the clock source for trace event entry time stamp. The following two item are port specific.
+ For example, if the time source is at the address 0x0a800024 and is 16-bits in size, the clock
source constants would be:
#define TX_TRACE_TIME_SOURCE *((ULONG *) 0x0a800024)
@@ -215,7 +210,7 @@ void _tx_win32_debug_entry_insert(char *action, char *file, unsigned long lin
/* Define the port-specific trace extension to pickup the Windows timer. */
-#define TX_TRACE_PORT_EXTENSION QueryPerformanceCounter((LARGE_INTEGER *)&_tx_win32_time_stamp);
+#define TX_TRACE_PORT_EXTENSION QueryPerformanceCounter((LARGE_INTEGER *)&_tx_win32_time_stamp);
/* Define the port specific options for the _tx_build_options variable. This variable indicates
@@ -238,7 +233,7 @@ void _tx_initialize_start_interrupts(void);
#define TX_PORT_SPECIFIC_PRE_SCHEDULER_INITIALIZATION _tx_initialize_start_interrupts();
-/* Determine whether or not stack checking is enabled. By default, ThreadX stack checking is
+/* Determine whether or not stack checking is enabled. By default, ThreadX stack checking is
disabled. When the following is defined, ThreadX thread stack checking is enabled. If stack
checking is enabled (TX_ENABLE_STACK_CHECKING is defined), the TX_DISABLE_STACK_FILLING
define is negated, thereby forcing the stack fill which is necessary for the stack checking
@@ -250,7 +245,7 @@ void _tx_initialize_start_interrupts(void);
/* Define the TX_THREAD control block extensions for this port. The main reason
- for the multiple macros is so that backward compatibility can be maintained with
+ for the multiple macros is so that backward compatibility can be maintained with
existing ThreadX kernel awareness modules. */
#define TX_THREAD_EXTENSION_0 HANDLE tx_thread_win32_thread_handle; \
@@ -258,9 +253,9 @@ void _tx_initialize_start_interrupts(void);
HANDLE tx_thread_win32_thread_run_semaphore; \
UINT tx_thread_win32_suspension_type; \
UINT tx_thread_win32_int_disabled_flag;
-#define TX_THREAD_EXTENSION_1
-#define TX_THREAD_EXTENSION_2
-#define TX_THREAD_EXTENSION_3
+#define TX_THREAD_EXTENSION_1
+#define TX_THREAD_EXTENSION_2
+#define TX_THREAD_EXTENSION_3
/* Define the port extensions of the remaining ThreadX objects. */
@@ -274,11 +269,11 @@ void _tx_initialize_start_interrupts(void);
#define TX_TIMER_EXTENSION
-/* Define the user extension field of the thread control block. Nothing
+/* Define the user extension field of the thread control block. Nothing
additional is needed for this port so it is defined as white space. */
#ifndef TX_THREAD_USER_EXTENSION
-#define TX_THREAD_USER_EXTENSION
+#define TX_THREAD_USER_EXTENSION
#endif
@@ -286,10 +281,10 @@ void _tx_initialize_start_interrupts(void);
tx_thread_shell_entry, and tx_thread_terminate. */
-#define TX_THREAD_CREATE_EXTENSION(thread_ptr)
+#define TX_THREAD_CREATE_EXTENSION(thread_ptr)
#define TX_THREAD_DELETE_EXTENSION(thread_ptr)
#define TX_THREAD_COMPLETED_EXTENSION(thread_ptr)
-#define TX_THREAD_TERMINATED_EXTENSION(thread_ptr)
+#define TX_THREAD_TERMINATED_EXTENSION(thread_ptr)
/* Define the ThreadX object creation extensions for the remaining objects. */
@@ -387,9 +382,9 @@ HANDLE threadhandle;
}
-/* Define ThreadX interrupt lockout and restore macros for protection on
- access of critical kernel information. The restore interrupt macro must
- restore the interrupt posture of the running thread prior to the value
+/* Define ThreadX interrupt lockout and restore macros for protection on
+ access of critical kernel information. The restore interrupt macro must
+ restore the interrupt posture of the running thread prior to the value
present prior to the disable macro. In most cases, the save area macro
is used to define a local function save area for the disable and restore
macros. */
@@ -417,8 +412,8 @@ VOID _tx_thread_interrupt_restore(UINT previous_posture);
/* Define the version ID of ThreadX. This may be utilized by the application. */
#ifdef TX_THREAD_INIT
-CHAR _tx_version_id[] =
- "Copyright (c) 2024 Microsoft Corporation. * ThreadX Win32/Visual Studio Version 6.4.2 *";
+CHAR _tx_version_id[] =
+ "(c) 2024 Microsoft Corp. (c) 2026-present Eclipse ThreadX contributors. * ThreadX Win32/Visual Studio Version 6.5.0.202601 *";
#else
extern CHAR _tx_version_id[];
#endif
diff --git a/ports/win32/vs_2019/readme_threadx.txt b/ports/win32/vs_2019/readme_threadx.txt
index 13ce3d33..2d17b995 100644
--- a/ports/win32/vs_2019/readme_threadx.txt
+++ b/ports/win32/vs_2019/readme_threadx.txt
@@ -1,26 +1,26 @@
- Microsoft's Azure RTOS ThreadX for Win32
+ Microsoft's Azure RTOS ThreadX for Win32
Using the Visual Studio Tools
1. Open the ThreadX Project Workspace
-In order to build the ThreadX library and the ThreadX demonstration first load
+In order to build the ThreadX library and the ThreadX demonstration first load
the Azure RTOS Workspace azure_rtos.sln, which is located inside the "example_build"
-directory.
+directory.
2. Building the ThreadX run-time Library
-Building the ThreadX library is easy; simply make the "tx" project active and
-then select the build button. You should now observe the compilation of the
-ThreadX library source. This project build produces the ThreadX library file
+Building the ThreadX library is easy; simply make the "tx" project active and
+then select the build button. You should now observe the compilation of the
+ThreadX library source. This project build produces the ThreadX library file
tx.lib.
3. Building the Demonstration System
-You are now ready to run the ThreadX Win32 demonstration. Simply make the
+You are now ready to run the ThreadX Win32 demonstration. Simply make the
"sample_thread" project active and then select the build button. When the build
is finished, select the run button from Visual Studio and observe various
demonstration statistics being printed to the console window. You may also set
@@ -29,15 +29,15 @@ breakpoints, single step, perform data watches, etc.
4. System Initialization
-The system entry point is at main(), which is defined in the application.
-Once the application calls tx_kernel_enter, ThreadX starts running and
-performs various initialization duties prior to starting the scheduler. The
+The system entry point is at main(), which is defined in the application.
+Once the application calls tx_kernel_enter, ThreadX starts running and
+performs various initialization duties prior to starting the scheduler. The
Win32-specific initialization is done in the function _tx_initialize_low_level,
-which is located in the file tx_initialize_low_level.c. This function is
-responsible for setting up various system data structures and simulated
+which is located in the file tx_initialize_low_level.c. This function is
+responsible for setting up various system data structures and simulated
interrupts - including the periodic timer interrupt source for ThreadX.
-In addition, _tx_initialize_low_level determines the first available
+In addition, _tx_initialize_low_level determines the first available
address for use by the application. In Win32, this is basically done
by using malloc to get a big block of memory from Windows.
@@ -46,32 +46,32 @@ by using malloc to get a big block of memory from Windows.
ThreadX for Win32 is implemented using Win32 threads. Each application
thread in ThreadX actually runs as a Win32 thread. The determination of
-which application thread to run is made by the ThreadX scheduler, which
-itself is a Win32 thread. The ThreadX scheduler is the highest priority
+which application thread to run is made by the ThreadX scheduler, which
+itself is a Win32 thread. The ThreadX scheduler is the highest priority
thread in the system.
Interrupts in ThreadX/Win32 are also simulated by threads. A good example
-is the ThreadX system timer interrupt, which can be found in
+is the ThreadX system timer interrupt, which can be found in
tx_initialize_low_level.c.
5.1 ThreadX Limitations
-ThreadX for Win32 behaves in the same manner as ThreadX in an embedded
-environment EXCEPT in the case of thread termination. Unfortunately, the
+ThreadX for Win32 behaves in the same manner as ThreadX in an embedded
+environment EXCEPT in the case of thread termination. Unfortunately, the
Win32 API does not have a good mechanism to terminate threads and instead
must rely on the thread itself terminating. Hence, threads in the ThreadX
-Win32 implementation must have some ThreadX call periodically in their
+Win32 implementation must have some ThreadX call periodically in their
processing if they can be terminated by another ThreadX thread.
6. Improving Performance
-The distribution version of ThreadX is built without any compiler
-optimizations. This makes it easy to debug because you can trace or set
-breakpoints inside of ThreadX itself. Of course, this costs some
-performance. To make it run faster, you can change the tx project file to
-enable all compiler optimizations. In addition, you can eliminate the
-ThreadX basic API error checking by compiling your application code with the
+The distribution version of ThreadX is built without any compiler
+optimizations. This makes it easy to debug because you can trace or set
+breakpoints inside of ThreadX itself. Of course, this costs some
+performance. To make it run faster, you can change the tx project file to
+enable all compiler optimizations. In addition, you can eliminate the
+ThreadX basic API error checking by compiling your application code with the
symbol TX_DISABLE_ERROR_CHECKING defined.
@@ -79,7 +79,7 @@ symbol TX_DISABLE_ERROR_CHECKING defined.
ThreadX provides simulated interrupt handling with Win32 threads. Simulated
interrupt threads may be created by the application or may be added to the
-simulated timer interrupt defined in tx_initialize_low_level.c. The following
+simulated timer interrupt defined in tx_initialize_low_level.c. The following
format for creating simulated interrupts should be used:
7.1 Data structures
@@ -116,7 +116,7 @@ in tx_initialize_low_level.c called _tx_initialize_start_interrupts or into the
7.4 Simulated Interrupt Thread Template
The following is a template for the simulated interrupt thread. This interrupt will occur on
-a periodic basis.
+a periodic basis.
DWORD WINAPI _sample_win32_interrupt(LPVOID *ptr)
{
@@ -135,7 +135,7 @@ DWORD WINAPI _sample_win32_interrupt(LPVOID *ptr)
/* Call ThreadX context restore for interrupt completion. */
_tx_thread_context_restore();
- }
+ }
}
diff --git a/ports/win32/vs_2019/src/tx_initialize_low_level.c b/ports/win32/vs_2019/src/tx_initialize_low_level.c
index b62d1615..dd364d06 100644
--- a/ports/win32/vs_2019/src/tx_initialize_low_level.c
+++ b/ports/win32/vs_2019/src/tx_initialize_low_level.c
@@ -1,18 +1,19 @@
/***************************************************************************
- * Copyright (c) 2024 Microsoft Corporation
- *
+ * Copyright (c) 2024 Microsoft Corporation
+ * Copyright (c) 2026-present Eclipse ThreadX contributors
+ *
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
- *
+ *
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
-/** */
-/** ThreadX Component */
+/** */
+/** ThreadX Component */
/** */
/** Initialize */
/** */
@@ -43,7 +44,7 @@ extern TX_THREAD *_tx_thread_current_ptr;
/* Define simulated timer interrupt. This is done inside a thread, which is
- how other interrupts may be defined as well. See code below for an
+ how other interrupts may be defined as well. See code below for an
example. */
UINT _tx_win32_timer_id;
@@ -115,22 +116,22 @@ void _tx_win32_debug_entry_insert(char *action, char *file, unsigned long lin
_tx_win32_debug_entry_array[_tx_win32_debug_entry_index].tx_win32_debug_entry_current_thread = _tx_thread_current_ptr;
if (_tx_thread_current_ptr)
_tx_win32_debug_entry_array[_tx_win32_debug_entry_index].tx_win32_debug_entry_current_thread_id = _tx_thread_current_ptr -> tx_thread_win32_thread_id;
- else
+ else
_tx_win32_debug_entry_array[_tx_win32_debug_entry_index].tx_win32_debug_entry_current_thread_id = 0;
_tx_win32_debug_entry_array[_tx_win32_debug_entry_index].tx_win32_debug_entry_execute_thread = _tx_thread_execute_ptr;
if (_tx_thread_execute_ptr)
_tx_win32_debug_entry_array[_tx_win32_debug_entry_index].tx_win32_debug_entry_execute_thread_id = _tx_thread_execute_ptr -> tx_thread_win32_thread_id;
- else
+ else
_tx_win32_debug_entry_array[_tx_win32_debug_entry_index].tx_win32_debug_entry_execute_thread_id = 0;
_tx_win32_debug_entry_array[_tx_win32_debug_entry_index].tx_win32_debug_entry_running_id = GetCurrentThreadId();
/* Now move to the next entry. */
_tx_win32_debug_entry_index++;
-
+
/* Determine if we need to wrap the list. */
if (_tx_win32_debug_entry_index >= TX_WIN32_DEBUG_EVENT_SIZE)
{
-
+
/* Yes, wrap the list! */
_tx_win32_debug_entry_index = 0;
}
@@ -156,50 +157,44 @@ VOID _tx_thread_context_restore(VOID);
extern VOID *_tx_initialize_unused_memory;
-/**************************************************************************/
-/* */
-/* FUNCTION RELEASE */
-/* */
-/* _tx_initialize_low_level Win32/Visual */
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _tx_initialize_low_level Win32/Visual */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
-/* */
-/* This function is responsible for any low-level processor */
-/* initialization, including setting up interrupt vectors, setting */
-/* up a periodic timer interrupt source, saving the system stack */
-/* pointer for use in ISR processing later, and finding the first */
-/* available RAM memory address for tx_application_define. */
-/* */
-/* INPUT */
-/* */
-/* None */
-/* */
-/* OUTPUT */
-/* */
-/* None */
-/* */
-/* CALLS */
-/* */
-/* CreateMutex Win32 create mutex */
-/* CreateThread Win32 create thread */
-/* CreateSemaphore Win32 create semaphore */
-/* GetCurrentThreadId Win32 get current thread ID */
-/* SetProcessAffinityMask Win32 process affinity set */
-/* SetThreadPriority Win32 set thread priority */
-/* */
-/* CALLED BY */
-/* */
-/* _tx_initialize_kernel_enter ThreadX entry function */
-/* */
-/* RELEASE HISTORY */
-/* */
-/* DATE NAME DESCRIPTION */
/* */
-/* 09-30-2020 William E. Lamie Initial Version 6.1 */
+/* This function is responsible for any low-level processor */
+/* initialization, including setting up interrupt vectors, setting */
+/* up a periodic timer interrupt source, saving the system stack */
+/* pointer for use in ISR processing later, and finding the first */
+/* available RAM memory address for tx_application_define. */
+/* */
+/* INPUT */
+/* */
+/* None */
+/* */
+/* OUTPUT */
+/* */
+/* None */
+/* */
+/* CALLS */
+/* */
+/* CreateMutex Win32 create mutex */
+/* CreateThread Win32 create thread */
+/* CreateSemaphore Win32 create semaphore */
+/* GetCurrentThreadId Win32 get current thread ID */
+/* SetProcessAffinityMask Win32 process affinity set */
+/* SetThreadPriority Win32 set thread priority */
+/* */
+/* CALLED BY */
+/* */
+/* _tx_initialize_kernel_enter ThreadX entry function */
/* */
/**************************************************************************/
VOID _tx_initialize_low_level(VOID)
@@ -213,7 +208,7 @@ VOID _tx_initialize_low_level(VOID)
/* Limit this ThreadX simulation on Win32 to a single core. */
if (SetProcessAffinityMask( GetCurrentProcess(), 1 ) == 0)
{
-
+
/* Error restricting the process to one core. */
printf("ThreadX Win32 error restricting the process to one core!\n");
while(1)
@@ -235,7 +230,7 @@ VOID _tx_initialize_low_level(VOID)
_tx_win32_critical_section.tx_win32_critical_section_mutex_handle = CreateMutex(NULL, FALSE, NULL);
_tx_win32_critical_section.tx_win32_critical_section_nested_count = 0;
_tx_win32_critical_section.tx_win32_critical_section_owner = 0;
-
+
/* Create the semaphore that regulates when the scheduler executes. */
_tx_win32_scheduler_semaphore = CreateSemaphore(NULL, 0, 1, NULL);
@@ -247,7 +242,7 @@ VOID _tx_initialize_low_level(VOID)
/* This routine is called after initialization is complete in order to start
- all interrupt threads. Interrupt threads in addition to the timer may
+ all interrupt threads. Interrupt threads in addition to the timer may
be added to this routine as well. */
void _tx_initialize_start_interrupts(void)
diff --git a/ports/win32/vs_2019/src/tx_thread_context_restore.c b/ports/win32/vs_2019/src/tx_thread_context_restore.c
index 3272348d..36fa1e4b 100644
--- a/ports/win32/vs_2019/src/tx_thread_context_restore.c
+++ b/ports/win32/vs_2019/src/tx_thread_context_restore.c
@@ -1,18 +1,19 @@
/***************************************************************************
- * Copyright (c) 2024 Microsoft Corporation
- *
+ * Copyright (c) 2024 Microsoft Corporation
+ * Copyright (c) 2026-present Eclipse ThreadX contributors
+ *
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
- *
+ *
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
-/** */
-/** ThreadX Component */
+/** */
+/** ThreadX Component */
/** */
/** Thread */
/** */
@@ -30,47 +31,41 @@
#include "tx_timer.h"
-/**************************************************************************/
-/* */
-/* FUNCTION RELEASE */
-/* */
-/* _tx_thread_context_restore Win32/Visual */
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _tx_thread_context_restore Win32/Visual */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
-/* */
-/* This function restores the interrupt context if it is processing a */
-/* nested interrupt. If not, it returns to the interrupt thread if no */
-/* preemption is necessary. Otherwise, if preemption is necessary or */
-/* if no thread was running, the function returns to the scheduler. */
-/* */
-/* INPUT */
-/* */
-/* None */
-/* */
-/* OUTPUT */
-/* */
-/* None */
-/* */
-/* CALLS */
-/* */
-/* ReleaseSemaphore Win32 release semaphore */
-/* ResumeThread Win32 resume thread */
-/* _tx_win32_critical_section_obtain Obtain critical section */
-/* _tx_win32_critical_section_release Release critical section */
-/* */
-/* CALLED BY */
-/* */
-/* ISRs Interrupt Service Routines */
-/* */
-/* RELEASE HISTORY */
-/* */
-/* DATE NAME DESCRIPTION */
/* */
-/* 09-30-2020 William E. Lamie Initial Version 6.1 */
+/* This function restores the interrupt context if it is processing a */
+/* nested interrupt. If not, it returns to the interrupt thread if no */
+/* preemption is necessary. Otherwise, if preemption is necessary or */
+/* if no thread was running, the function returns to the scheduler. */
+/* */
+/* INPUT */
+/* */
+/* None */
+/* */
+/* OUTPUT */
+/* */
+/* None */
+/* */
+/* CALLS */
+/* */
+/* ReleaseSemaphore Win32 release semaphore */
+/* ResumeThread Win32 resume thread */
+/* _tx_win32_critical_section_obtain Obtain critical section */
+/* _tx_win32_critical_section_release Release critical section */
+/* */
+/* CALLED BY */
+/* */
+/* ISRs Interrupt Service Routines */
/* */
/**************************************************************************/
VOID _tx_thread_context_restore(VOID)
@@ -97,7 +92,7 @@ VOID _tx_thread_context_restore(VOID)
if ((_tx_thread_preempt_disable == 0) && (_tx_thread_current_ptr != _tx_thread_execute_ptr))
{
- /* Preempt the running application thread. We don't need to suspend the
+ /* Preempt the running application thread. We don't need to suspend the
application thread since that is done in the context save processing. */
/* Indicate that this thread was suspended asynchronously. */
diff --git a/ports/win32/vs_2019/src/tx_thread_context_save.c b/ports/win32/vs_2019/src/tx_thread_context_save.c
index b39fc52c..2f4afb40 100644
--- a/ports/win32/vs_2019/src/tx_thread_context_save.c
+++ b/ports/win32/vs_2019/src/tx_thread_context_save.c
@@ -1,18 +1,19 @@
/***************************************************************************
- * Copyright (c) 2024 Microsoft Corporation
- *
+ * Copyright (c) 2024 Microsoft Corporation
+ * Copyright (c) 2026-present Eclipse ThreadX contributors
+ *
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
- *
+ *
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
-/** */
-/** ThreadX Component */
+/** */
+/** ThreadX Component */
/** */
/** Thread */
/** */
@@ -30,45 +31,39 @@
#include "tx_timer.h"
-/**************************************************************************/
-/* */
-/* FUNCTION RELEASE */
-/* */
-/* _tx_thread_context_save Win32/Visual */
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _tx_thread_context_save Win32/Visual */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
-/* */
-/* This function saves the context of an executing thread in the */
-/* beginning of interrupt processing. The function also ensures that */
-/* the system stack is used upon return to the calling ISR. */
-/* */
-/* INPUT */
-/* */
-/* None */
-/* */
-/* OUTPUT */
-/* */
-/* None */
-/* */
-/* CALLS */
-/* */
-/* SuspendThread Win32 thread suspend */
-/* _tx_win32_critical_section_obtain Obtain critical section */
-/* _tx_win32_critical_section_release Release critical section */
-/* */
-/* CALLED BY */
-/* */
-/* ISRs */
-/* */
-/* RELEASE HISTORY */
-/* */
-/* DATE NAME DESCRIPTION */
/* */
-/* 09-30-2020 William E. Lamie Initial Version 6.1 */
+/* This function saves the context of an executing thread in the */
+/* beginning of interrupt processing. The function also ensures that */
+/* the system stack is used upon return to the calling ISR. */
+/* */
+/* INPUT */
+/* */
+/* None */
+/* */
+/* OUTPUT */
+/* */
+/* None */
+/* */
+/* CALLS */
+/* */
+/* SuspendThread Win32 thread suspend */
+/* _tx_win32_critical_section_obtain Obtain critical section */
+/* _tx_win32_critical_section_release Release critical section */
+/* */
+/* CALLED BY */
+/* */
+/* ISRs */
/* */
/**************************************************************************/
VOID _tx_thread_context_save(VOID)
diff --git a/ports/win32/vs_2019/src/tx_thread_interrupt_control.c b/ports/win32/vs_2019/src/tx_thread_interrupt_control.c
index 5b99eeb8..019aabef 100644
--- a/ports/win32/vs_2019/src/tx_thread_interrupt_control.c
+++ b/ports/win32/vs_2019/src/tx_thread_interrupt_control.c
@@ -1,18 +1,19 @@
/***************************************************************************
- * Copyright (c) 2024 Microsoft Corporation
- *
+ * Copyright (c) 2024 Microsoft Corporation
+ * Copyright (c) 2026-present Eclipse ThreadX contributors
+ *
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
- *
+ *
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
-/** */
-/** ThreadX Component */
+/** */
+/** ThreadX Component */
/** */
/** Thread */
/** */
@@ -49,49 +50,43 @@ VOID _tx_thread_interrupt_restore(UINT previous_posture)
}
-/**************************************************************************/
-/* */
-/* FUNCTION RELEASE */
-/* */
-/* _tx_thread_interrupt_control Win32/Visual */
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _tx_thread_interrupt_control Win32/Visual */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
-/* */
-/* This function is responsible for changing the interrupt lockout */
-/* posture of the system. */
-/* */
-/* INPUT */
-/* */
-/* new_posture New interrupt lockout posture */
-/* */
-/* OUTPUT */
-/* */
-/* old_posture Old interrupt lockout posture */
-/* */
-/* CALLS */
-/* */
-/* ExitThread Win32 thread exit */
-/* GetCurrentThread Win32 get current thread */
-/* GetCurrentThreadId Win32 get current thread ID */
-/* GetThreadPriority Win32 get thread priority */
-/* _tx_win32_critical_section_obtain Obtain critical section */
-/* _tx_win32_critical_section_release Release critical section */
-/* _tx_win32_critical_section_release_all */
-/* Release critical section */
-/* */
-/* CALLED BY */
-/* */
-/* Application Code */
-/* */
-/* RELEASE HISTORY */
-/* */
-/* DATE NAME DESCRIPTION */
/* */
-/* 09-30-2020 William E. Lamie Initial Version 6.1 */
+/* This function is responsible for changing the interrupt lockout */
+/* posture of the system. */
+/* */
+/* INPUT */
+/* */
+/* new_posture New interrupt lockout posture */
+/* */
+/* OUTPUT */
+/* */
+/* old_posture Old interrupt lockout posture */
+/* */
+/* CALLS */
+/* */
+/* ExitThread Win32 thread exit */
+/* GetCurrentThread Win32 get current thread */
+/* GetCurrentThreadId Win32 get current thread ID */
+/* GetThreadPriority Win32 get thread priority */
+/* _tx_win32_critical_section_obtain Obtain critical section */
+/* _tx_win32_critical_section_release Release critical section */
+/* _tx_win32_critical_section_release_all */
+/* Release critical section */
+/* */
+/* CALLED BY */
+/* */
+/* Application Code */
/* */
/**************************************************************************/
UINT _tx_thread_interrupt_control(UINT new_posture)
@@ -99,9 +94,9 @@ UINT _tx_thread_interrupt_control(UINT new_posture)
UINT old_posture;
HANDLE threadhandle;
-int threadpriority;
+int threadpriority;
DWORD threadid;
-TX_THREAD *thread_ptr;
+TX_THREAD *thread_ptr;
/* Enter Win32 critical section. */
@@ -116,7 +111,7 @@ TX_THREAD *thread_ptr;
_tx_win32_debug_entry_insert("RESTORE", __FILE__, __LINE__);
}
else
- {
+ {
/* Disable. */
_tx_win32_debug_entry_insert("DISABLE", __FILE__, __LINE__);
}
@@ -131,24 +126,24 @@ TX_THREAD *thread_ptr;
thread_ptr = _tx_thread_current_ptr;
/* Pickup the priority of the current thread. */
- threadpriority = GetThreadPriority(threadhandle);
+ threadpriority = GetThreadPriority(threadhandle);
/* Pickup the ID of the current thread. */
threadid = GetCurrentThreadId();
- /* Determine if this is a thread (THREAD_PRIORITY_LOWEST) and it does not
+ /* Determine if this is a thread (THREAD_PRIORITY_LOWEST) and it does not
match the current thread pointer. */
- if ((threadpriority == THREAD_PRIORITY_LOWEST) &&
- ((!thread_ptr) || (thread_ptr -> tx_thread_win32_thread_id != threadid)))
- {
+ if ((threadpriority == THREAD_PRIORITY_LOWEST) &&
+ ((!thread_ptr) || (thread_ptr -> tx_thread_win32_thread_id != threadid)))
+ {
- /* This indicates the Win32 thread was actually terminated by ThreadX is only
+ /* This indicates the Win32 thread was actually terminated by ThreadX is only
being allowed to run in order to cleanup its resources. */
_tx_win32_critical_section_release_all(&_tx_win32_critical_section);
/* Exit this thread. */
- ExitThread(0);
- }
+ ExitThread(0);
+ }
/* Determine the current interrupt lockout condition. */
if (_tx_win32_critical_section.tx_win32_critical_section_nested_count == 1)
@@ -185,7 +180,7 @@ TX_THREAD *thread_ptr;
_tx_win32_global_int_disabled_flag = TX_TRUE;
}
}
- else if (thread_ptr)
+ else if (thread_ptr)
{
/* Determine how to apply the new posture. */
diff --git a/ports/win32/vs_2019/src/tx_thread_schedule.c b/ports/win32/vs_2019/src/tx_thread_schedule.c
index 9b8092da..d67efee8 100644
--- a/ports/win32/vs_2019/src/tx_thread_schedule.c
+++ b/ports/win32/vs_2019/src/tx_thread_schedule.c
@@ -1,18 +1,19 @@
/***************************************************************************
- * Copyright (c) 2024 Microsoft Corporation
- *
+ * Copyright (c) 2024 Microsoft Corporation
+ * Copyright (c) 2026-present Eclipse ThreadX contributors
+ *
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
- *
+ *
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
-/** */
-/** ThreadX Component */
+/** */
+/** ThreadX Component */
/** */
/** Thread */
/** */
@@ -30,48 +31,42 @@
#include "tx_timer.h"
-/**************************************************************************/
-/* */
-/* FUNCTION RELEASE */
-/* */
-/* _tx_thread_schedule Win32/Visual */
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _tx_thread_schedule Win32/Visual */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
-/* */
-/* This function waits for a thread control block pointer to appear in */
-/* the _tx_thread_execute_ptr variable. Once a thread pointer appears */
-/* in the variable, the corresponding thread is resumed. */
-/* */
-/* INPUT */
-/* */
-/* None */
-/* */
-/* OUTPUT */
-/* */
+/* */
+/* This function waits for a thread control block pointer to appear in */
+/* the _tx_thread_execute_ptr variable. Once a thread pointer appears */
+/* in the variable, the corresponding thread is resumed. */
+/* */
+/* INPUT */
+/* */
/* None */
-/* */
-/* CALLS */
-/* */
-/* ReleaseSemaphore Win32 release semaphore */
-/* ResumeThread Win32 resume thread */
-/* Sleep Win32 thread sleep */
-/* WaitForSingleObject Win32 wait on a semaphore */
-/* _tx_win32_critical_section_obtain Obtain critical section */
-/* _tx_win32_critical_section_release Release critical section */
-/* */
-/* CALLED BY */
-/* */
-/* _tx_initialize_kernel_enter ThreadX entry function */
-/* */
-/* RELEASE HISTORY */
-/* */
-/* DATE NAME DESCRIPTION */
/* */
-/* 09-30-2020 William E. Lamie Initial Version 6.1 */
+/* OUTPUT */
+/* */
+/* None */
+/* */
+/* CALLS */
+/* */
+/* ReleaseSemaphore Win32 release semaphore */
+/* ResumeThread Win32 resume thread */
+/* Sleep Win32 thread sleep */
+/* WaitForSingleObject Win32 wait on a semaphore */
+/* _tx_win32_critical_section_obtain Obtain critical section */
+/* _tx_win32_critical_section_release Release critical section */
+/* */
+/* CALLED BY */
+/* */
+/* _tx_initialize_kernel_enter ThreadX entry function */
/* */
/**************************************************************************/
VOID _tx_thread_schedule(VOID)
@@ -93,7 +88,7 @@ VOID _tx_thread_schedule(VOID)
/* Debug entry. */
_tx_win32_debug_entry_insert("SCHEDULE-wake_up", __FILE__, __LINE__);
- /* Determine if there is a thread ready to execute AND all ISRs
+ /* Determine if there is a thread ready to execute AND all ISRs
are complete. */
if ((_tx_thread_execute_ptr != TX_NULL) && (_tx_thread_system_state == 0))
{
@@ -111,8 +106,8 @@ VOID _tx_thread_schedule(VOID)
Sleep(2);
}
}
-
- /* Yes! We have a thread to execute. Note that the critical section is already
+
+ /* Yes! We have a thread to execute. Note that the critical section is already
active from the scheduling loop above. */
/* Setup the current thread pointer. */
@@ -168,12 +163,12 @@ TX_THREAD *thread_ptr;
/* Is the protection owned? */
if (critical_section -> tx_win32_critical_section_owner == GetCurrentThreadId())
{
-
+
/* Simply increment the nested counter. */
critical_section -> tx_win32_critical_section_nested_count++;
}
else
- {
+ {
/* Pickup the current thread pointer. */
thread_ptr = _tx_thread_current_ptr;
@@ -182,12 +177,12 @@ TX_THREAD *thread_ptr;
while (WaitForSingleObject(critical_section -> tx_win32_critical_section_mutex_handle, 3) != WAIT_OBJECT_0)
{
}
-
+
/* At this point we have the mutex. */
-
+
/* Increment the nesting counter. */
critical_section -> tx_win32_critical_section_nested_count = 1;
-
+
/* Remember the owner. */
critical_section -> tx_win32_critical_section_owner = GetCurrentThreadId();
}
@@ -201,25 +196,25 @@ void _tx_win32_critical_section_release(TX_WIN32_CRITICAL_SECTION *critical_s
/* Ensure the caller is the mutex owner. */
if (critical_section -> tx_win32_critical_section_owner == GetCurrentThreadId())
{
-
+
/* Determine if there is protection. */
if (critical_section -> tx_win32_critical_section_nested_count)
{
-
+
/* Decrement the nesting counter. */
critical_section -> tx_win32_critical_section_nested_count--;
-
+
/* Determine if the critical section is now being released. */
if (critical_section -> tx_win32_critical_section_nested_count == 0)
{
-
+
/* Yes, it is being released clear the owner. */
critical_section -> tx_win32_critical_section_owner = 0;
/* Finally, release the mutex. */
if (ReleaseMutex(critical_section -> tx_win32_critical_section_mutex_handle) != TX_TRUE)
{
-
+
/* Increment the system error counter. */
_tx_win32_system_error++;
}
@@ -239,7 +234,7 @@ void _tx_win32_critical_section_release(TX_WIN32_CRITICAL_SECTION *critical_s
}
else
{
-
+
/* Increment the system error counter. */
_tx_win32_system_error++;
}
@@ -252,14 +247,14 @@ void _tx_win32_critical_section_release_all(TX_WIN32_CRITICAL_SECTION *cri
/* Ensure the caller is the mutex owner. */
if (critical_section -> tx_win32_critical_section_owner == GetCurrentThreadId())
{
-
+
/* Determine if there is protection. */
if (critical_section -> tx_win32_critical_section_nested_count)
{
-
+
/* Clear the nesting counter. */
critical_section -> tx_win32_critical_section_nested_count = 0;
-
+
/* Yes, it is being release clear the owner. */
critical_section -> tx_win32_critical_section_owner = 0;
@@ -270,7 +265,7 @@ void _tx_win32_critical_section_release_all(TX_WIN32_CRITICAL_SECTION *cri
/* Increment the system error counter. */
_tx_win32_system_error++;
}
-
+
/* Just in case, make sure there the mutex is not owned. */
while (ReleaseMutex(critical_section -> tx_win32_critical_section_mutex_handle) == TX_TRUE)
{
@@ -282,7 +277,7 @@ void _tx_win32_critical_section_release_all(TX_WIN32_CRITICAL_SECTION *cri
}
else
{
-
+
/* Increment the system error counter. */
_tx_win32_system_error++;
}
diff --git a/ports/win32/vs_2019/src/tx_thread_stack_build.c b/ports/win32/vs_2019/src/tx_thread_stack_build.c
index 55b74c2b..da51e7c4 100644
--- a/ports/win32/vs_2019/src/tx_thread_stack_build.c
+++ b/ports/win32/vs_2019/src/tx_thread_stack_build.c
@@ -1,18 +1,19 @@
/***************************************************************************
- * Copyright (c) 2024 Microsoft Corporation
- *
+ * Copyright (c) 2024 Microsoft Corporation
+ * Copyright (c) 2026-present Eclipse ThreadX contributors
+ *
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
- *
+ *
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
-/** */
-/** ThreadX Component */
+/** */
+/** ThreadX Component */
/** */
/** Thread */
/** */
@@ -35,47 +36,41 @@
DWORD WINAPI _tx_win32_thread_entry(LPVOID p);
-/**************************************************************************/
-/* */
-/* FUNCTION RELEASE */
-/* */
-/* _tx_thread_stack_build Win32/Visual */
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _tx_thread_stack_build Win32/Visual */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
-/* */
+/* */
/* This function builds a stack frame on the supplied thread's stack. */
/* The stack frame results in a fake interrupt return to the supplied */
-/* function pointer. */
-/* */
-/* INPUT */
-/* */
+/* function pointer. */
+/* */
+/* INPUT */
+/* */
/* thread_ptr Pointer to thread control blk */
/* function_ptr Pointer to return function */
-/* */
-/* OUTPUT */
-/* */
+/* */
+/* OUTPUT */
+/* */
/* None */
-/* */
-/* CALLS */
-/* */
-/* CreateThread Win32 create thread */
-/* ResumeThread Win32 resume thread */
-/* SetThreadPriority Win32 set thread priority */
-/* */
-/* CALLED BY */
-/* */
-/* _tx_thread_create Create thread service */
-/* _tx_thread_reset Reset thread service */
-/* */
-/* RELEASE HISTORY */
-/* */
-/* DATE NAME DESCRIPTION */
/* */
-/* 09-30-2020 William E. Lamie Initial Version 6.1 */
+/* CALLS */
+/* */
+/* CreateThread Win32 create thread */
+/* ResumeThread Win32 resume thread */
+/* SetThreadPriority Win32 set thread priority */
+/* */
+/* CALLED BY */
+/* */
+/* _tx_thread_create Create thread service */
+/* _tx_thread_reset Reset thread service */
/* */
/**************************************************************************/
VOID _tx_thread_stack_build(TX_THREAD *thread_ptr, VOID (*function_ptr)(VOID))
@@ -83,7 +78,7 @@ VOID _tx_thread_stack_build(TX_THREAD *thread_ptr, VOID (*function_ptr)(VOID))
/* Create a Win32 thread for the application thread. */
thread_ptr -> tx_thread_win32_thread_handle =
- CreateThread(NULL, 0, _tx_win32_thread_entry, (LPVOID) thread_ptr, CREATE_SUSPENDED,
+ CreateThread(NULL, 0, _tx_win32_thread_entry, (LPVOID) thread_ptr, CREATE_SUSPENDED,
&(thread_ptr -> tx_thread_win32_thread_id));
/* Check for a good thread create. */
@@ -116,11 +111,11 @@ VOID _tx_thread_stack_build(TX_THREAD *thread_ptr, VOID (*function_ptr)(VOID))
}
}
- /* Setup the thread suspension type to solicited thread suspension.
+ /* Setup the thread suspension type to solicited thread suspension.
Pseudo interrupt handlers will suspend with this field set to 1. */
thread_ptr -> tx_thread_win32_suspension_type = 0;
- /* Clear the disabled count that will keep track of the
+ /* Clear the disabled count that will keep track of the
tx_interrupt_control nesting. */
thread_ptr -> tx_thread_win32_int_disabled_flag = 0;
diff --git a/ports/win32/vs_2019/src/tx_thread_system_return.c b/ports/win32/vs_2019/src/tx_thread_system_return.c
index c5870ee2..60176135 100644
--- a/ports/win32/vs_2019/src/tx_thread_system_return.c
+++ b/ports/win32/vs_2019/src/tx_thread_system_return.c
@@ -1,18 +1,19 @@
/***************************************************************************
- * Copyright (c) 2024 Microsoft Corporation
- *
+ * Copyright (c) 2024 Microsoft Corporation
+ * Copyright (c) 2026-present Eclipse ThreadX contributors
+ *
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
- *
+ *
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
-/** */
-/** ThreadX Component */
+/** */
+/** ThreadX Component */
/** */
/** Thread */
/** */
@@ -30,53 +31,47 @@
#include <stdio.h>
-/**************************************************************************/
-/* */
-/* FUNCTION RELEASE */
-/* */
-/* _tx_thread_system_return Win32/Visual */
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _tx_thread_system_return Win32/Visual */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
-/* */
-/* This function is target processor specific. It is used to transfer */
-/* control from a thread back to the system. Only a minimal context */
-/* is saved since the compiler assumes temp registers are going to get */
-/* slicked by a function call anyway. */
-/* */
-/* INPUT */
-/* */
-/* None */
-/* */
-/* OUTPUT */
-/* */
-/* None */
-/* */
-/* CALLS */
-/* */
-/* _tx_win32_critical_section_obtain Obtain critical section */
-/* _tx_win32_critical_section_release Release critical section */
-/* _tx_win32_critical_section_release_all */
-/* Release critical section */
-/* ExitThread Win32 thread exit */
-/* GetCurrentThread Win32 get current thread */
-/* GetCurrentThreadId Win32 get current thread ID */
-/* GetThreadPriority Win32 get thread priority */
-/* ReleaseSemaphore Win32 release semaphore */
-/* WaitForSingleObject Win32 wait on semaphore */
-/* */
-/* CALLED BY */
-/* */
-/* ThreadX components */
-/* */
-/* RELEASE HISTORY */
-/* */
-/* DATE NAME DESCRIPTION */
/* */
-/* 09-30-2020 William E. Lamie Initial Version 6.1 */
+/* This function is target processor specific. It is used to transfer */
+/* control from a thread back to the system. Only a minimal context */
+/* is saved since the compiler assumes temp registers are going to get */
+/* slicked by a function call anyway. */
+/* */
+/* INPUT */
+/* */
+/* None */
+/* */
+/* OUTPUT */
+/* */
+/* None */
+/* */
+/* CALLS */
+/* */
+/* _tx_win32_critical_section_obtain Obtain critical section */
+/* _tx_win32_critical_section_release Release critical section */
+/* _tx_win32_critical_section_release_all */
+/* Release critical section */
+/* ExitThread Win32 thread exit */
+/* GetCurrentThread Win32 get current thread */
+/* GetCurrentThreadId Win32 get current thread ID */
+/* GetThreadPriority Win32 get thread priority */
+/* ReleaseSemaphore Win32 release semaphore */
+/* WaitForSingleObject Win32 wait on semaphore */
+/* */
+/* CALLED BY */
+/* */
+/* ThreadX components */
/* */
/**************************************************************************/
VOID _tx_thread_system_return(VOID)
@@ -86,7 +81,7 @@ TX_THREAD *temp_thread_ptr;
HANDLE temp_run_semaphore;
UINT temp_thread_state;
HANDLE threadhandle;
-int threadpriority;
+int threadpriority;
DWORD threadid;
@@ -102,7 +97,7 @@ DWORD threadid;
/* First, determine if the thread was terminated. */
/* Pickup the priority of the current thread. */
- threadpriority = GetThreadPriority(threadhandle);
+ threadpriority = GetThreadPriority(threadhandle);
/* Pickup the ID of the current thread. */
threadid = GetCurrentThreadId();
@@ -110,21 +105,21 @@ DWORD threadid;
/* Pickup the current thread pointer. */
temp_thread_ptr = _tx_thread_current_ptr;
- /* Determine if this is a thread (THREAD_PRIORITY_LOWEST) and it does not
+ /* Determine if this is a thread (THREAD_PRIORITY_LOWEST) and it does not
match the current thread pointer. */
- if ((threadpriority == THREAD_PRIORITY_LOWEST) &&
- ((!temp_thread_ptr) || (temp_thread_ptr -> tx_thread_win32_thread_id != threadid)))
- {
+ if ((threadpriority == THREAD_PRIORITY_LOWEST) &&
+ ((!temp_thread_ptr) || (temp_thread_ptr -> tx_thread_win32_thread_id != threadid)))
+ {
- /* This indicates the Win32 thread was actually terminated by ThreadX and is only
+ /* This indicates the Win32 thread was actually terminated by ThreadX and is only
being allowed to run in order to cleanup its resources. */
-
+
/* Release critical section. */
_tx_win32_critical_section_release_all(&_tx_win32_critical_section);
-
+
/* Exit thread. */
- ExitThread(0);
- }
+ ExitThread(0);
+ }
/* Determine if the time-slice is active. */
if (_tx_timer_time_slice)
@@ -181,19 +176,19 @@ DWORD threadid;
/* Pickup the current thread pointer. */
temp_thread_ptr = _tx_thread_current_ptr;
- /* Determine if this is a thread (THREAD_PRIORITY_LOWEST) and it does not
+ /* Determine if this is a thread (THREAD_PRIORITY_LOWEST) and it does not
match the current thread pointer. */
- if ((threadpriority == THREAD_PRIORITY_LOWEST) &&
- ((!temp_thread_ptr) || (temp_thread_ptr -> tx_thread_win32_thread_id != threadid)))
- {
+ if ((threadpriority == THREAD_PRIORITY_LOWEST) &&
+ ((!temp_thread_ptr) || (temp_thread_ptr -> tx_thread_win32_thread_id != threadid)))
+ {
/* Leave Win32 critical section. */
_tx_win32_critical_section_release_all(&_tx_win32_critical_section);
- /* This indicates the Win32 thread was actually terminated by ThreadX and is only
+ /* This indicates the Win32 thread was actually terminated by ThreadX and is only
being allowed to run in order to cleanup its resources. */
- ExitThread(0);
- }
+ ExitThread(0);
+ }
/* Now determine if the application thread last had interrupts disabled. */
diff --git a/ports/win32/vs_2019/src/tx_timer_interrupt.c b/ports/win32/vs_2019/src/tx_timer_interrupt.c
index 7830536d..a60ad144 100644
--- a/ports/win32/vs_2019/src/tx_timer_interrupt.c
+++ b/ports/win32/vs_2019/src/tx_timer_interrupt.c
@@ -1,18 +1,19 @@
/***************************************************************************
- * Copyright (c) 2024 Microsoft Corporation
- *
+ * Copyright (c) 2024 Microsoft Corporation
+ * Copyright (c) 2026-present Eclipse ThreadX contributors
+ *
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
- *
+ *
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
-/** */
-/** ThreadX Component */
+/** */
+/** ThreadX Component */
/** */
/** Timer */
/** */
@@ -29,48 +30,42 @@
#include "tx_thread.h"
-/**************************************************************************/
-/* */
-/* FUNCTION RELEASE */
-/* */
-/* _tx_timer_interrupt Win32/Visual */
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _tx_timer_interrupt Win32/Visual */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
-/* */
-/* This function processes the hardware timer interrupt. This */
-/* processing includes incrementing the system clock and checking for */
-/* time slice and/or timer expiration. If either is found, the */
-/* interrupt context save/restore functions are called along with the */
-/* expiration functions. */
-/* */
-/* INPUT */
-/* */
-/* None */
-/* */
-/* OUTPUT */
-/* */
-/* None */
-/* */
-/* CALLS */
-/* */
-/* _tx_thread_time_slice Time slice interrupted thread */
-/* _tx_timer_expiration_process Timer expiration processing */
-/* _tx_win32_critical_section_obtain Obtain critical section */
-/* _tx_win32_critical_section_release Release critical section */
-/* */
-/* CALLED BY */
-/* */
-/* interrupt vector */
-/* */
-/* RELEASE HISTORY */
-/* */
-/* DATE NAME DESCRIPTION */
/* */
-/* 09-30-2020 William E. Lamie Initial Version 6.1 */
+/* This function processes the hardware timer interrupt. This */
+/* processing includes incrementing the system clock and checking for */
+/* time slice and/or timer expiration. If either is found, the */
+/* interrupt context save/restore functions are called along with the */
+/* expiration functions. */
+/* */
+/* INPUT */
+/* */
+/* None */
+/* */
+/* OUTPUT */
+/* */
+/* None */
+/* */
+/* CALLS */
+/* */
+/* _tx_thread_time_slice Time slice interrupted thread */
+/* _tx_timer_expiration_process Timer expiration processing */
+/* _tx_win32_critical_section_obtain Obtain critical section */
+/* _tx_win32_critical_section_release Release critical section */
+/* */
+/* CALLED BY */
+/* */
+/* interrupt vector */
/* */
/**************************************************************************/
VOID _tx_timer_interrupt(VOID)