fixed coding style in x86 branch

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2351 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
dzzxzz@gmail.com 2012-10-15 00:51:09 +00:00
parent 0c13711396
commit 9393c29224
2 changed files with 147 additions and 116 deletions

View File

@ -1,61 +1,80 @@
/* /** File : application.c
* File : application.c
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team
* COPYRIGHT (C) 2006 - 2012, RT-Thread Develop Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
* http://openlab.rt-thread.com/license/LICENSE * http://openlab.rt-thread.com/license/LICENSE
* *
* Change Logs:
* Change Logs:
* Date Author Notes * Date Author Notes
* 2006-09-15 QiuYi the first version * 2006-09-15 QiuYi the first version
*/ */
/** /**
* @addtogroup QEMU * @addtogroup QEMU
*/ */
/*@{*/ /*@{*/
#include <rtthread.h> #include <rtthread.h>
ALIGN(RT_ALIGN_SIZE) ALIGN(RT_ALIGN_SIZE)
static char thread_led1_stack[1024]; static char thread_led1_stack[1024];
struct rt_thread thread_led1; struct rt_thread thread_led1;
static void rt_thread_entry_led1(void* parameter) static void rt_thread_entry_led1(void *parameter)
{ {
unsigned int count=0; unsigned int count=0;
while (1) while (1)
{ {
/* led1 on */ /* led1 on */
#ifndef RT_USING_FINSH #ifndef RT_USING_FINSH
rt_kprintf("led1 on,count : %d\r\n",count); rt_kprintf("led1 on,count : %d\r\n",count);
#endif #endif
count++; count ++;
/* sleep 0.5 second and switch to other thread */ /* sleep 0.5 second and switch to other thread */
rt_thread_delay(RT_TICK_PER_SECOND/2); rt_thread_delay(RT_TICK_PER_SECOND / 2);
/* led1 off */ /* led1 off */
#ifndef RT_USING_FINSH #ifndef RT_USING_FINSH
rt_kprintf("led1 off\r\n"); rt_kprintf("led1 off\r\n");
#endif #endif
rt_thread_delay(RT_TICK_PER_SECOND/2); rt_thread_delay(RT_TICK_PER_SECOND / 2);
} }
} }
ALIGN(RT_ALIGN_SIZE) ALIGN(RT_ALIGN_SIZE)
static char thread_led2_stack[1024]; static char thread_led2_stack[1024];
struct rt_thread thread_led2; struct rt_thread thread_led2;
void rt_thread_entry_led2(void* parameter) void rt_thread_entry_led2(void *parameter)
{ {
unsigned int count=0; unsigned int count=0;
while (1) while (1)
{ {
/* led2 on */ /* led2 on */
#ifndef RT_USING_FINSH #ifndef RT_USING_FINSH
rt_kprintf("led2 on,count : %d\r\n",count); rt_kprintf("led2 on,count : %d\r\n",count);
#endif #endif
count++; count ++;
rt_thread_delay(RT_TICK_PER_SECOND); rt_thread_delay(RT_TICK_PER_SECOND);
/* led2 off */ /* led2 off */
@ -67,11 +86,17 @@ void rt_thread_entry_led2(void* parameter)
} }
/** /**
* This function will be invoked to initalize user application when system startup.
* This function will be invoked to initalize user application when system
* startup.
*/ */
int rt_application_init()
int rt_application_init(void)
{ {
//------- init led1 thread
// init led1 thread
rt_thread_init(&thread_led1, rt_thread_init(&thread_led1,
"led1", "led1",
rt_thread_entry_led1, rt_thread_entry_led1,
@ -80,7 +105,7 @@ int rt_application_init()
sizeof(thread_led1_stack),11,5); sizeof(thread_led1_stack),11,5);
rt_thread_startup(&thread_led1); rt_thread_startup(&thread_led1);
//------- init led2 thread // init led2 thread
rt_thread_init(&thread_led2, rt_thread_init(&thread_led2,
"led2", "led2",
rt_thread_entry_led2, rt_thread_entry_led2,
@ -89,7 +114,11 @@ int rt_application_init()
sizeof(thread_led2_stack),12,5); sizeof(thread_led2_stack),12,5);
rt_thread_startup(&thread_led2); rt_thread_startup(&thread_led2);
return 0; /* empty */ return 0;
} }
/*@}*/ /*@}*/

View File

@ -1,7 +1,7 @@
/* /*
* File : startup.c * File : startup.c
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Develop Team * COPYRIGHT (C) 2006 - 2012, RT-Thread Develop Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@ -28,7 +28,7 @@ extern int rt_application_init(void);
#ifdef RT_USING_FINSH #ifdef RT_USING_FINSH
extern void finsh_system_init(void); extern void finsh_system_init(void);
extern void finsh_set_device(const char* device); extern void finsh_set_device(const char *device);
#endif #endif
extern unsigned char __bss_start[]; extern unsigned char __bss_start[];
@ -37,71 +37,73 @@ extern unsigned char __bss_end[];
/** /**
* @addtogroup QEMU * @addtogroup QEMU
*/ */
/*@{*/ /*@{*/
/* clear .bss */ /* clear .bss */
void rt_hw_clear_bss() void rt_hw_clear_bss(void)
{ {
unsigned char *dst; unsigned char *dst;
dst = __bss_start; dst = __bss_start;
while(dst < __bss_end) *dst++ = 0; while (dst < __bss_end)
*dst++ = 0;
} }
/** /**
* This function will startup RT-Thread RTOS * This function will startup RT-Thread RTOS
*/ */
void rtthread_startup() void rtthread_startup(void)
{ {
/* clear .bss */ /* clear .bss */
rt_hw_clear_bss(); rt_hw_clear_bss();
/* init hardware interrupt */ /* init hardware interrupt */
rt_hw_interrupt_init(); rt_hw_interrupt_init();
/* init the console */ /* init the console */
rt_hw_console_init(); rt_hw_console_init();
rt_console_set_device("console"); rt_console_set_device("console");
/* init board */ /* init board */
rt_hw_board_init(); rt_hw_board_init();
rt_show_version(); rt_show_version();
/* init tick */ /* init tick */
rt_system_tick_init(); rt_system_tick_init();
/* init kernel object */ /* init kernel object */
rt_system_object_init(); rt_system_object_init();
/* init timer system */ /* init timer system */
rt_system_timer_init(); rt_system_timer_init();
/* init memory system */ /* init memory system */
#ifdef RT_USING_HEAP #ifdef RT_USING_HEAP
rt_system_heap_init((void*)&__bss_end, (void*)(1024UL*1024*8)); /* RAM 16M */ /* RAM 16M */
rt_system_heap_init((void *)&__bss_end, (void *)(1024UL*1024*8));
#endif #endif
/* init scheduler system */ /* init scheduler system */
rt_system_scheduler_init(); rt_system_scheduler_init();
/* init application */ /* init application */
rt_application_init(); rt_application_init();
#ifdef RT_USING_FINSH #ifdef RT_USING_FINSH
/* init finsh */ /* init finsh */
finsh_system_init(); finsh_system_init();
finsh_set_device("console"); finsh_set_device("console");
#endif #endif
/* init idle thread */ /* init idle thread */
rt_thread_idle_init(); rt_thread_idle_init();
/* start scheduler */ /* start scheduler */
rt_system_scheduler_start(); rt_system_scheduler_start();
/* never reach here */
return ;
/* never reach here */
return ;
} }
/*@}*/ /*@}*/