^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * arch/h8300/asm/include/flat.h -- uClinux flat-format executables
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #ifndef __H8300_FLAT_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #define __H8300_FLAT_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <asm/unaligned.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * on the H8 a couple of the relocations have an instruction in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * top byte. As there can only be 24bits of address space, we just
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * always preserve that 8bits at the top, when it isn't an instruction
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * is is 0 (davidm@snapgear.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define flat_get_relocate_addr(rel) (rel & ~0x00000001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) u32 *addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) u32 val = get_unaligned((__force u32 *)rp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) if (!(flags & FLAT_FLAG_GOTPIC))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) val &= 0x00ffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) *addr = val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) static inline int flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 rel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) u32 *p = (__force u32 *)rp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) put_unaligned((addr & 0x00ffffff) | (*(char *)p << 24), p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #endif /* __H8300_FLAT_H__ */