diff options
| author | Bernard Xiong <[email protected]> | 2021-02-19 23:55:17 +0800 |
|---|---|---|
| committer | Bernard Xiong <[email protected]> | 2021-02-19 23:55:17 +0800 |
| commit | 2da5d4a5d6b5e04838b77122410a049e0a10cfa6 (patch) | |
| tree | dce9f0cb86fefb7a189961f539faac4797e35374 /bsp/x86/drivers/board.c | |
| parent | e596921019839fdaf1c0c2c76a1aa13f4c083299 (diff) | |
[bsp][x86] update x86 with Kconfig and newlib toolchains.
Diffstat (limited to 'bsp/x86/drivers/board.c')
| -rw-r--r-- | bsp/x86/drivers/board.c | 75 |
1 files changed, 45 insertions, 30 deletions
diff --git a/bsp/x86/drivers/board.c b/bsp/x86/drivers/board.c index 211ae1832a..30aba8be54 100644 --- a/bsp/x86/drivers/board.c +++ b/bsp/x86/drivers/board.c @@ -1,11 +1,7 @@ /* - * File : board.c - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.fayfayspace.org/license/LICENSE. + * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes @@ -13,62 +9,81 @@ * 2006-10-10 Bernard add hardware related of finsh */ -#include <rtthread.h> #include <rthw.h> +#include <rtthread.h> #include <bsp.h> +extern unsigned char __bss_start[]; +extern unsigned char __bss_end[]; +extern void rt_hw_console_init(void); + /** * @addtogroup QEMU */ /*@{*/ - static void rt_timer_handler(int vector, void* param) { - rt_tick_increase(); + rt_tick_increase(); } #ifdef RT_USING_HOOK static void idle_hook(void) { - asm volatile("sti; hlt": : :"memory"); + asm volatile("sti; hlt": : :"memory"); } #endif +/* clear .bss */ +void rt_hw_clear_bss(void) +{ + unsigned char *dst; + dst = __bss_start; + while (dst < __bss_end) + *dst++ = 0; +} + /** * This function will init QEMU * */ void rt_hw_board_init(void) { - /* initialize 8253 clock to interrupt 1000 times/sec */ - outb(TIMER_MODE, TIMER_SEL0|TIMER_RATEGEN|TIMER_16BIT); - outb(IO_TIMER1, TIMER_DIV(RT_TICK_PER_SECOND) % 256); - outb(IO_TIMER1, TIMER_DIV(RT_TICK_PER_SECOND) / 256); + /* clear .bss */ + rt_hw_clear_bss(); + + /* init hardware interrupt */ + rt_hw_interrupt_init(); - /* install interrupt handler */ - rt_hw_interrupt_install(INTTIMER0, rt_timer_handler, RT_NULL, "tick"); - rt_hw_interrupt_umask(INTTIMER0); + /* init the console */ + rt_hw_console_init(); + rt_console_set_device("console"); + + /* initialize 8253 clock to interrupt 1000 times/sec */ + outb(TIMER_MODE, TIMER_SEL0|TIMER_RATEGEN|TIMER_16BIT); + outb(IO_TIMER1, TIMER_DIV(RT_TICK_PER_SECOND) % 256); + outb(IO_TIMER1, TIMER_DIV(RT_TICK_PER_SECOND) / 256); + + /* install interrupt handler */ + rt_hw_interrupt_install(INTTIMER0, rt_timer_handler, RT_NULL, "tick"); + rt_hw_interrupt_umask(INTTIMER0); + + /* init memory system */ +#ifdef RT_USING_HEAP + /* RAM 16M */ + rt_system_heap_init((void *)&__bss_end, (void *)(1024UL*1024*8)); +#endif #ifdef RT_USING_HOOK - rt_thread_idle_sethook(idle_hook); + rt_thread_idle_sethook(idle_hook); #endif } -void restart(void) +static int reboot(void) { outb(KBSTATP, 0xFE); /* pulse reset low */ - while(1); -} - -#ifdef RT_USING_FINSH -#include <finsh.h> -FINSH_FUNCTION_EXPORT(restart, reboot PC) -void reboot(void) -{ - restart(); + return 0; } -FINSH_FUNCTION_EXPORT(reboot, reboot PC) -#endif +MSH_CMD_EXPORT(reboot, reboot system); /*@}*/ |
