void kmain(unsigned long magic, multiboot_info_t * mbi) { if (magic != MULTIBOOT_BOOTLOADER_MAGIC) { printk ("Invalid magic number: 0x%x\n", (unsigned) magic); return; } gdt_install(); idt_install(); init_video(); isrs_install(); irq_install(); timer_install(); sys_setup(mbi); test_inode(); __asm__ __volatile__ ("sti"); printk("EgGS:hello there!\n"); // int i = 10 / 0; for (;;); }
void kmain(multiboot_info_t* mbd, unsigned int magic){ // kernel entry point. //unsigned char* videoram = (unsigned char*) 0xb8000; //videoram[0] = 65; //videoram[1] = 0x07; //setMode(0x13); setMode(320, 200, 8); // HOLY SHIT THIS WORKS clrscr(); gdt_install(); idt_install(); isrs_install(); irq_install(); timer_install(); start_paging(mbd); keyboard_install(); init_genrand(get_timer_ticks()); __asm__ __volatile__ ("sti"); kprint("Hello, We have booted successfully!\n\tTip: type help for command info\n"); while(1){ if(todo != NULL){ void(*function)() = todo; function(todoCP); todo = NULL; } } }
void kernel_main(struct multiboot_info *mboot, int initial_stack) { long int mem = 0; mboot_info = mboot; start_video(); putstr("Init Descriptor Tables................."); gdt_install(); idt_install(); putstr("[OK]\n"); putstr("Init ISRs.............................."); isr_install(); putstr("[OK]\n"); putstr("Init IRQs.............................."); irq_install(); __asm__ __volatile__ ("sti"); putstr("[OK]\n"); putstr("Init PIT..............................."); timer_install(); putstr("[OK]\n"); putstr("Amount of memory......................"); mem = mboot->mem_upper / 1024; putnum(mem); putstr("MB\n"); putstr("Init Memory............................"); init_memory_manager(); putstr("\n\n"); putstr("\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWelcome to Plex!"); for (;;); }
void init_kernel() { terminal_initialize(); init_serial(COM1); terminal_enable_serial_echo(COM1); terminal_printf("fOS version %s\n\n\n", KERNEL_VERSION); kinit(end + 4096, end + 4096 + (100 * 4096)); init_gdt(); load_gdt(); load_idt(); load_isrs(); irq_install(); asm volatile ( "sti" ); timer_install(); sleep(1); keyboard_install(); init_paging(); switch_to_paging(); }
/* * Called from boot.S, after global constructor */ void kernel_main(multiboot_info *mbt) { /* * second argument is an 8 bit flag. low bit sets verbosity. */ boot_info(mbt,MB_DRIVE | MB_DEV); printf ("Setting up Global Descriptor Table... "); gdt_install(); puts ("OK"); printf ("Setting up Interrupt Descriptor Table... "); idt_install(); puts ("OK"); printf ("Setting up IRQ... "); irq_install(); puts ("OK"); printf ("Configuring system clock... "); timer_install(100); puts ("OK"); printf ("Enabling keyboard... "); keyboard_install(); puts ("OK"); printf ("Enabling interrupts... "); irq_enable(); if (irq_on()) { puts ("OK"); } else { abort(); } /* * Testing cr0 register */ uint32_t _cr0 = cr0(); printf("PE (Protection Enabled, lowest bit of cr0 register) set? 0x%lx, %s\n", _cr0,_cr0&0x00000001?"yes":"no"); printf("Rho version %d.%d.%d booted\n",RHO_MAJOR,RHO_MINOR,RHO_PATCH); checkAllBuses(); /* * Wait until interrupted */ // mem_inspect(1024,1536); while ( 1 ) { /* * Update the cursos position */ upd_c(); /* * Wait for interrupts */ irq_wait(); } /* */ }
void x86_init() { gdt_install(); idt_install(); isrs_install(); apic_init(); /* apic */ irq_install(); console_init(); timer_install(); init_keyboard(); }
void main() { gdt_install(3) ; init_video(&sc) ; idt_install() ; isrs_install() ; irq_install() ; timer_install() ; keyboard_install() ; __asm__ __volatile__ ("sti"); int state = 0 ; screen sc ; //puts(&sc, "Hello world in new functions\n") ; print_int(&sc, state) ; /* Since there is no support for newlines in terminal_putchar yet, \n will produce some VGA specific character instead. This is normal. */ }
int kernel_main(uint32_t esp) { initial_esp = esp; gdt_install(); idt_install(); isrs_install(); irq_install(); asm volatile("sti"); timer_install(); keyboard_install(); ASSERT(mboot_ptr != 0); ASSERT(mboot_ptr->mods_count > 0); uint32_t initrd_location = *((uint32_t*)mboot_ptr->mods_addr); uint32_t initrd_end = *(uint32_t*)(mboot_ptr->mods_addr + 4); // move the start of our kernel heap to past the initrd placement_address = initrd_end; initialize_paging(); initialize_tasking(); fs_root = initialize_initrd(initrd_location); // Create a new process in a new address space which is a clone of this. int ret = fork(); printf("fork() returned %x, ", ret); printf(" getpid() returned %x\n", getpid()); printf("Loading initial ramdisk...\n"); asm volatile("cli"); traverse_initrd(); asm volatile("sti"); printf("That's all folks\n"); for(;;); return 0; }
void main(void) { gdt_install(); idt_install(); isrs_install(); irq_install(); timer_install(); keyboard_install(); mouse_install(); __asm__ __volatile__ ("sti"); clear_keyboard_buffers(); clear(BLACK,BLACK); bscreen(); for (;;); }
void kernel_main(){ console_initialize(); gdt_install(); idt_install(); isrs_install(); irq_install(); timer_install(); keyboard_install(); __asm__ __volatile__ ("sti"); console_putString("Hello, kernel World!\n"); for (;;){ } }
void kernel_main() { terminal_initialize(); kprintf("Identifying CPU...", COLOR_WHITE); cpuid_t cpu_data = get_cpuid(); kprintf(cpu_data.make, COLOR_WHITE); kprintf("\n", COLOR_WHITE); kprintf("Type: ", COLOR_WHITE); kprintf(itoa(cpu_data.family), COLOR_WHITE); kprintf("\n", COLOR_WHITE); kprintf("Family: ", COLOR_WHITE); kprintf(cpu_data.family, COLOR_WHITE); kprintf("\n", COLOR_WHITE); kprintf("Model: ", COLOR_WHITE); kprintf(cpu_data.model, COLOR_WHITE); kprintf("\n", COLOR_WHITE); kprintf("Enabling A20 Line...\n", COLOR_WHITE); enable_a20(); kprintf("Initilizing VGA Driver....\n",COLOR_WHITE); kprintf("Installing Global Descriptor Table....\n",COLOR_WHITE); gdt_install(); kprintf("Installing Interrupt Descriptor Table....\n",COLOR_WHITE); idt_install(); kprintf("Enabling paging...\n", COLOR_WHITE); init_paging(); kprintf("Setting up ISRs...\n",COLOR_WHITE); isrs_install(); kprintf("Remapping the PIC and setting up IRQs...\n",COLOR_WHITE); install_irq(); kprintf("Initializing the Kernel Address Translation Table...\n", COLOR_WHITE); kATT_Init(); kprintf("Identifying ATA drives.....\n", COLOR_WHITE); ATA_Init(); kprintf(DRIVE_DATA, COLOR_WHITE); kprintf("Installing Timer ISR....\n",COLOR_WHITE); timer_install(); // kprintf("Checking PCI device vendors....\n",COLOR_WHITE); // init_PCI(); kprintf("Starting shell....\n",COLOR_WHITE); init_shell(); for (;;); }
void kmain ( void* mbd, unsigned int magic ) { if ( magic != 0x2BADB002 ) { /* there is something wrong */ } else { clearscreen(); printline ("akv's - code is running"); gdt_install (); idt_install (); isrs_install (); irq_install (); __asm__ __volatile__ ("sti"); timer_install (2); keyboard_install (); for(;;); } }
void kmain( void* mbd, unsigned int magic ) { /* Installations */ gdt_install(); idt_install(); isrs_install(); irq_install(); timer_install(); keyboard_install(); init_video(); __asm__ __volatile__ ("sti"); // Disable interrupts settextcolor(0x0F, 0x00); unsigned char string[] = "Welcome to Gulinux 0.01. For a list of commands, type help.\n"; putsa(string); for(;;); }
void kernel_main() { gdt_install(); idt_install(); isrs_install(); irq_install(); terminal_initialize(); memory_manager_init(); enable_interrupts(); timer_install(); keyboard_install(); shell_init(); terminal_writestring("Hello, kernel World!\n"); terminal_writestring("Here is some text in a new line\n"); terminal_writestring("Here is some more text\n"); terminal_writestring("Here is a new line\n"); terminal_writestring("Here is some text after terminal scroll\n"); char str[] = "A string"; char ch = 'c'; int integer = 45; printf("This is a test for printf.\nThis is a char %c and this a string %s\n", ch, str); printf("This is an int %d. This is the same in hex %x\n", integer, integer); for (size_t i = 0; i < 5; i++) { printf("This is line number %d\n", i); } puts("waiting for 2 sec\n"); timer_wait(2); puts("waiting complete\n"); char buffer[200]; gets(buffer); printf("%s\n", buffer); while(1) { shell(); } }
void boot(void) { // note: function changes rsp, local stack variables can't be practically used register char *temp1, *temp2; uint32_t* modulep; void* physfree; __asm__( "movq %%rsp, %0;" "movq %1, %%rsp;" :"=g"(loader_stack) :"r"(&stack[INITIAL_STACK_SIZE]) ); setup_tss(); reload_gdt(); reload_idt(); irq_install(); timer_install(); keyboard_install(); __asm__("sti"); modulep = (uint32_t*)((char*)(uint64_t)loader_stack[3] + (uint64_t)&kernmem - (uint64_t)&physbase); physfree = (void*)(uint64_t)loader_stack[4]; kphysfree = physfree; mm_phy_init(modulep); vmmgr_init(); vmmgr_page_allocator_init(); cls(); scheduler_init(); /*start( (uint32_t*)((char*)(uint64_t)loader_stack[3] + (uint64_t)&kernmem - (uint64_t)&physbase), &physbase, (void*)(uint64_t)loader_stack[4] );*/ for( temp1 = "!!!!! start() returned !!!!!", temp2 = (char*)0xb8000; *temp1; temp1 += 1, temp2 += 2 ) *temp2 = *temp1; while(1); }
void main() { char *video_memory = (char *)0xb8000; *video_memory = 'X'; some_function(); init_video(); idt_install(); isr_install(); irq_install(); timer_install(); keyboard_install(); __asm__ __volatile__ ("sti"); print("Hello World\n"); print("\n\tFrom Ajay Saini!\n"); // test : running of exception handlers //print(20/0); }
void kmain(struct multiboot *mbp, u32 magic) { u32 initrd_location = *((u32*)mbp->mods_addr); //get the adress of initrd module u32 initrd_end = *(u32*)(mbp->mods_addr+4); placement_address = initrd_end; init_video_term(); puts("Welcome to chiffOS"); printk("\n"); videoram[1] = 2; videoram[3] = 4; videoram[5] = 6; videoram[7] = 8; videoram[9] = 10; videoram[11] = 12; videoram[13] = 14; videoram[15] = 12; videoram[17] = 10; videoram[19] = 8; videoram[21] = 6; videoram[23] = 4; videoram[25] = 2; videoram[27] = 6; videoram[29] = 10; videoram[31] = 14; printk("Initializing GDTs... "); gdt_install(); printk("[ok]\n"); printk("Initializing IDTs... "); idt_install(); printk("[ok]\n"); printk("Initializing ISRs and enabling interrupts... "); isrs_install(); irq_install(); printk("[ok]\n"); printk("\n"); printk("Initializing the PIT... "); timer_install(100); printk("[ok]\n"); printk("Initializing paging and the heap... "); _vmmngr_initialize(mbp); //get memory amount from grub printk("[ok]\n"); printk("Setting up the keyboard handler... "); _kbd_initialize(); printk("[ok]\n"); printk("Initializing initrd... "); fs_root = install_initrd(initrd_location); printk("[ok]\n"); printk("Initializing tasking... "); _task_initialize(); printk("[ok]\n"); _install_syscall_handler(); scan_pci_bus(0); ata_init_and_detect_drives(); mount_fat32(); fpu_install(); FAT_shell_newlib(); for(;;); }
/* * multiboot i386 (pc) kernel entry point */ int kmain(struct multiboot *mboot, uint32_t mboot_mag, uintptr_t esp) { initial_esp = esp; extern char * cmdline; uint32_t mboot_mods_count = 0; mboot_mod_t * mboot_mods = NULL; mboot_ptr = mboot; ENABLE_EARLY_BOOT_LOG(0); assert(mboot_mag == MULTIBOOT_EAX_MAGIC && "Didn't boot with multiboot, not sure how we got here."); debug_print(NOTICE, "Processing Multiboot information."); /* Initialize core modules */ gdt_install(); /* Global descriptor table */ idt_install(); /* IDT */ isrs_install(); /* Interrupt service requests */ irq_install(); /* Hardware interrupt requests */ if (mboot_ptr->flags & (1 << 3)) { debug_print(NOTICE, "There %s %d module%s starting at 0x%x.", mboot_ptr->mods_count == 1 ? "is" : "are", mboot_ptr->mods_count, mboot_ptr->mods_count == 1 ? "" : "s", mboot_ptr->mods_addr); debug_print(NOTICE, "Current kernel heap start point would be 0x%x.", &end); if (mboot_ptr->mods_count > 0) { uintptr_t last_mod = (uintptr_t)&end; uint32_t i; mboot_mods = (mboot_mod_t *)mboot_ptr->mods_addr; mboot_mods_count = mboot_ptr->mods_count; for (i = 0; i < mboot_ptr->mods_count; ++i ) { mboot_mod_t * mod = &mboot_mods[i]; uint32_t module_start = mod->mod_start; uint32_t module_end = mod->mod_end; if ((uintptr_t)mod + sizeof(mboot_mod_t) > last_mod) { /* Just in case some silly person put this *behind* the modules... */ last_mod = (uintptr_t)mod + sizeof(mboot_mod_t); } debug_print(NOTICE, "Module %d is at 0x%x:0x%x", i, module_start, module_end); if (last_mod < module_end) { last_mod = module_end; } } debug_print(NOTICE, "Moving kernel heap start to 0x%x", last_mod); kmalloc_startat(last_mod); } } paging_install(mboot_ptr->mem_upper + mboot_ptr->mem_lower); if (mboot_ptr->flags & (1 << 6)) { debug_print(NOTICE, "Parsing memory map."); mboot_memmap_t * mmap = (void *)mboot_ptr->mmap_addr; while ((uintptr_t)mmap < mboot_ptr->mmap_addr + mboot_ptr->mmap_length) { if (mmap->type == 2) { for (unsigned long long int i = 0; i < mmap->length; i += 0x1000) { if (mmap->base_addr + i > 0xFFFFFFFF) break; /* xxx */ debug_print(INFO, "Marking 0x%x", (uint32_t)(mmap->base_addr + i)); paging_mark_system((mmap->base_addr + i) & 0xFFFFF000); } } mmap = (mboot_memmap_t *) ((uintptr_t)mmap + mmap->size + sizeof(uintptr_t)); } } paging_finalize(); { char cmdline_[1024]; size_t len = strlen((char *)mboot_ptr->cmdline); memmove(cmdline_, (char *)mboot_ptr->cmdline, len + 1); /* Relocate the command line */ cmdline = (char *)kmalloc(len + 1); memcpy(cmdline, cmdline_, len + 1); } /* Memory management */ heap_install(); /* Kernel heap */ if (cmdline) { args_parse(cmdline); } vfs_install(); tasking_install(); /* Multi-tasking */ timer_install(); /* PIC driver */ fpu_install(); /* FPU/SSE magic */ syscalls_install(); /* Install the system calls */ shm_install(); /* Install shared memory */ modules_install(); /* Modules! */ DISABLE_EARLY_BOOT_LOG(); /* Load modules from bootloader */ debug_print(NOTICE, "%d modules to load", mboot_mods_count); for (unsigned int i = 0; i < mboot_ptr->mods_count; ++i ) { mboot_mod_t * mod = &mboot_mods[i]; uint32_t module_start = mod->mod_start; uint32_t module_end = mod->mod_end; size_t module_size = module_end - module_start; if (!module_quickcheck((void *)module_start)) { debug_print(NOTICE, "Loading ramdisk: 0x%x:0x%x", module_start, module_end); ramdisk_mount(module_start, module_size); } else { debug_print(NOTICE, "Loading a module: 0x%x:0x%x", module_start, module_end); module_data_t * mod_info = (module_data_t *)module_load_direct((void *)(module_start), module_size); if (mod_info) { debug_print(NOTICE, "Loaded: %s", mod_info->mod_info->name); } } } /* Map /dev to a device mapper */ map_vfs_directory("/dev"); if (args_present("root")) { vfs_mount_type("ext2", args_value("root"), "/"); } if (args_present("start")) { char * c = args_value("start"); if (!c) { debug_print(WARNING, "Expected an argument to kernel option `start`. Ignoring."); } else { debug_print(NOTICE, "Got start argument: %s", c); boot_arg = strdup(c); } } if (!fs_root) { debug_print(CRITICAL, "No root filesystem is mounted. Skipping init."); map_vfs_directory("/"); switch_task(0); } /* Prepare to run /bin/init */ char * argv[] = { "/bin/init", boot_arg, NULL }; int argc = 0; while (argv[argc]) { argc++; } system(argv[0], argc, argv); /* Run init */ return 0; }
void KERNEL_CALL os_main() { vga_install(); BRAG("Eve successfully switched to P-mode with paging enabled\n"); put_logo(); idt_install(); BRAG("ISRs & IRQs are on-line\n"); sys_call_table_install(); BRAG("System call table installed\n"); timer_install(); BRAG("PIT firing rate is %d Hz\n", _TIMER_RATE); mm_install(); BRAG("Memory manager is installed\n", _TIMER_RATE); //mm_print_info(); /*{ char* p; SEPARATE DBG_DUMP(p = sbrk(2)); DBG_DUMP(sbrk(0)); DBG_DUMP(*p); DBG_DUMP(p[1]); DBG_DUMP(p[4095]); // possable page fault //DBG_DUMP(p[4096]); // page fault for sure SEPARATE DBG_DUMP(p = sbrk(4 * MEGABYTE)); DBG_DUMP(sbrk(0)); DBG_DUMP(p[0]); DBG_DUMP(p[MEGABYTE]); DBG_DUMP(p[4 * MEGABYTE]); // possable page fault //DBG_DUMP(p[5 * MEGABYTE]); // page fault for sure SEPARATE DBG_DUMP(sbrk(-4 * MEGABYTE)); DBG_DUMP(p = sbrk(0)); DBG_DUMP(p[0]); // possable page fault //DBG_DUMP(p[MEGABYTE]); // page fault for sure DBG_DUMP(sbrk(-2)); DBG_DUMP(p = sbrk(0)); //DBG_DUMP(p[0]); // page fault for sure }*/ /*{ char* p; SEPARATE; DUMP(sbrk(0)); DUMP(p = malloc(2)); DUMP(sbrk(0)); DUMP(*p); DUMP(p[1]); //DUMP(p[4095]); // possable page fault //DUMP(p[4096]); // page fault for sure char* q; SEPARATE; DUMP(q = malloc(4 * MEGABYTE)); DUMP(sbrk(0)); DUMP(q[0]); DUMP(q[MEGABYTE]); DUMP(q[4 * MEGABYTE]); // possable page fault //DUMP(p[5 * MEGABYTE]); // page fault for sure SEPARATE; MARK(free(q)); DUMP(sbrk(0)); //DUMP(q[0]); // possable page fault //DUMP(p[MEGABYTE]); // page fault for sure MARK(free(p)); DUMP(sbrk(0)); //DUMP(p[0]); // page fault for sure }*/ keyboard_install(); BRAG("Keyboard is on-line (US layout)\n"); // prepare tss segment tss_install(); //BRAG("TSS is loaded\n"); // install resource manager before starting multitasking rm_install(); // task manager task_ring_node_t* pKernelNode = tm_install(); BRAG("Multitasking is enabled\n"); //print_task_tree(); // load shell app gEshTaskOffset = (dword_t)&gKernelEnd; tm_load_task((pointer_t) gEshTaskOffset, pKernelNode, ACC_USER, PRIOR_LOW, TRUE); extern dword_t gNextTaskOffset; gPingTaskOffset = gNextTaskOffset; /* from this point on Kernel process will serve as a resources manager */ rm_start(); for (;;); }