makefile: introduce a format command to run clang-format all over the kernel source.
This commit is contained in:
parent
c4e98f5ef2
commit
a379d66784
47 changed files with 5092 additions and 4603 deletions
63
kernel/src/sys/arch/x86_64/idt.c
Executable file → Normal file
63
kernel/src/sys/arch/x86_64/idt.c
Executable file → Normal file
|
@ -1,50 +1,51 @@
|
|||
//#include "sys/log.h"
|
||||
// #include "sys/log.h"
|
||||
#include "sys/arch/x86_64/pic.h"
|
||||
#include <sys/arch/x86_64/idt.h>
|
||||
#include <sys/log.h>
|
||||
|
||||
__attribute__((aligned(0x10)))
|
||||
static idt_entry_t idt[256];
|
||||
__attribute__((aligned(0x10))) static idt_entry_t idt[256];
|
||||
|
||||
static idtr_t idtr;
|
||||
|
||||
void idt_set_descriptor(uint8_t vector, void* isr, uint8_t flags) {
|
||||
idt_entry_t* descriptor = &idt[vector];
|
||||
void idt_set_descriptor(uint8_t vector, void *isr, uint8_t flags) {
|
||||
idt_entry_t *descriptor = &idt[vector];
|
||||
|
||||
descriptor->isr_low = (uint64_t)isr & 0xFFFF;
|
||||
descriptor->kernel_cs = 0x28;
|
||||
descriptor->ist = 0;
|
||||
descriptor->attributes = flags;
|
||||
descriptor->isr_mid = ((uint64_t)isr >> 16) & 0xFFFF;
|
||||
descriptor->isr_high = ((uint64_t)isr >> 32) & 0xFFFFFFFF;
|
||||
descriptor->reserved = 0;
|
||||
descriptor->isr_low = (uint64_t)isr & 0xFFFF;
|
||||
descriptor->kernel_cs = 0x28;
|
||||
descriptor->ist = 0;
|
||||
descriptor->attributes = flags;
|
||||
descriptor->isr_mid = ((uint64_t)isr >> 16) & 0xFFFF;
|
||||
descriptor->isr_high = ((uint64_t)isr >> 32) & 0xFFFFFFFF;
|
||||
descriptor->reserved = 0;
|
||||
}
|
||||
|
||||
static int vectors[256];
|
||||
|
||||
extern void* isr_stub_table[];
|
||||
extern void *isr_stub_table[];
|
||||
|
||||
void idt_init() {
|
||||
idtr.base = (uintptr_t)&idt[0];
|
||||
idtr.limit = (uint16_t)sizeof(idt_entry_t) * 256 - 1;
|
||||
idtr.base = (uintptr_t)&idt[0];
|
||||
idtr.limit = (uint16_t)sizeof(idt_entry_t) * 256 - 1;
|
||||
|
||||
for (uint16_t vector = 0; vector <= 256; vector++) {
|
||||
if (vector == 0x80)
|
||||
continue; // We skip the syscall handler, since it should be called from user space.
|
||||
idt_set_descriptor(vector, isr_stub_table[vector], 0x8E);
|
||||
vectors[vector] = 1;
|
||||
}
|
||||
|
||||
uint16_t vector = 0x80;
|
||||
idt_set_descriptor(vector, isr_stub_table[vector], 0xEE);
|
||||
for (uint16_t vector = 0; vector <= 256; vector++) {
|
||||
if (vector == 0x80)
|
||||
continue; // We skip the syscall handler, since it should be called from
|
||||
// user space.
|
||||
idt_set_descriptor(vector, isr_stub_table[vector], 0x8E);
|
||||
vectors[vector] = 1;
|
||||
}
|
||||
|
||||
pic_init();
|
||||
pic_unmask_irq(1);
|
||||
|
||||
__asm__ volatile ("lidt %0" : : "m"(idtr)); // load the new IDT
|
||||
__asm__ volatile ("sti"); // set the interrupt flag
|
||||
uint16_t vector = 0x80;
|
||||
idt_set_descriptor(vector, isr_stub_table[vector], 0xEE);
|
||||
vectors[vector] = 1;
|
||||
|
||||
//logln(progress, "kinit stage 1", "IDT initialized! Time to receive interrupts!\n");
|
||||
log("idt - initialized\n");
|
||||
pic_init();
|
||||
pic_unmask_irq(1);
|
||||
|
||||
__asm__ volatile("lidt %0" : : "m"(idtr)); // load the new IDT
|
||||
__asm__ volatile("sti"); // set the interrupt flag
|
||||
|
||||
// logln(progress, "kinit stage 1", "IDT initialized! Time to receive
|
||||
// interrupts!\n");
|
||||
log("idt - initialized\n");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue