]>
Commit | Line | Data |
---|---|---|
c6087fdc MS |
1 | /* |
2 | * uClinux flat-format executables | |
3 | * | |
4 | * Copyright (C) 2005 John Williams <jwilliams@itee.uq.edu.au> | |
5 | * | |
6 | * This file is subject to the terms and conditions of the GNU General | |
7 | * Public License. See the file COPYING in the main directory of this | |
8 | * archive for more details. | |
9 | */ | |
10 | ||
11 | #ifndef _ASM_MICROBLAZE_FLAT_H | |
12 | #define _ASM_MICROBLAZE_FLAT_H | |
13 | ||
14 | #include <asm/unaligned.h> | |
15 | ||
c6087fdc MS |
16 | #define flat_argvp_envp_on_stack() 0 |
17 | #define flat_old_ram_flag(flags) (flags) | |
18 | #define flat_reloc_valid(reloc, size) ((reloc) <= (size)) | |
19 | #define flat_set_persistent(relval, p) 0 | |
20 | ||
21 | /* | |
22 | * Microblaze works a little differently from other arches, because | |
23 | * of the MICROBLAZE_64 reloc type. Here, a 32 bit address is split | |
24 | * over two instructions, an 'imm' instruction which provides the top | |
25 | * 16 bits, then the instruction "proper" which provides the low 16 | |
26 | * bits. | |
27 | */ | |
28 | ||
29 | /* | |
30 | * Crack open a symbol reference and extract the address to be | |
31 | * relocated. rp is a potentially unaligned pointer to the | |
32 | * reference | |
33 | */ | |
34 | ||
468138d7 AV |
35 | static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, |
36 | u32 *addr, u32 *persistent) | |
c6087fdc | 37 | { |
468138d7 | 38 | u32 *p = (__force u32 *)rp; |
c6087fdc MS |
39 | |
40 | /* Is it a split 64/32 reference? */ | |
41 | if (relval & 0x80000000) { | |
42 | /* Grab the two halves of the reference */ | |
468138d7 | 43 | u32 val_hi, val_lo; |
c6087fdc | 44 | |
468138d7 AV |
45 | val_hi = get_unaligned(p); |
46 | val_lo = get_unaligned(p+1); | |
c6087fdc MS |
47 | |
48 | /* Crack the address out */ | |
468138d7 | 49 | *addr = ((val_hi & 0xffff) << 16) + (val_lo & 0xffff); |
c6087fdc MS |
50 | } else { |
51 | /* Get the address straight out */ | |
468138d7 | 52 | *addr = get_unaligned(p); |
c6087fdc MS |
53 | } |
54 | ||
468138d7 | 55 | return 0; |
c6087fdc MS |
56 | } |
57 | ||
58 | /* | |
59 | * Insert an address into the symbol reference at rp. rp is potentially | |
60 | * unaligned. | |
61 | */ | |
62 | ||
63 | static inline void | |
468138d7 | 64 | flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 relval) |
c6087fdc | 65 | { |
468138d7 | 66 | u32 *p = (__force u32 *)rp; |
c6087fdc MS |
67 | /* Is this a split 64/32 reloc? */ |
68 | if (relval & 0x80000000) { | |
69 | /* Get the two "halves" */ | |
468138d7 AV |
70 | unsigned long val_hi = get_unaligned(p); |
71 | unsigned long val_lo = get_unaligned(p + 1); | |
c6087fdc MS |
72 | |
73 | /* insert the address */ | |
74 | val_hi = (val_hi & 0xffff0000) | addr >> 16; | |
75 | val_lo = (val_lo & 0xffff0000) | (addr & 0xffff); | |
76 | ||
77 | /* store the two halves back into memory */ | |
468138d7 AV |
78 | put_unaligned(val_hi, p); |
79 | put_unaligned(val_lo, p+1); | |
c6087fdc MS |
80 | } else { |
81 | /* Put it straight in, no messing around */ | |
468138d7 | 82 | put_unaligned(addr, p); |
c6087fdc | 83 | } |
468138d7 | 84 | return 0; |
c6087fdc MS |
85 | } |
86 | ||
87 | #define flat_get_relocate_addr(rel) (rel & 0x7fffffff) | |
88 | ||
89 | #endif /* _ASM_MICROBLAZE_FLAT_H */ |