1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * flat.h -- uClinux flat-format executables 4 */ 5 6 #ifndef __M68KNOMMU_FLAT_H__ 7 #define __M68KNOMMU_FLAT_H__ 8 9 #include <linux/uaccess.h> 10 11 static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, 12 u32 *addr, u32 *persistent) 13 { 14 #ifdef CONFIG_CPU_HAS_NO_UNALIGNED 15 return copy_from_user(addr, rp, 4) ? -EFAULT : 0; 16 #else 17 return get_user(*addr, rp); 18 #endif 19 } 20 21 static inline int flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 rel) 22 { 23 #ifdef CONFIG_CPU_HAS_NO_UNALIGNED 24 return copy_to_user(rp, &addr, 4) ? -EFAULT : 0; 25 #else 26 return put_user(addr, rp); 27 #endif 28 } 29 30 #define FLAT_PLAT_INIT(regs) \ 31 do { \ 32 if (current->mm) \ 33 (regs)->d5 = current->mm->start_data; \ 34 } while (0) 35 36 #endif /* __M68KNOMMU_FLAT_H__ */ 37