Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*.crf
build
Debug
.vs
rtthread
settings
documentation/html
Expand Down
2 changes: 2 additions & 0 deletions bsp/simulator/template_vs2012.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<TreatSpecificWarningsAsErrors>4029</TreatSpecificWarningsAsErrors>
</ClCompile>
<Link>
<AdditionalDependencies>winmm.lib;Packet.lib;wpcap.lib;%(AdditionalDependencies)</AdditionalDependencies>
Expand Down
8 changes: 8 additions & 0 deletions components/finsh/finsh.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions include/rttypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 11 additions & 23 deletions libcpu/sim/win32/cpu_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/*
*********************************************************************************************************
Expand Down Expand Up @@ -248,39 +249,37 @@ 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);
} /*** rt_hw_context_switch_interrupt ***/



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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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")
39 changes: 8 additions & 31 deletions libcpu/sim/win32/startup.c → libcpu/sim/win32/startup_msvc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand All @@ -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)
Expand Down
11 changes: 8 additions & 3 deletions src/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/scheduler_up.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* 2023-10-17 ChuShicheng Modify the timing of clearing RT_THREAD_STAT_YIELD flag bits
*/

#define __RT_IPC_SOURCE__
#include <rtthread.h>
#include <rthw.h>

Expand Down