CoolPotOS/kernel/kernel.c

64 lines
1.7 KiB
C
Raw Normal View History

2024-04-11 22:53:15 +08:00
#include "../include/multiboot.h"
2024-04-09 23:46:56 +08:00
#include "../include/common.h"
2024-04-11 22:53:15 +08:00
#include "../include/graphics.h"
2024-04-09 23:46:56 +08:00
#include "../include/description_table.h"
#include "../include/io.h"
#include "../include/memory.h"
#include "../include/timer.h"
#include "../include/task.h"
#include "../include/cmos.h"
#include "../include/keyboard.h"
#include "../include/shell.h"
2024-04-10 01:18:08 +08:00
#include "../include/date.h"
2024-04-09 23:46:56 +08:00
extern uint32_t end;
2024-04-11 22:53:15 +08:00
extern int status;
2024-04-09 23:46:56 +08:00
uint32_t placement_address = (uint32_t) & end;
2024-04-13 22:22:25 +08:00
void reset_kernel(){
printf("Restart %s for x86...",OS_NAME);
clock_sleep(10);
outb(0x64,0xfe);
}
void shutdown_kernel(){
//TODO ACPI Driver
}
2024-04-11 22:53:15 +08:00
void kernel_main(multiboot_t *multiboot) {
2024-04-09 23:46:56 +08:00
io_cli();
vga_install();
2024-04-12 22:03:07 +08:00
if ((multiboot->mem_upper + multiboot->mem_lower) / 1024 + 1 < 16) {
printf("[kernel] Minimal RAM amount for CPOS is 16 MB, but you have only %d MB.\n",
(multiboot->mem_upper + multiboot->mem_lower) / 1024 + 1);
while (1) io_hlt();
}
initVBE(multiboot);
2024-04-11 22:53:15 +08:00
printf("[\035kernel\036]: VGA driver load success!\n");
2024-04-09 23:46:56 +08:00
gdt_install();
idt_install();
2024-04-11 22:53:15 +08:00
printf("[\035kernel\036]: description table config success!\n");
2024-04-09 23:46:56 +08:00
init_timer(10);
init_page();
2024-04-11 22:53:15 +08:00
printf("[\035kernel\036]: page set success!\n");
2024-04-09 23:46:56 +08:00
init_sched();
2024-04-11 22:53:15 +08:00
printf("[\035kernel\036]: PCB load success!\n");
2024-04-09 23:46:56 +08:00
init_keyboard();
2024-04-11 22:53:15 +08:00
printf("[\035kernel\036]: Keyboard driver load success!\n");
2024-04-09 23:46:56 +08:00
print_cpu_id();
io_sti();
2024-04-12 22:03:07 +08:00
printf("Memory: %dMB.",(multiboot->mem_upper + multiboot->mem_lower)/1024/1024);
2024-04-09 23:46:56 +08:00
clock_sleep(25);
2024-04-12 22:03:07 +08:00
kernel_thread(setup_shell, NULL, "CPOS-Shell");
if (!status) kernel_thread(setup_date, NULL, "CPOS-Date");
2024-04-09 23:46:56 +08:00
2024-04-12 22:03:07 +08:00
for (;;) {
2024-04-09 23:46:56 +08:00
io_hlt();
clock_sleep(1);
}
}