~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to arch/blackfin/kernel/module.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 * Licensed under the GPL-2 or later
5
5
 */
6
6
 
7
 
#define pr_fmt(fmt) "module %s: " fmt
 
7
#define pr_fmt(fmt) "module %s: " fmt, mod->name
8
8
 
9
9
#include <linux/moduleloader.h>
10
10
#include <linux/elf.h>
57
57
                        dest = l1_inst_sram_alloc(s->sh_size);
58
58
                        mod->arch.text_l1 = dest;
59
59
                        if (dest == NULL) {
60
 
                                pr_err("L1 inst memory allocation failed\n",
61
 
                                        mod->name);
 
60
                                pr_err("L1 inst memory allocation failed\n");
62
61
                                return -1;
63
62
                        }
64
63
                        dma_memcpy(dest, (void *)s->sh_addr, s->sh_size);
70
69
                        dest = l1_data_sram_alloc(s->sh_size);
71
70
                        mod->arch.data_a_l1 = dest;
72
71
                        if (dest == NULL) {
73
 
                                pr_err("L1 data memory allocation failed\n",
74
 
                                        mod->name);
 
72
                                pr_err("L1 data memory allocation failed\n");
75
73
                                return -1;
76
74
                        }
77
75
                        memcpy(dest, (void *)s->sh_addr, s->sh_size);
83
81
                        dest = l1_data_sram_zalloc(s->sh_size);
84
82
                        mod->arch.bss_a_l1 = dest;
85
83
                        if (dest == NULL) {
86
 
                                pr_err("L1 data memory allocation failed\n",
87
 
                                        mod->name);
 
84
                                pr_err("L1 data memory allocation failed\n");
88
85
                                return -1;
89
86
                        }
90
87
 
93
90
                        dest = l1_data_B_sram_alloc(s->sh_size);
94
91
                        mod->arch.data_b_l1 = dest;
95
92
                        if (dest == NULL) {
96
 
                                pr_err("L1 data memory allocation failed\n",
97
 
                                        mod->name);
 
93
                                pr_err("L1 data memory allocation failed\n");
98
94
                                return -1;
99
95
                        }
100
96
                        memcpy(dest, (void *)s->sh_addr, s->sh_size);
104
100
                        dest = l1_data_B_sram_alloc(s->sh_size);
105
101
                        mod->arch.bss_b_l1 = dest;
106
102
                        if (dest == NULL) {
107
 
                                pr_err("L1 data memory allocation failed\n",
108
 
                                        mod->name);
 
103
                                pr_err("L1 data memory allocation failed\n");
109
104
                                return -1;
110
105
                        }
111
106
                        memset(dest, 0, s->sh_size);
117
112
                        dest = l2_sram_alloc(s->sh_size);
118
113
                        mod->arch.text_l2 = dest;
119
114
                        if (dest == NULL) {
120
 
                                pr_err("L2 SRAM allocation failed\n",
121
 
                                        mod->name);
 
115
                                pr_err("L2 SRAM allocation failed\n");
122
116
                                return -1;
123
117
                        }
124
118
                        memcpy(dest, (void *)s->sh_addr, s->sh_size);
130
124
                        dest = l2_sram_alloc(s->sh_size);
131
125
                        mod->arch.data_l2 = dest;
132
126
                        if (dest == NULL) {
133
 
                                pr_err("L2 SRAM allocation failed\n",
134
 
                                        mod->name);
 
127
                                pr_err("L2 SRAM allocation failed\n");
135
128
                                return -1;
136
129
                        }
137
130
                        memcpy(dest, (void *)s->sh_addr, s->sh_size);
143
136
                        dest = l2_sram_zalloc(s->sh_size);
144
137
                        mod->arch.bss_l2 = dest;
145
138
                        if (dest == NULL) {
146
 
                                pr_err("L2 SRAM allocation failed\n",
147
 
                                        mod->name);
 
139
                                pr_err("L2 SRAM allocation failed\n");
148
140
                                return -1;
149
141
                        }
150
142
 
160
152
 
161
153
int
162
154
apply_relocate(Elf_Shdr * sechdrs, const char *strtab,
163
 
               unsigned int symindex, unsigned int relsec, struct module *me)
 
155
               unsigned int symindex, unsigned int relsec, struct module *mod)
164
156
{
165
 
        pr_err(".rel unsupported\n", me->name);
 
157
        pr_err(".rel unsupported\n");
166
158
        return -ENOEXEC;
167
159
}
168
160
 
186
178
        Elf32_Sym *sym;
187
179
        unsigned long location, value, size;
188
180
 
189
 
        pr_debug("applying relocate section %u to %u\n", mod->name,
 
181
        pr_debug("applying relocate section %u to %u\n",
190
182
                relsec, sechdrs[relsec].sh_info);
191
183
 
192
184
        for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
203
195
 
204
196
#ifdef CONFIG_SMP
205
197
                if (location >= COREB_L1_DATA_A_START) {
206
 
                        pr_err("cannot relocate in L1: %u (SMP kernel)",
207
 
                                mod->name, ELF32_R_TYPE(rel[i].r_info));
 
198
                        pr_err("cannot relocate in L1: %u (SMP kernel)\n",
 
199
                                ELF32_R_TYPE(rel[i].r_info));
208
200
                        return -ENOEXEC;
209
201
                }
210
202
#endif
211
203
 
212
204
                pr_debug("location is %lx, value is %lx type is %d\n",
213
 
                        mod->name, location, value, ELF32_R_TYPE(rel[i].r_info));
 
205
                        location, value, ELF32_R_TYPE(rel[i].r_info));
214
206
 
215
207
                switch (ELF32_R_TYPE(rel[i].r_info)) {
216
208
 
230
222
                case R_BFIN_PCREL12_JUMP_S:
231
223
                case R_BFIN_PCREL10:
232
224
                        pr_err("unsupported relocation: %u (no -mlong-calls?)\n",
233
 
                                mod->name, ELF32_R_TYPE(rel[i].r_info));
 
225
                                ELF32_R_TYPE(rel[i].r_info));
234
226
                        return -ENOEXEC;
235
227
 
236
228
                default:
237
 
                        pr_err("unknown relocation: %u\n", mod->name,
 
229
                        pr_err("unknown relocation: %u\n",
238
230
                                ELF32_R_TYPE(rel[i].r_info));
239
231
                        return -ENOEXEC;
240
232
                }
251
243
                        isram_memcpy((void *)location, &value, size);
252
244
                        break;
253
245
                default:
254
 
                        pr_err("invalid relocation for %#lx\n",
255
 
                                mod->name, location);
 
246
                        pr_err("invalid relocation for %#lx\n", location);
256
247
                        return -ENOEXEC;
257
248
                }
258
249
        }