@@ -173,7 +173,7 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
173173 for (s = sechdrs ; s < sechdrs_end ; ++ s ) {
174174 if ((strcmp (".l1.text" , secstrings + s -> sh_name ) == 0 ) ||
175175 ((strcmp (".text" , secstrings + s -> sh_name ) == 0 ) &&
176- (hdr -> e_flags & FLG_CODE_IN_L1 ) && (s -> sh_size > 0 ))) {
176+ (hdr -> e_flags & EF_BFIN_CODE_IN_L1 ) && (s -> sh_size > 0 ))) {
177177 dest = l1_inst_sram_alloc (s -> sh_size );
178178 mod -> arch .text_l1 = dest ;
179179 if (dest == NULL ) {
@@ -188,7 +188,7 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
188188 }
189189 if ((strcmp (".l1.data" , secstrings + s -> sh_name ) == 0 ) ||
190190 ((strcmp (".data" , secstrings + s -> sh_name ) == 0 ) &&
191- (hdr -> e_flags & FLG_DATA_IN_L1 ) && (s -> sh_size > 0 ))) {
191+ (hdr -> e_flags & EF_BFIN_DATA_IN_L1 ) && (s -> sh_size > 0 ))) {
192192 dest = l1_data_sram_alloc (s -> sh_size );
193193 mod -> arch .data_a_l1 = dest ;
194194 if (dest == NULL ) {
@@ -203,7 +203,7 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
203203 }
204204 if (strcmp (".l1.bss" , secstrings + s -> sh_name ) == 0 ||
205205 ((strcmp (".bss" , secstrings + s -> sh_name ) == 0 ) &&
206- (hdr -> e_flags & FLG_DATA_IN_L1 ) && (s -> sh_size > 0 ))) {
206+ (hdr -> e_flags & EF_BFIN_DATA_IN_L1 ) && (s -> sh_size > 0 ))) {
207207 dest = l1_data_sram_alloc (s -> sh_size );
208208 mod -> arch .bss_a_l1 = dest ;
209209 if (dest == NULL ) {
@@ -242,6 +242,51 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
242242 s -> sh_flags &= ~SHF_ALLOC ;
243243 s -> sh_addr = (unsigned long )dest ;
244244 }
245+ if ((strcmp (".l2.text" , secstrings + s -> sh_name ) == 0 ) ||
246+ ((strcmp (".text" , secstrings + s -> sh_name ) == 0 ) &&
247+ (hdr -> e_flags & EF_BFIN_CODE_IN_L2 ) && (s -> sh_size > 0 ))) {
248+ dest = l2_sram_alloc (s -> sh_size );
249+ mod -> arch .text_l2 = dest ;
250+ if (dest == NULL ) {
251+ printk (KERN_ERR
252+ "module %s: L2 SRAM allocation failed\n" ,
253+ mod -> name );
254+ return -1 ;
255+ }
256+ memcpy (dest , (void * )s -> sh_addr , s -> sh_size );
257+ s -> sh_flags &= ~SHF_ALLOC ;
258+ s -> sh_addr = (unsigned long )dest ;
259+ }
260+ if ((strcmp (".l2.data" , secstrings + s -> sh_name ) == 0 ) ||
261+ ((strcmp (".data" , secstrings + s -> sh_name ) == 0 ) &&
262+ (hdr -> e_flags & EF_BFIN_DATA_IN_L2 ) && (s -> sh_size > 0 ))) {
263+ dest = l2_sram_alloc (s -> sh_size );
264+ mod -> arch .data_l2 = dest ;
265+ if (dest == NULL ) {
266+ printk (KERN_ERR
267+ "module %s: L2 SRAM allocation failed\n" ,
268+ mod -> name );
269+ return -1 ;
270+ }
271+ memcpy (dest , (void * )s -> sh_addr , s -> sh_size );
272+ s -> sh_flags &= ~SHF_ALLOC ;
273+ s -> sh_addr = (unsigned long )dest ;
274+ }
275+ if (strcmp (".l2.bss" , secstrings + s -> sh_name ) == 0 ||
276+ ((strcmp (".bss" , secstrings + s -> sh_name ) == 0 ) &&
277+ (hdr -> e_flags & EF_BFIN_DATA_IN_L2 ) && (s -> sh_size > 0 ))) {
278+ dest = l2_sram_alloc (s -> sh_size );
279+ mod -> arch .bss_l2 = dest ;
280+ if (dest == NULL ) {
281+ printk (KERN_ERR
282+ "module %s: L2 SRAM allocation failed\n" ,
283+ mod -> name );
284+ return -1 ;
285+ }
286+ memset (dest , 0 , s -> sh_size );
287+ s -> sh_flags &= ~SHF_ALLOC ;
288+ s -> sh_addr = (unsigned long )dest ;
289+ }
245290 }
246291 return 0 ;
247292}
@@ -411,9 +456,10 @@ module_finalize(const Elf_Ehdr * hdr,
411456 continue ;
412457
413458 if ((sechdrs [i ].sh_type == SHT_RELA ) &&
414- ((strcmp (".rela.l1.text" , secstrings + sechdrs [i ].sh_name ) == 0 ) ||
459+ ((strcmp (".rela.l2.text" , secstrings + sechdrs [i ].sh_name ) == 0 ) ||
460+ (strcmp (".rela.l1.text" , secstrings + sechdrs [i ].sh_name ) == 0 ) ||
415461 ((strcmp (".rela.text" , secstrings + sechdrs [i ].sh_name ) == 0 ) &&
416- (hdr -> e_flags & FLG_CODE_IN_L1 )))) {
462+ (hdr -> e_flags & ( EF_BFIN_CODE_IN_L1 | EF_BFIN_CODE_IN_L2 ) )))) {
417463 apply_relocate_add ((Elf_Shdr * ) sechdrs , strtab ,
418464 symindex , i , mod );
419465 }
@@ -423,14 +469,12 @@ module_finalize(const Elf_Ehdr * hdr,
423469
424470void module_arch_cleanup (struct module * mod )
425471{
426- if (mod -> arch .text_l1 )
427- l1_inst_sram_free ((void * )mod -> arch .text_l1 );
428- if (mod -> arch .data_a_l1 )
429- l1_data_sram_free ((void * )mod -> arch .data_a_l1 );
430- if (mod -> arch .bss_a_l1 )
431- l1_data_sram_free ((void * )mod -> arch .bss_a_l1 );
432- if (mod -> arch .data_b_l1 )
433- l1_data_B_sram_free ((void * )mod -> arch .data_b_l1 );
434- if (mod -> arch .bss_b_l1 )
435- l1_data_B_sram_free ((void * )mod -> arch .bss_b_l1 );
472+ l1_inst_sram_free (mod -> arch .text_l1 );
473+ l1_data_A_sram_free (mod -> arch .data_a_l1 );
474+ l1_data_A_sram_free (mod -> arch .bss_a_l1 );
475+ l1_data_B_sram_free (mod -> arch .data_b_l1 );
476+ l1_data_B_sram_free (mod -> arch .bss_b_l1 );
477+ l2_sram_free (mod -> arch .text_l2 );
478+ l2_sram_free (mod -> arch .data_l2 );
479+ l2_sram_free (mod -> arch .bss_l2 );
436480}
0 commit comments