Exemple #1
0
void vm_mem_bootstrap(void)
{
	vm_offset_t	start, end;

	/*
	 *	Initializes resident memory structures.
	 *	From here on, all physical memory is accounted for,
	 *	and we use only virtual addresses.
	 */

	vm_page_bootstrap(&start, &end);

	/*
	 *	Initialize other VM packages
	 */

	slab_bootstrap();
	vm_object_bootstrap();
	vm_map_init();
	kmem_init(start, end);
	pmap_init();
	slab_init();
	kalloc_init();
	vm_fault_init();
	vm_page_module_init();
	memory_manager_default_init();
}
Exemple #2
0
void
vm_mem_bootstrap(void)
{
	vm_offset_t	start, end;

	/*
	 *	Initializes resident memory structures.
	 *	From here on, all physical memory is accounted for,
	 *	and we use only virtual addresses.
	 */

	vm_page_bootstrap(&start, &end);

	/*
	 *	Initialize other VM packages
	 */

	zone_bootstrap();
	vm_object_bootstrap();
	vm_map_init();
	kmem_init(start, end);
	pmap_init();
	zone_init((vm_size_t)ptoa(vm_page_free_count));
	kalloc_init();
#if	MACH_RT
	rtalloc_init();
#endif	/* MACH_RT */
	vm_fault_init();
	vm_page_module_init();
	memory_manager_default_init();
}
Exemple #3
0
void *
malloc(size_t size)
{
	register vm_size_t allocsize;
	union header *addr;
	register union header *fl;

#if	DEBUG
	if (debug)
		printf("malloc(%x)\n", size);
#endif
	if (!kalloc_initialized) {
	    kalloc_init();
	    kalloc_initialized = TRUE;
	}

	/* compute the size of the block that we will actually allocate */

	size += sizeof(union header);
	allocsize = size;
	if (size < kalloc_max) {
	    allocsize = MINSIZE;
	    fl = kfree_list;
	    while (allocsize < size) {
		allocsize <<= 1;
		fl++;
	    }
	} else {
		printf("malloc more than 16 K !!!\n");
		for(;;);
	}

	/*
	 * Check the queue for that size
	 * and allocate.
	 */

	if ((addr = fl->next) != 0) {
	    fl->next = addr->next;
	}
        else {
	    addr = kget_space(allocsize);
	}

	addr->size = allocsize;
#if	DEBUG
	if (debug)
		printf("malloc() returns %x\n", (void *) (addr + 1));
#endif
	return (void *) (addr + 1);
}
Exemple #4
0
void *
malloc(size_t size)
{
	register vm_size_t allocsize;
	union header *addr;
	union header *fl;

	if (size <= 0)
		return NULL;

	if (!kalloc_initialized) {
	    kalloc_init();
	    kalloc_initialized = TRUE;
	}

	/* compute the size of the block that we will actually allocate */

	size += sizeof(union header);
	allocsize = get_allocsize(size, &fl);

	/*
	 * If our size is still small enough, check the queue for that size
	 * and allocate.
	 */

	if (allocsize < kalloc_max) {
	    if ((addr = fl->next) != 0) {
		fl->next = addr->next;
	    }
	    else {
		addr = kget_space(allocsize);
	    }
	}
	else {
	    /* This will allocate page 0 if it is free, but the header
	       will prevent us from returning a 0 pointer.  */
	    if (vm_allocate(mach_task_self(), (vm_offset_t *)&addr,
			    allocsize, TRUE) != KERN_SUCCESS)
		return(0);
	}

	addr->size = allocsize;
	return (void *) (addr + 1);
}
Exemple #5
0
// Starts system
void 
init_system(multiboot_info_t* bi)
{
	// Start display
	vga_init();
	printk(" KiteOS V1.0 --- Initializing \n");
	// PIT-less wait to show user boot
	for(int i=0;i<64821125;i++);
	vga_color(0x3, 0x0);
	printk("-- STARTING LOWLEVEL KERNEL --\n");
	vga_color(0x5, 0x0);
	printk("!* Initiating GDT\n");
	gdt_init();
	printk("!* Initiating IDT\n");
	idt_init();
	printk("!* Installing Exceptions\n");
	isr_init();
	vga_color(0x4, 0x0);
	printk("*** ENTERTED PROTECTED MODE ***\n");
	vga_color(0x5, 0x0);
	printk("!* Initiating IRQ\n");
	irq_init();
	printk("!* Starting PIT\n");
	pit_init();
	printk("!* Starting RTC\n");
	rtc_init();
	printk("!* Restoring Interrupts\n");
	__asm__ __volatile__ ("sti");
	vga_color(0x3, 0x0);	
	printk("-- STARTING LOWLEVEL DRIVERS --\n");
	vga_color(0x5, 0x0);
	printk("!* Starting physical memory manager\n");
	kalloc_init((void*)bi->mmap_addr, (unsigned long)bi->mmap_length);
	printk("!* Starting keyboard driver\n");
	kb_init();
	printk("!* Starting IDE driver\n");
	ide_init(0x1F0, 0x3F6, 0x170, 0x366);
	vga_color(0x4, 0x0);
	printk("*** Initialized system successfully ***\n");
}