Set PIT IRQ in main
complete interrupt_frame struct and formatting
This commit is contained in:
parent
7248cd75ae
commit
a19f4cb609
@ -1,13 +1,21 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "stdarg.h"
|
#include "stdarg.h"
|
||||||
|
|
||||||
struct interrupt_frame;
|
|
||||||
|
|
||||||
//Exception
|
// c.f. intel software-developer-vol-1 6.4.1
|
||||||
|
struct interrupt_frame {
|
||||||
|
uint32_t eip;
|
||||||
|
uint32_t cs;
|
||||||
|
uint32_t eflags;
|
||||||
|
uint32_t esp;
|
||||||
|
uint32_t ss;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Exception
|
||||||
void print_handler(struct interrupt_frame *frame, ulong error_code);
|
void print_handler(struct interrupt_frame *frame, ulong error_code);
|
||||||
void pagefault_handler(struct interrupt_frame *frame, ulong error_code);
|
void pagefault_handler(struct interrupt_frame *frame, ulong error_code);
|
||||||
|
|
||||||
//IRQ
|
// IRQ
|
||||||
void keyboard_handler(struct interrupt_frame *frame);
|
void keyboard_handler(struct interrupt_frame *frame);
|
||||||
void timer_handler(struct interrupt_frame *frame);
|
void timer_handler(struct interrupt_frame *frame);
|
||||||
void serial_handler(struct interrupt_frame *frame);
|
void serial_handler(struct interrupt_frame *frame);
|
||||||
|
14
core/main.c
14
core/main.c
@ -70,16 +70,15 @@ void kmain(unsigned long magic, unsigned long addr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (CHECK_FLAG(mbi->flags, 6)) {
|
if (CHECK_FLAG(mbi->flags, 6)) {
|
||||||
struct multiboot_mmap_entry *mmap = (struct multiboot_mmap_entry*)mbi->mmap_addr;
|
struct multiboot_mmap_entry *mmap = (struct multiboot_mmap_entry *)mbi->mmap_addr;
|
||||||
uint size = mbi->mmap_length / sizeof(struct multiboot_mmap_entry);
|
uint size = mbi->mmap_length / sizeof(struct multiboot_mmap_entry);
|
||||||
printf("mmap buffer at %d size %d %d\n", mbi->mmap_addr, mbi->mmap_length, sizeof(multiboot_memory_map_t) );
|
printf("mmap buffer at %d size %d %d\n", mbi->mmap_addr, mbi->mmap_length,
|
||||||
for (uint i = 0; i < size; i++){
|
sizeof(multiboot_memory_map_t));
|
||||||
|
for (uint i = 0; i < size; i++) {
|
||||||
printf("base_addr_high = 0x%x, base_addr_low = 0x%x, "
|
printf("base_addr_high = 0x%x, base_addr_low = 0x%x, "
|
||||||
"length_high = 0x%x, length_low = 0x%x, type = 0x%x\n",
|
"length_high = 0x%x, length_low = 0x%x, type = 0x%x\n",
|
||||||
(unsigned) (mmap[i].addr >> 32),
|
(unsigned)(mmap[i].addr >> 32), (unsigned)(mmap[i].addr & 0xffffffff),
|
||||||
(unsigned) (mmap[i].addr & 0xffffffff),
|
(unsigned)(mmap[i].len >> 32), (unsigned)(mmap[i].len & 0xffffffff),
|
||||||
(unsigned) (mmap[i].len >> 32),
|
|
||||||
(unsigned) (mmap[i].len & 0xffffffff),
|
|
||||||
(uint32_t)mmap[i].type);
|
(uint32_t)mmap[i].type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -100,6 +99,7 @@ void kmain(unsigned long magic, unsigned long addr)
|
|||||||
|
|
||||||
printf("Setting up IRQ handlers\n");
|
printf("Setting up IRQ handlers\n");
|
||||||
irqSetRoutine(IRQ_KEYBOARD, keyboard_handler);
|
irqSetRoutine(IRQ_KEYBOARD, keyboard_handler);
|
||||||
|
irqSetRoutine(IRQ_TIMER, timer_handler);
|
||||||
|
|
||||||
printf("Enabling HW interrupts\n");
|
printf("Enabling HW interrupts\n");
|
||||||
exceptionSetRoutine(EXCEPTION_DOUBLE_FAULT, print_handler);
|
exceptionSetRoutine(EXCEPTION_DOUBLE_FAULT, print_handler);
|
||||||
|
@ -11,6 +11,5 @@ int pitSetup(unsigned int freq)
|
|||||||
outb(PIT_CHAN_0, divisor & 0xFF);
|
outb(PIT_CHAN_0, divisor & 0xFF);
|
||||||
outb(PIT_CHAN_0, divisor >> 8u);
|
outb(PIT_CHAN_0, divisor >> 8u);
|
||||||
|
|
||||||
irqSetRoutine(IRQ_TIMER, timer_handler);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user