Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1 | /* |
| 2 | * File: arch/blackfin/kernel/module.c |
| 3 | * Based on: |
| 4 | * Author: |
| 5 | * |
| 6 | * Created: |
| 7 | * Description: |
| 8 | * |
| 9 | * Modified: |
| 10 | * Copyright 2004-2006 Analog Devices Inc. |
| 11 | * |
| 12 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU General Public License as published by |
| 16 | * the Free Software Foundation; either version 2 of the License, or |
| 17 | * (at your option) any later version. |
| 18 | * |
| 19 | * This program is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | * GNU General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License |
| 25 | * along with this program; if not, see the file COPYING, or write |
| 26 | * to the Free Software Foundation, Inc., |
| 27 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 28 | */ |
| 29 | |
Mike Frysinger | dc6b1ac | 2009-06-26 00:35:24 +0000 | [diff] [blame^] | 30 | #define pr_fmt(fmt) "module %s: " fmt |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 31 | |
| 32 | #include <linux/moduleloader.h> |
| 33 | #include <linux/elf.h> |
| 34 | #include <linux/vmalloc.h> |
| 35 | #include <linux/fs.h> |
| 36 | #include <linux/string.h> |
| 37 | #include <linux/kernel.h> |
| 38 | #include <asm/dma.h> |
| 39 | #include <asm/cacheflush.h> |
| 40 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 41 | void *module_alloc(unsigned long size) |
| 42 | { |
| 43 | if (size == 0) |
| 44 | return NULL; |
| 45 | return vmalloc(size); |
| 46 | } |
| 47 | |
| 48 | /* Free memory returned from module_alloc */ |
| 49 | void module_free(struct module *mod, void *module_region) |
| 50 | { |
| 51 | vfree(module_region); |
| 52 | } |
| 53 | |
| 54 | /* Transfer the section to the L1 memory */ |
| 55 | int |
| 56 | module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs, |
| 57 | char *secstrings, struct module *mod) |
| 58 | { |
Meihui Fan | 96a87e2 | 2008-05-07 11:41:26 +0800 | [diff] [blame] | 59 | /* |
| 60 | * XXX: sechdrs are vmalloced in kernel/module.c |
| 61 | * and would be vfreed just after module is loaded, |
| 62 | * so we hack to keep the only information we needed |
| 63 | * in mod->arch to correctly free L1 I/D sram later. |
| 64 | * NOTE: this breaks the semantic of mod->arch structure. |
| 65 | */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 66 | Elf_Shdr *s, *sechdrs_end = sechdrs + hdr->e_shnum; |
| 67 | void *dest = NULL; |
| 68 | |
| 69 | for (s = sechdrs; s < sechdrs_end; ++s) { |
| 70 | if ((strcmp(".l1.text", secstrings + s->sh_name) == 0) || |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 71 | ((strcmp(".text", secstrings + s->sh_name) == 0) && |
Sonic Zhang | 262c382 | 2008-07-19 15:42:41 +0800 | [diff] [blame] | 72 | (hdr->e_flags & EF_BFIN_CODE_IN_L1) && (s->sh_size > 0))) { |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 73 | dest = l1_inst_sram_alloc(s->sh_size); |
Meihui Fan | 96a87e2 | 2008-05-07 11:41:26 +0800 | [diff] [blame] | 74 | mod->arch.text_l1 = dest; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 75 | if (dest == NULL) { |
Mike Frysinger | dc6b1ac | 2009-06-26 00:35:24 +0000 | [diff] [blame^] | 76 | pr_err("L1 inst memory allocation failed\n", |
| 77 | mod->name); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 78 | return -1; |
| 79 | } |
| 80 | dma_memcpy(dest, (void *)s->sh_addr, s->sh_size); |
| 81 | s->sh_flags &= ~SHF_ALLOC; |
| 82 | s->sh_addr = (unsigned long)dest; |
| 83 | } |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 84 | if ((strcmp(".l1.data", secstrings + s->sh_name) == 0) || |
| 85 | ((strcmp(".data", secstrings + s->sh_name) == 0) && |
Sonic Zhang | 262c382 | 2008-07-19 15:42:41 +0800 | [diff] [blame] | 86 | (hdr->e_flags & EF_BFIN_DATA_IN_L1) && (s->sh_size > 0))) { |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 87 | dest = l1_data_sram_alloc(s->sh_size); |
Meihui Fan | 96a87e2 | 2008-05-07 11:41:26 +0800 | [diff] [blame] | 88 | mod->arch.data_a_l1 = dest; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 89 | if (dest == NULL) { |
Mike Frysinger | dc6b1ac | 2009-06-26 00:35:24 +0000 | [diff] [blame^] | 90 | pr_err("L1 data memory allocation failed\n", |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 91 | mod->name); |
| 92 | return -1; |
| 93 | } |
| 94 | memcpy(dest, (void *)s->sh_addr, s->sh_size); |
| 95 | s->sh_flags &= ~SHF_ALLOC; |
| 96 | s->sh_addr = (unsigned long)dest; |
| 97 | } |
| 98 | if (strcmp(".l1.bss", secstrings + s->sh_name) == 0 || |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 99 | ((strcmp(".bss", secstrings + s->sh_name) == 0) && |
Sonic Zhang | 262c382 | 2008-07-19 15:42:41 +0800 | [diff] [blame] | 100 | (hdr->e_flags & EF_BFIN_DATA_IN_L1) && (s->sh_size > 0))) { |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 101 | dest = l1_data_sram_alloc(s->sh_size); |
Meihui Fan | 96a87e2 | 2008-05-07 11:41:26 +0800 | [diff] [blame] | 102 | mod->arch.bss_a_l1 = dest; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 103 | if (dest == NULL) { |
Mike Frysinger | dc6b1ac | 2009-06-26 00:35:24 +0000 | [diff] [blame^] | 104 | pr_err("L1 data memory allocation failed\n", |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 105 | mod->name); |
| 106 | return -1; |
| 107 | } |
| 108 | memset(dest, 0, s->sh_size); |
| 109 | s->sh_flags &= ~SHF_ALLOC; |
| 110 | s->sh_addr = (unsigned long)dest; |
| 111 | } |
| 112 | if (strcmp(".l1.data.B", secstrings + s->sh_name) == 0) { |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 113 | dest = l1_data_B_sram_alloc(s->sh_size); |
Meihui Fan | 96a87e2 | 2008-05-07 11:41:26 +0800 | [diff] [blame] | 114 | mod->arch.data_b_l1 = dest; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 115 | if (dest == NULL) { |
Mike Frysinger | dc6b1ac | 2009-06-26 00:35:24 +0000 | [diff] [blame^] | 116 | pr_err("L1 data memory allocation failed\n", |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 117 | mod->name); |
| 118 | return -1; |
| 119 | } |
| 120 | memcpy(dest, (void *)s->sh_addr, s->sh_size); |
| 121 | s->sh_flags &= ~SHF_ALLOC; |
| 122 | s->sh_addr = (unsigned long)dest; |
| 123 | } |
| 124 | if (strcmp(".l1.bss.B", secstrings + s->sh_name) == 0) { |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 125 | dest = l1_data_B_sram_alloc(s->sh_size); |
Meihui Fan | 96a87e2 | 2008-05-07 11:41:26 +0800 | [diff] [blame] | 126 | mod->arch.bss_b_l1 = dest; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 127 | if (dest == NULL) { |
Mike Frysinger | dc6b1ac | 2009-06-26 00:35:24 +0000 | [diff] [blame^] | 128 | pr_err("L1 data memory allocation failed\n", |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 129 | mod->name); |
| 130 | return -1; |
| 131 | } |
| 132 | memset(dest, 0, s->sh_size); |
| 133 | s->sh_flags &= ~SHF_ALLOC; |
| 134 | s->sh_addr = (unsigned long)dest; |
| 135 | } |
Sonic Zhang | 262c382 | 2008-07-19 15:42:41 +0800 | [diff] [blame] | 136 | if ((strcmp(".l2.text", secstrings + s->sh_name) == 0) || |
| 137 | ((strcmp(".text", secstrings + s->sh_name) == 0) && |
| 138 | (hdr->e_flags & EF_BFIN_CODE_IN_L2) && (s->sh_size > 0))) { |
| 139 | dest = l2_sram_alloc(s->sh_size); |
| 140 | mod->arch.text_l2 = dest; |
| 141 | if (dest == NULL) { |
Mike Frysinger | dc6b1ac | 2009-06-26 00:35:24 +0000 | [diff] [blame^] | 142 | pr_err("L2 SRAM allocation failed\n", |
| 143 | mod->name); |
Sonic Zhang | 262c382 | 2008-07-19 15:42:41 +0800 | [diff] [blame] | 144 | return -1; |
| 145 | } |
| 146 | memcpy(dest, (void *)s->sh_addr, s->sh_size); |
| 147 | s->sh_flags &= ~SHF_ALLOC; |
| 148 | s->sh_addr = (unsigned long)dest; |
| 149 | } |
| 150 | if ((strcmp(".l2.data", secstrings + s->sh_name) == 0) || |
| 151 | ((strcmp(".data", secstrings + s->sh_name) == 0) && |
| 152 | (hdr->e_flags & EF_BFIN_DATA_IN_L2) && (s->sh_size > 0))) { |
| 153 | dest = l2_sram_alloc(s->sh_size); |
| 154 | mod->arch.data_l2 = dest; |
| 155 | if (dest == NULL) { |
Mike Frysinger | dc6b1ac | 2009-06-26 00:35:24 +0000 | [diff] [blame^] | 156 | pr_err("L2 SRAM allocation failed\n", |
Sonic Zhang | 262c382 | 2008-07-19 15:42:41 +0800 | [diff] [blame] | 157 | mod->name); |
| 158 | return -1; |
| 159 | } |
| 160 | memcpy(dest, (void *)s->sh_addr, s->sh_size); |
| 161 | s->sh_flags &= ~SHF_ALLOC; |
| 162 | s->sh_addr = (unsigned long)dest; |
| 163 | } |
| 164 | if (strcmp(".l2.bss", secstrings + s->sh_name) == 0 || |
| 165 | ((strcmp(".bss", secstrings + s->sh_name) == 0) && |
| 166 | (hdr->e_flags & EF_BFIN_DATA_IN_L2) && (s->sh_size > 0))) { |
| 167 | dest = l2_sram_alloc(s->sh_size); |
| 168 | mod->arch.bss_l2 = dest; |
| 169 | if (dest == NULL) { |
Mike Frysinger | dc6b1ac | 2009-06-26 00:35:24 +0000 | [diff] [blame^] | 170 | pr_err("L2 SRAM allocation failed\n", |
Sonic Zhang | 262c382 | 2008-07-19 15:42:41 +0800 | [diff] [blame] | 171 | mod->name); |
| 172 | return -1; |
| 173 | } |
| 174 | memset(dest, 0, s->sh_size); |
| 175 | s->sh_flags &= ~SHF_ALLOC; |
| 176 | s->sh_addr = (unsigned long)dest; |
| 177 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 178 | } |
| 179 | return 0; |
| 180 | } |
| 181 | |
| 182 | int |
| 183 | apply_relocate(Elf_Shdr * sechdrs, const char *strtab, |
| 184 | unsigned int symindex, unsigned int relsec, struct module *me) |
| 185 | { |
Mike Frysinger | dc6b1ac | 2009-06-26 00:35:24 +0000 | [diff] [blame^] | 186 | pr_err(".rel unsupported\n", me->name); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 187 | return -ENOEXEC; |
| 188 | } |
| 189 | |
| 190 | /*************************************************************************/ |
| 191 | /* FUNCTION : apply_relocate_add */ |
| 192 | /* ABSTRACT : Blackfin specific relocation handling for the loadable */ |
| 193 | /* modules. Modules are expected to be .o files. */ |
| 194 | /* Arithmetic relocations are handled. */ |
| 195 | /* We do not expect LSETUP to be split and hence is not */ |
| 196 | /* handled. */ |
Mike Frysinger | 595d681 | 2009-06-02 00:35:33 +0000 | [diff] [blame] | 197 | /* R_BFIN_BYTE and R_BFIN_BYTE2 are also not handled as the */ |
| 198 | /* gas does not generate it. */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 199 | /*************************************************************************/ |
| 200 | int |
| 201 | apply_relocate_add(Elf_Shdr * sechdrs, const char *strtab, |
| 202 | unsigned int symindex, unsigned int relsec, |
| 203 | struct module *mod) |
| 204 | { |
| 205 | unsigned int i; |
| 206 | unsigned short tmp; |
| 207 | Elf32_Rela *rel = (void *)sechdrs[relsec].sh_addr; |
| 208 | Elf32_Sym *sym; |
| 209 | uint32_t *location32; |
| 210 | uint16_t *location16; |
| 211 | uint32_t value; |
| 212 | |
Mike Frysinger | dc6b1ac | 2009-06-26 00:35:24 +0000 | [diff] [blame^] | 213 | pr_debug("applying relocate section %u to %u\n", mod->name, |
| 214 | relsec, sechdrs[relsec].sh_info); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 215 | for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) { |
| 216 | /* This is where to make the change */ |
| 217 | location16 = |
| 218 | (uint16_t *) (sechdrs[sechdrs[relsec].sh_info].sh_addr + |
| 219 | rel[i].r_offset); |
| 220 | location32 = (uint32_t *) location16; |
| 221 | /* This is the symbol it is referring to. Note that all |
| 222 | undefined symbols have been resolved. */ |
| 223 | sym = (Elf32_Sym *) sechdrs[symindex].sh_addr |
| 224 | + ELF32_R_SYM(rel[i].r_info); |
Bernd Schmidt | d1a8530 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 225 | value = sym->st_value; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 226 | value += rel[i].r_addend; |
Mike Frysinger | dc6b1ac | 2009-06-26 00:35:24 +0000 | [diff] [blame^] | 227 | |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 228 | #ifdef CONFIG_SMP |
| 229 | if ((unsigned long)location16 >= COREB_L1_DATA_A_START) { |
Mike Frysinger | dc6b1ac | 2009-06-26 00:35:24 +0000 | [diff] [blame^] | 230 | pr_err("cannot relocate in L1: %u (SMP kernel)", |
| 231 | mod->name, ELF32_R_TYPE(rel[i].r_info)); |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 232 | return -ENOEXEC; |
| 233 | } |
| 234 | #endif |
Mike Frysinger | dc6b1ac | 2009-06-26 00:35:24 +0000 | [diff] [blame^] | 235 | |
| 236 | pr_debug("location is %lx, value is %x type is %d\n", |
| 237 | mod->name, (unsigned long)location32, value, |
| 238 | ELF32_R_TYPE(rel[i].r_info)); |
| 239 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 240 | switch (ELF32_R_TYPE(rel[i].r_info)) { |
| 241 | |
Mike Frysinger | 595d681 | 2009-06-02 00:35:33 +0000 | [diff] [blame] | 242 | case R_BFIN_LUIMM16: |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 243 | tmp = (value & 0xffff); |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 244 | if ((unsigned long)location16 >= L1_CODE_START) { |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 245 | dma_memcpy(location16, &tmp, 2); |
| 246 | } else |
| 247 | *location16 = tmp; |
| 248 | break; |
Mike Frysinger | 595d681 | 2009-06-02 00:35:33 +0000 | [diff] [blame] | 249 | case R_BFIN_HUIMM16: |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 250 | tmp = ((value >> 16) & 0xffff); |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 251 | if ((unsigned long)location16 >= L1_CODE_START) { |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 252 | dma_memcpy(location16, &tmp, 2); |
| 253 | } else |
| 254 | *location16 = tmp; |
| 255 | break; |
Mike Frysinger | 595d681 | 2009-06-02 00:35:33 +0000 | [diff] [blame] | 256 | case R_BFIN_RIMM16: |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 257 | *location16 = (value & 0xffff); |
| 258 | break; |
Mike Frysinger | 595d681 | 2009-06-02 00:35:33 +0000 | [diff] [blame] | 259 | case R_BFIN_BYTE4_DATA: |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 260 | *location32 = value; |
| 261 | break; |
Robin Getz | 2253257 | 2009-06-25 15:49:38 +0000 | [diff] [blame] | 262 | case R_BFIN_PCREL24: |
| 263 | case R_BFIN_PCREL24_JUMP_L: |
| 264 | case R_BFIN_PCREL12_JUMP: |
| 265 | case R_BFIN_PCREL12_JUMP_S: |
| 266 | case R_BFIN_PCREL10: |
Mike Frysinger | dc6b1ac | 2009-06-26 00:35:24 +0000 | [diff] [blame^] | 267 | pr_err("unsupported relocation: %u (no -mlong-calls?)\n", |
Robin Getz | 2253257 | 2009-06-25 15:49:38 +0000 | [diff] [blame] | 268 | mod->name, ELF32_R_TYPE(rel[i].r_info)); |
| 269 | return -ENOEXEC; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 270 | default: |
Mike Frysinger | dc6b1ac | 2009-06-26 00:35:24 +0000 | [diff] [blame^] | 271 | pr_err("unknown relocation: %u\n", mod->name, |
| 272 | ELF32_R_TYPE(rel[i].r_info)); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 273 | return -ENOEXEC; |
| 274 | } |
| 275 | } |
| 276 | return 0; |
| 277 | } |
| 278 | |
| 279 | int |
| 280 | module_finalize(const Elf_Ehdr * hdr, |
| 281 | const Elf_Shdr * sechdrs, struct module *mod) |
| 282 | { |
| 283 | unsigned int i, strindex = 0, symindex = 0; |
| 284 | char *secstrings; |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 285 | long err = 0; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 286 | |
| 287 | secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; |
| 288 | |
| 289 | for (i = 1; i < hdr->e_shnum; i++) { |
| 290 | /* Internal symbols and strings. */ |
| 291 | if (sechdrs[i].sh_type == SHT_SYMTAB) { |
| 292 | symindex = i; |
| 293 | strindex = sechdrs[i].sh_link; |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | for (i = 1; i < hdr->e_shnum; i++) { |
| 298 | const char *strtab = (char *)sechdrs[strindex].sh_addr; |
| 299 | unsigned int info = sechdrs[i].sh_info; |
| 300 | |
| 301 | /* Not a valid relocation section? */ |
| 302 | if (info >= hdr->e_shnum) |
| 303 | continue; |
| 304 | |
| 305 | if ((sechdrs[i].sh_type == SHT_RELA) && |
Sonic Zhang | 262c382 | 2008-07-19 15:42:41 +0800 | [diff] [blame] | 306 | ((strcmp(".rela.l2.text", secstrings + sechdrs[i].sh_name) == 0) || |
| 307 | (strcmp(".rela.l1.text", secstrings + sechdrs[i].sh_name) == 0) || |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 308 | ((strcmp(".rela.text", secstrings + sechdrs[i].sh_name) == 0) && |
Sonic Zhang | 262c382 | 2008-07-19 15:42:41 +0800 | [diff] [blame] | 309 | (hdr->e_flags & (EF_BFIN_CODE_IN_L1|EF_BFIN_CODE_IN_L2))))) { |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 310 | err = apply_relocate_add((Elf_Shdr *) sechdrs, strtab, |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 311 | symindex, i, mod); |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 312 | if (err < 0) |
| 313 | return -ENOEXEC; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 314 | } |
| 315 | } |
| 316 | return 0; |
| 317 | } |
| 318 | |
| 319 | void module_arch_cleanup(struct module *mod) |
| 320 | { |
Sonic Zhang | 262c382 | 2008-07-19 15:42:41 +0800 | [diff] [blame] | 321 | l1_inst_sram_free(mod->arch.text_l1); |
| 322 | l1_data_A_sram_free(mod->arch.data_a_l1); |
| 323 | l1_data_A_sram_free(mod->arch.bss_a_l1); |
| 324 | l1_data_B_sram_free(mod->arch.data_b_l1); |
| 325 | l1_data_B_sram_free(mod->arch.bss_b_l1); |
| 326 | l2_sram_free(mod->arch.text_l2); |
| 327 | l2_sram_free(mod->arch.data_l2); |
| 328 | l2_sram_free(mod->arch.bss_l2); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 329 | } |