123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- /*
- * interrupt.h
- *
- * Copyright (C) 2013 Aleksandar Andrejevic <theflash@sdf.lonestar.org>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- #ifndef _INTERRUPT_H_
- #define _INTERRUPT_H_
- #include <common.h>
- #include <sdk/cpu.h>
- #include <sdk/list.h>
- #define IDT_NUM_INTERRUPTS 256
- #define ISR_STUB_SIZE 64
- #define HAS_ERROR_CODE(x) (((x) == 8) || ((x) >= 10 && (x) <= 14))
- #define IDT_GATE_KERNEL 0x8E
- #define IDT_GATE_USER 0xEE
- #define CONTEXT_SWITCH_MAGIC 0xDEADBEEF
- #pragma pack(push, 1)
- typedef struct
- {
- word_t offset;
- word_t selector;
- byte_t zero;
- byte_t type;
- word_t offset_high;
- } idt_entry_t;
- #pragma pack(pop)
- typedef void (*isr_proc_t)(registers_t *regs, byte_t interrupt_num);
- typedef struct
- {
- isr_proc_t procedure;
- bool_t interrupts;
- } interrupt_handler_t;
- void interrupt_init(void);
- dword_t set_int_handler(byte_t interrupt_num, isr_proc_t proc, bool_t interrupts, bool_t usermode);
- dword_t remove_int_handler(byte_t interrupt_num);
- #endif
|