]>
git.dujemihanovic.xyz Git - nameless-os.git/blob - kernel/kernel.c
5 #include <irq/interrupt.h>
6 #include <irq/i8259a.h>
10 struct idt_descriptor idt
[256] __attribute__((aligned(0x10)));
11 struct idtr idtr
__attribute__((aligned(0x10)));
12 extern void (*_int_handler_table
[48])(void);
14 /* Small handler for double faults. Will be put elsewhere eventually. */
15 int double_fault_handler(struct interrupt_frame
*frame
)
17 kprint("PANIC: Double fault occurred!\n", VGA_COLOR_BRIGHT_RED
);
18 kprint("EAX: ", VGA_COLOR_BRIGHT_RED
);
20 kprint("\n", VGA_COLOR_BRIGHT_RED
);
21 kprint("EBX: ", VGA_COLOR_BRIGHT_RED
);
23 kprint("\n", VGA_COLOR_BRIGHT_RED
);
24 kprint("ECX: ", VGA_COLOR_BRIGHT_RED
);
26 kprint("\n", VGA_COLOR_BRIGHT_RED
);
27 kprint("EDX: ", VGA_COLOR_BRIGHT_RED
);
29 kprint("\n", VGA_COLOR_BRIGHT_RED
);
30 kprint("EBP: ", VGA_COLOR_BRIGHT_RED
);
32 kprint("\n", VGA_COLOR_BRIGHT_RED
);
33 kprint("ESP: ", VGA_COLOR_BRIGHT_RED
);
35 kprint("\n", VGA_COLOR_BRIGHT_RED
);
36 kprint("ESI: ", VGA_COLOR_BRIGHT_RED
);
38 kprint("\n", VGA_COLOR_BRIGHT_RED
);
39 kprint("EDI: ", VGA_COLOR_BRIGHT_RED
);
41 kprint("\n", VGA_COLOR_BRIGHT_RED
);
42 kprint("EIP: ", VGA_COLOR_BRIGHT_RED
);
44 kprint("\n", VGA_COLOR_BRIGHT_RED
);
45 kprint("EFLAGS: ", VGA_COLOR_BRIGHT_RED
);
46 kprintd(frame
->eflags
);
47 kprint("\n", VGA_COLOR_BRIGHT_RED
);
49 /* IF has already been cleared for us */
59 kprint("Welcome to Nameless OS!\nRunning revision: ", 0);
60 kprint(GIT_COMMIT
, 0);
62 kprint("Preparing IDT...\n", 0);
63 for (int i
=0; i
<48; i
++) {
64 idt_set_descriptor(idt
, i
, 0x8, _int_handler_table
[i
], IDT_INTERRUPT_GATE
, 0);
66 kprint("IDT prepared, loading...\n", 0);
67 populate_idtr(&idtr
, idt
);
69 kprint("Setting up interrupts...\n", 0);
70 register_interrupt(8, &double_fault_handler
);
73 ps2_success
= ps2_initialize();
74 switch (ps2_success
) {
76 kprint("No PS/2 devices found or working, we will have no input\n", 0);
79 kprint("Found one working PS/2 device\n", 0);
82 kprint("Found two working PS/2 devices\n", 0);
85 kprint("All done\n", 0);
90 kprint(string
, VGA_COLOR_LIME
);