From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,69431b06fe9a3239 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!y31g2000vbp.googlegroups.com!not-for-mail From: Rolf Newsgroups: comp.lang.ada Subject: Re: How do I disable elaboration code on this Date: Sun, 10 Apr 2011 09:34:52 -0700 (PDT) Organization: http://groups.google.com Message-ID: <1beda06f-ec11-4dac-8cb3-e4785c9c5de6@y31g2000vbp.googlegroups.com> References: <58bc4fb4-5f6a-48d6-9c98-0dde7ac619df@p16g2000vbo.googlegroups.com> NNTP-Posting-Host: 91.4.244.36 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1302453292 17151 127.0.0.1 (10 Apr 2011 16:34:52 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 10 Apr 2011 16:34:52 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: y31g2000vbp.googlegroups.com; posting-host=91.4.244.36; posting-account=-RRRjAkAAAAGFvmHqTCN-L7gNQ7lRGfd User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.1; rv:2.0) Gecko/20100101 Firefox/4.0,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:18743 Date: 2011-04-10T09:34:52-07:00 List-Id: On 9 Apr., 15:58, Lucretia 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 ... > =A0 =A0[type isr__TvectorsB is array (1 .. 4 range <>) of isr__cb] > =A0 =A0freeze isr__TvectorsB [ > =A0 =A0 =A0 procedure isr__TvectorsBIP (_init : in out isr__TvectorsB) is > =A0 =A0 =A0 =A0 =A0%push_constraint_error_label () > =A0 =A0 =A0 =A0 =A0%push_program_error_label () > =A0 =A0 =A0 =A0 =A0%push_storage_error_label () > =A0 =A0 =A0 =A0 =A0subtype isr__TvectorsBIP__S4s is isr__TvectorsB (_init= 'first( > =A0 =A0 =A0 =A0 =A0 =A01) .. _init'last(1)); > =A0 =A0 =A0 begin > =A0 =A0 =A0 =A0 =A0for J1 in _init'first(1) .. _init'last(1) loop > =A0 =A0 =A0 =A0 =A0 =A0 [constraint_error "access check failed"] > =A0 =A0 =A0 =A0 =A0 =A0 _init (J1) :=3D null; > =A0 =A0 =A0 =A0 =A0end loop; This part is the only dynamic elaboration code that I see. It initializes the elements of the vector with null pointers. > =A0 =A0isr__vector : constant isr__vectors :=3D (isr__dummy'access, > =A0 =A0 =A0isr__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 :=3D Dummy'Access; Vector2 : constant CB :=3D 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