blob: b2a41f5b3890a524d0335b89aaa3111194cd189d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Greg Ungerer120c4d92016-07-21 17:05:41 +10002 * flat.h -- uClinux flat-format executables
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 */
4
5#ifndef __M68KNOMMU_FLAT_H__
6#define __M68KNOMMU_FLAT_H__
7
Al Viro468138d2017-05-02 19:52:17 -04008#include <linux/uaccess.h>
9
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#define flat_argvp_envp_on_stack() 1
11#define flat_old_ram_flag(flags) (flags)
12#define flat_reloc_valid(reloc, size) ((reloc) <= (size))
Al Viro468138d2017-05-02 19:52:17 -040013static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags,
14 u32 *addr, u32 *persistent)
15{
16#ifdef CONFIG_CPU_HAS_NO_UNALIGNED
17 return copy_from_user(addr, rp, 4) ? -EFAULT : 0;
18#else
19 return get_user(*addr, rp);
20#endif
21}
22
23static inline int flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 rel)
24{
25#ifdef CONFIG_CPU_HAS_NO_UNALIGNED
26 return copy_to_user(rp, &addr, 4) ? -EFAULT : 0;
27#else
28 return put_user(addr, rp);
29#endif
30}
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#define flat_get_relocate_addr(rel) (rel)
Ezequiel Garciaf106eac2012-04-28 11:13:04 -030032
Geert Uytterhoeven9f42ef42017-07-16 13:57:28 +020033static inline int flat_set_persistent(u32 relval, u32 *persistent)
Ezequiel Garciaf106eac2012-04-28 11:13:04 -030034{
35 return 0;
36}
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
Greg Ungerer89e6ffd2016-07-21 16:28:48 +100038#define FLAT_PLAT_INIT(regs) \
39 do { \
40 if (current->mm) \
41 (regs)->d5 = current->mm->start_data; \
42 } while (0)
43
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#endif /* __M68KNOMMU_FLAT_H__ */