Exemple #1
0
BYTE if2Space(BYTE a, BYTE b, BYTE bUser)
{
	BYTE t = if1Space(a, b);
	if (t)
	{
		if (bUser)ATUB(
			MAKELONG(MAKEWORD(b, b),
			MAKEWORD(t, a))
			);
		return 1;
	}
	for (t = a + 1; t%X_NUM != 0 && iti2pai[t] == (BYTE)-1; ++t)
	{
		if (ATB(a, t, b, bUser))return 1;
	}
	for (t = a - 1; t%X_NUM != X_NUM - 1 && iti2pai[t] == (BYTE)-1; --t)
	{
		if (ATB(a, t, b, bUser))return 1;
	}
	for (t = a + X_NUM; t<MAX_KOMASUU&&
		iti2pai[t] == (BYTE)-1; t += X_NUM)
	{
		if (ATB(a, t, b, bUser))return 1;
	}
	for (t = a - X_NUM; t<MAX_KOMASUU&&
		iti2pai[t] == (BYTE)-1; t -= X_NUM)
	{
		if (ATB(a, t, b, bUser))return 1;
	}
	return 0;
}
Exemple #2
0
kern_obj * spawn_process(const uchar * cd, ulong csz, ulong dsz, ulong bsz, kern_obj * par, uchar priv, uchar priority)
{
	ulong i, pbase, ssz, absz, pgs;
	kern_obj * proc = alloc_kobj();
	
	ssz = csz + dsz;
	absz = bsz;

	if (csz % 0x1000 != 0) csz = csz - (csz % 0x1000) + 0x1000;
	if (dsz % 0x1000 != 0) dsz = dsz - (dsz % 0x1000) + 0x1000;
	if (bsz % 0x1000 != 0) bsz = bsz - (bsz % 0x1000) + 0x1000;

	proc->type = KOBJ_PROCESS;
	proc->u.proc.parent = par;
	proc->u.proc.priv = priv;
	proc->u.proc.priority = priority;
	
	proc->u.proc.code_data_ws = alloc_ws();
	
	pgs = csz / 0x1000 + dsz / 0x1000 + bsz / 0x1000;
	pbase = alloc_pages(pgs + 0x200, PHYS_PAGES);
	if (pbase == 0) {
		free_kobj(proc);
		return NULL;
	}

	add_pgs_to_ws(proc->u.proc.code_data_ws, USPACE_BOT, pbase, csz + dsz + bsz + 0x200000, 7);

	for (i = 0; i < ssz + absz; i++) {
		if (i % 0x1000 == 0) {
			ATQ(KPT0_0_LOC) = (pbase + i) | 3;
			INVLPG(KSPACE_LOC);
		}
		if (i < ssz) ATB(KSPACE_LOC + i % 0x1000) = cd[i];
		else ATB(KSPACE_LOC + i % 0x1000) = 0;
	}

	if (spawn_thread(proc, (int (*)())USPACE_BOT) == NULL) {
		free_kobj(proc);
		free_pages(pbase, pgs, PHYS_PAGES);
		return NULL;
	}

	getlock(&procthrd_lock, 0);
	if (head_process == NULL) {
		proc->u.proc.next = proc;
		head_process = proc;
	} else {
		proc->u.proc.next = head_process->u.proc.next;
		head_process->u.proc.next = proc;
	}
	unlock(&procthrd_lock, 0);
	
	return proc;
}
Exemple #3
0
static ulong check_table(ulong baddr, ulong parent, uint shf, uint fl)
{
	uint i;
	ulong eaddr = get_entry_addr(baddr, parent, shf);
	ulong r = ATQ(eaddr);

	if (!(r & PRESENT_BIT)) {
		r = alloc_pages(1, PHYS_PAGES) | fl;

		ATQ(eaddr) = r;
		page_to_kpt0_0(r);
		
		for (i = 0; i < 0x1000; i++) ATB(KSPACE_LOC + i) = 0;
		
		r = KSPACE_LOC;
	} else {
		page_to_kpt0_0(r);
		r = KSPACE_LOC;
	}
		
	return r & ~0xfff;
}