Running a section of code from internal memory

5 messages, 3 authors, 2008-05-12 · open the first message on its own page

Running a section of code from internal memory

From: Sanal Kumar V K <hidden>
Date: 2008-05-08 12:06:54

Hi All,

I am porting a GW/router application to embedded Linux for a product
based on SoC; following is the version information:

kernel: 2.6.10
uClibc: 0.9.27
gcc: 3.4.3
binutils: 2.15.94.0.2.2

A small part of the code needs to run from the on-chip "L2 scratch" for
getting optimum performance. I would really appreciate if some could
give me some pointers regarding the following questions:

1. Is #pragma section supported by gcc.
The compiler prints this warning "ignoring #pragma section" and the
pragma is ignored indicating that it is not supported. Is there any way
I can get the pragma working for gcc or any alternative?

2. Is there any patch available to modify the kernel thread creation so
as to place the stack and tcb in the user configured addresses for
kernel threads (similar to taskInit() in VxWorks)?

Thanks in advance,
Sanal

Re: Running a section of code from internal memory

From: Marco Stornelli <hidden>
Date: 2008-05-08 13:14:18

Sanal Kumar V K ha scritto:
Hi All,

I am porting a GW/router application to embedded Linux for a product
based on SoC; following is the version information:

kernel: 2.6.10
uClibc: 0.9.27
gcc: 3.4.3
binutils: 2.15.94.0.2.2

A small part of the code needs to run from the on-chip "L2 scratch" for
getting optimum performance. I would really appreciate if some could
give me some pointers regarding the following questions:

1. Is #pragma section supported by gcc.
The compiler prints this warning "ignoring #pragma section" and the
pragma is ignored indicating that it is not supported. Is there any way
I can get the pragma working for gcc or any alternative?

2. Is there any patch available to modify the kernel thread creation so
as to place the stack and tcb in the user configured addresses for
kernel threads (similar to taskInit() in VxWorks)?

Thanks in advance,
Sanal


_______________________________________________
Linuxppc-embedded mailing list
Linuxppc-embedded@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-embedded
I think at application level you can use the #pragma directive but I'm sure that you can't use this directive at kernel level.

Re: Running a section of code from internal memory

From: Scott Wood <hidden>
Date: 2008-05-08 15:33:21

On Thu, May 08, 2008 at 05:06:46PM +0530, Sanal Kumar V K wrote:
A small part of the code needs to run from the on-chip "L2 scratch" for
getting optimum performance. I would really appreciate if some could
give me some pointers regarding the following questions:

1. Is #pragma section supported by gcc.
The compiler prints this warning "ignoring #pragma section" and the
pragma is ignored indicating that it is not supported. Is there any way
I can get the pragma working for gcc or any alternative?
__attribute__((section("section name")))

-Scott

Re: Running a section of code from internal memory

From: Sanal Kumar V K <hidden>
Date: 2008-05-12 14:33:57

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Thanks a lot Scott for replying.<br>
<br>
The attribute section is working, but one problem: the compiler is
automatically assigning address for the section and ld returns error is
I try to assign the address for this section in a linker script:<br>
<br>
Following is the disassembly when I don't specify an address for the
same section name in the linker script:<br>
Disassembly of section .l2_scratch:<br>
<br>
004ae820 &lt;.l2_scratch&gt;:<br>
&nbsp; 4ae820:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3c1c0fb9&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lui&nbsp;&nbsp;&nbsp;&nbsp; gp,0xfb9<br>
&nbsp; 4ae824:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 279c1d90&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; addiu&nbsp;&nbsp; gp,gp,7568<br>
&nbsp; 4ae828:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0399e021&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; addu&nbsp;&nbsp;&nbsp; gp,gp,t9<br>
&nbsp; 4ae82c:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 27bdffd0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; addiu&nbsp;&nbsp; sp,sp,-48<br>
&nbsp; 4ae830:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; afbf0028&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sw&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ra,40(sp)<br>
&nbsp; 4ae834:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; afbe0024&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sw&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s8,36(sp)<br>
&nbsp; 4ae838:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ----------&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ----&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ---------<br>
&nbsp; <br>
<br>
And the section shows:<br>
Idx Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Size&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VMA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LMA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; File off&nbsp; Algn<br>
&nbsp; 0 .reginfo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 00000018&nbsp; 00400094&nbsp; 00400094&nbsp; 00000094&nbsp; 2**2<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CONTENTS, ALLOC, LOAD, READONLY, DATA,
LINK_ONCE_SAME_SIZE<br>
&nbsp; 1 .init&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 00000088&nbsp; 004000ac&nbsp; 004000ac&nbsp; 000000ac&nbsp; 2**2<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CONTENTS, ALLOC, LOAD, READONLY, CODE<br>
&nbsp; 2 .text&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 000ae6e0&nbsp; 00400140&nbsp; 00400140&nbsp; 00000140&nbsp; 2**4<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CONTENTS, ALLOC, LOAD, READONLY, CODE<br>
&nbsp; 3 .l2_scratch&nbsp;&nbsp; 000004f0&nbsp; 004ae820&nbsp; 004ae820&nbsp; 000ae820&nbsp; 2**2<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CONTENTS, ALLOC, LOAD, READONLY, CODE<br>
&nbsp; 4 -----&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --------------------------------------------------------<br>
<br>
<br>

39 more lines

Re: Running a section of code from internal memory

From: Scott Wood <hidden>
Date: 2008-05-12 15:56:25

Sanal Kumar V K wrote:
Now if I make the following entry in the linker script,
  /* define L2 scratch here */
  . = 0x9FC16800;
  .l2_scratch         : { *(.l2_scratch) }

it says "collect2: ld returned 1 exit status".
I'm guessing there was an earlier error message printed by ld?

You probably located the L2 section too far away from the main section, and it's trying to do short branches or other limited relocations.

-Scott
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help