GNU Linux-libre 4.14.266-gnu1
[releases.git] / arch / m68k / include / asm / flat.h
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 #define flat_argvp_envp_on_stack()              1
12 #define flat_old_ram_flag(flags)                (flags)
13 #define flat_reloc_valid(reloc, size)           ((reloc) <= (size))
14 static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags,
15                                         u32 *addr, u32 *persistent)
16 {
17 #ifdef CONFIG_CPU_HAS_NO_UNALIGNED
18         return copy_from_user(addr, rp, 4) ? -EFAULT : 0;
19 #else
20         return get_user(*addr, rp);
21 #endif
22 }
23
24 static inline int flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 rel)
25 {
26 #ifdef CONFIG_CPU_HAS_NO_UNALIGNED
27         return copy_to_user(rp, &addr, 4) ? -EFAULT : 0;
28 #else
29         return put_user(addr, rp);
30 #endif
31 }
32 #define flat_get_relocate_addr(rel)             (rel)
33
34 static inline int flat_set_persistent(u32 relval, u32 *persistent)
35 {
36         return 0;
37 }
38
39 #define FLAT_PLAT_INIT(regs) \
40         do { \
41                 if (current->mm) \
42                         (regs)->d5 = current->mm->start_data; \
43         } while (0)
44
45 #endif /* __M68KNOMMU_FLAT_H__ */