diff options
author | Alex Auvolat <alex.auvolat@ens.fr> | 2014-12-01 18:20:45 +0100 |
---|---|---|
committer | Alex Auvolat <alex.auvolat@ens.fr> | 2014-12-01 18:20:45 +0100 |
commit | c7bcf94b1e70721d0f7bfb5ca383d996559c2559 (patch) | |
tree | 845f9e6c2193f444c80b1506438e9280a52585e5 /kernel/include | |
parent | 8f936e07ecb5af4053ad7d457a32e69695cb357e (diff) | |
download | macroscope-c7bcf94b1e70721d0f7bfb5ca383d996559c2559.tar.gz macroscope-c7bcf94b1e70721d0f7bfb5ca383d996559c2559.zip |
Small adjustments:
- add missing vim modelines
- idt_set_ex_handler, idt_set_irq_handler
- inline inb,inw,outb,outw
- add defines for exceptions and irqs
Diffstat (limited to 'kernel/include')
-rw-r--r-- | kernel/include/idt.h | 53 | ||||
-rw-r--r-- | kernel/include/sys.h | 23 |
2 files changed, 71 insertions, 5 deletions
diff --git a/kernel/include/idt.h b/kernel/include/idt.h index 5730f5e..ba344c9 100644 --- a/kernel/include/idt.h +++ b/kernel/include/idt.h @@ -8,6 +8,56 @@ #include <config.h> +#define IRQ0 0 +#define IRQ1 1 +#define IRQ2 2 +#define IRQ3 3 +#define IRQ4 4 +#define IRQ5 5 +#define IRQ6 6 +#define IRQ7 7 +#define IRQ8 8 +#define IRQ9 9 +#define IRQ10 10 +#define IRQ11 11 +#define IRQ12 12 +#define IRQ13 13 +#define IRQ14 14 +#define IRQ15 15 + +#define EX_DIVIDE_ERROR 0 // No error code +#define EX_DEBUG 1 // No error code +#define EX_NMI_INTERRUPT 2 // No error code +#define EX_BREAKPOINT 3 // No error code +#define EX_OVERFLOW 4 // No error code +#define EX_BOUND_RANGE_EXCEDEED 5 // No error code +#define EX_INVALID_OPCODE 6 // No error code +#define EX_DEVICE_NOT_AVAILABLE 7 // No error code +#define EX_DOUBLE_FAULT 8 // Yes (Zero) +#define EX_COPROCESSOR_SEGMENT_OVERRUN 9 // No error code +#define EX_INVALID_TSS 10 // Yes +#define EX_SEGMENT_NOT_PRESENT 11 // Yes +#define EX_STACK_SEGMENT_FAULT 12 // Yes +#define EX_GENERAL_PROTECTION 13 // Yes +#define EX_PAGE_FAULT 14 // Yes +#define EX_INTEL_RESERVED_1 15 // No +#define EX_FLOATING_POINT_ERROR 16 // No +#define EX_ALIGNEMENT_CHECK 17 // Yes (Zero) +#define EX_MACHINE_CHECK 18 // No +#define EX_INTEL_RESERVED_2 19 // No +#define EX_INTEL_RESERVED_3 20 // No +#define EX_INTEL_RESERVED_4 21 // No +#define EX_INTEL_RESERVED_5 22 // No +#define EX_INTEL_RESERVED_6 23 // No +#define EX_INTEL_RESERVED_7 24 // No +#define EX_INTEL_RESERVED_8 25 // No +#define EX_INTEL_RESERVED_9 26 // No +#define EX_INTEL_RESERVED_10 27 // No +#define EX_INTEL_RESERVED_11 28 // No +#define EX_INTEL_RESERVED_12 29 // No +#define EX_INTEL_RESERVED_13 30 // No +#define EX_INTEL_RESERVED_14 31 // No + struct idt_entry { uint16_t base_lo; //Low part of address to jump to uint16_t sel; //Kernel segment selector @@ -34,7 +84,8 @@ typedef struct registers registers_t; typedef void (*isr_handler_t)(registers_t*); void idt_init(); -//void idt_handleIrq(int number, isr_handler_t func); //Set IRQ handler +void idt_set_ex_handler(int number, isr_handler_t func); //Set exception handler +void idt_set_irq_handler(int number, isr_handler_t func); //Set IRQ handler /* vim: set ts=4 sw=4 tw=0 noet :*/ diff --git a/kernel/include/sys.h b/kernel/include/sys.h index 319cbef..2304eec 100644 --- a/kernel/include/sys.h +++ b/kernel/include/sys.h @@ -2,10 +2,25 @@ #include <config.h> -void outb(uint16_t port, uint8_t value); -void outw(uint16_t port, uint16_t value); -uint8_t inb(uint16_t port); -uint16_t inw(uint16_t port); +static inline void outb(uint16_t port, uint8_t value) { + asm volatile("outb %1, %0" : : "dN"(port), "a"(value)); +} + +static inline void outw(uint16_t port, uint16_t value) { + asm volatile("outw %1, %0" : : "dN"(port), "a"(value)); +} + +static inline uint8_t inb(uint16_t port) { + uint8_t ret; + asm volatile("inb %1, %0" : "=a"(ret) : "dN"(port)); + return ret; +} + +static inline uint16_t inw(uint16_t port) { + uint16_t ret; + asm volatile("inw %1, %0" : "=a"(ret) : "dN"(port)); + return ret; +} void panic(const char* message, const char* file, int line); void panic_assert(const char* assertion, const char* file, int line); |