]>
git.dujemihanovic.xyz Git - nameless-os.git/blob - kernel/kernel.c
c82bd4d7bc085d4f36ed4dbad94df65dbf304250
5 #include <irq/interrupt.h>
6 #include <irq/i8259a.h>
9 struct idt_descriptor idt
[256] __attribute__((aligned(0x10)));
10 struct idtr idtr
__attribute__((aligned(0x10)));
11 extern void (*_int_handler_table
[48])(void);
13 /* Small handler for double faults. Will be put elsewhere eventually. */
14 int double_fault_handler(struct interrupt_frame
*frame
)
16 kprint("PANIC: Double fault occurred!\n", VGA_COLOR_BRIGHT_RED
);
17 kprint("EAX: ", VGA_COLOR_BRIGHT_RED
);
19 kprint("\n", VGA_COLOR_BRIGHT_RED
);
20 kprint("EBX: ", VGA_COLOR_BRIGHT_RED
);
22 kprint("\n", VGA_COLOR_BRIGHT_RED
);
23 kprint("ECX: ", VGA_COLOR_BRIGHT_RED
);
25 kprint("\n", VGA_COLOR_BRIGHT_RED
);
26 kprint("EDX: ", VGA_COLOR_BRIGHT_RED
);
28 kprint("\n", VGA_COLOR_BRIGHT_RED
);
29 kprint("EBP: ", VGA_COLOR_BRIGHT_RED
);
31 kprint("\n", VGA_COLOR_BRIGHT_RED
);
32 kprint("ESP: ", VGA_COLOR_BRIGHT_RED
);
34 kprint("\n", VGA_COLOR_BRIGHT_RED
);
35 kprint("ESI: ", VGA_COLOR_BRIGHT_RED
);
37 kprint("\n", VGA_COLOR_BRIGHT_RED
);
38 kprint("EDI: ", VGA_COLOR_BRIGHT_RED
);
40 kprint("\n", VGA_COLOR_BRIGHT_RED
);
41 kprint("EIP: ", VGA_COLOR_BRIGHT_RED
);
43 kprint("\n", VGA_COLOR_BRIGHT_RED
);
44 kprint("EFLAGS: ", VGA_COLOR_BRIGHT_RED
);
45 kprintd(frame
->eflags
);
46 kprint("\n", VGA_COLOR_BRIGHT_RED
);
48 /* IF has already been cleared for us */
58 kprint("Welcome to Nameless OS!\nRunning revision: ", 0);
59 kprint(GIT_COMMIT
, 0);
61 kprint("Preparing IDT...\n", 0);
62 for (int i
=0; i
<48; i
++) {
63 idt_set_descriptor(idt
, i
, 0x8, _int_handler_table
[i
], IDT_INTERRUPT_GATE
, 0);
65 kprint("IDT prepared, loading...\n", 0);
66 populate_idtr(&idtr
, idt
);
68 kprint("Setting up interrupts...\n", 0);
69 register_interrupt(8, &double_fault_handler
);
72 ps2_success
= ps2_initialize();
73 switch (ps2_success
) {
75 kprint("No PS/2 devices found or working, we will have no input\n", 0);
78 kprint("Found one working PS/2 device\n", 0);
81 kprint("Found two working PS/2 devices\n", 0);
84 kprint("All done\n", 0);