comp.lang.ada
 help / color / mirror / Atom feed
From: Rolf <rolf.ebert_nospam_@gmx.net>
Subject: Re: How do I disable elaboration code on this
Date: Sun, 10 Apr 2011 09:34:52 -0700 (PDT)
Date: 2011-04-10T09:34:52-07:00	[thread overview]
Message-ID: <1beda06f-ec11-4dac-8cb3-e4785c9c5de6@y31g2000vbp.googlegroups.com> (raw)
In-Reply-To: 58bc4fb4-5f6a-48d6-9c98-0dde7ac619df@p16g2000vbo.googlegroups.com

On 9 Apr., 15:58, Lucretia <Lucretia9...@yahoo.co.uk> wrote:
> The following code will not compile no matter what I do. Basically, I
> want to write the startup code for Cortex-M3 in Ada with no assembly.
> So, the ISR code needs to be elaboration free as it's the first bit of
> code that would run on reset.

If I understand you correctly you need to set up the vector table
statically so that no dynamic code is needed to attach the actual ISR
code to the vector jump table.  That is similar to the AVR interrupt
architecture.

> Essentially, at address 0 the exception vectors are stored. These are
> in flash ROM so elaboration code is out of the question anyway. Each
> element of the array is a pointer to an interrupt service routine.
> I've specified a 4 element vector to test this out:
>

...

>
> I get the following output:
>
> -- Start of output

...

>    [type isr__TvectorsB is array (1 .. 4 range <>) of isr__cb]
>    freeze isr__TvectorsB [
>       procedure isr__TvectorsBIP (_init : in out isr__TvectorsB) is
>          %push_constraint_error_label ()
>          %push_program_error_label ()
>          %push_storage_error_label ()
>          subtype isr__TvectorsBIP__S4s is isr__TvectorsB (_init'first(
>            1) .. _init'last(1));
>       begin
>          for J1 in _init'first(1) .. _init'last(1) loop
>             [constraint_error "access check failed"]
>             _init (J1) := null;
>          end loop;

This part is the only dynamic elaboration code that I see. It
initializes the elements of the vector with null pointers.

>    isr__vector : constant isr__vectors := (isr__dummy'access,
>      isr__dummy'access, isr__dummy'access, isr__dummy'access);

Here the vecor gets set up with four copies of Dummy's address as you
express it in your code.

I think it is a missed optimization of the compiler as the vector
first is initialized with zeroes and then imidiately following it is
set up with the correct values.

If you want to get rid of dynamic code you must somehow convince the
compiler that initializing with zeroes is not necessary. I'd try to
use separate constants, like:

Vector1 : constant CB := Dummy'Access;
Vector2 : constant CB := Dummy'Access;
...

You probably have to add address clauses and pragma Convention C
statements.


>
> I've also tried an array of addresses, this produces the same problem.
> Can anyone point me in the right direction? Surely, this is possible
> in Ada?

The problem is that you use an array. It does not depend on the types
stored in the array.  Having an array GNAT generates a loop for the
init code.

HTH
   Rolf



      parent reply	other threads:[~2011-04-10 16:34 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-09 13:58 How do I disable elaboration code on this Lucretia
2011-04-09 16:57 ` Jeffrey Carter
2011-04-09 17:01   ` Simon Wright
2011-04-09 17:44     ` Ludovic Brenta
2011-04-09 19:19       ` Simon Wright
2011-04-09 19:32         ` Jeffrey Carter
2011-04-10  9:06           ` Lucretia
2011-04-10  9:31             ` Simon Wright
2011-04-09 19:35         ` Ludovic Brenta
2011-04-09 22:05           ` Simon Wright
2011-04-10  5:39             ` Simon Wright
2011-04-10 17:20   ` Lucretia
2011-04-10 20:12     ` Jeffrey Carter
2011-04-10 20:47     ` Georg Bauhaus
2011-04-10 21:19       ` Lucretia
2011-04-11  5:08         ` Lucretia
2011-04-11  6:28           ` Simon Wright
2011-04-11  8:54             ` Lucretia
2011-04-11 10:10               ` Simon Wright
2011-04-11 11:59                 ` Simon Clubley
2011-04-11 18:30                   ` Simon Wright
2011-04-11 19:12                     ` Simon Wright
2011-04-11 19:50                       ` Simon Wright
2011-04-11 21:40                       ` Lucretia
2011-04-11 23:12                         ` Lucretia
2011-04-11 23:16                           ` Lucretia
2011-04-11 23:31                           ` Lucretia
2011-04-12  5:22                             ` Simon Wright
2011-04-12 17:07                             ` Simon Clubley
2011-04-13 16:53                       ` Simon Wright
2011-04-15  8:38                       ` Simon Wright
2011-04-11 23:08                   ` Lucretia
2011-04-12 11:50                     ` Simon Clubley
2011-04-12 16:48                       ` Lucretia
2011-04-11 11:19               ` Georg Bauhaus
2011-04-11 13:50                 ` Simon Wright
2011-04-14 19:19               ` Florian Weimer
2011-04-10 16:34 ` Rolf [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox