void copy_in_cb(int pid, seL4_CPtr reply_cap, void *_args, int err) { if (SOS_DEBUG) printf("copy_in_cb\n"); copy_in_args *args = _args; if (err) { eprintf("Error caught in copy_in_cb\n"); args->cb(pid, reply_cap, args->cb_args, err); free(args); return; } //only copy up the end of a user page int to_copy = args->nbyte - args->count; if ((args->usr_ptr & ~PAGE_MASK) + to_copy > PAGE_SIZE) { to_copy = PAGE_SIZE - (args->usr_ptr & ~PAGE_MASK); } //get the actual mapping of the user page seL4_Word src = user_to_kernel_ptr(args->usr_ptr, pid); //copy in the data memcpy((void *) (args->k_ptr + args->count), (void *) src, to_copy); //increment the pointers etc. args->count += to_copy; args->usr_ptr += to_copy; copy_in(pid, reply_cap, args, 0); if (SOS_DEBUG) printf("copy_in_cb ended\n"); }
void copy_page_cb(int pid, seL4_CPtr reply_cap, void *args, int err) { if (SOS_DEBUG) printf("copy_page_cb\n"); copy_page_args *copy_args = (copy_page_args *) args; seL4_Word kptr = user_to_kernel_ptr(copy_args->dst, pid); memcpy((void *)kptr, (void *)copy_args->src , copy_args->count); copy_args->cb(pid, reply_cap, copy_args->cb_args, err); free(args); if (SOS_DEBUG) printf("copy_page_cb ended\n"); }
void get_arg (struct intr_frame *f, int *arg, int n); void check_valid_ptr (const void *vaddr); void check_valid_buffer (void* buffer, unsigned size); void check_valid_string (const void* str); void syscall_init (void) { intr_register_int (0x30, 3, INTR_ON, syscall_handler, "syscall"); } static void syscall_handler (struct intr_frame *f UNUSED) { int arg[MAX_ARGS]; int esp = user_to_kernel_ptr((const void*) f->esp); switch (* (int *) esp) { case SYS_HALT: { halt(); break; } case SYS_EXIT: { get_arg(f, &arg[0], 1); exit(arg[0]); break; } case SYS_EXEC: {