提交 ae4cd3ca 创建 作者: Silas Boyd-Wickizer's avatar Silas Boyd-Wickizer

Get dev. intrs working (with the help of the magical ioapic.c, of course).

上级 cda77810
......@@ -30,8 +30,10 @@ OBJS = \
exec.o \
file.o \
fs.o \
ioapic.o \
lapic.o \
kalloc.o \
kbd.o \
main.o \
memide.o \
mp.o \
......@@ -56,6 +58,7 @@ ULIB = ulib.o usys.o printf.o umalloc.o
UPROGS= \
_init \
_sh \
_ls \
kernel: boot.o $(OBJS) initcode bootother fs.img
$(LD) $(LDFLAGS) -T kernel.ld -z max-page-size=4096 -e start \
......
......@@ -13,6 +13,7 @@
#include "x86.h"
#include "queue.h"
#include "proc.h"
#include "traps.h"
#include <stdarg.h>
#define BACKSPACE 0x100
......@@ -325,6 +326,8 @@ initconsole(void)
devsw[CONSOLE].write = consolewrite;
devsw[CONSOLE].read = consoleread;
picenable(IRQ_KBD);
ioapicenable(IRQ_KBD, 0);
// XXX(sbw) enable once we setup %gs
cons.locking = 0;
}
......@@ -5,6 +5,7 @@
#include "cpu.h"
extern void initpic(void);
extern void initioapic(void);
extern void inituart(void);
extern void initcga(void);
extern void initconsole(void);
......@@ -77,12 +78,13 @@ cmain(void)
{
extern pml4e_t kpml4[];
initpg();
initpic(); // interrupt controller
initioapic();
inituart();
initcga();
initconsole();
inittrap();
initpg();
initseg();
initmp();
initlapic();
......
......@@ -85,18 +85,12 @@ trap(struct trapframe *tf)
// Bochs generates spurious IDE1 interrupts.
break;
case T_IRQ0 + IRQ_KBD:
#if 0
kbdintr();
lapiceoi();
#endif
panic("IRQ_KBD");
break;
case T_IRQ0 + IRQ_COM1:
#if 0
uartintr();
lapiceoi();
#endif
panic("IRQ_COM1");
break;
case T_IRQ0 + 7:
case T_IRQ0 + IRQ_SPURIOUS:
......
......@@ -2,6 +2,7 @@
#include "types.h"
#include "kernel.h"
#include "x86.h"
#include "traps.h"
#define COM1 0x3f8
......@@ -19,6 +20,22 @@ uartputc(char c)
outb(COM1+0, c);
}
static int
uartgetc(void)
{
if(!uart)
return -1;
if(!(inb(COM1+5) & 0x01))
return -1;
return inb(COM1+0);
}
void
uartintr(void)
{
consoleintr(uartgetc);
}
void
inituart(void)
{
......@@ -44,6 +61,8 @@ inituart(void)
// enable interrupts.
inb(COM1+2);
inb(COM1+0);
picenable(IRQ_COM1);
ioapicenable(IRQ_COM1, 0);
// Announce that we're here.
for(p="uart...\n"; *p; p++)
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论