comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Using GNAT in a C and assembly toolchain
Date: Tue, 04 May 2010 20:50:27 +0100
Date: 2010-05-04T20:50:27+01:00	[thread overview]
Message-ID: <m2sk67jvjw.fsf@pushface.org> (raw)
In-Reply-To: bdef2689-1218-422a-a9e8-0bf574076809@b18g2000yqb.googlegroups.com

Tom <tomahawkins@gmail.com> writes:

> On our particular application -- an automotive ECU -- we're locked
> into a proprietary C-based flow.  The operating system and hardware
> abstraction layer come precompiled and the application code must be
> compiled and linked with the established tool chain (GHS C, not Ada).
> The application programmer defines a procedure, which is invoked by
> the OS as a periodic rate.  This procedure references global C
> variables to access the hardware abstraction layer.

I would have expected engine control software to require a pretty high
degree of certification, if not for safety-related reasons then because
fixing problems in deployed firmware is going to be expensive and
possibly embarrassing, see Toyota, and part of that involves the tool
chain. OK, I work on military systems, but my Software Design Authority
would need A Whole Lot Of Convincing to change the tool chain in a way
not supported by the tool vendor.

> The question is how can I best use Ada and GNAT in such an
> environment?  One method that comes to mind is to compile Ada to
> assembly code, which is then passed to GHS for assembling and linking
> with the closed source OS and HAL.  I don't see an assembly switch,
> like GCC's -S.  Would this mean I would need the compile Ada modules
> individually with GCC instead of using gnatmake?  Are there any
> options to compile Ada down to C by chance?

"gnatmake -c -S foo.adb" compiles the closure of foo to assembler (.s)
files. Of course these are going to be in GNU assembler, which may or
may not be that used by GHS.

There is a tool created by Sofcheck called AdaMagic which generates
C. GCC does not. (I'm not sure that Sofcheck is still in business? there
was a discussion here recently).

> And how does gnatbind fit into this picture?  It appears to create
> initialization code.  Would I just need to insert this code such that
> it is invoked at power up?

I think you'd call gnatbind with -C (to generate C binder code rather
than Ada) and -n (no Ada main program).

The generated code includes an adainit() to be called to initialize the
Ada runtime and an adafinal() to finalize it (not that I've ever had to
call adafinal()).



  reply	other threads:[~2010-05-04 19:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-03 15:04 Building GNAT Tom
2010-05-03 17:03 ` Simon Wright
2010-05-04  5:03   ` Using GNAT in a C and assembly toolchain Tom
2010-05-04 19:50     ` Simon Wright [this message]
2010-05-04 22:04       ` Randy Brukardt
2010-05-05  2:10       ` Robert A Duff
2010-05-05  7:54         ` sjw
2010-05-05  5:52       ` Tom
replies disabled

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