x86: support both keyboard input and serial COM1 input

Signed-off-by: Parai Wang <parai@foxmail.com>
This commit is contained in:
Parai Wang 2017-08-18 12:02:43 +08:00
parent 3416187ecf
commit 0cd49a20ad
3 changed files with 22 additions and 8 deletions

View File

@ -14,4 +14,4 @@ floppy.img:
wget https://github.com/bajdcc/tinix/raw/master/floppy.img
run:
qemu-system-i386 -fda floppy.img -boot a -m 64M
qemu-system-i386 -fda floppy.img -boot a -m 64M -serial stdio

View File

@ -25,6 +25,10 @@ extern void init_keyboard();
extern void rt_keyboard_isr(void);
extern rt_bool_t rt_keyboard_getc(char* c);
extern void rt_serial_init(void);
extern char rt_serial_getc(void);
extern void rt_serial_putc(const char c);
static void rt_console_putc(int c);
/**
@ -126,7 +130,7 @@ static void rt_cga_putc(int c)
static void rt_console_putc(int c)
{
rt_cga_putc(c);
// rt_serial_putc(c);
rt_serial_putc(c);
}
/* RT-Thread Device Interface */
@ -217,9 +221,18 @@ static void rt_console_isr(int vector, void* param)
rt_bool_t ret;
rt_base_t level;
if(INTUART0_RX == vector)
{
c = rt_serial_getc();
ret = RT_TRUE;
}
else
{
rt_keyboard_isr();
ret = rt_keyboard_getc(&c);
}
if(ret == RT_FALSE)
{
/* do nothing */
@ -275,12 +288,16 @@ static void rt_console_isr(int vector, void* param)
void rt_hw_console_init(void)
{
rt_cga_init();
rt_serial_init();
init_keyboard();
/* install keyboard isr */
rt_hw_interrupt_install(INTKEYBOARD, rt_console_isr, RT_NULL, "kbd");
rt_hw_interrupt_umask(INTKEYBOARD);
rt_hw_interrupt_install(INTUART0_RX, rt_console_isr, RT_NULL, "COM1");
rt_hw_interrupt_umask(INTUART0_RX);
console_device.type = RT_Device_Class_Char;
console_device.rx_indicate = RT_NULL;
console_device.tx_complete = RT_NULL;

View File

@ -17,7 +17,6 @@
#include <rthw.h>
#include <bsp.h>
extern char rt_keyboard_getc(void);
/**
* @addtogroup QEMU
@ -45,13 +44,11 @@ void rt_serial_init(void)
*/
char rt_serial_getc(void)
{
return rt_keyboard_getc();
#if 0
while(!(inb(COM1+COMSTATUS) & COMDATA));
return inb(COM1+COMREAD);
#endif
}
/**