syscall_args.h revision 4f7b9506
1// syscall_args.h
2
3#ifndef _SYSCALL_ARGS_H
4#define _SYSCALL_ARGS_H
5
6#include <kernel.h>
7
8
9// Hack to be able to use the IS_USER_ADDRESS macro when compiling for R5.
10#ifdef R5_MEMORY_LAYOUT
11#	undef KERNEL_BASE
12#	define KERNEL_BASE 0x0
13#endif
14
15// copy_ref_var_from_user
16template<typename T>
17inline
18status_t
19copy_ref_var_from_user(T *user, T &kernel)
20{
21	if (!IS_USER_ADDRESS(user))
22		return B_BAD_ADDRESS;
23	return user_memcpy(&kernel, user, sizeof(T));
24}
25
26// copy_ref_var_to_user
27template<typename T>
28inline
29status_t
30copy_ref_var_to_user(T &kernel, T *user)
31{
32	if (!IS_USER_ADDRESS(user))
33		return B_BAD_ADDRESS;
34	return user_memcpy(user, &kernel, sizeof(T));
35}
36
37
38#endif	// _SYSCALL_ARGS_H
39