2009-07-03 07:19:19 +08:00
|
|
|
/*
|
|
|
|
* File : board.c
|
|
|
|
* This file is part of RT-Thread RTOS
|
|
|
|
* COPYRIGHT (C) 2006, 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.
|
|
|
|
*
|
|
|
|
* 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 <rtthread.h>
|
|
|
|
#include <rthw.h>
|
|
|
|
|
|
|
|
#include <bsp.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
* This function will init QEMU
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void rt_hw_board_init(void)
|
|
|
|
{
|
2012-02-16 23:58:52 +08:00
|
|
|
/* initialize 8253 clock to interrupt 1000 times/sec */
|
2009-07-03 07:19:19 +08:00
|
|
|
outb(TIMER_MODE, TIMER_SEL0|TIMER_RATEGEN|TIMER_16BIT);
|
2012-02-16 23:58:52 +08:00
|
|
|
outb(IO_TIMER1, TIMER_DIV(RT_TICK_PER_SECOND) % 256);
|
|
|
|
outb(IO_TIMER1, TIMER_DIV(RT_TICK_PER_SECOND) / 256);
|
2009-07-03 07:19:19 +08:00
|
|
|
|
|
|
|
/* install interrupt handler */
|
2015-09-15 19:50:29 +08:00
|
|
|
rt_hw_interrupt_install(INTTIMER0, rt_timer_handler, RT_NULL, "tick");
|
2013-01-08 22:40:58 +08:00
|
|
|
rt_hw_interrupt_umask(INTTIMER0);
|
|
|
|
|
2012-02-18 22:49:46 +08:00
|
|
|
#ifdef RT_USING_HOOK
|
|
|
|
rt_thread_idle_sethook(idle_hook);
|
|
|
|
#endif
|
2009-07-03 07:19:19 +08:00
|
|
|
}
|
2013-01-08 22:40:58 +08:00
|
|
|
|
|
|
|
void restart(void)
|
|
|
|
{
|
|
|
|
outb(KBSTATP, 0xFE); /* pulse reset low */
|
|
|
|
while(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef RT_USING_FINSH
|
|
|
|
#include <finsh.h>
|
2012-02-16 23:58:52 +08:00
|
|
|
FINSH_FUNCTION_EXPORT(restart, reboot PC)
|
2013-01-08 22:40:58 +08:00
|
|
|
|
|
|
|
void reboot(void)
|
|
|
|
{
|
|
|
|
restart();
|
|
|
|
}
|
2012-02-16 23:58:52 +08:00
|
|
|
FINSH_FUNCTION_EXPORT(reboot, reboot PC)
|
2013-01-08 22:40:58 +08:00
|
|
|
#endif
|
2009-07-03 07:19:19 +08:00
|
|
|
/*@}*/
|