示例#1
0
void create_init(void)
{
	uint8_t *j;

	init_process = ptab_alloc();
	udata.u_ptab = init_process;
	udata.u_top = PROGLOAD + 4096;	/* Plenty for the boot */
	init_process->p_top = udata.u_top;
	map_init();
	newproc(init_process);

	udata.u_insys = 1;

	init_process->p_status = P_RUNNING;

	/* wipe file table */
	for (j = udata.u_files; j < (udata.u_files + UFTSIZE); ++j) {
		*j = NO_FILE;
	}
	/* Poke the execve arguments into user data space so _execve() can read them back */
	argptr = PROGLOAD;
	progptr = PROGLOAD + 2048;

	uzero((void *)progptr, 32);
	add_argument("/init");
}
示例#2
0
文件: start.c 项目: Abioy/FUZIX
void create_init(void)
{
	uint8_t *j;
	/* userspace: 0x100+ 0   1   2   3   4   5   6   7   8   9   A   B   C */
	const char arg[] =
	    { '/', 'i', 'n', 'i', 't', 0, 0, 1, 1, 0, 0, 0, 0 };

	init_process = ptab_alloc();
	udata.u_ptab = init_process;
	udata.u_top = 4096;	/* Plenty for the boot */
	map_init();
	newproc(init_process);

	init_process->p_status = P_RUNNING;

	/* wipe file table */
	for (j = udata.u_files; j < (udata.u_files + UFTSIZE); ++j) {
		*j = NO_FILE;
	}
	/* Poke the execve arguments into user data space so _execve() can read them back */
	uput(arg, PROGBASE, sizeof(arg));

	/* Set up things to look like the process is calling _execve() */
	udata.u_argn = (uint16_t) PROGBASE;
	/* FIXME - should be relative to PROGBASE... */
	udata.u_argn1 = 0x107;	/* Arguments (just "/init") */
	udata.u_argn2 = 0x10b;	/* Environment (none) */
}
示例#3
0
void create_init(void)
{
	uint8_t *j, *e;

	udata.u_top = PROGLOAD + 512;	/* Plenty for the boot */
	init_process = ptab_alloc();
	udata.u_ptab = init_process;
	init_process->p_top = udata.u_top;
	map_init();

	/* wipe file table */
	e = udata.u_files + UFTSIZE;
	for (j = udata.u_files; j < e; ++j)
		*j = NO_FILE;

	makeproc(init_process, &udata);
	init_process->p_status = P_RUNNING;

	udata.u_insys = 1;

	init_process->p_status = P_RUNNING;

	/* Poke the execve arguments into user data space so _execve() can read them back */
	/* Some systems only have a tiny window we can use at boot as most of
	   this space is loaded with common memory */
	argptr = PROGLOAD;
	progptr = PROGLOAD + 256;

	uzero((void *)progptr, 32);
	add_argument("/init");
}
示例#4
0
void base_paging_init(void)
{
	if (ptab_alloc(&base_pdir_pa))
		panic("Can't allocate kernel page directory");

	if (pdir_map_range(base_pdir_pa, 0, 0, round_superpage(phys_mem_max),
		INTEL_PDE_VALID | INTEL_PDE_WRITE | INTEL_PDE_USER))
		panic("Can't direct-map physical memory");
}
示例#5
0
arg_t _fork(void)
{
	// allocate new process
	struct p_tab *new_process;
	arg_t r;
	irqflags_t irq;

	if (flags) {
		/* Brief period of grace... */
//		udata.u_error = EINVAL;
//		return -1;
		kputs("warning: rebuild libc\n");
	}

	new_process = ptab_alloc();
	if (!new_process)
		return -1;

	irq = di();
	// we're going to run our child process next, so mark this process as being ready to run
	udata.u_ptab->p_status = P_READY;
	// kick off the new process (the bifurcation happens inside here, we returns in both 
	// the child and parent contexts)
	r = dofork(new_process);
#ifdef DEBUG
	kprintf("Dofork %x (n %x)returns %d\n", udata.u_ptab,
		new_process, r);
	kprintf("udata.u_page %d p_page %d\n", udata.u_page,
		udata.u_ptab->p_page);
	kprintf("parent %x\n", udata.u_ptab->p_pptr);
#endif
	// if we fail this returns -1
	if (r == -1) {
		udata.u_ptab->p_status = P_RUNNING;
		pagemap_free(new_process);
		new_process->p_status = P_EMPTY;
		udata.u_error = ENOMEM;
		nproc--;
		nready--;
	}
	irqrestore(irq);

	return r;
}