void runTerm() { initIDT(); int Color = LIGHT_BLUE; int Color2 = LIGHT_RED; int Color3 = LIGHT_GREEN; int Color4 = LIGHT_CYAN; const char *dir = "~/root"; int year = 2014; kPrintf("Anmu OS v0.01 Alpha CLI \n",Color); kPrintf("CopyRight (c) %d Yeshua Colon\n",Color2, year); putch('[',Color3); kPrintf("Anmu@Computer ",Color); kPrintf("%s",Color2, dir); putch(']',Color3); kPrintf("#",Color4); while(1==1);//hang }
void kmain(MultibootInfo *info) { ASM("cli"); kernelStatus = KERNEL_RUNNING; initConsole(); kprintf("Successfully booted into 64-bit mode\n"); if (info->modsCount != 1) { panic("the initrd was not loaded"); }; kprintf_debug(" *** TO TRAP THE KERNEL *** \n"); kprintf_debug(" set r15=rip\n"); kprintf_debug(" set rip=%a\n", &trapKernel); kprintf_debug(" *** END OF INFO *** \n"); kprintf("Initializing the IDT... "); initIDT(); kprintf("%$\x02" "Done%#\n"); kprintf("Checking amount of memory... "); int memSize = info->memLower + info->memUpper; if (info->flags & 1) { kprintf("%$\x01%dMB%#\n", (memSize/1024)); } else { kprintf("%$\x04" "Failed%#\n"); panic("could not determine memory size"); }; if ((info->flags & (1 << 6)) == 0) { panic("no memory map from bootloader"); }; uint64_t mmapAddr = (uint64_t) info->mmapAddr + 0xFFFF800000000000; uint64_t mmapEnd = mmapAddr + info->mmapLen; kprintf("Memory map address: %a memory map size = %d\n", mmapAddr, info->mmapLen); MultibootMemoryMap *mmap = (MultibootMemoryMap*) mmapAddr; kprintf("Size\tBase\tLen\tType\n"); while ((uint64_t)mmap < mmapEnd) { kprintf("%d\t%a\t%d\t%d\n", mmap->size, mmap->baseAddr, mmap->len, mmap->type); mmap = (MultibootMemoryMap*) ((uint64_t) mmap + mmap->size + 4); }; MultibootModule *mod = (MultibootModule*) ((uint64_t) info->modsAddr + 0xFFFF800000000000); uint64_t end = (uint64_t) mod->modEnd + 0xFFFF800000000000; kprintf("Initializing memory allocation phase 1 (base=%a)... ", end); initMemoryPhase1(end); kprintf("%$\x02" "Done%#\n"); kprintf("Initializing the physical memory manager (%d pages)... ", (memSize/4)); initPhysMem(memSize/4, (MultibootMemoryMap*) mmapAddr, mmapEnd); kprintf("%$\x02" "Done%#\n"); kprintf("Initializing the ISP... "); ispInit(); kprintf("%$\x02" "Done%#\n"); kprintf("Initializing memory allocation phase 2... "); initMemoryPhase2(); kprintf("%$\x02" "Done%#\n"); kprintf("Initializing the frame stack... "); initPhysMem2(); kprintf("%$\x02" "Done%#\n"); initModuleInterface(); kprintf("Getting ACPI info... "); acpiInit(); msrWrite(0x1B, 0xFEE00000 | (1 << 11) /*| (1 << 8)*/ ); apic->sivr = 0x1FF; kprintf("Initializing the FPU... "); fpuInit(); DONE(); kprintf("Initializing the VFS... "); vfsInit(); kprintf("%$\x02" "Done%#\n"); kprintf("Initializing the initrdfs... "); initInitrdfs(info); kprintf("%$\x02" "Done%#\n"); kprintf("Initializing the procfs... "); initProcfs(); kprintf("%$\x02" "Done%#\n"); kprintf("Initializing the devfs... "); initDevfs(); kprintf("%$\x02" "Done%#\n"); kprintf("Initializing PCI... "); pciInit(); kprintf("%$\x02" "Done%#\n"); kprintf("Initializing the FS driver interface... "); initFSDrivers(); kprintf("%$\x02" "Done%#\n"); kprintf("Initializing the PIT... "); uint16_t divisor = 1193180 / 1000; // 1000 Hz outb(0x43, 0x36); uint8_t l = (uint8_t)(divisor & 0xFF); uint8_t h = (uint8_t)( (divisor>>8) & 0xFF ); outb(0x40, l); outb(0x40, h); kprintf("%$\x02" "Done%#\n"); kprintf("Initializing the APIC timer..."); ASM("sti"); apic->timerDivide = 3; apic->timerInitCount = 0xFFFFFFFF; sleep(35); apic->lvtTimer = 0; quantumTicks = 0xFFFFFFFF - apic->timerCurrentCount; apic->timerInitCount = 0; // put the timer in single-shot mode at the appropriate interrupt vector. apic->lvtTimer = I_APIC_TIMER; DONE(); kprintf("Initializing the scheduler and syscalls... "); //msrWrite(0xC0000080, msrRead(0xC0000080) | 1); //msrWrite(0xC0000081, ((uint64_t)8 << 32)); //msrWrite(0xC0000082, (uint64_t)(&_syscall_entry)); //msrWrite(0xC0000084, (1 << 9)); initSched(); // "Done" will be displayed by initSched(), and then kmain2() will be called. };