interrupt descriptor table setup, but has no handlers yet
This commit is contained in:
parent
e8fc06943c
commit
fc33c711b3
24
interrupts.c
24
interrupts.c
@ -1,10 +1,34 @@
|
||||
#include "interrupts.h"
|
||||
#include "mem.h"
|
||||
#include "types.h"
|
||||
|
||||
void setup_idt_entry(u32 t_idx, u32 base, u16 sel, u8 type_attrs) {
|
||||
// Configuring a single given entry in the IDT table
|
||||
IDT[t_idx].offset_low = (base & 0xffff);
|
||||
IDT[t_idx].offset_high = ((base >> 16) & 0xffff);
|
||||
|
||||
IDT[t_idx].type_attrs = type_attrs;
|
||||
IDT[t_idx].selector = sel;
|
||||
}
|
||||
|
||||
void load_idt() {
|
||||
asm("lidt [idt_ptr]");
|
||||
return;
|
||||
}
|
||||
|
||||
// Generic interrupt handler to be used later on
|
||||
//void interrupt_handler(struct cpu_reg_state cpu, struct stack_state stack, u32 interrupt_code) {
|
||||
//}
|
||||
|
||||
void init_idt() {
|
||||
// setup special idt pointer
|
||||
idt_ptr.address = (u32)(&IDT);
|
||||
idt_ptr.limit = sizeof(struct IDT_Entry) * IDT_SIZE;
|
||||
// clear table
|
||||
memset((u8*)IDT, 0x00, (sizeof(struct IDT_Entry) * IDT_SIZE) - 1);
|
||||
// add interrupt service routines here
|
||||
// TODO
|
||||
|
||||
// Load IDT with all the new information in place, ready to use
|
||||
load_idt();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "types.h"
|
||||
|
||||
|
||||
struct cpu_reg_state {
|
||||
u32 eax;
|
||||
u32 ebx;
|
||||
@ -30,6 +31,8 @@ struct stack_state {
|
||||
u32 eflags;
|
||||
};
|
||||
|
||||
#define IDT_SIZE 256
|
||||
|
||||
struct IDT_Entry {
|
||||
u16 offset_low; // offset bits 0..15
|
||||
u16 selector; // code segment in either gdt or ldt
|
||||
@ -48,8 +51,10 @@ struct IDT_PTR {
|
||||
u32 address;
|
||||
}__attribute__((packed));
|
||||
|
||||
struct IDT_Entry IDT[255];
|
||||
struct IDT_Entry IDT[IDT_SIZE];
|
||||
struct IDT_PTR idt_ptr;
|
||||
|
||||
//void interrupt_handler(struct cpu_reg_state, struct stack_state, u32);
|
||||
void load_idt();
|
||||
void init_idt();
|
||||
void setup_idt_entry(u32 t_idx, u32 base, u16 sel, u8 type_attrs);
|
||||
//void interrupt_handler(struct cpu_reg_state, struct stack_state, u32);
|
||||
|
4
kernel.c
4
kernel.c
@ -1,10 +1,12 @@
|
||||
#include "kernel.h"
|
||||
#include "types.h"
|
||||
#include "tests.h"
|
||||
#include "interrupts.h"
|
||||
#include "gdt.h"
|
||||
#include "kernel.h"
|
||||
|
||||
void kinit() {
|
||||
gdt_configure();
|
||||
init_idt();
|
||||
test_dispatcher();
|
||||
}
|
||||
|
||||
|
3
makefile
3
makefile
@ -3,7 +3,8 @@ ASM=nasm
|
||||
LINK=ld
|
||||
ISO=genisoimage
|
||||
|
||||
OBJECTS=kernel.o gdt_seg.o gdt.o interrupts.o loader.o serial.o framebuffer.o ports.o stlio.o tests.o
|
||||
OBJECTS=mem.o kernel.o gdt_seg.o gdt.o interrupts.o loader.o serial.o \
|
||||
framebuffer.o ports.o stlio.o tests.o
|
||||
AFLAGS=-f elf32
|
||||
CFLAGS=-masm=intel -O2 -m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles \
|
||||
-nodefaultlibs -Wall -Wextra -Werror -c
|
||||
|
Loading…
Reference in New Issue
Block a user