diff --git a/.gitignore b/.gitignore
index 7f7bab74a77..72a8882ed48 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,6 +13,7 @@
*.crf
build
Debug
+.vs
rtthread
settings
documentation/html
diff --git a/bsp/simulator/template_vs2012.vcxproj b/bsp/simulator/template_vs2012.vcxproj
index 0ace6590650..610a05b4c47 100644
--- a/bsp/simulator/template_vs2012.vcxproj
+++ b/bsp/simulator/template_vs2012.vcxproj
@@ -44,6 +44,8 @@
Level3
EditAndContinue
/utf-8 %(AdditionalOptions)
+ stdc11
+ 4029
winmm.lib;Packet.lib;wpcap.lib;%(AdditionalDependencies)
diff --git a/components/finsh/finsh.h b/components/finsh/finsh.h
index 5c97ccd7315..d9ddec59831 100644
--- a/components/finsh/finsh.h
+++ b/components/finsh/finsh.h
@@ -212,14 +212,22 @@ typedef struct msh_cmd_opt
*
* @param[in] command The command associated with these options.
*/
+#ifdef _MSC_VER
+#define CMD_OPTIONS_STATEMENT(command) static struct msh_cmd_opt command##_msh_options[16];
+#else
#define CMD_OPTIONS_STATEMENT(command) static struct msh_cmd_opt command##_msh_options[];
+#endif
/**
* @brief Starts the definition of command options for a specific command.
*
* @param[in] command The command these options are associated with.
*/
+#ifdef _MSC_VER
+#define CMD_OPTIONS_NODE_START(command) static struct msh_cmd_opt command##_msh_options[16] = {
+#else
#define CMD_OPTIONS_NODE_START(command) static struct msh_cmd_opt command##_msh_options[] = {
+#endif
/**
* @brief Defines a single command option.
diff --git a/include/rttypes.h b/include/rttypes.h
index 75bf58d52f9..aa2d70d7b4a 100644
--- a/include/rttypes.h
+++ b/include/rttypes.h
@@ -32,6 +32,12 @@ extern "C" {
* RT-Thread basic data types definition
*/
+#if defined(_WIN64) || defined(__x86_64__)
+#ifndef ARCH_CPU_64BIT
+#define ARCH_CPU_64BIT
+#endif // ARCH_CPU_64BIT
+#endif // defined(_WIN64) || defined(__x86_64__)
+
typedef int rt_bool_t; /**< boolean type */
#ifndef RT_USING_ARCH_DATA_TYPE
diff --git a/libcpu/sim/win32/cpu_port.c b/libcpu/sim/win32/cpu_port.c
index 4f8b32271b6..ad5891c91fa 100644
--- a/libcpu/sim/win32/cpu_port.c
+++ b/libcpu/sim/win32/cpu_port.c
@@ -97,8 +97,9 @@ static MMRESULT OSTick_TimerID;
/*
* flag in interrupt handling
*/
-rt_uint32_t rt_interrupt_from_thread, rt_interrupt_to_thread;
-rt_uint32_t rt_thread_switch_interrupt_flag;
+volatile rt_ubase_t rt_interrupt_from_thread = 0;
+volatile rt_ubase_t rt_interrupt_to_thread = 0;
+volatile rt_uint32_t rt_thread_switch_interrupt_flag = 0;
/*
*********************************************************************************************************
@@ -248,18 +249,17 @@ void rt_hw_interrupt_enable(rt_base_t level)
* Note(s) : none
*********************************************************************************************************
*/
-void rt_hw_context_switch_interrupt(rt_uint32_t from,
- rt_uint32_t to)
+void rt_hw_context_switch_interrupt(rt_ubase_t from, rt_ubase_t to, rt_thread_t from_thread, rt_thread_t to_thread)
{
if(rt_thread_switch_interrupt_flag != 1)
{
rt_thread_switch_interrupt_flag = 1;
// set rt_interrupt_from_thread
- rt_interrupt_from_thread = *((rt_uint32_t *)(from));
+ rt_interrupt_from_thread = *((rt_ubase_t *)(from));
}
- rt_interrupt_to_thread = *((rt_uint32_t *)(to));
+ rt_interrupt_to_thread = *((rt_ubase_t *)(to));
//trigger YIELD exception(cause context switch)
TriggerSimulateInterrupt(CPU_INTERRUPT_YIELD);
@@ -267,20 +267,19 @@ void rt_hw_context_switch_interrupt(rt_uint32_t from,
-void rt_hw_context_switch(rt_uint32_t from,
- rt_uint32_t to)
+void rt_hw_context_switch(rt_ubase_t from, rt_ubase_t to)
{
if(rt_thread_switch_interrupt_flag != 1)
{
rt_thread_switch_interrupt_flag = 1;
// set rt_interrupt_from_thread
- rt_interrupt_from_thread = *((rt_uint32_t *)(from));
+ rt_interrupt_from_thread = *((rt_ubase_t *)(from));
}
// set rt_interrupt_to_thread
- rt_interrupt_to_thread = *((rt_uint32_t *)(to));
+ rt_interrupt_to_thread = *((rt_ubase_t *)(to));
//trigger YIELD exception(cause contex switch)
TriggerSimulateInterrupt(CPU_INTERRUPT_YIELD);
@@ -310,10 +309,10 @@ void rt_hw_context_switch(rt_uint32_t from,
* Note(s) : this function is used to perform the first thread switch
*********************************************************************************************************
*/
-void rt_hw_context_switch_to(rt_uint32_t to)
+void rt_hw_context_switch_to(rt_ubase_t to)
{
//set to thread
- rt_interrupt_to_thread = *((rt_uint32_t *)(to));
+ rt_interrupt_to_thread = *((rt_ubase_t *)(to));
//clear from thread
rt_interrupt_from_thread = 0;
@@ -699,14 +698,3 @@ rt_uint32_t YieldInterruptHandle(void)
return 0;
} /*** YieldInterruptHandle ***/
-
-/* system entry */
-extern int rtthread_startup(void);
-int wmain(int argc, char* argv[])
-{
- /* disable interrupt first */
- rt_hw_interrupt_disable();
- /* startup RT-Thread RTOS */
- rtthread_startup();
-}
-#pragma comment(linker, "/subsystem:console /entry:wmainCRTStartup")
diff --git a/libcpu/sim/win32/startup.c b/libcpu/sim/win32/startup_msvc.c
similarity index 90%
rename from libcpu/sim/win32/startup.c
rename to libcpu/sim/win32/startup_msvc.c
index f0f2784a7a1..6bf7a575bcd 100644
--- a/libcpu/sim/win32/startup.c
+++ b/libcpu/sim/win32/startup_msvc.c
@@ -221,33 +221,16 @@ void rt_application_init(void);
void rt_hw_board_init(void);
int rtthread_startup(void);
-#if defined(__ARMCC_VERSION)
-extern int $Super$$main(void);
-/* re-define main function */
-int $Sub$$main(void)
-{
- rtthread_startup();
- return 0;
-}
-#elif defined(__ICCARM__)
-extern int main(void);
-/* __low_level_init will auto called by IAR cstartup */
-extern void __iar_data_init3(void);
-int __low_level_init(void)
-{
- // call IAR table copy function.
- __iar_data_init3();
- rtthread_startup();
- return 0;
-}
-#elif defined(__GNUC__)
-/* Add -eentry to arm-none-eabi-gcc argument */
-int entry(void)
+/* system entry */
+extern int rtthread_startup(void);
+int wmain(int argc, char* argv[])
{
+ /* disable interrupt first */
+ rt_hw_interrupt_disable();
+ /* startup RT-Thread RTOS */
rtthread_startup();
- return 0;
}
-#endif
+#pragma comment(linker, "/subsystem:console /entry:wmainCRTStartup")
#ifndef RT_USING_HEAP
/* if there is not enable heap, we should use static thread and stack. */
@@ -269,15 +252,9 @@ void main_thread_entry(void *parameter)
#ifdef RT_USING_SMP
rt_hw_secondary_cpu_up();
#endif
+
/* invoke system main function */
-#if defined(__ARMCC_VERSION)
- {
- extern int $Super$$main(void);
- $Super$$main(); /* for ARMCC. */
- }
-#elif defined(__ICCARM__) || defined(__GNUC__) || defined(__TASKING__) || defined(_MSC_VER)
main();
-#endif
}
void rt_application_init(void)
diff --git a/src/SConscript b/src/SConscript
index 93b8e8e3f3d..7b2dec5e4ce 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -50,9 +50,14 @@ if GetDepend('RT_USING_HOOKLIST') == True:
elif rtconfig.PLATFORM in ['armcc']:
LOCAL_CFLAGS += ' --c99 --gnu'
-group = DefineGroup('Kernel', src, depend=[''], CPPPATH=inc,
- LINKFLAGS=LINKFLAGS, LOCAL_CFLAGS=LOCAL_CFLAGS,
- CPPDEFINES=['__RTTHREAD__'], LOCAL_CPPDEFINES=['__RT_KERNEL_SOURCE__'])
+if rtconfig.CROSS_TOOL == 'msvc':
+ group = DefineGroup('Kernel', src, depend=[''], CPPPATH=inc,
+ LINKFLAGS=LINKFLAGS, LOCAL_CFLAGS=LOCAL_CFLAGS,
+ CPPDEFINES=['__RTTHREAD__', '__RT_KERNEL_SOURCE__'])
+else:
+ group = DefineGroup('Kernel', src, depend=[''], CPPPATH=inc,
+ LINKFLAGS=LINKFLAGS, LOCAL_CFLAGS=LOCAL_CFLAGS,
+ CPPDEFINES=['__RTTHREAD__'], LOCAL_CPPDEFINES=['__RT_KERNEL_SOURCE__'])
list = os.listdir(cwd)
for item in list:
diff --git a/src/scheduler_up.c b/src/scheduler_up.c
index 693cfcae0ed..95e3cc7fb64 100644
--- a/src/scheduler_up.c
+++ b/src/scheduler_up.c
@@ -32,6 +32,7 @@
* 2023-10-17 ChuShicheng Modify the timing of clearing RT_THREAD_STAT_YIELD flag bits
*/
+#define __RT_IPC_SOURCE__
#include
#include