os/kernel/kernel.c

64 lines
1.5 KiB
C
Raw Normal View History

2019-02-09 12:52:45 -06:00
#include "../cpu/cpu_init.h"
#include "../cpu/i386/ports.h"
2019-02-11 09:30:28 -06:00
#include "../cpu/i386/tasking.h"
2019-02-09 14:35:29 -06:00
#include "../drivers/vga.h"
2019-02-09 14:33:29 -06:00
#include <grub/text_fb_info.h>
#include <stdlib.h>
#include "multiboot.h"
2019-02-09 12:52:45 -06:00
2019-02-11 09:30:28 -06:00
void task() {
vga_write_string("TASK!\n");
for (;;) {
yield();
}
}
2019-02-09 14:33:29 -06:00
void kmain(multiboot_info_t* header) {
2019-02-09 12:52:45 -06:00
cpu_init();
2019-02-09 14:33:29 -06:00
text_fb_info info;
if (header->flags&MULTIBOOT_INFO_FRAMEBUFFER_INFO&&header->framebuffer_type==2) {
info.address=(char*)((header->framebuffer_addr&0xFFFFFFFF)+0xC0000000);
info.width=header->framebuffer_width;
info.height=header->framebuffer_height;
} else {
info.address=(char*)0xC00B8000;
info.width=80;
info.height=25;
}
2019-02-09 14:35:29 -06:00
vga_init(info);
2019-02-10 14:11:07 -06:00
vga_write_string("Hello\n");
2019-02-11 09:30:28 -06:00
// asm volatile(" \
// cli; \
// mov $0x23, %ax; \
// mov %ax, %ds; \
// mov %ax, %es; \
// mov %ax, %fs; \
// mov %ax, %gs; \
// \
// mov %esp, %eax; \
// pushl $0x23; \
// pushl %eax; \
// pushf; \
// pop %eax; \
// or $0x200,%eax; \
// push %eax; \
// pushl $0x1B; \
// push $1f; \
// iret; \
// 1: \
// ");
2019-02-10 15:05:03 -06:00
vga_write_string("UMODE!\n");
port_byte_out(0xe9,'U');
port_byte_out(0xe9,'M');
port_byte_out(0xe9,'O');
port_byte_out(0xe9,'D');
port_byte_out(0xe9,'E');
port_byte_out(0xe9,'!');
port_byte_out(0xe9,'\n');
2019-02-11 09:30:28 -06:00
vga_write_string("Task create\n");
createTask(task);
vga_write_string("Task switch\n");
yield();
vga_write_string("Back in main\n");
2019-02-09 12:52:45 -06:00
}