Example #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.
	/*stone's solution for lab3-B*/
	int32_t ret = -E_INVAL;
	switch (syscallno){
		case SYS_cputs:
			sys_cputs((char*)a1, a2);
			ret = 0;
			break;
		case SYS_cgetc:
			ret = sys_cgetc();
			break;
		case SYS_getenvid:
			ret = sys_getenvid();
			break;
		case SYS_env_destroy:
			ret = sys_env_destroy(a1);
			break;
		case SYS_map_kernel_page:
			ret = sys_map_kernel_page((void*)a1, (void*)a2);
			break;
		case SYS_sbrk:
			ret = sys_sbrk(a1);
			break;
		default:
			break;
	}
	return ret;
	//panic("syscall not implemented");
}
Example #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.
	int32_t ret = -E_INVAL;
	switch(syscallno) {
		case SYS_cputs:
			sys_cputs((char *)a1, a2);
			break;
		case SYS_cgetc:
			ret = sys_cgetc();
			break;
		case SYS_getenvid:
			ret = sys_getenvid();
			break;
		case SYS_env_destroy:
			ret = sys_env_destroy(a1);
			break;
		case SYS_yield:
			sys_yield();
			ret = 0;
			break;
		case SYS_map_kernel_page:
			ret = sys_map_kernel_page((void *)a1, (void *)a2);
			break;
		case SYS_sbrk:
			ret = sys_sbrk(a1);
			break;
		case SYS_exofork:
			ret = sys_exofork();
			break;
		case SYS_env_set_status:
			ret = sys_env_set_status(a1,a2);
			break;
		case SYS_page_alloc:
			ret = sys_page_alloc(a1,(void*)a2,a3);
			break;
		case SYS_page_map:
			ret = sys_page_map(a1,(void*)a2,a3,(void*)a4,a5);
			break;
		case SYS_page_unmap:
			ret = sys_page_unmap(a1,(void*)a2);
			break;
		case SYS_env_set_pgfault_upcall:
			ret = sys_env_set_pgfault_upcall(a1,(void*)a2);
			break;
		case SYS_ipc_try_send:
			ret = sys_ipc_try_send(a1,a2,(void*)a3,a4);
			break;
		case SYS_ipc_recv:
			ret = sys_ipc_recv((void*)a1);
	}
	return ret;
//	panic("syscall not implemented");
}
Example #3
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_getenvid:
			return sys_getenvid();
		case SYS_cputs:
			sys_cputs((const char*)a1, a2);
			return 0;
		case SYS_cgetc:
			return sys_cgetc();
		case SYS_env_destroy:
			return sys_env_destroy(a1);
		case SYS_map_kernel_page:
			return sys_map_kernel_page((void*)a1, (void*)a2);
		case SYS_sbrk:
			return sys_sbrk(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)*((uint32_t*)a1),
					(void*)*((uint32_t*)a1+1), 
					(envid_t)*((uint32_t*)a1+2), 
					(void*)*((uint32_t*)a1+3), 
					(int)*((uint32_t*)a1+4));
		case SYS_page_unmap:
			return sys_page_unmap((envid_t)a1, (void*)a2);
		case SYS_env_set_priority:
			return sys_env_set_priority((envid_t)a1, (int) a2);
		case SYS_env_set_pgfault_upcall:
			return sys_env_set_pgfault_upcall((envid_t)a1,
						 (void*)a2);
		case SYS_ipc_recv:
			return sys_ipc_recv((void*)a1);
		case SYS_ipc_try_send:
			return sys_ipc_try_send((envid_t)a1, a2, 
						(void*)a3, (int)a4);
		default:
			return -E_INVAL;
	}
}
Example #4
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.
	//cprintf("syscallno is %d\n",syscallno);
	switch (syscallno){
		case SYS_getenvid:
			//cprintf("in kernel SYS_getenvid!\n");
			return sys_getenvid();
		case SYS_cputs:
			//cprintf("in kernel SYS_cputs!\n");
			sys_cputs((const char*) a1,a2);
			return 0;
		case SYS_cgetc:
			//cprintf("in kernel SYS_cgetc!\n");
			return sys_cgetc();
		case SYS_env_destroy:
			//cprintf("in kernel SYS_env_destroy!\n");
			return sys_env_destroy(a1);
		case SYS_map_kernel_page:
			//cprintf("in kernel SYS_map_kernel_page!\n");
			return sys_map_kernel_page((void *)a1, (void *)a2);
		case SYS_yield:
			//cprintf("in kernel SYS_yield!\n");
			//unlock_kernel();
			sys_yield();
			return 0;
		case SYS_page_alloc:
			//cprintf("in kernel SYS_page_alloc!\n");
			//cprintf("in kern sys_page_alloc!\n");
			return sys_page_alloc((envid_t) a1, (void *) a2, (int) a3);
		case SYS_page_map:
			//cprintf("in kernel SYS_page_map!\n");
			//cprintf("in kern sys_page_map!\n");
			//cprintf("in kern get arglist is %p\n",a1);
			//cprintf("value of a1 is %p\n",*((uint32_t *)a1+1));
			return sys_page_map((envid_t) *((uint32_t *)a1), (void *) *((uint32_t *)a1+1), 
						(envid_t) *((uint32_t *)a1+2), (void *) *((uint32_t *)a1+3), (int) *((uint32_t *)a1+4));
		case SYS_page_unmap:
			//cprintf("in kernel SYS_page_unmap!\n");
			//cprintf("in kern sys_page_unmap!\n");
			return sys_page_unmap((envid_t) a1, (void *) a2);
		case SYS_exofork:
			//cprintf("in kernel SYS_exofork!\n");
			//cprintf("in kern sys_exofork!\n");
			return sys_exofork();
		case SYS_env_set_status:
			//cprintf("in kernel SYS_env_set_status!\n");
			//cprintf("in kern sys_env_set_status!\n");
			//cprintf("syscall in envid %p status %p\n",a1,a2);
			return sys_env_set_status((envid_t) a1, (int) a2);
		case SYS_env_set_pgfault_upcall:
			//cprintf("in kernel SYS_env_set_pgfault_upcall!\n");
			return sys_env_set_pgfault_upcall((envid_t) a1, (void *) a2);
		case SYS_ipc_recv:
			//cprintf("in syscall recive!\n");
			return sys_ipc_recv((void*)a1);
		case SYS_ipc_try_send:
			//cprintf("in syscall send!\n");
			return sys_ipc_try_send((envid_t)a1,a2,(void*)a3,(int)a4);
		case SYS_proc_save:
			return sys_proc_save((envid_t)a1,(struct proc *)a2);
		case SYS_proc_resume:
			return sys_proc_resume((envid_t)a1,(struct proc*)a2);
		default:
			return -E_INVAL;
	}

//	panic("syscall not implemented");
}
Example #5
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.
	/*stone's solution for lab3-B*/
	int32_t ret = -E_INVAL;
	switch (syscallno){
		case SYS_cputs:
			sys_cputs((char*)a1, a2);
			ret = 0;
			break;
		case SYS_cgetc:
			ret = sys_cgetc();
			break;
		case SYS_getenvid:
			ret = sys_getenvid();
			break;
		case SYS_env_destroy:
			ret = sys_env_destroy(a1);
			break;
		case SYS_map_kernel_page:
			ret = sys_map_kernel_page((void*)a1, (void*)a2);
			break;
		case SYS_sbrk:
			ret = sys_sbrk(a1);
			break;
		/*stone's solution for lab4-A*/
		case SYS_yield:
			sys_yield();
			ret = 0;
			break;
		case SYS_exofork:
			ret = sys_exofork();
			break;
		case SYS_env_set_status:
			ret = sys_env_set_status(a1, a2);
			break;
		case SYS_env_set_pgfault_upcall:
			ret = sys_env_set_pgfault_upcall((envid_t)a1, (void*)a2);
			break;
		case SYS_page_alloc:
			ret = sys_page_alloc((envid_t)a1, (void*)a2, (int)a3);
			break;
		case SYS_page_map:
			/*stone: see lib/syscall.c for modification details*/
			ret = sys_page_map(*((uint32_t*)a1), (void*)*((uint32_t*)a1 + 1), *((uint32_t*)a1 + 2), (void*)*((uint32_t*)a1 + 3), *((uint32_t*)a1 + 4));
			//ret = sys_page_map(a1, (void*)a2, a3, (void*)a4, a5);
			break;
		case SYS_page_unmap:
			ret = sys_page_unmap(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, a2, (void*)a3, (int)a4);
			break;
		case SYS_env_set_trapframe:
			ret = sys_env_set_trapframe((envid_t)a1, (struct Trapframe*)a2);
			break;
		default:
			break;
	}
	return ret;
	//panic("syscall not implemented");
}
Example #6
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 res;
    a5 = syscallno >> 8;
    syscallno -= (a5<<8);
    //if(a5!=0)cprintf("syscallno %d %x %x\n",syscallno,a1,a5);
    switch(syscallno)
    {
        case SYS_cputs:
            sys_cputs((const char*)a1,(size_t)a2);
            res = 0;
            break;
        case SYS_cgetc:
            res = sys_cgetc();
            break;
        case SYS_getenvid:
            res = sys_getenvid();
            break;
        case SYS_env_destroy:
            res = sys_env_destroy(a1);
            break;
        case SYS_map_kernel_page:
            res = sys_map_kernel_page((void*)a1,(void*)a2);
            break;
        case SYS_yield:
            res = 0;
            sys_yield();
            break;
        case SYS_exofork:
            res = sys_exofork();
            break;
        case SYS_env_set_status:
            res = sys_env_set_status(a1,a2);
            break;
        case SYS_page_alloc:
            res = sys_page_alloc(a1,(void*)a2,a3);
            break;
        case SYS_page_map:
            res = sys_page_map(a1,(void*)a2,a3,(void*)a4,(int)a5);
            break;
        case SYS_page_unmap:
            res = sys_page_unmap(a1,(void*)a2);
            break;
        case SYS_env_set_pgfault_upcall:
            res = sys_env_set_pgfault_upcall(a1,(void*)a2);
            break;
        case SYS_ipc_try_send:
            res = sys_ipc_try_send(a1,a2,(void*)a3,a4);
            break;
        case SYS_ipc_recv:
            res = sys_ipc_recv((void*)a1);
            break;
        case NSYSCALLS:
        default:
            res = -E_INVAL;
    }
    //cprintf("res %x\n",res);
    return res;
}