void kernel_early(multiboot_t *mboot, uint32_t magic, uintptr_t esp) { initialize_terminal(); terminal_writestring("[TTY] ... \x1b[32mDONE\n\x1b[00m[GDT] ... "); initialize_gdt(); terminal_writestring("\x1b[32mDONE\n\x1b[00m[IDT] ... "); initialize_idt(); terminal_writestring("\x1b[32mDONE\n\x1b[00m[IRQ] ... "); initialize_irq(); __asm__ __volatile__("sti"); terminal_writestring("\x1b[32mDONE\n\x1b[00m[PAGE] ... "); initialize_paging(mboot->mem_upper + mboot->mem_lower); terminal_writestring("\x1b[32mDONE\n\x1b[00m"); }
/* * Initialize the interrupt system. */ general_error interrupt_init(void) { int i; /* Loop counter. */ /* Initialize the IDT. */ initialize_idt(); /* Load the IDT. */ load_idt(&idt_pointer); /* Load the jump table. */ for (i=0; i<=255; i++) interrupt_handler_table[i] = &default_interrupt_handler; /* If this goes wrong, there's little we can do about it. In * fact, we will have probably already crashed by now. */ return GENERAL_OK; }
void main(void) { clear(); println_newline(); print_colored(" _ _ ", LOGO_NEM_COLOR); println_colored(" ____ _____", LOGO_OS_COLOR); print_colored(" | \\ | | ", LOGO_NEM_COLOR); println_colored("/ __ \\ / ____|", LOGO_OS_COLOR); print_colored(" | \\| | ___ _ __ ___ ", LOGO_NEM_COLOR); println_colored("| | | | (___ ", LOGO_OS_COLOR); print_colored(" | . ` |/ _ \\ '_ ` _ \\", LOGO_NEM_COLOR); println_colored("| | | |\\___ \\ ", LOGO_OS_COLOR); print_colored(" | |\\ | __/ | | | | ", LOGO_NEM_COLOR); println_colored("| |__| |____) |", LOGO_OS_COLOR); print_colored(" |_| \\_|\\___|_| |_| |_|", LOGO_NEM_COLOR); println_colored("\\____/|_____/ ", LOGO_OS_COLOR); println_newline(); initialize_idt(); initialize_keyboard(); while (1); }
int start_kernel(unsigned long magic, unsigned long addr) { multiboot_info_t *mbi; int i=0; /* Initialize GDT */ initialize_gdt(); screen_init_early(); screen_reset(0); printf("Welcome to StarxOS!\n"); /* Am I booted by a Multiboot-compliant boot loader? */ if (magic != MULTIBOOT_BOOTLOADER_MAGIC) { printf("Invalid magic number: %x\n", (unsigned) magic); return -1; } /* Set MBI to the address of the Multiboot information structure. */ mbi = (multiboot_info_t *) addr; /* Print out the flags. */ printf_bochs("Welcome to StarxOS!\n"); printf_bochs("flags = 0x%x\n", (unsigned) mbi->flags); /* Are mem_* valid? */ if ( mbi->flags != 0) printf_bochs ("mem_lower = %x Byte, mem_upper = %x Byte\n", (unsigned) mbi->mem_lower * 0x400, (unsigned) mbi->mem_upper * 0x400); printf_bochs("kernel code: %p\n", &code); printf_bochs("kernel data: %p\n", &data); printf_bochs("kernel bss : %p\n", &bss); printf_bochs("kernel end : %p\n", &end); /* Initialize IDT */ initialize_idt(); /* Initialize Timer */ init_timer(50); /* Enable Interrupt */ asm volatile("sti"); mem_lower = mbi->mem_lower * 0x400; mem_upper = mbi->mem_upper * 0x400; /* Setup memory, and init frame_bitmap */ setup_memory(mem_lower, mem_upper); /* Enable Paging */ init_paging(); /* Init heap */ init_kheap(); u32int *ptr = (u32int*)kmalloc(0x1000+2); *ptr = 0x1234; printf_bochs("ptr:%x *ptr:%x\n", ptr, *ptr); u32int *ptr2 = (u32int*)kmalloc(0x1000+2); *ptr2 = 0x4567; printf_bochs("ptr2:%x *ptr2:%x\n", ptr2, *ptr2); bochs_enter_debugger(); bochs_shutdown(); return 0xBAD; }