[refactor] 整理注释
This commit is contained in:
+11
-11
@@ -13,37 +13,37 @@ static inline UINT8 inb(UINT16 port) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
// 慢速 PIC 的小延迟
|
||||
static void pic_wait(void) {
|
||||
// Small delay for slow PICs
|
||||
ASM("jmp 1f\n\t1: jmp 1f\n\t1:");
|
||||
}
|
||||
|
||||
void pic_init(void) {
|
||||
serial_write("PIC: remapping 8259 PIC\n");
|
||||
|
||||
// Save masks
|
||||
// 保存掩码
|
||||
UINT8 mask1 = inb(PIC1_DATA);
|
||||
UINT8 mask2 = inb(PIC2_DATA);
|
||||
|
||||
// ICW1: begin initialization, ICW4 needed
|
||||
// ICW1:开始初始化,需要 ICW4
|
||||
outb(PIC1_CMD, 0x11); pic_wait();
|
||||
outb(PIC2_CMD, 0x11); pic_wait();
|
||||
|
||||
// ICW2: vector offset
|
||||
outb(PIC1_DATA, PIC_IRQ_BASE); // IRQ 0-7 → vector 0x20-0x27
|
||||
// ICW2:向量偏移
|
||||
outb(PIC1_DATA, PIC_IRQ_BASE); // IRQ 0-7 → 向量 0x20-0x27
|
||||
pic_wait();
|
||||
outb(PIC2_DATA, PIC_IRQ_BASE + 8); // IRQ 8-15 → vector 0x28-0x2F
|
||||
outb(PIC2_DATA, PIC_IRQ_BASE + 8); // IRQ 8-15 → 向量 0x28-0x2F
|
||||
pic_wait();
|
||||
|
||||
// ICW3: cascading
|
||||
outb(PIC1_DATA, 0x04); pic_wait(); // slave on IRQ 2
|
||||
outb(PIC2_DATA, 0x02); pic_wait(); // cascade identity
|
||||
// ICW3:级联
|
||||
outb(PIC1_DATA, 0x04); pic_wait(); // 从片在 IRQ 2
|
||||
outb(PIC2_DATA, 0x02); pic_wait(); // 级联标识
|
||||
|
||||
// ICW4: 8086 mode
|
||||
// ICW4:8086 模式
|
||||
outb(PIC1_DATA, 0x01); pic_wait();
|
||||
outb(PIC2_DATA, 0x01); pic_wait();
|
||||
|
||||
// Restore masks
|
||||
// 恢复掩码
|
||||
outb(PIC1_DATA, mask1);
|
||||
outb(PIC2_DATA, mask2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user