Ejemplo n.º 1
0
void vm_bootstrap() {
	
	swap_initialized = 0;

	paddr_t ram_hi;
	paddr_t ram_low;

	ram_getsize(&ram_low, &ram_hi);	// get the current size of ram

	int ram_pages = (ram_hi-ram_low)/PAGE_SIZE;	// find out how many pages of ram we have

	int cm_bytes = ram_pages*sizeof(struct cm_entry);	// how many bytes our coremap will need to be

	while (cm_bytes % PAGE_SIZE != 0)	// page align the value
		cm_bytes++;

	int cm_pages = cm_bytes/PAGE_SIZE;	// number of pages we need to steal for the coremap

	ram_stealmem(cm_pages);

	paddr_t ram_start = ram_low + (cm_pages*PAGE_SIZE);	// ram will then start at address right after coremap

	ram_pages -= cm_pages;		// don't want the coremap to map to itself

	coremap_init(ram_pages,ram_start,ram_low);	// initialize the coremap

	vm_has_bootstrapped = 1;	// vm has finished initializing
}
Ejemplo n.º 2
0
void
vm_bootstrap(void)
{
	char fname[] = "lhd0raw:";
	vm_lock = lock_create("vm_lock");
	int result = vfs_open(fname, 0, O_RDWR , &swap_file);
	if(result)
    		panic("Virtual Memory: Swap space could not be created \n");
	alloc = (struct alloc_status*)kmalloc(64*sizeof(struct alloc_status));	
	coreswap_init();
	coremap_init();	
	myvm_fl=1;
}
Ejemplo n.º 3
0
/*
 * Initial boot sequence.
 */
static
void
boot(void)
{
	/*
	 * The order of these is important!
	 * Don't go changing it without thinking about the consequences.
	 *
	 * Among other things, be aware that console output gets
	 * buffered up at first and does not actually appear until
	 * mainbus_bootstrap() attaches the console device. This can
	 * be remarkably confusing if a bug occurs at this point. So
	 * don't put new code before mainbus_bootstrap if you don't
	 * absolutely have to.
	 *
	 * Also note that the buffer for this is only 1k. If you
	 * overflow it, the system will crash without printing
	 * anything at all. You can make it larger though (it's in
	 * dev/generic/console.c).
	 */
	kprintf("\n");
	kprintf("OS/161 base system version %s\n", BASE_VERSION);
	kprintf("%s", harvard_copyright);
	kprintf("\n");

	kprintf("Put-your-group-name-here's system version %s (%s #%d)\n", 
		GROUP_VERSION, buildconfig, buildversion);
	kprintf("\n");

	/* Early initialization. */
	ram_bootstrap();
	coremap_init();
	proc_bootstrap();
	thread_bootstrap();
	hardclock_bootstrap();
	vfs_bootstrap();

	/* Probe and initialize devices. Interrupts should come on. */
	kprintf("Device probe...\n");
	KASSERT(curthread->t_curspl > 0);
	mainbus_bootstrap();
	KASSERT(curthread->t_curspl == 0);
	/* Now do pseudo-devices. */
	pseudoconfig();
	kprintf("\n");

	/* Late phase of initialization. */
	vm_bootstrap();
	kprintf_bootstrap();
	thread_start_cpus();

	// boot the stdin, stdout, stderr for fd_tuple
	fd_tuple_bootstrap();

	/* Default bootfs - but ignore failure, in case emu0 doesn't exist */
	vfs_setbootfs("emu0");

	#if OPT_A0
	   hello();
	#endif /* OPT_A0 */	

	finish_boot();
	swapfile_init();

	/*
	 * Make sure various things aren't screwed up.
	 */
	COMPILE_ASSERT(sizeof(userptr_t) == sizeof(char *));
	COMPILE_ASSERT(sizeof(*(userptr_t)0) == sizeof(char));
}