2009-03-27 21:25:34 +08:00
|
|
|
/*
|
|
|
|
* uClinux flat-format executables
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 John Williams <jwilliams@itee.uq.edu.au>
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General
|
|
|
|
* Public License. See the file COPYING in the main directory of this
|
|
|
|
* archive for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ASM_MICROBLAZE_FLAT_H
|
|
|
|
#define _ASM_MICROBLAZE_FLAT_H
|
|
|
|
|
|
|
|
#include <asm/unaligned.h>
|
|
|
|
|
|
|
|
#define flat_argvp_envp_on_stack() 0
|
|
|
|
#define flat_old_ram_flag(flags) (flags)
|
|
|
|
#define flat_reloc_valid(reloc, size) ((reloc) <= (size))
|
|
|
|
#define flat_set_persistent(relval, p) 0
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Microblaze works a little differently from other arches, because
|
|
|
|
* of the MICROBLAZE_64 reloc type. Here, a 32 bit address is split
|
|
|
|
* over two instructions, an 'imm' instruction which provides the top
|
|
|
|
* 16 bits, then the instruction "proper" which provides the low 16
|
|
|
|
* bits.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Crack open a symbol reference and extract the address to be
|
|
|
|
* relocated. rp is a potentially unaligned pointer to the
|
|
|
|
* reference
|
|
|
|
*/
|
|
|
|
|
2017-05-03 07:52:17 +08:00
|
|
|
static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags,
|
|
|
|
u32 *addr, u32 *persistent)
|
2009-03-27 21:25:34 +08:00
|
|
|
{
|
2017-05-03 07:52:17 +08:00
|
|
|
u32 *p = (__force u32 *)rp;
|
2009-03-27 21:25:34 +08:00
|
|
|
|
|
|
|
/* Is it a split 64/32 reference? */
|
|
|
|
if (relval & 0x80000000) {
|
|
|
|
/* Grab the two halves of the reference */
|
2017-05-03 07:52:17 +08:00
|
|
|
u32 val_hi, val_lo;
|
2009-03-27 21:25:34 +08:00
|
|
|
|
2017-05-03 07:52:17 +08:00
|
|
|
val_hi = get_unaligned(p);
|
|
|
|
val_lo = get_unaligned(p+1);
|
2009-03-27 21:25:34 +08:00
|
|
|
|
|
|
|
/* Crack the address out */
|
2017-05-03 07:52:17 +08:00
|
|
|
*addr = ((val_hi & 0xffff) << 16) + (val_lo & 0xffff);
|
2009-03-27 21:25:34 +08:00
|
|
|
} else {
|
|
|
|
/* Get the address straight out */
|
2017-05-03 07:52:17 +08:00
|
|
|
*addr = get_unaligned(p);
|
2009-03-27 21:25:34 +08:00
|
|
|
}
|
|
|
|
|
2017-05-03 07:52:17 +08:00
|
|
|
return 0;
|
2009-03-27 21:25:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Insert an address into the symbol reference at rp. rp is potentially
|
|
|
|
* unaligned.
|
|
|
|
*/
|
|
|
|
|
2017-07-31 01:25:37 +08:00
|
|
|
static inline int
|
2017-05-03 07:52:17 +08:00
|
|
|
flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 relval)
|
2009-03-27 21:25:34 +08:00
|
|
|
{
|
2017-05-03 07:52:17 +08:00
|
|
|
u32 *p = (__force u32 *)rp;
|
2009-03-27 21:25:34 +08:00
|
|
|
/* Is this a split 64/32 reloc? */
|
|
|
|
if (relval & 0x80000000) {
|
|
|
|
/* Get the two "halves" */
|
2017-05-03 07:52:17 +08:00
|
|
|
unsigned long val_hi = get_unaligned(p);
|
|
|
|
unsigned long val_lo = get_unaligned(p + 1);
|
2009-03-27 21:25:34 +08:00
|
|
|
|
|
|
|
/* insert the address */
|
|
|
|
val_hi = (val_hi & 0xffff0000) | addr >> 16;
|
|
|
|
val_lo = (val_lo & 0xffff0000) | (addr & 0xffff);
|
|
|
|
|
|
|
|
/* store the two halves back into memory */
|
2017-05-03 07:52:17 +08:00
|
|
|
put_unaligned(val_hi, p);
|
|
|
|
put_unaligned(val_lo, p+1);
|
2009-03-27 21:25:34 +08:00
|
|
|
} else {
|
|
|
|
/* Put it straight in, no messing around */
|
2017-05-03 07:52:17 +08:00
|
|
|
put_unaligned(addr, p);
|
2009-03-27 21:25:34 +08:00
|
|
|
}
|
2017-05-03 07:52:17 +08:00
|
|
|
return 0;
|
2009-03-27 21:25:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#define flat_get_relocate_addr(rel) (rel & 0x7fffffff)
|
|
|
|
|
|
|
|
#endif /* _ASM_MICROBLAZE_FLAT_H */
|