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

Update ioapic.c.

上级 732f7c4c
......@@ -3,10 +3,10 @@
// See also picirq.c.
#include "types.h"
#include "defs.h"
#include "traps.h"
#include "kernel.h"
#define IOAPIC 0xFEC00000 // Default physical address of IO APIC
#define IOAPIC (PBASE + 0xFEC00000) // Default physical address of IO APIC
#define REG_ID 0x00 // Register index: ID
#define REG_VER 0x01 // Register index: version
......@@ -26,12 +26,12 @@ volatile struct ioapic *ioapic;
// IO APIC MMIO structure: write reg, then read or write data.
struct ioapic {
uint reg;
uint pad[3];
uint data;
u32 reg;
u32 pad[3];
u32 data;
};
static uint
static u32
ioapicread(int reg)
{
ioapic->reg = reg;
......@@ -39,25 +39,30 @@ ioapicread(int reg)
}
static void
ioapicwrite(int reg, uint data)
ioapicwrite(int reg, u32 data)
{
ioapic->reg = reg;
ioapic->data = data;
}
void
ioapicinit(void)
ioapicenable(int irq, int cpunum)
{
int i, id, maxintr;
// Mark interrupt edge-triggered, active high,
// enabled, and routed to the given cpunum,
// which happens to be that cpu's APIC ID.
ioapicwrite(REG_TABLE+2*irq, T_IRQ0 + irq);
ioapicwrite(REG_TABLE+2*irq+1, cpunum << 24);
}
if(!ismp)
return;
void
initioapic(void)
{
int i, id, maxintr;
ioapic = (volatile struct ioapic*)IOAPIC;
maxintr = (ioapicread(REG_VER) >> 16) & 0xFF;
id = ioapicread(REG_ID) >> 24;
if(id != ioapicid)
cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n");
// Mark all interrupts edge-triggered, active high, disabled,
// and not routed to any CPUs.
......@@ -66,16 +71,3 @@ ioapicinit(void)
ioapicwrite(REG_TABLE+2*i+1, 0);
}
}
void
ioapicenable(int irq, int cpunum)
{
if(!ismp)
return;
// Mark interrupt edge-triggered, active high,
// enabled, and routed to the given cpunum,
// which happens to be that cpu's APIC ID.
ioapicwrite(REG_TABLE+2*irq, T_IRQ0 + irq);
ioapicwrite(REG_TABLE+2*irq+1, cpunum << 24);
}
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论