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