📄 interrupt.c
字号:
#include "hos.h"unsigned long get_current_eflags(void);void do_dummy_interrupt_handler(struct pt_regs *regs){ printk("[kernel]Not implemented interrupt\n"); display_regs(regs); //dump_interrupt_state(state); STOP();}/* =========================================================== *//* =========================================================== */void init_interrupt(void){ int i; for(i = 0; i < 256; i++) set_intr_gate(i, &dummy_interrupt_handler); init_idt(); enable_interrupts();}int is_interrupts_enabled(void){ unsigned long efalgs = get_current_eflags(); return (efalgs & EFLAGS_IF) != 0;}unsigned long get_current_eflags(void){ unsigned long eflags; __asm__ __volatile__ ( "pushfl \t\n" "pop %0 \t\n" : "=a" (eflags) ); return eflags;}void mask_irq(unsigned char irq){ if(irq < 8) outbyte(0x21, ((1<<irq) | inbyte(0x21))); else outbyte(0xA1, ((1<<(irq-8)) | inbyte(0xA1)));}void unmask_irq(unsigned char irq){ if(irq < 8) outbyte(0x21, (~(1<<irq) & inbyte(0x21))); else outbyte(0xA1, (~(1<<(irq-8)) & inbyte(0xA1)));}/*void dump_interrupt_state(interrupt_state_t *state){ unsigned int errorcode = state->errorcode; printk("eax = %x ebx = %x ecx = %x edx = %x\n" "esi = %x edi = %x ebp = %x\n" "eip = %x cs = %x eflags = %x\n" "interrupt number = %d, error code = %d\n" "index = %d, TI = %d, IDT = %d, EXT = %d\n", state->eax, state->ebx, state->ecx, state->edx, state->esi, state->edi, state->ebp, state->eip, state->cs, state->eflags, state->intnum, errorcode, errorcode >> 3, (errorcode >> 2) & 1, (errorcode >> 1) & 1, errorcode & 1);}*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -