Esempio n. 1
0
// Dispatches to the correct kernel function, passing the arguments.
int32_t
syscall(uint32_t syscallno, uint32_t a1, uint32_t a2, uint32_t a3, uint32_t a4, uint32_t a5)
{
	// Call the function corresponding to the 'syscallno' parameter.
	// Return any appropriate return value.
	// LAB 3: Your code here.
	// My code: gmenghani
	// An invalid system call
	if(syscallno >= NSYSCALLS)
		return -E_INVAL;

	switch(syscallno) {
		case SYS_cputs: 	sys_cputs((char *) a1, (size_t)a2);
					return 0;
		case SYS_cgetc:		return sys_cgetc();
		case SYS_getenvid:	return sys_getenvid();
		case SYS_env_destroy:	return sys_env_destroy((envid_t)a1);
		case SYS_yield : sys_yield(); break;
		case SYS_exofork : return sys_exofork();
		case SYS_env_set_status : return sys_env_set_status((envid_t)a1, (int)a2);
		case SYS_page_alloc : return sys_page_alloc((envid_t)a1, (void*)a2, (int)a3);
		case SYS_page_map : return sys_page_map((envid_t)a1, (void*)a2, (envid_t)a3, (void*)a5, (int)a4);
		case SYS_page_unmap : return sys_page_unmap((envid_t)a1, (void*)a2);
		// For Challenge problem 1 Lab 4a
		case SYS_env_set_nice:	sys_env_set_nice(a1);
					return 0;
		case SYS_env_set_pgfault_upcall: sys_env_set_pgfault_upcall((envid_t)a1, (void *)a2);
		                                 return 0;
		case SYS_ipc_try_send: return sys_ipc_try_send((envid_t)a1, (uint32_t)a2, (void*)a3, (unsigned)a5);
		case SYS_ipc_recv: return sys_ipc_recv((void*)a1);
		case SYS_env_set_trapframe: return sys_env_set_trapframe((envid_t)a1, (struct Trapframe*)a2);
		case SYS_time_msec: return sys_time_msec();
		case SYS_net_send: return sys_net_send((void*)a1, (uint32_t) a2);
		case SYS_net_recv: return sys_net_recv((void*)a1, (uint16_t*) a2);
	}
	return 0;
}
Esempio n. 2
0
// Dispatches to the correct kernel function, passing the arguments.
int32_t
syscall(uint32_t syscallno, uint32_t a1, uint32_t a2, uint32_t a3, uint32_t a4, uint32_t a5)
{
	// Call the function corresponding to the 'syscallno' parameter.
	// Return any appropriate return value.
	switch(syscallno){
		case SYS_cputs:
			user_mem_assert(curenv, (void *)a1, a2, PTE_U);
			sys_cputs((char *)a1, a2);
			return 0;
			break;
		case SYS_cgetc:
			return sys_cgetc();
			break;
		case SYS_getenvid:
			return sys_getenvid();
			break;
		case SYS_getenv_parent_id:
			return sys_getenv_parent_id(a1);
			break;
		case SYS_env_destroy:
			return sys_env_destroy(a1);
			break;
		case SYS_page_alloc:
			return sys_page_alloc(a1, (void *)a2, a3);
			break;
		case SYS_page_map:
			return sys_page_map(a1, (void *)a2, a3, (void *)a4, a5);
			break;
		case SYS_page_unmap:
			return sys_page_unmap(a1, (void *)a2);
			break;
		case SYS_exofork:
			return sys_exofork();
			break;
		case SYS_env_set_status:
			return sys_env_set_status(a1, a2);
			break;
		case SYS_env_set_trapframe:
			return sys_env_set_trapframe(a1, (struct Trapframe *)a2);
			break;
		case SYS_env_set_pgfault_upcall:
			return sys_env_set_pgfault_upcall(a1, (void *)a2);
			break;
		case SYS_env_get_curdir:
			return sys_env_get_curdir((envid_t)a1, (char *)a2);
			break;
		case SYS_env_set_curdir:
			return sys_env_set_curdir((envid_t)a1, (char *)a2);
			break;
		case SYS_yield:
			sys_yield();
			break;
		case SYS_ipc_try_send:
			return sys_ipc_try_send(a1, a2, (void *)a3, a4);
			break;
		case SYS_ipc_recv:
			return sys_ipc_recv((void *)a1);
			break;
		case SYS_time_msec:
			return sys_time_msec();
			break;
		case SYS_net_send:
			return sys_net_send((void *)a1, a2);
			break;
		case SYS_net_recv:
			return sys_net_recv((void *)a1, a2);
			break;
		case NSYSCALLS:
		default:
			return -E_INVAL;
			break;
	}
	return 0;
}