void kernel_init(boot_info_t bootInfo) { tty_init(); multiboot_init(bootInfo.multiboot_magic, bootInfo.multiboot_addr); if(a20_enable()) { serial_writestring(1, "A20 enable failed - triggering panic\n"); kernel_panic(); }; gdt_install(); idt_install(); irq_install(); _protected_mode_init(); paging_init(); _paging_enable(); PIC_init(); serial_init(); keyboard_init(); timer_init(); serial_writestring(1, "End kernel_init\n"); kernel_main(); };
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 gdt_init(void) { /* that's kind of ugly (setting the null segment) */ memset(&gdt[SEG_NULL_IDX], 0x0, sizeof(struct gdt_entry)); /* 0x08 */ gdt_set_segment(SEG_KCODE_IDX, 0x0, 0xffffffff, GDTE_DPL_KERNEL | GDTE_X | GDTE_W | GDTE_NOT_TSS, GDTE_PAGE_GRAN | GDTE_32_BIT); /* 0x10 */ gdt_set_segment(SEG_KDATA_IDX, 0x0, 0xffffffff, GDTE_DPL_KERNEL | GDTE_R | GDTE_NOT_TSS, GDTE_PAGE_GRAN | GDTE_32_BIT); /* 0x18 */ gdt_set_segment(SEG_UCODE_IDX, 0x0, 0xffffffff, GDTE_DPL_USER | GDTE_X | GDTE_W | GDTE_NOT_TSS, GDTE_PAGE_GRAN | GDTE_32_BIT); /* 0x20 */ gdt_set_segment(SEG_UDATA_IDX, 0x0, 0xffffffff, GDTE_DPL_USER | GDTE_R | GDTE_NOT_TSS, GDTE_PAGE_GRAN | GDTE_32_BIT); /* task switching structure */ tss_init(SEG_KDATA, (uint32_t)&kernel_stack_top); gdt_install(); kprintf("[gdt] global descriptors were set up\n"); tss_flush(SEG_TSS); }
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 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 init_descriptors() { gdt_install(); idt_install(); init_handlers(); irq_install(); }
void kernel_main(struct mboot_info_struct *mbinfo) { // addr = (int*) kernel_main; // log("[LOAD] " DISTNAME " kernel is started. Disabling interrupts..."); log("[DISCLAIMER] " DISTNAME " is totally free. If you have bought it, please report us seller's contact information to prevent further project law violation."); asm("cli"); log("done."); log("[INFO] Setting up GDT..."); gdt_install(); log("done."); log("[INFO] Setting up IDT..."); idt_install(); log("done."); log("[INFO] Setting up ISRs..."); isrs_install(); log("done."); log("[INFO] Setting up IRQ handlers..."); irq_install(); log("done."); asm("sti"); log("[INFO] Setting up fonts..."); setupFonts(); log("done."); log("[INFO] Initializing PIC..."); //kprint("OS365 Kernel 1.0 is loaded.\nInitializing PIC...",0,0); init_pics(0x20,0x28); log("done."); //setupPaging(); //asm("int $8"); //kprint("\nAll pre-start processes are finished. Preparing to load shell...\n",0,8); log("[INFO] Setting VBE graphics mode..."); //sleep(18); //setGraphicsMode(); vbe_info_t* vbeInfo=(vbe_info_t*)(uint32_t)mbinfo->vbe_mode; framebuffer =(uint8_t*)(mbinfo->framebuffer_addr); fbpitch =mbinfo->framebuffer_pitch; fbbpp =mbinfo->framebuffer_bpp; //memset((void*)framebuffer,0x004DFF,1024*768*3); initKbd(); log("done."); //mouse_install(); log("[INFO] Setting up the timer..."); setupPIT(); log("done."); log("[INFO] Loading Z Window System..."); //abort(); while(true) { shellStart(); fRun=true; log("[WARNING] Error in program: Not returned to Z"); log("[INFO] Getting back to Z..."); } }
void kernel_early(void) { fb_initialize(); printf("Frame buffer initialized\n"); gdt_install(); printf("GDT initialized\n"); // a paging algorithm isn't actually set up yet // pg_initialize(); // printf("Paging initialized\n"); }
/* * 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 cpu_init() { gdt_set_descriptor(0, 0, 0, 0, 0); gdt_set_descriptor (1,0,0xffffffff, I86_GDT_DESC_READWRITE|I86_GDT_DESC_EXEC_CODE|I86_GDT_DESC_CODEDATA|I86_GDT_DESC_MEMORY, I86_GDT_GRAND_4K | I86_GDT_GRAND_32BIT | I86_GDT_GRAND_LIMITHI_MASK); gdt_set_descriptor (2,0,0xffffffff, I86_GDT_DESC_READWRITE|I86_GDT_DESC_CODEDATA|I86_GDT_DESC_MEMORY, I86_GDT_GRAND_4K | I86_GDT_GRAND_32BIT | I86_GDT_GRAND_LIMITHI_MASK); gdt_install(); }
void x86_init() { gdt_install(); idt_install(); isrs_install(); apic_init(); /* apic */ irq_install(); console_init(); timer_install(); init_keyboard(); }
void kernel_main(multiboot_info_t* mbd,unsigned int magic) { /* Initialization */ terminal_initialize(); kprint("Kernel Loading...\nInitializing GDT......"); gdt_install(); kprint("DONE\nInitializing IDT......"); idt_install(); kprint("DONE\n"); total_memory=mbd->mem_upper; total_memory*=1024; enter_pmode(); }
void main(){ pic_remap(); irq_handlers_init(); idt_init(); keyboard_init(); gdt_install(); cls(); printk("> ",'s'); asm("sti"); }
void kmain(struct multiboot_info *mbt) { vga_init(); gdt_install(); idt_install(); isr_install(); irq_install(); syscalls_install(); puts_c(__kernel_name " kernel v" __kernel_version_str "\n\n", COLOR_LIGHT_BLUE, COLOR_DEFAULT_BG); uint64_t mem; get_multiboot_info(mbt, &mem); extern uint32_t _kernel_memory_end[]; kprintf("End of kernel's memory: 0x%x\n", (uint64_t) (uint32_t) _kernel_memory_end); kprintf("Memory:\n%l B\n%l KB\n%l MB\n%l GB\n", mem, mem / 1024, mem / 1024 / 1024, mem / 1024 / 1024 / 1024); init_paging(); map_page(0xFD7FF000, 0x60000, 3); int *p = (int *) 0xFD7FF000; *p = 12; kprintf("*(0x%x) = %i\n", (uint64_t) (uint32_t) p, *p); map_page(0x10000000, 0x60000, 3); int *p2 = (int *) 0x10000000; kprintf("*(0x%x) = %i\n", (uint64_t) (uint32_t) p2, *p2); print_next_available_page(); uint32_t ap = allocate_page(203); map_page(ap, 0x60000, 3); int *p3 = (int *) ap; kprintf("*(0x%x) = %i\n", (uint64_t) ap, *p3); print_next_available_page(); ap = allocate_page(203); kprintf("ap = 0x%x\n", (uint32_t) ap); struct kthread thread; create_kthread(thread_test, &thread); start_kthread(&thread); kprintf("Returned from thread.\n"); _asm_print_test(); return; }
void kernel_entry (multiboot_info* bootinfo) { clear_screen(); puts("Kernel loaded.\n"); gdt_install(); puts("GDT initialised.\n"); idt_install(); puts("IDT initialised.\n"); memman_init(bootinfo); kheap_init(); fat32_init(); // TODO: figure out how to do it safely //acpi_init(); apic_init(); ioapic_init(); // keyboard only for now register_handler(0x21, keyboard_handler); register_handler(0xD, gpf_handler); syscalls_init(); // maybe syscalls_init() like acpi_init, apic_init, etc... there should be common naming timer_init(0x20, 0x002fffff, 0xB, 1); // vector, counter, divider, periodic -- check manual before using // sets up kernel task and registers handler for timer scheduler_init(); // registers locking sys monitor_init(); keyboard_init(); // testing scheduler if (fork_kernel() == 0) { if (!exec("SHELL")) { // something horrible happend // exit() } exit(); } else { for(;;) { asm volatile("hlt"); } } asm ("sti"); // release monsters, it can be set earlier, but fails horribly if set before acpi_init for(;;); }
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 kmain(struct multiboot_info *info, unsigned long magic) { #define bprintf(fmt, ...) _kprintf(0xA, fmt, ## __VA_ARGS__) mb_info = info; // initialize console so we can print boot status console_clear(0); // check multiboot magic number if (magic != MULTIBOOT_BOOTLOADER_MAGIC) { kprintf("Invalid Multiboot magic number\n"); return; } bprintf("32 bit Telos " VERSION "\n"); bprintf("Initializing machine state...\n"); idt_install(); gdt_install(); pic_init(0x20, 0x28); // map IRQs after exceptions/reserved vectors pit_init(100); // 10ms timer clock_init(); bprintf("Initializing kernel subsystems...\n"); init_subsystems(); bprintf("\n----------- MEMORY -----------\n"); bprintf("Kernel: %p - %p\n", &_kstart, &_kend); bprintf("Userspace: %p - %p\n", &_ustart, &_uend); bprintf("Total: %lx bytes\n", MULTIBOOT_MEM_MAX(mb_info)); mount_root(); bprintf("Starting Telos...\n\n"); sched_start(); #undef bprintf }
/* This is the entry point to the bulk of the kernel. * @mb is a pointer to a <multiboot_info> structure which has important * information about the layout of memory which is passed along from the * bootloader. * First, the kernel sets up the <gdt> or Global Descriptor Table which * describes the layout of memory. * Next, it installs the <idt> or interrupt descriptor table, which declares * which interrupts are available, and whether they can be accessed from user * mode. * After the basic CPU state has been initialized, logging and the VGA terminal * are initialized, and the kernel heap is installed. Next, the physical memory * allocator and the keyboard drivers are initialized. Note that the kernel * heap must be initialized before the physical memory allocator since certain * parts of the allocator live on the heap. Finally the init process page table * is created, and multi-processing is initialized. * @return this function should never return. */ void kernel_main(struct multiboot_info *mb) { gdt_install(); idt_install(); terminal_initialize(); initialize_klog(); kheap_install((struct kheap_metadata*)KHEAP_PHYS_ROOT, PAGE_SIZE); physical_allocator_init(mb->mem_upper + mb->mem_lower); keyboard_install(); char *hi = "Hello kernel!\n"; void *testing = kmalloc(16); memcpy(testing, hi, 16); kputs(testing); klog(testing); kfree(testing); (void)kernel_page_table_install(mb); proc_init(); struct process *worker_proc = create_proc(worker); schedule_proc(worker_proc); while (1) { klog("kernel\n"); } }
/** * Run kernel. */ void kmain() { gdt_install(); idt_install(); isr_install(); irq_install(); clock_install(); vga_init(); vga_write("Bandit Kernel v0.0.1\n"); vga_write("Developer: Matheus Vieira Portela\n"); vga_write("Contact: matheusvportela at gmail dot com\n\n"); clock_set_frequency(1); /* test_division_by_zero_exception(); */ /* Kernel infinite loop */ while(1) { vga_write("tick\n"); clock_wait(18); } }
/* * 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 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(;;); }
int main(void) { int line =0; unsigned int *s; int wCol=5; clearscreen(line); writeln("Initializing OS"); writeln("Setting up OS descriptor..."); gdt_install(); pmWriteScr(wCol,32," done"); wCol++; pmWriteln(wCol,32); /*while(1);*/ //program3 starts here clearscreen(0); writeln("Running Ten processes"); front = rear = 0; next_pcb = 0; nextstack = 0; s=allocStack(); // Allocating stack createProcess((unsigned int)16,(unsigned int) 24,(unsigned int) (s+1024),(unsigned int ) 8,(unsigned int) p1); s=allocStack(); createProcess((unsigned int)16,(unsigned int) 24,(unsigned int) (s+1024),(unsigned int ) 8,(unsigned int) p2); /* s=allocStack(); createProcess((unsigned int)16,(unsigned int) 24,(unsigned int) (s+1024),(unsigned int ) 8,(unsigned int) p3); s=allocStack(); createProcess((unsigned int)16,(unsigned int) 24,(unsigned int) (s+1024),(unsigned int ) 8,(unsigned int) p4); s=allocStack(); createProcess((unsigned int)16,(unsigned int) 24,(unsigned int) (s+1024),(unsigned int ) 8,(unsigned int) p5); s=allocStack(); createProcess((unsigned int)16,(unsigned int) 24,(unsigned int) (s+1024),(unsigned int ) 8,(unsigned int) p6); s=allocStack(); createProcess((unsigned int)16,(unsigned int) 24,(unsigned int) (s+1024),(unsigned int ) 8,(unsigned int) p7); s=allocStack(); createProcess((unsigned int)16,(unsigned int) 24,(unsigned int) (s+1024),(unsigned int ) 8,(unsigned int) p8); s=allocStack(); createProcess((unsigned int)16,(unsigned int) 24,(unsigned int) (s+1024),(unsigned int ) 8,(unsigned int) p9); s=allocStack(); createProcess((unsigned int)16,(unsigned int) 24,(unsigned int) (s+1024),(unsigned int ) 8,(unsigned int) p10); */ current = dequeue(); go(current); while(1); return 0; } /*Main ends Here */