mirror of
https://github.com/cfenollosa/os-tutorial.git
synced 2024-10-27 20:34:19 +00:00
d24ea64b7b
"idt.h" included by idt.c and kernel.c, which will cause link failed. so move the definition of idt to idt.c to avoid the failure below. ld: cpu/idt.o:(.bss+0x0): multiple definition of `idt'; kernel/kernel.o:(.bss+0x0): first defined here ld: cpu/idt.o:(.bss+0x800): multiple definition of `idt_reg'; kernel/kernel.o:(.bss+0x800): first defined here ld: cpu/isr.o:(.bss+0x0): multiple definition of `idt'; kernel/kernel.o:(.bss+0x0): first defined here ld: cpu/isr.o:(.bss+0x800): multiple definition of `idt_reg'; kernel/kernel.o:(.bss+0x800): first defined here
36 lines
933 B
C
36 lines
933 B
C
#ifndef IDT_H
|
|
#define IDT_H
|
|
|
|
#include "types.h"
|
|
|
|
/* Segment selectors */
|
|
#define KERNEL_CS 0x08
|
|
|
|
/* How every interrupt gate (handler) is defined */
|
|
typedef struct {
|
|
u16 low_offset; /* Lower 16 bits of handler function address */
|
|
u16 sel; /* Kernel segment selector */
|
|
u8 always0;
|
|
/* First byte
|
|
* Bit 7: "Interrupt is present"
|
|
* Bits 6-5: Privilege level of caller (0=kernel..3=user)
|
|
* Bit 4: Set to 0 for interrupt gates
|
|
* Bits 3-0: bits 1110 = decimal 14 = "32 bit interrupt gate" */
|
|
u8 flags;
|
|
u16 high_offset; /* Higher 16 bits of handler function address */
|
|
} __attribute__((packed)) idt_gate_t ;
|
|
|
|
/* A pointer to the array of interrupt handlers.
|
|
* Assembly instruction 'lidt' will read it */
|
|
typedef struct {
|
|
u16 limit;
|
|
u32 base;
|
|
} __attribute__((packed)) idt_register_t;
|
|
|
|
|
|
/* Functions implemented in idt.c */
|
|
void set_idt_gate(int n, u32 handler);
|
|
void set_idt();
|
|
|
|
#endif
|