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