2009-07-03 07:19:19 +08:00
|
|
|
/*
|
2021-02-19 23:55:17 +08:00
|
|
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
2009-07-03 07:19:19 +08:00
|
|
|
*
|
2021-02-19 23:55:17 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2009-07-03 07:19:19 +08:00
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2006-09-15 QiuYi the first version
|
|
|
|
* 2006-10-10 Bernard add hardware related of finsh
|
|
|
|
*/
|
2012-02-16 23:58:52 +08:00
|
|
|
|
2009-07-03 07:19:19 +08:00
|
|
|
#include <rthw.h>
|
2021-02-19 23:55:17 +08:00
|
|
|
#include <rtthread.h>
|
2009-07-03 07:19:19 +08:00
|
|
|
|
|
|
|
#include <bsp.h>
|
|
|
|
|
2021-02-19 23:55:17 +08:00
|
|
|
extern unsigned char __bss_start[];
|
|
|
|
extern unsigned char __bss_end[];
|
|
|
|
extern void rt_hw_console_init(void);
|
|
|
|
|
2009-07-03 07:19:19 +08:00
|
|
|
/**
|
|
|
|
* @addtogroup QEMU
|
|
|
|
*/
|
|
|
|
/*@{*/
|
2015-09-15 19:50:29 +08:00
|
|
|
static void rt_timer_handler(int vector, void* param)
|
2009-07-03 07:19:19 +08:00
|
|
|
{
|
2021-02-19 23:55:17 +08:00
|
|
|
rt_tick_increase();
|
2013-01-08 22:40:58 +08:00
|
|
|
}
|
|
|
|
|
2012-02-18 22:49:46 +08:00
|
|
|
#ifdef RT_USING_HOOK
|
2013-01-08 22:40:58 +08:00
|
|
|
static void idle_hook(void)
|
|
|
|
{
|
2021-02-19 23:55:17 +08:00
|
|
|
asm volatile("sti; hlt": : :"memory");
|
2009-07-03 07:19:19 +08:00
|
|
|
}
|
2012-02-18 22:49:46 +08:00
|
|
|
#endif
|
2009-07-03 07:19:19 +08:00
|
|
|
|
2021-02-19 23:55:17 +08:00
|
|
|
/* clear .bss */
|
|
|
|
void rt_hw_clear_bss(void)
|
|
|
|
{
|
|
|
|
unsigned char *dst;
|
|
|
|
dst = __bss_start;
|
|
|
|
while (dst < __bss_end)
|
|
|
|
*dst++ = 0;
|
|
|
|
}
|
|
|
|
|
2009-07-03 07:19:19 +08:00
|
|
|
/**
|
|
|
|
* This function will init QEMU
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void rt_hw_board_init(void)
|
|
|
|
{
|
2021-02-19 23:55:17 +08:00
|
|
|
/* clear .bss */
|
|
|
|
rt_hw_clear_bss();
|
|
|
|
|
|
|
|
/* init hardware interrupt */
|
|
|
|
rt_hw_interrupt_init();
|
2009-07-03 07:19:19 +08:00
|
|
|
|
2021-02-19 23:55:17 +08:00
|
|
|
/* 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
|
2013-01-08 22:40:58 +08:00
|
|
|
|
2012-02-18 22:49:46 +08:00
|
|
|
#ifdef RT_USING_HOOK
|
2021-02-19 23:55:17 +08:00
|
|
|
rt_thread_idle_sethook(idle_hook);
|
2012-02-18 22:49:46 +08:00
|
|
|
#endif
|
2009-07-03 07:19:19 +08:00
|
|
|
}
|
2013-01-08 22:40:58 +08:00
|
|
|
|
2021-02-19 23:55:17 +08:00
|
|
|
static int reboot(void)
|
2013-01-08 22:40:58 +08:00
|
|
|
{
|
|
|
|
outb(KBSTATP, 0xFE); /* pulse reset low */
|
|
|
|
|
2021-02-19 23:55:17 +08:00
|
|
|
return 0;
|
2013-01-08 22:40:58 +08:00
|
|
|
}
|
2021-02-19 23:55:17 +08:00
|
|
|
MSH_CMD_EXPORT(reboot, reboot system);
|
2009-07-03 07:19:19 +08:00
|
|
|
/*@}*/
|