Exemple #1
0
void kmain(ol_mmap_register_t mmr)
{
	textinit();
	clearscreen();

	println("The openLoader kernel is executing. \n");

	print("Current stack pointer: ");
	ol_registers_t regs = getregs();
	printnum(regs->esp, 16, FALSE, FALSE);
	putc(0xa);

	char status = inb(0x60);
	if((status & 2) == 2)
	{
		println("The A20 gate is open.");
		putc(0xa);
	}
	
	pic_init();
	setIDT();
	outb(OL_KBC_COMMAND, OL_KB_INIT);	// enable the keyboard

// display mmap
	init_mmap(mmr);
	println("Multiboot memory map:\n");
	display_mmap(mmr);

#if 0
	uint8_t active = ide_init(bootdrive);
	ide_read(0x100, 1<<20, &bootdrive[active], 60);
	uint8_t eax = ata_identify();
	printnum(active, 16, FALSE, FALSE);
#endif

	putc(0xa);

	println("Waiting for service interrupts..");
	while(1) halt();
	println("End of program reached!");
	endprogram();
}
Exemple #2
0
// The main function
int init(unsigned long magic, multiboot_info_t* hdr)
{
        setGDT();
        init_heap();
#ifdef SLAB
        slab_alloc_init();
#endif
        textInit();
        /**
         * \todo Make complement_heap so that it allocates memory from pte
         */
        complement_heap(&end, HEAPSIZE);
        addr_t tmp = (addr_t)hdr + offset;
        hdr = (multiboot_info_t*)tmp;

        if (magic != MULTIBOOT_BOOTLOADER_MAGIC)
        {
                printf("\nInvalid magic word: %X\n", magic);
                panic("");
        }
        if (hdr->flags & MULTIBOOT_INFO_MEMORY)
        {
                memsize = hdr->mem_upper;
                memsize += 1024;
        }
        else
                panic("No memory flags!");
        if (!(hdr->flags & MULTIBOOT_INFO_MEM_MAP))
                panic("Invalid memory map");

        mmap = (multiboot_memory_map_t*) hdr->mmap_addr;

        /** Build the memory map and allow for allocation */
        x86_pte_init();
        page_alloc_init(mmap, (unsigned int)hdr->mmap_length);
        vm_init();
#ifdef PA_DBG
//         endProg();
#endif
        /** In the progress of phasing out */
        /** Set up paging administration */
        x86_page_init(memsize);
        mboot_page_setup(mmap, (uint32_t)hdr->mmap_length);
        mboot_map_modules((void*)hdr->mods_addr, hdr->mods_count);

        /** For now this is the temporary page table map */
        build_map(mmap, (unsigned int) hdr->mmap_length);

        /** end of deprication */
        task_init();

        page_init();
        printf(WELCOME); // The only screen output that should be maintained
        page_unmap_low_mem();
        pic_init();
        setIDT();
        setup_irq_data();

        if (dev_init() != -E_SUCCESS)
                panic("Couldn't initialise /dev");

        ol_pit_init(1024); // program pic to 1024 hertz

        debug("Size of the heap: 0x%x\tStarting at: %x\n", HEAPSIZE, heap);

        acpi_init();
        ol_cpu_t cpu = kalloc(sizeof (*cpu));
        if (cpu == NULL)
                panic("OUT OF MEMORY!");
        ol_cpu_init(cpu);

        ol_ps2_init_keyboard();
        ol_apic_init(cpu);
        init_ioapic();
        ol_pci_init();
        debug("Little endian 0xf in net endian %x\n", htons(0xf));
#ifdef DBG
#ifdef __IOAPIC_DBG
        ioapic_debug();
#endif
#ifdef __MEMTEST
        ol_detach_all_devices(); /* free's al the pci devices */
#endif
#ifdef __DBG_HEAP
        printf("Heap list:\n");
        ol_dbg_heap();
#endif
        printf("\nSome (temp) debug info:\n");
        printf("CPU vendor: %s\n", cpus->vendor);

        if(systables->magic == SYS_TABLE_MAGIC)
        {
                printf("RSDP ASCII signature: 0x%x%x\n",
                *(((uint32_t*) systables->rsdp->signature) + 1),
                *(((uint32_t*) systables->rsdp->signature)));
                printf("MP specification signature: 0x%x\n", systables->mp->signature);
        }
#endif
#ifdef PA_DBG
        addr_t p = (addr_t)page_alloc();
        page_free((void*)p);
        printf("Allocated: %X\n", p);
        page_dump();
#endif
#ifdef PA_DBG
        addr_t p = (addr_t)page_alloc();
        page_free((void*)p);
        printf("Allocated: %X\n", p);
        page_dump();
#endif

        core_loop();
        return 0; // To keep the compiler happy.
}