comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pogner.demon.co.uk>
Subject: Re: question re Ada equivalent of C function
Date: 1998/02/22
Date: 1998-02-22T00:00:00+00:00	[thread overview]
Message-ID: <x7vk9anwq2i.fsf@pogner.demon.co.uk> (raw)
In-Reply-To: x7vyaz4rp9p.fsf@pogner.demon.co.uk


Simon Wright <simon@pogner.demon.co.uk> writes:

> David Fisher <frc@stellar1.com> writes:
> 
> > The hardware will be a Pentium; the OS will be Linux, the compiler
> > (presumably) GNAT.
> 
> Check out "A Data Acquisition System For Linux", Dr Dobb's Journal Feb
> 1998, p.62. You'll need to use "pragma Import" to specify inb() etc.

Actually, inb() and friends seem to be macros. You may know how to use
the "assembler" features of Ada, but if this seems daunting (as it
does to me) you might proceed as follows:

Not at all clear from <asm/io.h> what the type of "port" should be,
but you'll need something like

(C, compiled with at least -O to get gcc to generate the outb instruction)
#include <asm/io.h>
void outb_wrapper(unsigned char val, int port)
{
  outb(val, port);
}

(Ada)
procedure Outb (Val : Interfaces.C.Unsigned_Char; Port : Interfaces.C.Int);
pragma Import (C, Outb, "outb_wrapper");

NB also I've no idea what you may need to do if the code needs to
execute as a driver(*). This would be quite problematic in Ada, I
suspect, unless you can avoid the need for elaboration (I suppose you
could get this to work as the driver initializes? come to think, all
you have to do is call adainit(), adafinal()??? anyone else tried
this?)

(*) In most Unixes you would expect to _have_ to access IO from the
kernel, ie in a driver. The referenced DDJ article says it's possible
from user mode if you're root.




  reply	other threads:[~1998-02-22  0:00 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-02-21  0:00 question re Ada equivalent of C function David Fisher
1998-02-21  0:00 ` Corey Ashford
1998-02-22  0:00   ` Nick Roberts
1998-02-21  0:00 ` Robert Dewar
1998-02-21  0:00 ` Brian Rogoff
1998-02-21  0:00   ` Robert Dewar
1998-02-22  0:00     ` Brian Rogoff
1998-02-21  0:00   ` Jerry van Dijk
1998-02-21  0:00     ` David Fisher
1998-02-22  0:00       ` Simon Wright
1998-02-22  0:00         ` Simon Wright [this message]
1998-02-22  0:00       ` Jerry van Dijk
1998-02-22  0:00         ` Robert Dewar
1998-02-22  0:00           ` Andi Kleen
1998-02-22  0:00   ` Nick Roberts
1998-02-22  0:00     ` frc
1998-02-22  0:00 ` Larry Kilgallen
1998-02-22  0:00   ` Robert Dewar
1998-02-22  0:00   ` frc
1998-02-22  0:00     ` Linux/POSIX packages for GNAT Markus Kuhn
1998-02-22  0:00       ` Robert Dewar
1998-02-23  0:00         ` Andi Kleen
1998-02-22  0:00           ` Robert Dewar
1998-02-23  0:00             ` Markus Kuhn
1998-02-23  0:00               ` Robert Dewar
1998-02-23  0:00         ` Markus Kuhn
1998-02-23  0:00           ` Robert Dewar
1998-02-23  0:00             ` Markus Kuhn
1998-02-24  0:00               ` question re Ada equivalent of C function Dale Stanbrough
1998-02-22  0:00       ` Linux/POSIX packages for GNAT Andi Kleen
1998-02-22  0:00         ` Markus Kuhn
1998-02-22  0:00           ` Robert Dewar
1998-02-22  0:00         ` Samuel Tardieu
1998-02-23  0:00           ` Nick Roberts
1998-02-23  0:00             ` Samuel Tardieu
1998-03-05  0:00             ` Testing exception handlers James M. Darlack
replies disabled

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