1 // syscall_args.h 2 3 #ifndef _SYSCALL_ARGS_H 4 #define _SYSCALL_ARGS_H 5 6 #include <kernel.h> 7 //#include <vm.h> 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 16 template<typename T> 17 inline 18 status_t 19 copy_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 27 template<typename T> 28 inline 29 status_t 30 copy_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 #endif // _SYSCALL_ARGS_H 38