Beispiel #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.

	int32_t ret = 0;

	switch (syscallno) {
	case SYS_cputs:
		sys_cputs((char *)a1, (size_t)a2);
		break;
	case SYS_cgetc:
		ret = sys_cgetc();
		break;
	case SYS_getenvid:
		ret = sys_getenvid();
		break;
	case SYS_env_destroy:
		ret = sys_env_destroy((envid_t)a1);
		break;
	case SYS_yield:
		sys_yield();
		break;
	case SYS_exofork:
		ret = sys_exofork();
		break;
	case SYS_env_set_status:
		ret = sys_env_set_status((envid_t)a1, a2);
		break;
	case SYS_page_alloc:
		ret = sys_page_alloc((envid_t)a1, (void *)a2, a3);
		break;
	case SYS_page_map:
		ret = sys_page_map((envid_t)a1, (void *)a2, (envid_t)a3, (void *)a4, a5);
		break;
	case SYS_page_unmap:
		ret = sys_page_unmap((envid_t)a1, (void *)a2);
		break;
	case SYS_env_set_pgfault_upcall:
		ret = sys_env_set_pgfault_upcall((envid_t)a1, (void *)a2);
		break;
	case SYS_ipc_recv:
		ret = sys_ipc_recv((void *)a1);
		break;
	case SYS_ipc_try_send:
		ret = sys_ipc_try_send((envid_t)a1, (uint32_t)a2, (void *)a3, (unsigned)a4);
		break;
	case SYS_env_set_trapframe:
		ret = sys_env_set_trapframe((envid_t)a1, (struct Trapframe *)a2);
		break;
	case SYS_time_msec:
		ret = sys_time_msec();
		break;
	case SYS_transmit_packet:
		ret = sys_transmit_packet((void *)a1, a2);
		break;
	case SYS_receive_packet:
		ret = sys_receive_packet((void *)a1);
		break;
	default:
		return -E_INVAL;
	}

	return ret;
}
Beispiel #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.
	// LAB 3: Your code here.
	switch (syscallno) {
		case SYS_cputs :
			sys_cputs((const char*) a1, (size_t) a2);
			return 0;
		case SYS_env_set_trapframe:
			return sys_env_set_trapframe((envid_t)a1, (struct Trapframe*) a2);
		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();
			return 0;
 		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 *)a4, (int)a5);
		case SYS_page_unmap:
                	return sys_page_unmap((envid_t)a1, (void *)a2);
		case SYS_env_set_pgfault_upcall:
                	return sys_env_set_pgfault_upcall((envid_t)a1, (void *)a2);
		case SYS_ipc_try_send:
			//cprintf("Sending ipc..\n\n\n");
                	return sys_ipc_try_send((envid_t)a1, (uint32_t)a2, (void *)a3, (unsigned)a4);
        	case SYS_ipc_recv:
                	return sys_ipc_recv((void *)a1);
        	case SYS_clear_block_access_bit:
        		return sys_clear_block_access_bit((envid_t)a1, (void*) a2);
        	case SYS_time_msec:
        		return sys_time_msec();
		case SYS_send_packet:
			return sys_send_packet((void *)a1, (unsigned)a2);
		case SYS_receive_packet:
			return sys_receive_packet((void *)a1);
		case SYS_get_mac_address:
			return sys_get_mac_address((uint8_t *) a1);
		case SYS_get_logged_user_name:
			return sys_get_logged_user_name((char *)a1);
		case SYS_get_current_path:
			return sys_get_current_path((char *)a1);
		case SYS_update_current_path:
			return sys_update_current_path((char *)a1);
		case SYS_get_home_dir:
			return sys_get_home_dir((char *)a1);
		default:
			return -E_INVAL;
	}
		
	
	//panic("syscall not implemented");
}