comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Clubley <clubley@remove_me.eisner.decus.org-Earth.UFP>
Subject: Re: Runtime startup code for the GNAT Runtime...and a bit of humble pie.
Date: Tue, 26 Mar 2013 22:38:15 +0000 (UTC)
Date: 2013-03-26T22:38:15+00:00	[thread overview]
Message-ID: <kit80m$kak$1@dont-email.me> (raw)
In-Reply-To: kirvb5$9c4$1@dont-email.me

On 2013-03-26, Brian Drummond <brian@shapes.demon.co.uk> wrote:
> On Wed, 20 Mar 2013 13:18:57 +0000, Simon Clubley wrote:
>
>> On 2013-03-20, Brian Drummond <brian@shapes.demon.co.uk> wrote:
>>> On Wed, 20 Mar 2013 00:54:38 +0000, Simon Clubley wrote:
>
>>>> Reading the comments, I think my problem here isn't really with Ada,
>>>> but with GNAT; hence it's really a toolchain problem and not a
>>>> language problem.
> [...]
>>>> You also have no confidence that the model you have built is
>>>> sufficiently complete to result in a robust port.
>>>
>>> What in your view would be required to give you that confidence?
>>>
>>>
>> Coherent and structured porting documentation.
>> 
>> Something designed for documenting the porting process will cover the
>> overall architecture in a way which allows you to build a consistent
>> model and is also going to cover the major "gotcha" issues. Even if the
>> initial versions did not cover all the major issues, the later versions
>> would as a result of the inevitable peer review type process which would
>> occur.
>
> I admit I am surprised to hear documentation ahead of test. But that 
> makes it all the more worth hearing.
>

Both are required, but good documentation is way more important because it
answers the question "_why_ do we do this ?" but testing can only test what
has been written _after_ you understand what needs writing in the first
place.

For example, when discussing Ada exception support, a porting document
should discuss at a conceptual level what is required to implement exception
support in GNAT hence allowing you to build a model of how a exception
raised during the execution of user code flows through the various levels
of the compiler generated code and the RTS and into the low-level bits you
need to supply.

It should then go on to take a specific example from the current code base,
and show how the various bits of the current code base fit into that model.

The information you would obtain in that way would allow you to build a
much more robust and complete model than you would get trying to work it
out a bit at a time by looking at the code base only.

(And yes, I know the thesis already touches on some of this, although as
pointed out already the thesis is about a decade old and is written with
more of a academic than a practical focus. I am just using exception
support as a example.)

For me, it's all about building a model of operation. Looking at a code
base in isolation (as currently exists with GNAT) allows you to determine
_how_ various specific bits of code work, but it doesn't tell you _why_
they work in that way or easily tell how they fit into the greater whole.
This makes it very difficult to build a model of operation, covering GNAT
as a whole, by looking at the code base in isolation.

IOW, building a solid model of what is going on in the code base is the
root stage from which all later stages, including testing, are derived from.

> OK, here goes...
>
> http://sourceforge.net/projects/msp430ada/files/doc/MSP430-Ada.pdf/
> download
>
> how am I doing so far?
>
> Frank criticism welcome. 
>
> And I don't expect many people to actually follow the process at this 
> stage : it's a record of how I got to the current stage (that the 
> dedicated can follow). I am painfully aware that toolchains need to be 
> available in easier forms. 
>

Actually, I would expect to find duplicating the process of building this
specific compiler from what you have written in this document to be rather
easy. You have covered various issues in detail and provided lots of
references to source kits, including exact version numbers.

However, your document is more about how to build a specific port, although
people could look at the steps you have taken to get to this stage and
try duplicating them on their own architecture in a mechanical/by rote
fashion. What it does not discuss is _why_ the changes are needed or how
those changes fit into the overall GNAT/GCC architecture.

A by rote approach can get you quite a bit of the way (assuming a similar
architecture) but at some point, for example, when you start adding in
exception support to your new architecture, you need to have a model of
what is actually going on in GNAT and gcc.

Some specific notes from reading your document:

Have you hit any other volatile issues ? In C, I define the object itself,
rather than the data type, as volatile. This includes the case when the
data type is a struct (used when modelling a register set for a specific
peripheral).

Your gnatmake command may appear to be complicated, but it's the kind of
thing which could easily be turned into a pattern rule in a makefile so
it would not be high on the list of things I would worry about too much.

A processor and peripheral support library is not really a GNAT specific
problem (although it is required for GNAT); you have most of the same issues
when you need to provide this support in C, whether you are writing all the
headers/code/linker scripts yourself or are porting something like Newlib.

I've been through all this myself in C. Apart from what's needed to write
a RTEMS BSP, when it came to running bare metal code in C on ARMs, I also
wrote everything (startup code, headers, linker scripts, interrupt support
code, I/O library, etc) myself.

In other words, you don't really need a large amount of GNAT specific
knowledge to implement much of the processor and peripheral library
support, although you do need to know how you are going to implement, say,
interrupts and what GNAT and RTS specific support you might need for that.

Interrupts are a good example of how a porting document can only provide
limited guidance in some areas. In your MSP430 example, you appear to
associate the interrupt vector with the routine at link time (I don't
know the MSP430; I am just going by your example), yet on a 32-bit
traditional ARM (ie: ARM7TDMI/ARM9) running bare metal code, I load the
interrupt handler's address into a interrupt dispatch table at runtime
and I need to supply interrupt support code to handle the interrupt.

BTW, the complexity of that support code is also directly impacted by
if you want to do things like priority nesting (my ARM bare metal interrupt
support code does this).

> And having spent 9 hours yesterday building AVR-Ada 1.2.1 from its "one 
> click" script I know that getting toolchains into that stage is not 
> trivial. 
>

:-)

Oh, I _so_ agree. :-)

Simon.

-- 
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
Microsoft: Bringing you 1980s technology to a 21st century world

  reply	other threads:[~2013-03-26 22:38 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-18 20:59 Runtime startup code for the GNAT Runtime...and a bit of humble pie Diogenes
2013-03-18 21:14 ` Robert A Duff
2013-03-19  0:07 ` Diogenes
2013-03-19 10:04   ` Brian Drummond
2013-03-19 12:51     ` Simon Clubley
2013-03-19 18:16       ` Ludovic Brenta
2013-03-20  1:05         ` Simon Clubley
2013-03-20 10:13           ` Mike H
2013-03-20 20:44             ` Ludovic Brenta
2013-03-19 21:43       ` Randy Brukardt
2013-03-20  8:24         ` Dmitry A. Kazakov
2013-03-21  0:16           ` Randy Brukardt
2013-03-21 19:08             ` Shark8
2013-03-21 23:34               ` Randy Brukardt
2013-03-22 16:39                 ` Jacob Sparre Andersen
2013-03-23 10:56                   ` Thomas Løcke
2013-03-19 23:13       ` Brian Drummond
2013-03-20  0:54         ` Simon Clubley
2013-03-20 11:50           ` Brian Drummond
2013-03-20 13:18             ` Simon Clubley
2013-03-26 11:04               ` Brian Drummond
2013-03-26 22:38                 ` Simon Clubley [this message]
2013-03-27 11:34                   ` Brian Drummond
2013-03-27 14:38                     ` Simon Clubley
2013-03-27 22:58                       ` Brian Drummond
2013-03-20 14:17           ` Lucretia
2013-03-20 15:00             ` Lucretia
2013-03-21 16:39             ` Brian Drummond
2013-03-23  4:35 ` Diogenes
2013-03-26 21:27 ` Diogenes
2013-03-26 21:57   ` Shark8
2013-03-27  0:28     ` Diogenes
2013-03-27  2:27       ` Shark8
2013-03-27 10:05       ` Brian Drummond
2013-03-27 12:23         ` Simon Wright
2013-03-27 19:07   ` Randy Brukardt
2013-03-27 21:10     ` Diogenes
replies disabled

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