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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3cfb384718eb4f7a X-Google-Attributes: gid103376,public From: Simon Wright Subject: Re: question re Ada equivalent of C function Date: 1998/02/22 Message-ID: #1/1 X-Deja-AN: 327962265 X-NNTP-Posting-Host: pogner.demon.co.uk [158.152.70.98] References: <34EEFF9C.1D01FA5D@stellar1.com> <01bd3f1d$44728800$582c5c8b@aptiva> <34EF6CC6.28EF2D4A@stellar1.com> Organization: At Home Newsgroups: comp.lang.ada Date: 1998-02-22T00:00:00+00:00 List-Id: Simon Wright writes: > David Fisher 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 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 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.